Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/emdump → emdump
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ if [ -z "$PYTHON" ]; then
exit 1
fi

exec "$PYTHON" "$0.py" "$@"
exec "$PYTHON" "$(dirname $0)/tools/emdump.py" "$@"
2 changes: 1 addition & 1 deletion tools/emdump.bat → emdump.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
set EM_PY=python
)

@"%EM_PY%" "%~dp0\%~n0.py" %*
@"%EM_PY%" "%~dp0\tools\emdump.py" %*
2 changes: 1 addition & 1 deletion emprofile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ if [ -z "$PYTHON" ]; then
exit 1
fi

exec "$PYTHON" "tools/$0.py" "$@"
exec "$PYTHON" "$(dirname $0)/tools/emprofile.py" "$@"
2 changes: 1 addition & 1 deletion emprofile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
set EM_PY=python
)

@"%EM_PY%" "%~dp0\tools\%~n0.py" %*
@"%EM_PY%" "%~dp0\tools\emprofile.py" %*
43 changes: 31 additions & 12 deletions tools/create_entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"""

import os
import shutil
import sys
import stat

compiler_entry_points = '''
emcc
Expand All @@ -33,29 +33,48 @@
emrun
emscons
emsize
tools/emdump
emdump
emprofile
tools/file_packager
tests/runner
'''.split()


# For some tools the entry point doesn't live alongside the python
# script.
entry_remap = {
'emdump': 'tools/emdump',
'emprofile': 'tools/emprofile',
}

tools_dir = os.path.dirname(os.path.abspath(__file__))


def main():
tools_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(tools_dir)

def generate_entry_points(cmd, path):
sh_file = path + '.sh'
bat_file = path + '.bat'
with open(sh_file) as f:
sh_file = f.read()
with open(bat_file) as f:
bat_file = f.read()

for entry_point in cmd:
dst = os.path.join(root_dir, entry_point)
if os.path.exists(dst):
os.remove(dst)
shutil.copy2(sh_file, dst)

dst += '.bat'
if os.path.exists(dst):
os.remove(dst)
shutil.copy2(bat_file, dst)
sh_data = sh_file
bat_data = bat_file
if entry_point in entry_remap:
sh_data = sh_data.replace('$0', '$(dirname $0)/' + entry_remap[entry_point])
bat_data = bat_data.replace('%~n0', entry_remap[entry_point].replace('/', '\\'))

out_sh_file = os.path.join(root_dir, entry_point)
with open(out_sh_file, 'w') as f:
f.write(sh_data)
os.chmod(out_sh_file, stat.S_IMODE(os.stat(out_sh_file).st_mode) | stat.S_IXUSR)

with open(os.path.join(root_dir, entry_point + '.bat'), 'w') as f:
f.write(bat_data)

generate_entry_points(entry_points, os.path.join(tools_dir, 'run_python'))
generate_entry_points(compiler_entry_points, os.path.join(tools_dir, 'run_python_compiler'))
Expand Down