Skip to content

Commit

Permalink
modularized binaries (#1231)
Browse files Browse the repository at this point in the history
* modularized binary

* modularized binary
  • Loading branch information
DerThorsten authored Jul 22, 2024
1 parent 5a7b67f commit e8b4804
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 7 deletions.
5 changes: 5 additions & 0 deletions recipes/recipes/run_modularized/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

mkdir -p $PREFIX/bin
cp $RECIPE_DIR/run_modularized.js $PREFIX/bin/run_modularized
chmod +x $PREFIX/bin/run_modularized

22 changes: 22 additions & 0 deletions recipes/recipes/run_modularized/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
context:
name: run_modularized
version: "0.1.0"

package:
name: ${{ name|lower }}
version: ${{ version }}

build:
number: 0

requirements:
run:
- nodejs

about:
license: BSD-3-Clause
summary: run_modularized
description: run_modularized
extra:
recipe-maintainers:
- DerThorsten
18 changes: 18 additions & 0 deletions recipes/recipes/run_modularized/run_modularized.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

const binary_js_runner = process.argv[2];
process.argv = process.argv.slice(3);
async function my_main(){
const ModuleF = require(binary_js_runner);
const Module = await ModuleF({
noInitialRun: true,
// arguments: args_without_js_path
});
const ret = Module.callMain(process.argv);
return ret;
}
(async function() {
const exitCode = await my_main();
// exit the process
process.exit(exitCode);
})();
8 changes: 6 additions & 2 deletions recipes/recipes_emscripten/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ foreach(lua_binary ${lua_binaries})
target_compile_definitions(${lua_binary}
PUBLIC "SHELL: -s FORCE_FILESYSTEM"
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
# PUBLIC "SHELL: -s MODULARIZE=1"
PUBLIC "SHELL: -s ENVIRONMENT=web,worker,node"
PUBLIC "SHELL: -s EXPORTED_RUNTIME_METHODS=callMain,FS,ENV,getEnvStrings"
PUBLIC "SHELL: -s MODULARIZE=1"
)
# set target link options
target_link_options(${lua_binary}
PUBLIC "SHELL: -s FORCE_FILESYSTEM"
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
# PUBLIC "SHELL: -s MODULARIZE=1"
PUBLIC "SHELL: -s ENVIRONMENT=web,worker,node"
PUBLIC "SHELL: -s EXPORTED_RUNTIME_METHODS=callMain,FS,ENV,getEnvStrings"
PUBLIC "SHELL: -s MODULARIZE=1"
)
endforeach()

Expand Down
21 changes: 16 additions & 5 deletions recipes/recipes_emscripten/lua/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ source:
- path: CMakeLists.txt

build:
number: 6
number: 10

requirements:
build:
Expand All @@ -31,14 +31,25 @@ requirements:


tests:
- script: node $PREFIX/bin/lua.js -e "a=1+1;print(a)"
- script: |
OUTPUT=$(run_modularized $PREFIX/bin/lua.js -e "a=1+1;print(a)")
if [[ "$OUTPUT" != "2" ]]; then
echo "Unexpected output: $OUTPUT"
exit 1
fi
requirements:
build:
- nodejs
- script: node $PREFIX/bin/luac.js -v
- run_modularized
- script: |
OUTPUT=$(run_modularized $PREFIX/bin/luac.js -v)
if [[ "$OUTPUT" != "Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio" ]]; then
echo "Unexpected output: $OUTPUT"
exit 1
fi
requirements:
build:
- nodejs
- run_modularized
about:
summary: Lua is a powerful, fast, lightweight, embeddable scripting language
Expand Down

0 comments on commit e8b4804

Please sign in to comment.