-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Deepak Rajamohan
committed
Jul 30, 2021
1 parent
e02e8a4
commit 56dd4af
Showing
9 changed files
with
212 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/node_modules | ||
/build | ||
/benchmark/build | ||
/benchmark/src | ||
/test/addon_build/addons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
'target_defaults': { | ||
'includes': ['common.gypi'], | ||
'variables': { | ||
'sources': "<!(node -p \"process.env['files_to_run'].split(',')\")", | ||
'build_sources': [ | ||
'../test/name.cc', | ||
'./generated/binding.cc' | ||
] | ||
}, | ||
}, | ||
'targets': [ | ||
{ | ||
"target_name": "generateBindingCC", | ||
"type": "none", | ||
"actions": [ { | ||
"action_name": "generateBindingCC", | ||
"message": "Generating binding cc file", | ||
"outputs": ["generated/binding.cc"], | ||
"conditions": [ | ||
[ "'true'=='true'", { | ||
"inputs": [""], | ||
"action": [ | ||
"node", | ||
"generate-binding-cc.js", | ||
"<!(node -p \"process.env['files_to_compile']\")" | ||
] | ||
} ] | ||
] | ||
} ] | ||
}, | ||
{ | ||
'target_name': 'binding', | ||
'includes': ['../except.gypi'], | ||
'sources': ['>@(build_sources)'], | ||
'dependencies': [ 'generateBindingCC' ] | ||
}, | ||
{ | ||
'target_name': 'binding_noexcept', | ||
'includes': ['../noexcept.gypi'], | ||
'sources': ['>@(build_sources)'], | ||
'dependencies': [ 'generateBindingCC' ] | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
'variables': { | ||
'NAPI_VERSION%': "<!(node -p \"process.versions.napi\")", | ||
'disable_deprecated': "<!(node -p \"process.env['npm_config_disable_deprecated']\")" | ||
}, | ||
'conditions': [ | ||
['NAPI_VERSION!=""', { 'defines': ['NAPI_VERSION=<@(NAPI_VERSION)'] } ], | ||
['disable_deprecated=="true"', { | ||
'defines': ['NODE_ADDON_API_DISABLE_DEPRECATED'] | ||
}], | ||
['OS=="mac"', { | ||
'cflags+': ['-fvisibility=hidden'], | ||
'xcode_settings': { | ||
'OTHER_CFLAGS': ['-fvisibility=hidden'] | ||
} | ||
}] | ||
], | ||
'include_dirs': ["<!(node -p \"require('../').include_dir\")", "./generated"], | ||
'cflags': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ], | ||
'cflags_cc': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const NapiVersionMap = require('./napi-version-map'); | ||
|
||
|
||
console.log('generate start', new Date()) | ||
|
||
const filesToRun = process.argv.slice(2); | ||
console.log('files to compile: ', process.argv, filesToRun); | ||
|
||
p = new Promise((resolve, reject) => { | ||
/*setTimeout(() => { | ||
r('done') | ||
}, 8000)*/ | ||
const content = []; | ||
|
||
const files = filesToRun[0].split(','); | ||
files.forEach((file) => { | ||
|
||
const configName = file.split('.cc')[0]; | ||
|
||
if (!NapiVersionMap[configName]) return; | ||
|
||
const config = NapiVersionMap[configName]; | ||
console.log(config) | ||
content.push("#include \"napi.h\""); | ||
content.push("using namespace Napi;"); | ||
content.push("Object InitName(Env env);"); | ||
content.push("Object Init(Env env, Object exports) {"); | ||
content.push("exports.Set(\"name\", InitName(env));"); | ||
content.push("return exports;"); | ||
content.push("}"); | ||
}); | ||
|
||
resolve(content); | ||
}); | ||
|
||
p.then((content) => { | ||
const generatedFilePath = path.join(__dirname, 'generated', 'binding.cc' ); | ||
|
||
console.log( "generatedFilePath", generatedFilePath) | ||
|
||
fs.writeFileSync( generatedFilePath , "" ); | ||
|
||
fs.writeFileSync( generatedFilePath, content.join('\r\n'), { flag: "a" } ); | ||
|
||
console.log('completed', new Date()) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "napi.h" | ||
using namespace Napi; | ||
Object InitName(Env env); | ||
Object Init(Env env, Object exports) { | ||
exports.Set("name", InitName(env)); | ||
return exports; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { spawn } = require("child_process"); | ||
|
||
process.argv.forEach(function (val, index, array) { | ||
console.log(index + ': ' + val); | ||
}); | ||
|
||
const ls = spawn("node-gyp", ["rebuild"], {cwd: __dirname, env: { ...process.env, files_to_run: '../test/name.cc,generated/binding.cc', files_to_compile: 'name.cc' }}); | ||
|
||
ls.stdout.on("data", data => { | ||
console.log(`stdout: ${data}`); | ||
}); | ||
|
||
ls.stderr.on("data", data => { | ||
console.log(`stderr: ${data}`); | ||
}); | ||
|
||
ls.on('error', (error) => { | ||
console.log(`error: ${error.message}`); | ||
}); | ||
|
||
ls.on("close", code => { | ||
console.log(`child process exited with code ${code}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"addon": { | ||
"objectName": "Addon", | ||
"versioning": "> 5" | ||
}, | ||
"addon_data": { | ||
"objectName": "AddonData", | ||
"versioning": "> 5" | ||
}, | ||
"arraybuffer": { | ||
"objectName": "ArrayBuffer" | ||
}, | ||
"asynccontext": { | ||
"objectName": "AsyncContext" | ||
}, | ||
"asyncprogressqueueworker": { | ||
"objectName": "AsyncProgressQueueWorker", | ||
"versioning": "> 3" | ||
}, | ||
"asyncprogressworker": { | ||
"objectName": "AsyncProgressWorker", | ||
"versioning": "> 3" | ||
}, | ||
"asyncworker-persistent": { | ||
"objectName": "PersistentAsyncWorker" | ||
}, | ||
"asyncworker": { | ||
"objectName": "AsyncWorker" | ||
}, | ||
"bigint": { "objectName": "bigint" }, | ||
"binding-swallowexcept": { "objectName": "binding-swallowexcept" }, | ||
"binding": { "objectName": "binding" }, | ||
"buffer": { "objectName": "buffer" }, | ||
"callbackscope": { "objectName": "callbackscope" }, | ||
"date": { "objectName": "date" }, | ||
"error": { "objectName": "error" }, | ||
"external": { "objectName": "external" }, | ||
"function": { "objectName": "function" }, | ||
"functionreference": { "objectName": "functionreference" }, | ||
"handlescope": { "objectName": "handlescope" }, | ||
"memory_management": { "objectName": "memory_management" }, | ||
"movable_callbacks": { "objectName": "movable_callbacks" }, | ||
"name": { "objectName": "Name" }, | ||
"objectreference": { "objectName": "objectreference" }, | ||
"objectwrap-removewrap": { "objectName": "objectwrap-removewrap" }, | ||
"objectwrap": { "objectName": "ObjectWrap" }, | ||
"objectwrap_constructor_exception": { "objectName": "objectwrap_constructor_exception" }, | ||
"objectwrap_multiple_inheritance": { "objectName": "objectwrap_multiple_inheritance" }, | ||
"promise": { "objectName": "promise" }, | ||
"reference": { "objectName": "reference" }, | ||
"run_script": { "objectName": "run_script" }, | ||
"symbol": { "objectName": "symbol" }, | ||
"thunking_manual": { "objectName": "thunking_manual" }, | ||
"typedarray": { "objectName": "typedarray" }, | ||
"version_management": { "objectName": "version_management" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
require('./build/Release/binding.node'); |