fix windows bats

This commit is contained in:
Luis Blanco 2018-01-30 11:26:47 +03:00
parent 528c58c005
commit 1f44e78a8d
6 changed files with 29 additions and 21 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017 Luis Blanco
Copyright (c) 2018 Luis Blanco
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -28,7 +28,7 @@ dependency packages.
[index.js](#indexjs)
[\_rd.bat / \_del.bat](#_rdbat--_delbat)
[Windows BAT](#windows-bat)
---
@ -38,11 +38,12 @@ dependency packages.
### binding.gyp
* For Windows custom file/folder removers are present, you can put them into variables.
* For Windows custom file/folder removers/creators are present, you can put them into variables.
```
'variables': {
'_rd' : '<!(node -e "console.log(require(\'addon-tools-raub\')._rd)")',
'_md' : '<!(node -e "console.log(require(\'addon-tools-raub\')._md)")',
'_del' : '<!(node -e "console.log(require(\'addon-tools-raub\')._del)")',
},
```
@ -72,8 +73,9 @@ Unix systems and custom remover on Windows.
'<(module_root_dir)/build/Release/addon.node'
] } ],
[ 'OS=="win"', { 'action' : [
'<(_del) "<(module_root_dir)/build/Release/addon.*" && ' +
'<(_del) "<(module_root_dir)/build/Release/obj/addon/*.*"'
'<(_del)',
'<(module_root_dir)/build/Release/addon.*',
'<(module_root_dir)/build/Release/obj/addon/*.*'
] } ],
```
@ -147,10 +149,7 @@ If you always copy your compiled addon to the `binary` directory, it will be eas
'conditions' : [
[ 'OS=="linux"', { 'action': ['mkdir', '-p', 'binary'] } ],
[ 'OS=="mac"', { 'action': ['mkdir', '-p', 'binary'] } ],
[ 'OS=="win"', { 'action': [
'<(_rd) "<(module_root_dir)/binary" && ' +
'md "<(module_root_dir)/binary"'
] } ],
[ 'OS=="win"', { 'action': ['<(_md)', 'binary'] } ],
],
}],
},
@ -203,7 +202,7 @@ module.exports = require('./binary/addon');
{
'variables': {
'_del' : '<!(node -e "console.log(require(\'addon-tools-raub\')._del)")',
'_rd' : '<!(node -e "console.log(require(\'addon-tools-raub\')._rd)")',
'_md' : '<!(node -e "console.log(require(\'addon-tools-raub\')._md)")',
'EXT_LIB_include' : '<!(node -e "console.log(require(\'node-deps-EXT_LIB-raub\').include)")',
'EXT_LIB_bin' : '<!(node -e "console.log(require(\'node-deps-EXT_LIB-raub\').bin)")',
},
@ -275,10 +274,7 @@ module.exports = require('./binary/addon');
'conditions' : [
[ 'OS=="linux"', { 'action': ['mkdir', '-p', 'binary'] } ],
[ 'OS=="mac"', { 'action': ['mkdir', '-p', 'binary'] } ],
[ 'OS=="win"', { 'action': [
'<(_rd) "<(module_root_dir)/binary" && ' +
'md "<(module_root_dir)/binary"'
] } ],
[ 'OS=="win"', { 'action': ['<(_md)', 'binary'] } ],
],
}],
},
@ -330,8 +326,9 @@ module.exports = require('./binary/addon');
'<(module_root_dir)/build/Release/MY_ADDON.node'
] } ],
[ 'OS=="win"', { 'action' : [
'<(_del) "<(module_root_dir)/build/Release/MY_ADDON.*" && ' +
'<(_del) "<(module_root_dir)/build/Release/obj/MY_ADDON/*.*"'
'<(_del)',
'<(module_root_dir)/build/Release/MY_ADDON.*',
'<(module_root_dir)/build/Release/obj/MY_ADDON/*.*'
] } ],
],
}],
@ -537,12 +534,13 @@ input `dir`.
* `root` - where `'addon-tools-raub'` module is situated.
* `include` - `'addon-tools-raub'` own 'include' directory.
* `_rd` - the location of `'_rd.bat'` file.
* `_md` - the location of `'_md.bat'` file.
* `_del` - the location of `'_del.bat'` file.
---
## \_rd.bat / \_del.bat
## Windows BAT
Windows-only utilities. Because in gyp any `/` on Windows is converted to `\`, it is
impossible to put correct commands for file/directory removal. Those need such
@ -550,6 +548,9 @@ parameters as `/Q`, but gyp makes them `\Q` which is inappropriate. So these fil
simply contain their respective commands with all necessary parameters, avoiding any
conflict with gyp.
Also on Windows there is no `mkdir -p`, hence if directory exists you get an error
trying to make it great again with `md`.
```
...
[ 'OS=="mac"', { 'action' : [
@ -558,7 +559,8 @@ conflict with gyp.
'<(module_root_dir)/build/Release/addon.node'
] } ],
[ 'OS=="win"', { 'action' : [
'<(_del) "<(module_root_dir)/build/Release/addon.*" && ' +
'<(_del) "<(module_root_dir)/build/Release/obj/addon/*.*"'
'<(_del)',
'<(module_root_dir)/build/Release/addon.*',
'<(module_root_dir)/build/Release/obj/addon/*.*'
] } ],
```

View File

@ -1 +1,3 @@
del /f /q %*
for %%x in (%*) do (
if exist %%x del /f /q %%x
)

3
_md.bat Normal file
View File

@ -0,0 +1,3 @@
for %%x in (%*) do (
if not exist %%x md %%x
)

View File

@ -50,6 +50,7 @@ module.exports = {
printNan() { require('nan'); },
_rd :`${thisDir}/_rd.bat`,
_md :`${thisDir}/_md.bat`,
_del :`${thisDir}/_del.bat`,
};

View File

@ -2,7 +2,7 @@
"name": "addon-tools-raub",
"author": "Luis Blanco <raubtierxxx@gmail.com>",
"description": "A set of extra tools for Node.js addons",
"version": "0.0.3",
"version": "0.0.4",
"main": "index.js",
"keywords": [
"node",