- Changed mkapp.py flags to embed files and directories.

'--resource name' now copies file or directory 'name' into the app's private filesystem
'--resource-dir dir' copies all files _inside_ 'dir' into the app's private filesystem
This commit is contained in:
Martin Fouilleul 2023-06-26 12:24:22 +02:00
parent 4e90290add
commit 463e6322a4
2 changed files with 14 additions and 9 deletions

View File

@ -24,4 +24,4 @@ wasmFlags="--target=wasm32 \
$CLANG $wasmFlags -o ./module.wasm ../../sdk/orca.c ../../cstdlib/src/*.c src/main.c $CLANG $wasmFlags -o ./module.wasm ../../sdk/orca.c ../../cstdlib/src/*.c src/main.c
python3 ../../scripts/mkapp.py --orca-dir ../.. --name Pong --icon icon.png --data-file data/ball.png --data-file data/wall.png module.wasm python3 ../../scripts/mkapp.py --orca-dir ../.. --name Pong --icon icon.png --resource-dir data module.wasm

View File

@ -50,13 +50,18 @@ def macos_make_app(args):
#----------------------------------------------------------- #-----------------------------------------------------------
shutil.copy(args.module, wasm_dir + '/module.wasm') shutil.copy(args.module, wasm_dir + '/module.wasm')
if args.data_files != None: if args.resource_files != None:
for data in args.data_files: for resource in args.resource_files:
shutil.copy(data, data_dir) shutil.copytree(resource, data_dir + '/' + os.path.basename(resource), dirs_exist_ok=True)
if args.data_dirs != None: if args.resource_dirs != None:
for data in args.data_dirs: for resource_dir in args.resource_dirs:
shutil.copytree(data, data_dir + '/' + os.path.basename(data), dirs_exist_ok=True) for resource in os.listdir(resource_dir):
src = resource_dir + '/' + resource
if os.path.isdir(src):
shutil.copytree(src, data_dir + '/' + os.path.basename(resource), dirs_exist_ok=True)
else:
shutil.copy(src, data_dir)
#----------------------------------------------------------- #-----------------------------------------------------------
#NOTE: copy runtime resources #NOTE: copy runtime resources
@ -216,8 +221,8 @@ def windows_make_app(args):
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------
parser = ArgumentParser(prog='mkapp') parser = ArgumentParser(prog='mkapp')
parser.add_argument("-d", "--data-file", action='append', dest='data_files') parser.add_argument("-d", "--resource", action='append', dest='resource_files')
parser.add_argument("-D", "--data-dir", action='append', dest='data_dirs') parser.add_argument("-D", "--resource-dir", action='append', dest='resource_dirs')
parser.add_argument("-i", "--icon") parser.add_argument("-i", "--icon")
parser.add_argument("-C", "--out-dir", default=os.getcwd()) parser.add_argument("-C", "--out-dir", default=os.getcwd())
parser.add_argument("-n", "--name", default='out') parser.add_argument("-n", "--name", default='out')