Skip to content

Commit

Permalink
allow selecting variant (defold#9490)
Browse files Browse the repository at this point in the history
* allow selecting variant

* Add ability to generate dwarf symbols in addition to source maps
  • Loading branch information
smagnuso authored Oct 9, 2024
1 parent 59744d3 commit 0450cb0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
17 changes: 9 additions & 8 deletions build_tools/waf_dynamo.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,10 @@ def default_flags(self):

if Options.options.with_webgpu and platform_supports_feature(build_util.get_target_platform(), 'webgpu', {}):
emflags_link += ['USE_WEBGPU', 'GL_WORKAROUND_SAFARI_GETCONTEXT_BUG=0']
# This is needed so long as we have to use sleep to make initialization blocking
emflags_link += ['ASYNCIFY', 'ASYNCIFY_ADVISE', 'ASYNCIFY_IGNORE_INDIRECT', 'ASYNCIFY_ADD=["main", "dmEngineCreate(int, char**)"]' ]
# This is needed so long as we have to use sleep to make initialization
emflags_link += ['ASYNCIFY']
if int(opt_level) >= 3:
emflags_link += ['ASYNCIFY_ADVISE', 'ASYNCIFY_IGNORE_INDIRECT', 'ASYNCIFY_ADD=["main", "dmEngineCreate(int, char**)"]' ]

if 'wasm' == build_util.get_target_architecture():
emflags_link += ['WASM=1', 'ALLOW_MEMORY_GROWTH=1']
Expand All @@ -508,11 +510,10 @@ def default_flags(self):
flags = []
linkflags = []
if int(opt_level) < 2:
flags = ['-gsource-map']
linkflags = ['-gsource-map']

flags += ['-O3']
linkflags += ['-O3']
flags = ['-gseparate-dwarf', '-gsource-map']
linkflags = ['-gseparate-dwarf', '-gsource-map']
flags += ['-O%s' % opt_level]
linkflags += ['-O%s' % opt_level]

self.env['DM_HOSTFS'] = '/node_vfs/'
self.env.append_value('DEFINES', ['DM_NO_THREAD_SUPPORT', 'JC_TEST_NO_DEATH_TEST'])
Expand All @@ -521,7 +522,7 @@ def default_flags(self):

for f in ['CFLAGS', 'CXXFLAGS']:
self.env.append_value(f, ['-Wall', '-fPIC', '-fno-exceptions', '-fno-rtti',
'-DGL_ES_VERSION_2_0', '-DGOOGLE_PROTOBUF_NO_RTTI', '-D__STDC_LIMIT_MACROS', '-DDDF_EXPOSE_DESCRIPTORS', '-DDM_NO_SYSTEM_FUNCTION'])
'-DGL_ES_VERSION_2_0', '-DGOOGLE_PROTOBUF_NO_RTTI', '-D__STDC_LIMIT_MACROS', '-DDDF_EXPOSE_DESCRIPTORS', '-DDM_NO_SYSTEM_FUNCTION'])
self.env.append_value(f, emflags_compile)
self.env.append_value(f, flags)

Expand Down
2 changes: 1 addition & 1 deletion engine/engine/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def build(bld):
srcPath = os.path.join('build', 'src')
builds = ['','_release', '_headless']
for build in builds:
for suffix in ('.js.mem', '.js.symbols', '.js.map', '.wasm', '.wasm.map', '.dSYM.zip'):
for suffix in ('.js.mem', '.js.symbols', '.js.map', '.wasm', '.wasm.map', '.wasm.debug.wasm', '.dSYM.zip'):
filePath = os.path.join(srcPath, 'dmengine' + build + suffix)
if (os.path.exists(filePath)):
bld.install_files('${PREFIX}/bin/%s' % bld.env.PLATFORM, filePath)
Expand Down
3 changes: 3 additions & 0 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,9 @@ def archive_engine(self):
engine_symbols = join(bin_dir, engine_name + '.symbols')
if os.path.exists(engine_symbols):
self.upload_to_archive(engine_symbols, '%s/%s.symbols' % (full_archive_path, engine_name))
engine_dwarf = join(bin_dir, engine_name + '.debug.wasm')
if os.path.exists(engine_dwarf):
self.upload_to_archive(engine_symbols, '%s/%s.debug.wasm' % (full_archive_path, engine_name))
elif 'macos' in self.target_platform or 'ios' in self.target_platform:
engine_symbols = join(bin_dir, engine_name + '.dSYM.zip')
if os.path.exists(engine_symbols):
Expand Down
28 changes: 21 additions & 7 deletions scripts/web/web-repack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ function terminate_trap() {
SOURCE="${1:-}" && [ ! -z "${SOURCE}" ] || terminate_usage
SOURCE="$(cd "$(dirname "${SOURCE}")"; pwd)/$(basename "${SOURCE}")"

if [ "$#" -gt 1 ]; then
VARIANT="${2}"
else
VARIANT="debug"
fi

[ -d "${SOURCE}" ] || terminate "Source does not exist: ${SOURCE}"

# ----------------------------------------------------------------------------
Expand All @@ -59,23 +65,31 @@ PROJECTNAME=$(cd "${SOURCE}" && ls *_*.js | head -1 | sed 's,_.*.js$,,')
echo $PROJECTNAME

TARGET="${SOURCE}.repack"

echo "$TARGET"
echo "$TARGET [${VARIANT}]"

if [ -d "$TARGET" ]; then
rm -rf "$TARGET"
fi

SUFFIX=""
[ "$VARIANT" != "debug" ] && SUFFIX="_${VARIANT}"

cp -r "${SOURCE}/" "${TARGET}/"

if [ -d "${DYNAMO_HOME}/bin/js-web" ]; then
cp -v "${DYNAMO_HOME}/bin/js-web/dmengine.js" "${TARGET}/${PROJECTNAME}_asmjs.js"
cp -v "${DYNAMO_HOME}/bin/js-web/dmengine${SUFFIX}.js" "${TARGET}/${PROJECTNAME}_asmjs.js"
if [ -e "${DYNAMO_HOME}/bin/js-web/dmengine${SUFFIX}.wasm.map" ]; then
cp -v "${DYNAMO_HOME}/bin/js-web/dmengine${SUFFIX}.js.symbols" "${TARGET}/${PROJECTNAME}_asmjs.symbols"
fi
fi
if [ -d "${DYNAMO_HOME}/bin/wasm-web" ]; then
cp -v "${DYNAMO_HOME}/bin/wasm-web/dmengine.js" "${TARGET}/${PROJECTNAME}_wasm.js"
cp -v "${DYNAMO_HOME}/bin/wasm-web/dmengine.wasm" "${TARGET}/${PROJECTNAME}.wasm"
if [ -e "${DYNAMO_HOME}/bin/wasm-web/dmengine.wasm.map" ]; then
cp -v "${DYNAMO_HOME}/bin/wasm-web/dmengine.wasm.map" "${TARGET}/dmengine.wasm.map"
cp -v "${DYNAMO_HOME}/bin/wasm-web/dmengine${SUFFIX}.js" "${TARGET}/${PROJECTNAME}_wasm.js"
cp -v "${DYNAMO_HOME}/bin/wasm-web/dmengine${SUFFIX}.wasm" "${TARGET}/${PROJECTNAME}.wasm"
if [ -e "${DYNAMO_HOME}/bin/wasm-web/dmengine${SUFFIX}.wasm.debug.wasm" ]; then
cp -v "${DYNAMO_HOME}/bin/wasm-web/dmengine${SUFFIX}.wasm.debug.wasm" "${TARGET}/${PROJECTNAME}.wasm.debug.wasm"
fi
if [ -e "${DYNAMO_HOME}/bin/wasm-web/dmengine${SUFFIX}.wasm.map" ]; then
cp -v "${DYNAMO_HOME}/bin/wasm-web/dmengine${SUFFIX}.wasm.map" "${TARGET}/${PROJECTNAME}.wasm.map"
fi
fi

Expand Down

0 comments on commit 0450cb0

Please sign in to comment.