Skip to content
This repository was archived by the owner on Jun 13, 2019. It is now read-only.

Commit a111e84

Browse files
hansmbakkerGabriel Schulhof
authored andcommitted
Build: Add OSX build
Support OSX 10.12 and XCode 8.2 Closes gh-116
1 parent 8d65773 commit a111e84

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,39 @@ matrix:
2121

2222
- env: NODE_VERSION=0.12 TEST_SCRIPT=test
2323
os: osx
24+
osx_image: xcode8.2
2425

2526
- env: NODE_VERSION=4.0 TEST_SCRIPT=test
2627
os: linux
2728
addons: *buildpackages
2829

2930
- env: NODE_VERSION=4.0 TEST_SCRIPT=test
3031
os: osx
32+
osx_image: xcode8.2
3133

3234
- env: NODE_VERSION=4.4 TEST_SCRIPT=test
3335
os: linux
3436
addons: *buildpackages
3537

3638
- env: NODE_VERSION=4.4 TEST_SCRIPT=test
3739
os: osx
40+
osx_image: xcode8.2
3841

3942
- env: NODE_VERSION=4.5 TEST_SCRIPT=test
4043
os: linux
4144
addons: *buildpackages
4245

4346
- env: NODE_VERSION=4.5 TEST_SCRIPT=test
4447
os: osx
48+
osx_image: xcode8.2
4549

4650
- env: NODE_VERSION=6 TEST_SCRIPT=test
4751
os: linux
4852
addons: *buildpackages
4953

5054
- env: NODE_VERSION=6 TEST_SCRIPT=test
5155
os: osx
56+
osx_image: xcode8.2
5257

5358
# Allowed failures must be specified twice - once in "include" to have them
5459
# run, and again in "allow_failures" to not have them break the build.

build-scripts/build-csdk.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ var spawnSync = require( "child_process" ).spawnSync;
1818
var fs = require( "fs" );
1919
var repoPaths = require( "./helpers/repo-paths" );
2020
var 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 ) ) {
7587
tinycborPath = 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

Comments
 (0)