@@ -18,11 +18,12 @@ var spawnSync = require( "child_process" ).spawnSync;
1818var fs = require ( "fs" ) ;
1919var repoPaths = require ( "./helpers/repo-paths" ) ;
2020var shelljs = require ( "shelljs" ) ;
21+ var os = require ( "os" ) ;
2122
22- function run ( command , arguments , options ) {
23+ function run ( command , args , options ) {
2324 var status ;
2425 options = options || { } ;
25- status = spawnSync ( command , arguments , _ . extend ( { } , options , {
26+ status = spawnSync ( command , args , _ . extend ( { } , options , {
2627 stdio : [ process . stdin , process . stdout , process . stderr ] ,
2728 shell : true
2829 } ) ) . status ;
@@ -48,7 +49,8 @@ function findBins( iotivityPath ) {
4849 return thePath ;
4950}
5051
51- var binariesSource , installWinHeaders , architecture , tinycborPath ;
52+ var binariesSource , installWinHeaders , tinycborPath ,
53+ userAgentParts , platform , localArch , targetArch , sysVersion ;
5254
5355// Map npm arch to iotivity arch - different mapping in each OS, it seems :/
5456// This can get complicated ...
@@ -57,7 +59,17 @@ var archMap = {
5759 "linux" : {
5860 "x64" : "x86_64" ,
5961 "arm" : "arm"
60- }
62+ } ,
63+ "darwin" : { "x64" : "x86_64" }
64+ } ;
65+
66+ // map of major version in os.release() to SYS_VERSION
67+ var darwinMap = {
68+ "12" : "10.8" ,
69+ "13" : "10.9" ,
70+ "14" : "10.10" ,
71+ "15" : "10.11" ,
72+ "16" : "10.12"
6173} ;
6274
6375// Determine the CSDK revision
@@ -75,9 +87,20 @@ if ( fs.existsSync( repoPaths.installPrefix ) ) {
7587tinycborPath = path . join ( repoPaths . iotivity , "extlibs" , "tinycbor" , "tinycbor" ) ;
7688
7789// Attempt to determine the architecture
78- architecture = ( process . env . npm_config_user_agent || "" ) . match ( / \S + / g ) || [ ] ;
79- architecture =
80- archMap [ architecture [ 2 ] ] ? archMap [ architecture [ 2 ] ] [ architecture [ 3 ] ] : null ;
90+ userAgentParts = ( process . env . npm_config_user_agent || "" ) . match ( / \S + / g ) || [ ] ;
91+ platform = userAgentParts [ 2 ] ;
92+ localArch = userAgentParts [ 3 ] ;
93+
94+ targetArch =
95+ archMap [ platform ] ? archMap [ platform ] [ localArch ] : null ;
96+
97+ if ( platform === "darwin" ) {
98+ var kernelVersionParts = os . release ( ) . split ( "." ) ;
99+ var majorVersion = kernelVersionParts [ 0 ] ;
100+ sysVersion = darwinMap [ majorVersion ] ? darwinMap [ majorVersion ] : null ;
101+ } else {
102+ sysVersion = null ;
103+ }
81104
82105// If the iotivity source tree is in place, we assume it's build and ready to go. This reduces this
83106// script to an install.
@@ -107,8 +130,10 @@ if ( !fs.existsSync( repoPaths.iotivity ) ) {
107130 run ( "scons" , [ ]
108131 . concat ( ( process . env . V === "1" || process . env . npm_config_verbose === "true" ) ?
109132 [ "VERBOSE=True" ] : [ ] )
110- . concat ( architecture ?
111- [ "TARGET_ARCH=" + architecture ] : [ ] )
133+ . concat ( targetArch ?
134+ [ "TARGET_ARCH=" + targetArch ] : [ ] )
135+ . concat ( sysVersion ?
136+ [ "SYS_VERSION=" + sysVersion ] : [ ] )
112137 . concat ( process . env . npm_config_debug === "true" ?
113138 [ "RELEASE=False" ] : [ ] )
114139 . concat (
0 commit comments