*added ImGUI styles *added new assets (fonts, shaders) *added cimgui.dll *added imports for bindbc-sdl (for WASM) *added simple demo *added demo launcher *added snake demo *impoved demo utils *added cimgui.bc library for WASM -improved wasm build script -small change in vector
99 lines
3.1 KiB
Python
99 lines
3.1 KiB
Python
import os
|
|
import ntpath
|
|
import sys
|
|
|
|
def compile(sources, output):
|
|
files = []
|
|
# r=root, d=directories, f = files
|
|
for path in sources:
|
|
for r, d, f in os.walk(path):
|
|
for file in f:
|
|
if ntpath.basename(file) != 'win_dll.d':
|
|
filename, file_extension = os.path.splitext(file)
|
|
if file_extension == '.d' and filename != 'package':
|
|
files.append(os.path.join(r, file))
|
|
|
|
ldc_cmd = 'ldc2 ' + shared_flags + ldc_flags + '-oq -mtriple=wasm32-unknown-unknown-wasm -betterC -L-allow-undefined --output-bc --od=.bc --singleobj --checkaction=C --of=' + output + ' '
|
|
|
|
for path in sources:
|
|
ldc_cmd += '-I' + path + ' '
|
|
|
|
for path in import_paths:
|
|
ldc_cmd += '-I' + path + ' '
|
|
|
|
for f in files:
|
|
ldc_cmd += f + ' '
|
|
|
|
print ldc_cmd
|
|
|
|
if os.system(ldc_cmd):
|
|
exit(0)
|
|
print
|
|
|
|
|
|
shared_flags = ''
|
|
clean = 0
|
|
demo = 0
|
|
sources = ['tests', 'source']
|
|
emc_flags = '-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS="[\'png\']" --preload-file assets '
|
|
ldc_flags = '--d-version=SDL_209 --d-version=BindSDL_Static --d-version=BindSDL_Image --d-version=MM_USE_POSIX_THREADS '
|
|
import_paths = ['external/sources', 'external/imports', 'external/wasm_imports', '../source', 'utils/source', 'simple/source']
|
|
|
|
for arg in sys.argv[1:]:
|
|
if(arg == '-release'):
|
|
ldc_flags += '-release '
|
|
elif(arg == '-enable-inlining'):
|
|
ldc_flags += '-enable-inlining '
|
|
elif(arg == '-O3'):
|
|
shared_flags += '-O3 '
|
|
elif(arg == '-O2'):
|
|
shared_flags += '-O2 '
|
|
elif(arg == '-O1'):
|
|
shared_flags += '-O1 '
|
|
elif(arg == '-O0'):
|
|
shared_flags += '-O0 '
|
|
elif(arg == '-Os'):
|
|
shared_flags += '-Os '
|
|
elif(arg == '-Oz'):
|
|
shared_flags += '-Oz '
|
|
elif(arg == '-g'):
|
|
shared_flags += '-g '
|
|
elif(arg == '--llvm-lto'):
|
|
emc_flags += '--llvm-lto 3 '
|
|
elif(arg == '--simd'):
|
|
emc_flags += '-s SIMD=1 '
|
|
elif(arg == '-opt'):
|
|
shared_flags += '-O3 '
|
|
ldc_flags += '-release -enable-inlining '
|
|
emc_flags += '--llvm-lto 3 -s SIMD=1 '
|
|
elif(arg == '--clean'):
|
|
clean = 1
|
|
elif(arg == '--demo=simple'):
|
|
demo = 0
|
|
else:
|
|
print('unknown argument: ' + arg)
|
|
exit()
|
|
|
|
compile(['external/wasm_imports/bindbc/sdl'], 'bindbc-sdl.bc')
|
|
compile(['utils/source'], 'utils.bc')
|
|
compile(['external/sources/mmutils'], 'mmutils.bc')
|
|
compile(['external/sources/glad'], 'glad.bc')
|
|
compile(['source'], 'demo.bc')
|
|
|
|
if clean or os.path.exists('../ecs.bc') == 0 or os.path.isfile('../ecs.bc') == 0:
|
|
compile(['../source'], '../ecs.bc')
|
|
|
|
emcc_cmd = 'emcc -v ' + shared_flags + emc_flags + '-s ALLOW_MEMORY_GROWTH=1 -s MALLOC=dlmalloc -s FULL_ES2=1 -s WASM=1 -o index.html '
|
|
|
|
emcc_cmd += '../ecs.bc '
|
|
emcc_cmd += 'utils.bc '
|
|
emcc_cmd += 'bindbc-sdl.bc '
|
|
emcc_cmd += 'glad.bc '
|
|
emcc_cmd += 'cimgui.bc '
|
|
emcc_cmd += 'nuklear.bc '
|
|
emcc_cmd += 'mmutils.bc '
|
|
emcc_cmd += 'demo.bc '
|
|
|
|
print emcc_cmd
|
|
|
|
os.system(emcc_cmd)
|