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,17 +8,35 @@
"include_dirs": [ "include_dirs": [
"native/target/release/", "native/target/release/",
], ],
"conditions": [
["OS!='win'", {
"actions": [ "actions": [
{ {
"action_name": "build minify-html-ffi static library", "action_name": "build minify-html-ffi static library",
"inputs": ["native/src/lib.rs"], "inputs": ["native/src/lib.rs"],
"outputs": ["native/target/release/libminify_html_ffi.a", "native/target/release/minify_html_ffi.h"], "outputs": ["native/target/release/libminify_html_ffi.a", "native/target/release/minify_html_ffi.h"],
"action": ["cargo", "build", "--manifest-path", "native/Cargo.toml", "--release"], "action": ["cargo build --manifest-path ../native/Cargo.toml --release"],
}, },
], ],
"libraries": [ "libraries": [
"../native/target/release/libminify_html_ffi.a", "../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" "postinstall.js"
], ],
"scripts": { "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" "postinstall": "node postinstall.js"
}, },
"repository": { "repository": {
@ -28,7 +28,8 @@
}, },
"homepage": "https://github.com/wilsonzlin/minify-html#readme", "homepage": "https://github.com/wilsonzlin/minify-html#readme",
"devDependencies": { "devDependencies": {
"node-gyp": "^7.0.0" "node-gyp": "^7.0.0",
"shx": "^0.3.2"
}, },
"keywords": [ "keywords": [
"build", "build",