diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index a99b5ea..32d0492 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -60,7 +60,7 @@ jobs: run: npm ci - name: Build Sample Addon - run: npm run test-build + run: npm run build-test - name: Run Unit Tests run: npm run test-ci diff --git a/include/index.js b/include/index.js index 1deb7a0..f49eda2 100644 --- a/include/index.js +++ b/include/index.js @@ -1,11 +1,7 @@ 'use strict'; -let napi = null; -try { - napi = require('node-addon-api'); -} catch (ex) { - // do nothing -} +const path = require('node:path'); + const nameWindows = 'windows'; const platformAndArch = `${process.platform}-${process.arch}`; @@ -21,15 +17,8 @@ const platformName = platformNames[platformAndArch] || platformAndArch; const isWindows = platformName === nameWindows; -const rootPath = __dirname.replace(/\\/g, '/'); - -const napiInclude = napi ? napi.include_dir.replace(/\\/g, '/') : ''; -const thisInclude = `${rootPath}/include`; -const includePath = `${napiInclude} ${thisInclude}`; - - -const paths = (dir) => { +const getPaths = (dir) => { dir = dir.replace(/\\/g, '/'); const bin = `${dir}/bin-${platformName}`; @@ -43,9 +32,34 @@ const paths = (dir) => { }; -module.exports = { - paths, - bin: `bin-${platformName}`, - platform: platformName, - include: includePath, +const getBin = () => { + return `bin-${platformName}`; +}; + +const getPlatform = () => { + return platformName; +}; + +const getInclude = () => { + let napi = null; + try { + napi = require('node-addon-api'); + } catch (ex) { + // do nothing + } + + const rootPath = path.resolve(`${__dirname}/..`).replace(/\\/g, '/'); + const napiInclude = napi ? napi.include_dir.replace(/\\/g, '/') : ''; + const thisInclude = `${rootPath}/include`; + const includePath = `${napiInclude} ${thisInclude}`; + + return includePath; +}; + + +module.exports = { + getPaths, + getBin, + getPlatform, + getInclude, }; diff --git a/include/snippets.md b/include/snippets.md index 80c23ef..326a0d0 100644 --- a/include/snippets.md +++ b/include/snippets.md @@ -14,9 +14,8 @@ A snippet for **src/package.json**: "version": "0.0.0", "private": true, "scripts": { - "build": "node-gyp rebuild" - "build-dev": "node-gyp build && node -e \"require('addon-tools-raub/cpbin')('ADDON')\"" - "rebuild-dev": "node-gyp rebuild && node -e \"require('addon-tools-raub/cpbin')('ADDON')\"" + "build-all": "cd src && node-gyp rebuild -j max --silent && node -e \"require('addon-tools-raub/utils').cpbin('ADDON')\" && cd ..", + "build-only": "cd src && node-gyp build -j max --silent && node -e \"require('addon-tools-raub/utils').cpbin('ADDON')\" && cd ..", }, "dependencies": { "addon-tools-raub": "6.2.0", @@ -44,7 +43,6 @@ In **package.json**: }, "dependencies": { "addon-tools-raub": "^6.2.0", - "adm-zip": "^0.5.10" }, "devDependencies": { "node-addon-api": "^5.0.0" @@ -55,7 +53,7 @@ Create the **install.js** file: ``` 'use strict'; -const install = require('addon-tools-raub/install'); +const { install } = require('addon-tools-raub/utils'); const prefix = 'https://github.com/node-3d/glfw-raub/releases/download'; const tag = '4.8.0'; install(`${prefix}/${tag}`); @@ -95,9 +93,9 @@ from **Addon Tools** is that it should be a zipped set of files/folders. ``` 'variables': { - 'bin': ' - C:\_projects\addon-tools-raub\test\build\Release\test.node + C:\_projects\addon-tools-raub\test-addon\build\Release\test.node diff --git a/test-addon/build/Release/obj/test/test.obj b/test-addon/build/Release/obj/test/test.obj index e1239b9..cba4b4f 100644 Binary files a/test-addon/build/Release/obj/test/test.obj and b/test-addon/build/Release/obj/test/test.obj differ diff --git a/test-addon/build/Release/obj/test/test.tlog/CL.command.1.tlog b/test-addon/build/Release/obj/test/test.tlog/CL.command.1.tlog index 2f6a89d..7cb8a70 100644 Binary files a/test-addon/build/Release/obj/test/test.tlog/CL.command.1.tlog and b/test-addon/build/Release/obj/test/test.tlog/CL.command.1.tlog differ diff --git a/test-addon/build/Release/obj/test/test.tlog/CL.read.1.tlog b/test-addon/build/Release/obj/test/test.tlog/CL.read.1.tlog index eb8a726..162f967 100644 Binary files a/test-addon/build/Release/obj/test/test.tlog/CL.read.1.tlog and b/test-addon/build/Release/obj/test/test.tlog/CL.read.1.tlog differ diff --git a/test-addon/build/Release/obj/test/test.tlog/CL.write.1.tlog b/test-addon/build/Release/obj/test/test.tlog/CL.write.1.tlog index d02062b..a77074a 100644 Binary files a/test-addon/build/Release/obj/test/test.tlog/CL.write.1.tlog and b/test-addon/build/Release/obj/test/test.tlog/CL.write.1.tlog differ diff --git a/test-addon/build/Release/obj/test/test.tlog/link.command.1.tlog b/test-addon/build/Release/obj/test/test.tlog/link.command.1.tlog index 8c767ab..702cba0 100644 Binary files a/test-addon/build/Release/obj/test/test.tlog/link.command.1.tlog and b/test-addon/build/Release/obj/test/test.tlog/link.command.1.tlog differ diff --git a/test-addon/build/Release/obj/test/test.tlog/link.read.1.tlog b/test-addon/build/Release/obj/test/test.tlog/link.read.1.tlog index c9d88d2..177d2ca 100644 Binary files a/test-addon/build/Release/obj/test/test.tlog/link.read.1.tlog and b/test-addon/build/Release/obj/test/test.tlog/link.read.1.tlog differ diff --git a/test-addon/build/Release/obj/test/test.tlog/link.write.1.tlog b/test-addon/build/Release/obj/test/test.tlog/link.write.1.tlog index d14a285..2d4d20a 100644 Binary files a/test-addon/build/Release/obj/test/test.tlog/link.write.1.tlog and b/test-addon/build/Release/obj/test/test.tlog/link.write.1.tlog differ diff --git a/test-addon/build/Release/obj/test/test.tlog/test.lastbuildstate b/test-addon/build/Release/obj/test/test.tlog/test.lastbuildstate index f5f7862..01ffe36 100644 --- a/test-addon/build/Release/obj/test/test.tlog/test.lastbuildstate +++ b/test-addon/build/Release/obj/test/test.tlog/test.lastbuildstate @@ -1,2 +1,2 @@ PlatformToolSet=v142:VCToolArchitecture=Native64Bit:VCToolsVersion=14.28.29910:TargetPlatformVersion=10.0.19041.0: -Release|x64|C:\_projects\addon-tools-raub\test\build\| +Release|x64|C:\_projects\addon-tools-raub\test-addon\build\| diff --git a/test-addon/build/Release/obj/test/win_delay_load_hook.obj b/test-addon/build/Release/obj/test/win_delay_load_hook.obj index ed5fe02..b3c4d0a 100644 Binary files a/test-addon/build/Release/obj/test/win_delay_load_hook.obj and b/test-addon/build/Release/obj/test/win_delay_load_hook.obj differ diff --git a/test-addon/build/Release/test.node b/test-addon/build/Release/test.node index f43da94..ecb7c65 100644 Binary files a/test-addon/build/Release/test.node and b/test-addon/build/Release/test.node differ diff --git a/test-addon/build/Release/test.pdb b/test-addon/build/Release/test.pdb deleted file mode 100644 index b620a74..0000000 Binary files a/test-addon/build/Release/test.pdb and /dev/null differ diff --git a/test-addon/build/binding.sln b/test-addon/build/binding.sln index debc5b2..aa66125 100644 --- a/test-addon/build/binding.sln +++ b/test-addon/build/binding.sln @@ -1,17 +1,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2015 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcxproj", "{CA6D0C46-51F8-CCC5-FA71-4D2E9A260624}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcxproj", "{027E2789-D2D0-762D-B6D2-3AA4C73B3DD7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release|x64 = Release|x64 Debug|x64 = Debug|x64 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CA6D0C46-51F8-CCC5-FA71-4D2E9A260624}.Release|x64.ActiveCfg = Release|x64 - {CA6D0C46-51F8-CCC5-FA71-4D2E9A260624}.Release|x64.Build.0 = Release|x64 - {CA6D0C46-51F8-CCC5-FA71-4D2E9A260624}.Debug|x64.ActiveCfg = Debug|x64 - {CA6D0C46-51F8-CCC5-FA71-4D2E9A260624}.Debug|x64.Build.0 = Debug|x64 + {027E2789-D2D0-762D-B6D2-3AA4C73B3DD7}.Debug|x64.ActiveCfg = Debug|x64 + {027E2789-D2D0-762D-B6D2-3AA4C73B3DD7}.Debug|x64.Build.0 = Debug|x64 + {027E2789-D2D0-762D-B6D2-3AA4C73B3DD7}.Release|x64.ActiveCfg = Release|x64 + {027E2789-D2D0-762D-B6D2-3AA4C73B3DD7}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test-addon/build/test.vcxproj b/test-addon/build/test.vcxproj index 77cafc8..f1493ba 100644 --- a/test-addon/build/test.vcxproj +++ b/test-addon/build/test.vcxproj @@ -11,7 +11,7 @@ - {CA6D0C46-51F8-CCC5-FA71-4D2E9A260624} + {027E2789-D2D0-762D-B6D2-3AA4C73B3DD7} Win32Proj test true @@ -60,7 +60,7 @@ false Disabled NotUsing - NODE_GYP_MODULE_NAME=test;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;_WIN32;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions) + NODE_GYP_MODULE_NAME=test;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;_WIN32;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions) MultiThreadedDebug true true @@ -73,7 +73,7 @@ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\Luis\\AppData\\Local\\node-gyp\\Cache\\18.12.1\\x64\\node.lib" - /LTCG:INCREMENTAL /OPT:REF /OPT:ICF /LTCG /ignore:4199 %(AdditionalOptions) + /LTCG:INCREMENTAL /DEBUG:NONE /LTCG /OPT:NOREF /ignore:4199 %(AdditionalOptions) node.exe;%(DelayLoadDLLs) true true @@ -85,7 +85,7 @@ C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\include\node;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\src;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\openssl\config;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\openssl\openssl\include;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\uv\include;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\zlib;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\v8\include;..\..\node_modules\node-addon-api;C:\_projects\addon-tools-raub\include;%(AdditionalIncludeDirectories) - NODE_GYP_MODULE_NAME=test;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;_WIN32;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + NODE_GYP_MODULE_NAME=test;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;_WIN32;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions) @@ -104,7 +104,7 @@ true Full NotUsing - NODE_GYP_MODULE_NAME=test;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;_WIN32;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions) + NODE_GYP_MODULE_NAME=test;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;_WIN32;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions) MultiThreaded false true @@ -118,7 +118,7 @@ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\Luis\\AppData\\Local\\node-gyp\\Cache\\18.12.1\\x64\\node.lib" - /LTCG:INCREMENTAL /OPT:REF /OPT:ICF /LTCG /ignore:4199 %(AdditionalOptions) + /LTCG:INCREMENTAL /DEBUG:NONE /LTCG /OPT:NOREF /ignore:4199 %(AdditionalOptions) node.exe;%(DelayLoadDLLs) true true @@ -130,7 +130,7 @@ C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\include\node;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\src;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\openssl\config;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\openssl\openssl\include;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\uv\include;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\zlib;C:\Users\Luis\AppData\Local\node-gyp\Cache\18.12.1\deps\v8\include;..\..\node_modules\node-addon-api;C:\_projects\addon-tools-raub\include;%(AdditionalIncludeDirectories) - NODE_GYP_MODULE_NAME=test;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;_WIN32;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions) + NODE_GYP_MODULE_NAME=test;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;_WIN32;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions)