node-nim 7.8.3-rc.2 → 7.8.13-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,36 +1,36 @@
1
- # NetEase IM Node.js addon wrapper
2
-
3
- ## Build environment
4
-
5
- - CMake 3.10 or higher
6
- - Visual Studio 2017 or MSBuild 2017
7
-
8
- ## Command line
9
-
10
- |Options|Descroption|
11
- |---|---|
12
- |fetch-wrapper|Download NIM C++ SDK source files and C binary files|
13
- |build-wrapper|Build NIM C++ SDK|
14
- |package|Package the compiled artifacts|
15
- |build|Build with specified parameters (build-wrapper+package)|
16
-
17
- Examples:
18
-
19
- Fetch C++ wrapper source files and build C++ addon for node.js.
20
-
21
- ```bash
22
- npx just fetch-wrapper --target_platform=win32 --target_arch=ia32
23
- npx just build --runtime=electron --target=13.1.2 --target_platform=win32 --target_arch=ia32
24
- ```
25
-
26
- Just build NIM C++ wrapper, needs `npx just fetch-wrapper` before.
27
-
28
- ```bash
29
- npx just build-wrapper --target_platform=win32 --target_arch=ia32
30
- ```
31
-
32
- Packing a compiled artifact as `.tar.gz` in `packages` folder.
33
-
34
- ```bash
35
- npx just package --runtime=electron --target=13.1.2 --target_platform=win32 --target_arch=ia32
36
- ```
1
+ # NetEase IM Node.js addon wrapper
2
+
3
+ ## Build environment
4
+
5
+ - CMake 3.10 or higher
6
+ - Visual Studio 2017 or MSBuild 2017
7
+
8
+ ## Command line
9
+
10
+ |Options|Descroption|
11
+ |---|---|
12
+ |fetch-wrapper|Download NIM C++ SDK source files and C binary files|
13
+ |build-wrapper|Build NIM C++ SDK|
14
+ |package|Package the compiled artifacts|
15
+ |build|Build with specified parameters (build-wrapper+package)|
16
+
17
+ Examples:
18
+
19
+ Fetch C++ wrapper source files and build C++ addon for node.js.
20
+
21
+ ```bash
22
+ npx just fetch-wrapper --target_platform=win32 --target_arch=ia32
23
+ npx just build --runtime=electron --target=13.1.2 --target_platform=win32 --target_arch=ia32
24
+ ```
25
+
26
+ Just build NIM C++ wrapper, needs `npx just fetch-wrapper` before.
27
+
28
+ ```bash
29
+ npx just build-wrapper --target_platform=win32 --target_arch=ia32
30
+ ```
31
+
32
+ Packing a compiled artifact as `.tar.gz` in `packages` folder.
33
+
34
+ ```bash
35
+ npx just package --runtime=electron --target=13.1.2 --target_platform=win32 --target_arch=ia32
36
+ ```
package/just-task.js CHANGED
@@ -1,154 +1,168 @@
1
- const { task, option, logger, argv } = require('just-task')
2
- const fs = require('fs')
3
- const download = require('download')
4
- const path = require('path')
5
- const fetchWrapper = require(path.join(__dirname, './scripts/fetch_wrapper'))
6
- const buildWrapper = require(path.join(__dirname, './scripts/build_wrapper'))
7
- const buildAddon = require(path.join(__dirname, './scripts/build_addon'))
8
- const packAddon = require(path.join(__dirname, './scripts/pack_addon'))
9
- const packageMeta = require(path.join(__dirname, 'package.json'))
10
-
11
- option('target')
12
- option('target_platform', { default: process.platform, choices: ['darwin', 'win32', 'linux'] })
13
- option('target_arch', { default: process.arch, choices: ['ia32', 'x64'] })
14
- option('runtime', { default: 'electron', choices: ['electron', 'node'] })
15
- option('debug', { default: false, boolean: true })
16
- option('silent', { default: false, boolean: true })
17
-
18
- const nativeUrl = 'https://yx-web-nosdn.netease.im/package/1632832061/NIM_CrossPlatform_SDK_v7.8.3.zip?download=NIM_CrossPlatform_SDK_v7.8.3.zip'
19
-
20
- task('fetch-wrapper', () => {
21
- const platform = argv().target_platform
22
- const arch = argv().target_arch
23
- const cachePath = path.join(__dirname, 'nim_sdk')
24
- const temporaryPath = path.join(__dirname, 'temporary')
25
- return fetchWrapper({
26
- fetchUrl: nativeUrl,
27
- temporaryPath,
28
- extractPath: cachePath,
29
- platform,
30
- arch
31
- })
32
- })
33
-
34
- task('build-wrapper', () => {
35
- const platform = argv().target_platform
36
- const arch = argv().target_arch
37
- const sourcePath = path.join(__dirname, 'nim_sdk')
38
- return buildWrapper({
39
- platform,
40
- arch,
41
- sourcePath
42
- })
43
- })
44
-
45
- task('build', () => {
46
- const target = argv().target
47
- const platform = argv().target_platform || process.platform
48
- const arch = argv().target_arch || process.arch
49
- const runtime = argv().runtime
50
- const version = packageMeta.version
51
- const packageName = packageMeta.name
52
- const sourcePath = path.join(__dirname, 'nim_sdk')
53
-
54
- logger.info(JSON.stringify(argv()))
55
-
56
- return new Promise((resolve, reject) => {
57
- buildWrapper({
58
- platform,
59
- arch,
60
- sourcePath
61
- }).then(() => {
62
- return buildAddon({
63
- target,
64
- runtime,
65
- platform,
66
- arch
67
- })
68
- }).then(() => {
69
- return packAddon({
70
- packageName,
71
- version,
72
- target,
73
- platform,
74
- arch,
75
- runtime
76
- })
77
- }).then(() => resolve())
78
- })
79
- })
80
-
81
- task('package', () => {
82
- logger.info(JSON.stringify(argv()))
83
- const target = argv().target
84
- const platform = argv().target_platform
85
- const arch = argv().target_arch
86
- const runtime = argv().runtime
87
- const version = packageMeta.version
88
- const packageName = packageMeta.name
89
- return packAddon({
90
- packageName,
91
- version,
92
- target,
93
- platform,
94
- arch,
95
- runtime
96
- })
97
- })
98
-
99
- task('install', () => {
100
- if ((process.env.npm_config_skip_install || false)) {
101
- logger.info('[install] Skip downlaod prebuilt libraries.')
102
- return
103
- }
104
- let target = '5.0.8'
105
- let runtime = 'electron'
106
- const targetPlatform = process.env.npm_config_target_platform || process.platform
107
- const targetArch = process.env.npm_config_target_arch || process.arch
108
- const downloadUrl = process.env.npm_config_download_url
109
- const curPkgMeta = require(path.join(__dirname, 'package.json'))
110
- const rootPkgMeta = require(path.join(process.env.INIT_CWD, 'package.json'))
111
- logger.info('------------------ just install --------------------')
112
- if (rootPkgMeta.devDependencies && rootPkgMeta.devDependencies.electron) {
113
- // v13.1.2 => 13.1.2, remove prefix 'v'
114
- target = rootPkgMeta.devDependencies.electron.replace(/^.*?(\d+.+\d).*/, '$1')
115
- } else {
116
- target = process.version.match(/^v(\d+\.\d+)/)[1]
117
- runtime = 'node'
118
- }
119
- // 13.1.2 => 13.1, match major.minor only
120
- const nodeAbi = `${runtime}-v${target.replace(/^(\d+.+?\d+).*/, '$1')}`
121
- return new Promise((resolve, reject) => {
122
- const host = 'https://yx-web-nosdn.netease.im'
123
- const remotePath = 'package'
124
- const packageName = `${curPkgMeta.name}-v${curPkgMeta.version}-${nodeAbi}-${targetPlatform}-${targetArch}.tar.gz`
125
- const localPath = 'build/Release'
126
- fs.rmdirSync(path.join(__dirname, localPath), { recursive: true })
127
- download(`${host}/${remotePath}/${packageName}`, path.join(__dirname, localPath), {
128
- strip: 1,
129
- extract: true
130
- }).then(() => {
131
- logger.info(`[install] Download prebuilt binaries from ${host}/${remotePath}/${packageName}`)
132
- resolve()
133
- }).catch(err => {
134
- logger.warn(`[install] Failed to download package from: ${host}/${remotePath}/${packageName}, error code: ${err.statusCode}`)
135
- logger.info('[install] Start build from local source file.')
136
- const cachePath = path.join(__dirname, 'nim_sdk')
137
- const temporaryPath = path.join(__dirname, 'temporary')
138
- fetchWrapper({
139
- fetchUrl: nativeUrl,
140
- temporaryPath,
141
- extractPath: cachePath
142
- }).then(() => {
143
- return buildWrapper({
144
- sourcePath: cachePath
145
- })
146
- }).then(() => {
147
- return buildAddon({
148
- target,
149
- runtime
150
- })
151
- }).then(() => resolve())
152
- })
153
- })
154
- })
1
+ const { task, option, logger, argv } = require('just-task')
2
+ const fs = require('fs')
3
+ const download = require('download')
4
+ const path = require('path')
5
+ const fetchWrapper = require(path.join(__dirname, './scripts/fetch_wrapper'))
6
+ const buildWrapper = require(path.join(__dirname, './scripts/build_wrapper'))
7
+ const buildAddon = require(path.join(__dirname, './scripts/build_addon'))
8
+ const packAddon = require(path.join(__dirname, './scripts/pack_addon'))
9
+ const packageMeta = require(path.join(__dirname, 'package.json'))
10
+
11
+ option('target')
12
+ option('target_platform', {
13
+ default: process.platform,
14
+ choices: ['darwin', 'win32', 'linux']
15
+ })
16
+ option('target_arch', { default: process.arch, choices: ['ia32', 'x64'] })
17
+ option('runtime', { default: 'electron', choices: ['electron', 'node'] })
18
+ option('debug', { default: false, boolean: true })
19
+ option('silent', { default: false, boolean: true })
20
+
21
+ const nativeUrl = 'https://yx-web-nosdn.netease.im/package/1682303944593/NIM_CrossPlatform_SDK_v7.8.13.zip?download=NIM_CrossPlatform_SDK_v7.8.13.zip'
22
+
23
+ task('fetch-wrapper', () => {
24
+ const platform = argv().target_platform
25
+ const arch = argv().target_arch
26
+ const cachePath = path.join(__dirname, 'nim_sdk')
27
+ const temporaryPath = path.join(__dirname, 'temporary')
28
+ return fetchWrapper({
29
+ fetchUrl: nativeUrl,
30
+ temporaryPath,
31
+ extractPath: cachePath,
32
+ platform,
33
+ arch
34
+ })
35
+ })
36
+
37
+ task('build-wrapper', () => {
38
+ const platform = argv().target_platform
39
+ const arch = argv().target_arch
40
+ const sourcePath = path.join(__dirname, 'nim_sdk')
41
+ return buildWrapper({
42
+ platform,
43
+ arch,
44
+ sourcePath
45
+ })
46
+ })
47
+
48
+ task('build', () => {
49
+ const target = argv().target
50
+ const platform = argv().target_platform || process.platform
51
+ const arch = argv().target_arch || process.arch
52
+ const runtime = argv().runtime
53
+ const version = packageMeta.version
54
+ const packageName = packageMeta.name
55
+ const sourcePath = path.join(__dirname, 'nim_sdk')
56
+
57
+ logger.info(JSON.stringify(argv()))
58
+
59
+ return new Promise((resolve, reject) => {
60
+ buildWrapper({
61
+ platform,
62
+ arch,
63
+ sourcePath
64
+ })
65
+ .then(() => {
66
+ return buildAddon({
67
+ target,
68
+ runtime,
69
+ platform,
70
+ arch
71
+ })
72
+ })
73
+ .then(() => {
74
+ return packAddon({
75
+ packageName,
76
+ version,
77
+ target,
78
+ platform,
79
+ arch,
80
+ runtime
81
+ })
82
+ })
83
+ .then(() => resolve())
84
+ })
85
+ })
86
+
87
+ task('package', () => {
88
+ logger.info(JSON.stringify(argv()))
89
+ const target = argv().target
90
+ const platform = argv().target_platform
91
+ const arch = argv().target_arch
92
+ const runtime = argv().runtime
93
+ const version = packageMeta.version
94
+ const packageName = packageMeta.name
95
+ return packAddon({
96
+ packageName,
97
+ version,
98
+ target,
99
+ platform,
100
+ arch,
101
+ runtime
102
+ })
103
+ })
104
+
105
+ task('install', () => {
106
+ if (process.env.npm_config_skip_install || false) {
107
+ logger.info('[install] Skip downlaod prebuilt libraries.')
108
+ return
109
+ }
110
+ let target = '5.0.8'
111
+ let runtime = 'electron'
112
+ const targetPlatform = process.env.npm_config_target_platform || process.platform
113
+ const targetArch = process.env.npm_config_target_arch || process.arch
114
+ const downloadUrl = process.env.npm_config_download_url
115
+ const curPkgMeta = require(path.join(__dirname, 'package.json'))
116
+ const rootPkgMeta = require(path.join(process.env.INIT_CWD, 'package.json'))
117
+ logger.info('------------------ just install --------------------')
118
+ if (rootPkgMeta.devDependencies && rootPkgMeta.devDependencies.electron) {
119
+ // v13.1.2 => 13.1.2, remove prefix 'v'
120
+ target = rootPkgMeta.devDependencies.electron.replace(/^.*?(\d+.+\d).*/, '$1')
121
+ } else {
122
+ target = process.version.match(/^v(\d+\.\d+)/)[1]
123
+ runtime = 'node'
124
+ }
125
+ // 13.1.2 => 13.1, match major.minor only
126
+ const nodeAbi = `${runtime}-v${target.replace(/^(\d+.+?\d+).*/, '$1')}`
127
+ return new Promise((resolve, reject) => {
128
+ const host = 'https://yx-web-nosdn.netease.im'
129
+ const remotePath = 'package'
130
+ const packageName = `${curPkgMeta.name}-v${curPkgMeta.version}-${nodeAbi}-${targetPlatform}-${targetArch}.tar.gz`
131
+ const localPath = 'build/Release'
132
+ if (fs.existsSync(path.join(__dirname, localPath, packageName))) {
133
+ fs.rmSync(path.join(__dirname, localPath), { recursive: true })
134
+ }
135
+ fs.mkdirSync(path.join(__dirname, localPath), { recursive: true })
136
+ download(`${host}/${remotePath}/${packageName}`, path.join(__dirname, localPath), {
137
+ strip: 1,
138
+ extract: true
139
+ })
140
+ .then(() => {
141
+ logger.info(`[install] Download prebuilt binaries from ${host}/${remotePath}/${packageName}`)
142
+ resolve()
143
+ })
144
+ .catch((err) => {
145
+ logger.warn(`[install] Failed to download package from: ${host}/${remotePath}/${packageName}, error code: ${err.statusCode}`)
146
+ logger.info('[install] Start build from local source file.')
147
+ const cachePath = path.join(__dirname, 'nim_sdk')
148
+ const temporaryPath = path.join(__dirname, 'temporary')
149
+ fetchWrapper({
150
+ fetchUrl: nativeUrl,
151
+ temporaryPath,
152
+ extractPath: cachePath
153
+ })
154
+ .then(() => {
155
+ return buildWrapper({
156
+ sourcePath: cachePath
157
+ })
158
+ })
159
+ .then(() => {
160
+ return buildAddon({
161
+ target,
162
+ runtime
163
+ })
164
+ })
165
+ .then(() => resolve())
166
+ })
167
+ })
168
+ })
package/package.json CHANGED
@@ -1,49 +1,49 @@
1
- {
2
- "name": "node-nim",
3
- "version": "7.8.3-rc.2",
4
- "description": "NetEase IM nodejs wrapper based on NetEase IM C++ SDK",
5
- "main": "js/nim.js",
6
- "types": "types/nim.d.ts",
7
- "author": "Dylan",
8
- "license": "ISC",
9
- "scripts": {
10
- "test": "mocha test -slow 200 -timeout 5000",
11
- "install": "just install",
12
- "build:ts": "rimraf ./js && rimraf ./types && tsc",
13
- "prepare": "npm run build:ts"
14
- },
15
- "dependencies": {
16
- "bindings": "^1.5.0",
17
- "download": "^8.0.0",
18
- "extract-zip": "^2.0.1",
19
- "just-task": "^1.4.1",
20
- "node-gyp": "^8.1.0",
21
- "shelljs": "^0.8.4",
22
- "tar": "^6.1.0"
23
- },
24
- "devDependencies": {
25
- "eslint": "^7.31.0",
26
- "eslint-config-standard": "^16.0.3",
27
- "eslint-plugin-import": "^2.23.4",
28
- "eslint-plugin-node": "^11.1.0",
29
- "eslint-plugin-promise": "^5.1.0",
30
- "eslint-plugin-standard": "^5.0.0",
31
- "mocha": "^8.4.0",
32
- "typescript": "^4.3.5",
33
- "typescript-eslint": "0.0.1-alpha.0"
34
- },
35
- "keywords": [
36
- "netease",
37
- "nim",
38
- "chatroom",
39
- "im sdk",
40
- "nim sdk",
41
- "nim node",
42
- "nim electron"
43
- ],
44
- "files": [
45
- "js",
46
- "scripts",
47
- "just-task.js"
48
- ]
49
- }
1
+ {
2
+ "name": "node-nim",
3
+ "version": "7.8.13-rc.2",
4
+ "description": "NetEase IM nodejs wrapper based on NetEase IM C++ SDK",
5
+ "main": "js/nim.js",
6
+ "types": "types/nim.d.ts",
7
+ "author": "Dylan",
8
+ "license": "ISC",
9
+ "scripts": {
10
+ "test": "mocha test -slow 200 -timeout 5000",
11
+ "install": "just install",
12
+ "build:ts": "rimraf ./js && rimraf ./types && tsc",
13
+ "prepare": "npm run build:ts"
14
+ },
15
+ "dependencies": {
16
+ "bindings": "^1.5.0",
17
+ "download": "^8.0.0",
18
+ "extract-zip": "^2.0.1",
19
+ "just-task": "^1.4.1",
20
+ "node-gyp": "^8.1.0",
21
+ "shelljs": "^0.8.4",
22
+ "tar": "^6.1.0"
23
+ },
24
+ "devDependencies": {
25
+ "eslint": "^7.31.0",
26
+ "eslint-config-standard": "^16.0.3",
27
+ "eslint-plugin-import": "^2.23.4",
28
+ "eslint-plugin-node": "^11.1.0",
29
+ "eslint-plugin-promise": "^5.1.0",
30
+ "eslint-plugin-standard": "^5.0.0",
31
+ "mocha": "^8.4.0",
32
+ "typescript": "^4.3.5",
33
+ "typescript-eslint": "0.0.1-alpha.0"
34
+ },
35
+ "keywords": [
36
+ "netease",
37
+ "nim",
38
+ "chatroom",
39
+ "im sdk",
40
+ "nim sdk",
41
+ "nim node",
42
+ "nim electron"
43
+ ],
44
+ "files": [
45
+ "js",
46
+ "scripts",
47
+ "just-task.js"
48
+ ]
49
+ }
@@ -1,56 +1,56 @@
1
- const { logger } = require('just-task')
2
- const shell = require('shelljs')
3
- const path = require('path')
4
- const fs = require('fs')
5
-
6
- module.exports = ({
7
- target = '8.0.0',
8
- runtime = 'electron',
9
- platform = process.platform,
10
- arch = process.arch,
11
- debug = false,
12
- silent = false,
13
- msvcVersion = '2017',
14
- distUrl = 'https://electronjs.org/headers',
15
- forceClean = false
16
- }) => {
17
- return new Promise((resolve, reject) => {
18
- logger.info(`[build] start building [${runtime}-${target}]`)
19
- const command = [`npx node-gyp configure`]
20
- command.push(`--arch=${arch} --msvs_version=${msvcVersion}`)
21
- if (runtime === 'electron') {
22
- command.push(`--target=${target} --dist-url=${distUrl}`)
23
- }
24
- if (debug) {
25
- command.push('--debug')
26
- if (platform === 'darwin') {
27
- command.push('-- -f xcode')
28
- }
29
- }
30
- logger.info(command.join(' '))
31
- logger.info('[build] platform:', platform)
32
- logger.info('[build] arch:', arch)
33
- logger.info('[build] target:', target)
34
- logger.info('[build] runtime:', runtime)
35
- if (forceClean) {
36
- if (shell.exec(`npx node-gyp clean`, { silent }) !== 0) {
37
- reject(new Error('failed to clean up build folder.'))
38
- }
39
- }
40
- shell.exec(command.join(' '), { silent }, (code, stdout, stderr) => {
41
- logger.info(`[build] configure done ${stdout}`)
42
- if (code !== 0) {
43
- reject(stderr)
44
- }
45
- shell.exec(`npx node-gyp build`, { silent }, (code, stdout, stderr) => {
46
- if (code !== 0) {
47
- logger.error('[build] failed to build C++ addon manually.')
48
- logger.error(stderr)
49
- reject(stderr)
50
- }
51
- logger.info(`[build] build complete ${stdout}`)
52
- resolve()
53
- })
54
- })
55
- })
56
- }
1
+ const { logger } = require('just-task')
2
+ const shell = require('shelljs')
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+
6
+ module.exports = ({
7
+ target = '8.0.0',
8
+ runtime = 'electron',
9
+ platform = process.platform,
10
+ arch = process.arch,
11
+ debug = false,
12
+ silent = false,
13
+ msvcVersion = '2017',
14
+ distUrl = 'https://electronjs.org/headers',
15
+ forceClean = false
16
+ }) => {
17
+ return new Promise((resolve, reject) => {
18
+ logger.info(`[build] start building [${runtime}-${target}]`)
19
+ const command = [`npx node-gyp configure`]
20
+ command.push(`--arch=${arch} --msvs_version=${msvcVersion}`)
21
+ if (runtime === 'electron') {
22
+ command.push(`--target=${target} --dist-url=${distUrl}`)
23
+ }
24
+ if (debug) {
25
+ command.push('--debug')
26
+ if (platform === 'darwin') {
27
+ command.push('-- -f xcode')
28
+ }
29
+ }
30
+ logger.info(command.join(' '))
31
+ logger.info('[build] platform:', platform)
32
+ logger.info('[build] arch:', arch)
33
+ logger.info('[build] target:', target)
34
+ logger.info('[build] runtime:', runtime)
35
+ if (forceClean) {
36
+ if (shell.exec(`npx node-gyp clean`, { silent }) !== 0) {
37
+ reject(new Error('failed to clean up build folder.'))
38
+ }
39
+ }
40
+ shell.exec(command.join(' '), { silent }, (code, stdout, stderr) => {
41
+ logger.info(`[build] configure done ${stdout}`)
42
+ if (code !== 0) {
43
+ reject(stderr)
44
+ }
45
+ shell.exec(`npx node-gyp build`, { silent }, (code, stdout, stderr) => {
46
+ if (code !== 0) {
47
+ logger.error('[build] failed to build C++ addon manually.')
48
+ logger.error(stderr)
49
+ reject(stderr)
50
+ }
51
+ logger.info(`[build] build complete ${stdout}`)
52
+ resolve()
53
+ })
54
+ })
55
+ })
56
+ }
@@ -1,45 +1,45 @@
1
- const path = require('path')
2
- const shell = require('shelljs')
3
- const { logger } = require('just-task')
4
-
5
- module.exports = ({
6
- platform = process.platform,
7
- arch = process.arch,
8
- sourcePath
9
- }) => {
10
- return new Promise((resolve, reject) => {
11
- const wrapperSource = path.join(sourcePath, 'wrapper')
12
-
13
- // Generate Visual Studio solution
14
- const temporaryPath = path.join(sourcePath, `build_${platform}_${arch}`)
15
- const cmakeGenerate = [`cmake ${wrapperSource}`]
16
- cmakeGenerate.push(`-B${temporaryPath}`)
17
- cmakeGenerate.push('-T"v141_xp"')
18
- cmakeGenerate.push(`-DCMAKE_INSTALL_PREFIX=${sourcePath}`)
19
- if (platform === 'win32') {
20
- cmakeGenerate.push('-DBUILD_SHARED_LIBS=ON')
21
- cmakeGenerate.push(arch === 'ia32' ? '-G"Visual Studio 15 2017"' : '-G"Visual Studio 15 2017 Win64"')
22
- } else if (platform === 'darwin') {
23
- cmakeGenerate.push('-G"Xcode" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
24
- } else {
25
- reject(new Error('Unsupported platform.'))
26
- }
27
- logger.info(`[wrapper] ${cmakeGenerate.join(' ')}`)
28
- if (shell.exec(cmakeGenerate.join(' ')).code !== 0) {
29
- logger.error('[wrapper] Failed to generate NIM C++ wrapper solution.')
30
- process.exit(1)
31
- }
32
-
33
- // Build C++ wrapper
34
- const cmakeBuild = [`cmake --build ${temporaryPath}`]
35
- cmakeBuild.push('--config Release')
36
- cmakeBuild.push('--target install')
37
- logger.info(`[wrapper] ${cmakeBuild.join(' ')}`)
38
- if (shell.exec(cmakeBuild.join(' ')).code !== 0) {
39
- logger.error('[wrapper] Failed to build NIM C++ wrapper.')
40
- process.exit(1)
41
- }
42
-
43
- resolve()
44
- })
45
- }
1
+ const path = require('path')
2
+ const shell = require('shelljs')
3
+ const { logger } = require('just-task')
4
+
5
+ module.exports = ({
6
+ platform = process.platform,
7
+ arch = process.arch,
8
+ sourcePath
9
+ }) => {
10
+ return new Promise((resolve, reject) => {
11
+ const wrapperSource = path.join(sourcePath, 'wrapper')
12
+
13
+ // Generate Visual Studio solution
14
+ const temporaryPath = path.join(sourcePath, `build_${platform}_${arch}`)
15
+ const cmakeGenerate = [`cmake ${wrapperSource}`]
16
+ cmakeGenerate.push(`-B${temporaryPath}`)
17
+ cmakeGenerate.push('-T"v141_xp"')
18
+ cmakeGenerate.push(`-DCMAKE_INSTALL_PREFIX=${sourcePath}`)
19
+ if (platform === 'win32') {
20
+ cmakeGenerate.push('-DBUILD_SHARED_LIBS=ON')
21
+ cmakeGenerate.push(arch === 'ia32' ? '-G"Visual Studio 15 2017"' : '-G"Visual Studio 15 2017 Win64"')
22
+ } else if (platform === 'darwin') {
23
+ cmakeGenerate.push('-G"Xcode" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
24
+ } else {
25
+ reject(new Error('Unsupported platform.'))
26
+ }
27
+ logger.info(`[wrapper] ${cmakeGenerate.join(' ')}`)
28
+ if (shell.exec(cmakeGenerate.join(' ')).code !== 0) {
29
+ logger.error('[wrapper] Failed to generate NIM C++ wrapper solution.')
30
+ process.exit(1)
31
+ }
32
+
33
+ // Build C++ wrapper
34
+ const cmakeBuild = [`cmake --build ${temporaryPath}`]
35
+ cmakeBuild.push('--config Release')
36
+ cmakeBuild.push('--target install')
37
+ logger.info(`[wrapper] ${cmakeBuild.join(' ')}`)
38
+ if (shell.exec(cmakeBuild.join(' ')).code !== 0) {
39
+ logger.error('[wrapper] Failed to build NIM C++ wrapper.')
40
+ process.exit(1)
41
+ }
42
+
43
+ resolve()
44
+ })
45
+ }
@@ -1,45 +1,51 @@
1
- const path = require('path')
2
- const download = require('download')
3
- const tar = require('tar')
4
- const fs = require('fs')
5
- const { logger } = require('just-task')
6
-
7
- module.exports = ({
8
- platform = process.platform,
9
- arch = process.arch,
10
- fetchUrl,
11
- temporaryPath,
12
- extractPath
13
- }) => {
14
- return new Promise((resolve, reject) => {
15
- logger.info(fetchUrl)
16
- download(fetchUrl, temporaryPath, {
17
- strip: 1,
18
- extract: true
19
- }).then(() => {
20
- logger.info(`[fetch] Download file from ${fetchUrl}`)
21
- const files = fs.readdirSync(temporaryPath)
22
- const matchPlatform = platform === 'win32' ? 'windows' : 'macosx'
23
- const matchArch = arch === 'ia32' ? 'x86' : (platform === 'win32' ? 'x64' : 'x86_64')
24
- for (let i = 0; i < files.length; i++) {
25
- logger.info(`[fetch] found resource: ${files[i]}`)
26
- if (files[i].indexOf(matchPlatform) !== -1 && files[i].indexOf(matchArch) !== -1) {
27
- const sourceFile = path.join(temporaryPath, files[i])
28
- if (!fs.existsSync(extractPath)) {
29
- fs.mkdirSync(extractPath)
30
- }
31
- logger.info(`[wrapper] Extract file from ${sourceFile} to ${extractPath}`)
32
- tar.extract({
33
- file: sourceFile,
34
- cwd: extractPath,
35
- sync: true
36
- })
37
- resolve()
38
- break
39
- }
40
- }
41
- }).catch(err => {
42
- reject(err)
43
- })
44
- })
45
- }
1
+ const path = require('path')
2
+ const download = require('download')
3
+ const tar = require('tar')
4
+ const fs = require('fs')
5
+ const { logger } = require('just-task')
6
+
7
+ module.exports = ({
8
+ platform = process.platform,
9
+ arch = process.arch,
10
+ fetchUrl,
11
+ temporaryPath,
12
+ extractPath
13
+ }) => {
14
+ return new Promise((resolve, reject) => {
15
+ logger.info(fetchUrl)
16
+ download(fetchUrl, temporaryPath, {
17
+ strip: 1,
18
+ extract: true
19
+ }).then(() => {
20
+ logger.info(`[fetch] Download file from ${fetchUrl}`)
21
+ const files = fs.readdirSync(temporaryPath)
22
+ const matchPlatform = platform === 'win32' ? 'windows' : 'macosx'
23
+ const matchArch = arch === 'ia32' ? 'x86' : (platform === 'win32' ? 'x64' : 'x86_64')
24
+ for (let i = 0; i < files.length; i++) {
25
+ logger.info(`[fetch] found resource: ${files[i]}`)
26
+ if (files[i].indexOf(matchPlatform) !== -1 && files[i].indexOf(matchArch) !== -1) {
27
+ const sourceFile = path.join(temporaryPath, files[i])
28
+ if (!fs.existsSync(extractPath)) {
29
+ fs.mkdirSync(extractPath)
30
+ }
31
+ logger.info(`[wrapper] Extract file from ${sourceFile} to ${extractPath}`)
32
+ tar.extract({
33
+ file: sourceFile,
34
+ cwd: extractPath,
35
+ sync: true,
36
+ filter: (path, entry) => {
37
+ if (path.includes('._')) {
38
+ return false
39
+ }
40
+ return true
41
+ }
42
+ })
43
+ resolve()
44
+ break
45
+ }
46
+ }
47
+ }).catch(err => {
48
+ reject(err)
49
+ })
50
+ })
51
+ }
@@ -1,41 +1,41 @@
1
- const path = require('path')
2
- const tar = require('tar')
3
- const fs = require('fs')
4
- const { logger } = require('just-task')
5
-
6
- module.exports = ({
7
- packageName,
8
- version,
9
- target,
10
- platform,
11
- arch,
12
- runtime,
13
- artifactsDirectory = path.join(__dirname, '../build/Release'),
14
- distDirectory = path.join(__dirname, '../packages')
15
- }) => {
16
- return new Promise((resolve, reject) => {
17
- const strippedVersion = target.replace(/^.*?(\d+.+?\d).*/, '$1')
18
- const artifacts = fs.readdirSync(artifactsDirectory)
19
- const targetName = `${packageName}-v${version}-${runtime}-v${strippedVersion}-${platform}-${arch}.tar.gz`
20
- const targetFile = path.join(distDirectory, targetName)
21
- if (!fs.existsSync(distDirectory)) {
22
- fs.mkdirSync(distDirectory)
23
- }
24
- logger.info(`[package] Tar artifacts as: ${targetName}`)
25
- tar.create({
26
- gzip: true,
27
- file: targetFile,
28
- cwd: artifactsDirectory,
29
- filter: (path, stat) => {
30
- if (path.match(/\.pdb|\.dll|\.node|\.framework|\.dylib/g) !== null) {
31
- logger.info(`[package] ${path}`)
32
- return true
33
- }
34
- }
35
- }, artifacts).then(() => {
36
- resolve()
37
- }).catch(err => {
38
- reject(err)
39
- })
40
- })
41
- }
1
+ const path = require('path')
2
+ const tar = require('tar')
3
+ const fs = require('fs')
4
+ const { logger } = require('just-task')
5
+
6
+ module.exports = ({
7
+ packageName,
8
+ version,
9
+ target,
10
+ platform,
11
+ arch,
12
+ runtime,
13
+ artifactsDirectory = path.join(__dirname, '../build/Release'),
14
+ distDirectory = path.join(__dirname, '../packages')
15
+ }) => {
16
+ return new Promise((resolve, reject) => {
17
+ const strippedVersion = target.replace(/^.*?(\d+.+?\d).*/, '$1')
18
+ const artifacts = fs.readdirSync(artifactsDirectory)
19
+ const targetName = `${packageName}-v${version}-${runtime}-v${strippedVersion}-${platform}-${arch}.tar.gz`
20
+ const targetFile = path.join(distDirectory, targetName)
21
+ if (!fs.existsSync(distDirectory)) {
22
+ fs.mkdirSync(distDirectory)
23
+ }
24
+ logger.info(`[package] Tar artifacts as: ${targetName}`)
25
+ tar.create({
26
+ gzip: true,
27
+ file: targetFile,
28
+ cwd: artifactsDirectory,
29
+ filter: (path, stat) => {
30
+ if (path.match(/\.pdb|\.dll|\.node|\.framework|\.dylib/g) !== null) {
31
+ logger.info(`[package] ${path}`)
32
+ return true
33
+ }
34
+ }
35
+ }, artifacts).then(() => {
36
+ resolve()
37
+ }).catch(err => {
38
+ reject(err)
39
+ })
40
+ })
41
+ }