Implement Windows support for Node.js

This commit is contained in:
Wilson Lin 2020-07-24 17:35:26 +10:00
parent 33782aa858
commit aacfb78e0f
3 changed files with 35 additions and 12 deletions

4
nodejs/.cargo/config Normal file
View File

@ -0,0 +1,4 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["--print=native-static-libs"]
[target.i686-pc-windows-msvc]
rustflags = ["--print=native-static-libs"]

View File

@ -8,16 +8,34 @@
"include_dirs": [
"native/target/release/",
],
"actions": [
{
"action_name": "build minify-html-ffi static library",
"inputs": ["native/src/lib.rs"],
"outputs": ["native/target/release/libminify_html_ffi.a", "native/target/release/minify_html_ffi.h"],
"action": ["cargo", "build", "--manifest-path", "native/Cargo.toml", "--release"],
},
],
"libraries": [
"../native/target/release/libminify_html_ffi.a",
"conditions": [
["OS!='win'", {
"actions": [
{
"action_name": "build minify-html-ffi static library",
"inputs": ["native/src/lib.rs"],
"outputs": ["native/target/release/libminify_html_ffi.a", "native/target/release/minify_html_ffi.h"],
"action": ["cargo build --manifest-path ../native/Cargo.toml --release"],
},
],
"libraries": [
"../native/target/release/libminify_html_ffi.a",
],
}],
["OS=='win'", {
"actions": [
{
"action_name": "build minify-html-ffi static library",
"inputs": ["native/src/lib.rs"],
"outputs": ["native/target/release/minify_html_ffi.lib", "native/target/release/minify_html_ffi.h"],
"action": ["cargo build --manifest-path ../native/Cargo.toml --release"],
},
],
"libraries": [
"advapi32.lib", "ws2_32.lib", "userenv.lib", "msvcrt.lib",
"../native/target/release/minify_html_ffi.lib",
],
}],
],
},
],

View File

@ -7,7 +7,7 @@
"postinstall.js"
],
"scripts": {
"build": "node-gyp build && mv build/Release/index.node index.node",
"build": "node-gyp build && shx mv build/Release/index.node index.node",
"postinstall": "node postinstall.js"
},
"repository": {
@ -28,7 +28,8 @@
},
"homepage": "https://github.com/wilsonzlin/minify-html#readme",
"devDependencies": {
"node-gyp": "^7.0.0"
"node-gyp": "^7.0.0",
"shx": "^0.3.2"
},
"keywords": [
"build",