Skip to content

Commit

Permalink
target -sWASM=0
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi committed Jan 15, 2021
1 parent d86c083 commit 433d5c2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 41 deletions.
6 changes: 4 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ mkdir -p ../lib/cjs-modern/util
mkdir -p ../lib/esm/util
mkdir -p ../lib/esm-modern/util
cp -rpf "$cmakeoutdir/$exename.js" "../lib/cjs-modern/util/$exename.js"
cp -rpf "$cmakeoutdir/$exename.js" "../lib/esm/util/$exename.js"
node -e "\"require('fs').writeFileSync('./.cgenbuild/"$exename"asm.js', require('fs').readFileSync('./.cgenbuild/"$exename"asm.js', 'utf8').replace('"$exename"asm.js.mem', '"$exename".js.mem').replace('"$exename"asm.wasm', '"$exename".wasm'), 'utf8')\""
cp -rpf "$cmakeoutdir/"$exename"asm.js" "../lib/esm/util/$exename.js"
cp -rpf "$cmakeoutdir/$exename.js" "../lib/esm-modern/util/$exename.js"
cp -rpf "$cmakeoutdir/$exename.wasm" "../lib/cjs-modern/util/$exename.wasm"
cp -rpf "$cmakeoutdir/$exename.wasm" "../lib/esm/util/$exename.wasm"
cp -rpf "$cmakeoutdir/"$exename"asm.js.mem" "../lib/esm/util/$exename.js.mem"
cp -rpf "$cmakeoutdir/"$exename"asm.wasm" "../lib/esm/util/$exename.wasm"
cp -rpf "$cmakeoutdir/$exename.wasm" "../lib/esm-modern/util/$exename.wasm"
cd ..
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tybys/wz",
"version": "1.1.3",
"version": "1.1.4",
"description": "MapleStory wz reader.",
"typings": "./lib/cjs-modern/index.d.ts",
"module": "./lib/esm-modern/index.js",
Expand Down Expand Up @@ -37,7 +37,7 @@
"access": "public"
},
"devDependencies": {
"@tybys/cgen": "^0.3.4",
"@tybys/cgen": "^0.3.5",
"@tybys/tsgo": "^0.8.0",
"@types/crypto-js": "^4.0.1",
"@types/node": "^12.12.36",
Expand All @@ -50,11 +50,11 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^5.0.0",
"typescript": "4.0.5",
"webpack": "^4.44.2"
"typescript": "4.1.3",
"webpack": "^4.46.0"
},
"dependencies": {
"@tybys/binreader": "^0.1.6",
"@tybys/binreader": "^0.1.7",
"@tybys/native-require": "^3.0.0",
"jimp": "^0.16.1"
}
Expand Down
69 changes: 37 additions & 32 deletions wasm/cgen.config.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
const { defineFunctionConfig } = require('@tybys/cgen')

module.exports = defineFunctionConfig(function (_options, { isDebug }) {

function createTarget (name, asm, isDebug) {
const debugFlags = [
'-sDISABLE_EXCEPTION_CATCHING=0',
'-sSAFE_HEAP=1'
'-sSAFE_HEAP=1',
...(!asm ? ['-g4', '--source-map-base', './'] : [])
]

const commonFlags = [
'--bind',
'-sALLOW_MEMORY_GROWTH=1',
// '-sWASM=0',
...(asm ? ['-sWASM=0'] : []),
// '-sDISABLE_EXCEPTION_CATCHING=0',
...(isDebug ? debugFlags : [])
...(isDebug ? debugFlags : ['-O3'])
]

return {
name: name,
type: 'exe',
sources: [
'./src/main.cpp'
],
defines: [
'AES256=1',
'ECB=1'
],
wrapScript: './export.js',
compileOptions: [
...commonFlags
],
linkOptions: [
...commonFlags
],
includePaths: [
'./deps/zlib',
'./deps/openssl/include'
],
libs: [
'zlibstatic',
'./deps/openssl/lib/libcrypto.a',
'./deps/openssl/lib/libssl.a',
]
}
}

module.exports = defineFunctionConfig(function (_options, { isDebug }) {
return {
project: 'wz',
dependencies: {
'./deps/zlib': {}
},
targets: [
{
name: 'wz',
type: 'exe',
sources: [
'./src/main.cpp'
],
defines: [
'AES256=1',
'ECB=1'
],
wrapScript: './export.js',
compileOptions: [
...commonFlags
],
linkOptions: [
...commonFlags
],
includePaths: [
'./deps/zlib',
'./deps/openssl/include'
],
libs: [
'zlibstatic',
'./deps/openssl/lib/libcrypto.a',
'./deps/openssl/lib/libssl.a',
]
}
createTarget('wz', false, isDebug),
createTarget('wzasm', true, isDebug)
]
}
})
6 changes: 4 additions & 2 deletions wasm/cmakebuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ mkdir ..\lib\cjs-modern\util
mkdir ..\lib\esm\util
mkdir ..\lib\esm-modern\util
copy /Y %cmakeoutdir%\%exename%.js ..\lib\cjs-modern\util\%exename%.js
copy /Y %cmakeoutdir%\%exename%.js ..\lib\esm\util\%exename%.js
node -e "require('fs').writeFileSync('./.cgenbuild/%exename%asm.js', require('fs').readFileSync('./.cgenbuild/%exename%asm.js', 'utf8').replace('%exename%asm.js.mem', '%exename%.js.mem').replace('%exename%asm.wasm', '%exename%.wasm'), 'utf8')"
copy /Y %cmakeoutdir%\%exename%asm.js ..\lib\esm\util\%exename%.js
copy /Y %cmakeoutdir%\%exename%.js ..\lib\esm-modern\util\%exename%.js
copy /Y %cmakeoutdir%\%exename%.wasm .\dist\%exename%.wasm
copy /Y %cmakeoutdir%\%exename%.wasm ..\lib\cjs-modern\util\%exename%.wasm
copy /Y %cmakeoutdir%\%exename%.wasm ..\lib\esm\util\%exename%.wasm
copy /Y %cmakeoutdir%\%exename%asm.js.mem ..\lib\esm\util\%exename%.js.mem
copy /Y %cmakeoutdir%\%exename%asm.wasm ..\lib\esm\util\%exename%.wasm
copy /Y %cmakeoutdir%\%exename%.wasm ..\lib\esm-modern\util\%exename%.wasm
copy /Y %cmakeoutdir%\%exename%.wasm.map .\%exename%.wasm.map

0 comments on commit 433d5c2

Please sign in to comment.