From 453ad91a85716ff20f72ee6c291ae42be7c4988d Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 14 Jul 2021 16:56:09 -0700 Subject: [PATCH] Create wrappers for llvm-dwp and llvm-nm Fixes: #14533 --- em-dwp | 31 +++++++++++++++++++++++++++++++ em-dwp.bat | 14 ++++++++++++++ emar.py | 18 +++--------------- emdwp | 31 +++++++++++++++++++++++++++++++ emdwp.bat | 14 ++++++++++++++ emnm | 31 +++++++++++++++++++++++++++++++ emnm.bat | 14 ++++++++++++++ tests/test_other.py | 2 +- tools/create_entry_points.py | 4 ++++ tools/emdwp.py | 16 ++++++++++++++++ tools/emnm.py | 16 ++++++++++++++++ tools/shared.py | 2 ++ 12 files changed, 177 insertions(+), 16 deletions(-) create mode 100755 em-dwp create mode 100644 em-dwp.bat create mode 100755 emdwp create mode 100644 emdwp.bat create mode 100755 emnm create mode 100644 emnm.bat create mode 100755 tools/emdwp.py create mode 100755 tools/emnm.py diff --git a/em-dwp b/em-dwp new file mode 100755 index 0000000000000..232f947841a40 --- /dev/null +++ b/em-dwp @@ -0,0 +1,31 @@ +#!/bin/sh +# Copyright 2020 The Emscripten Authors. All rights reserved. +# Emscripten is available under two separate licenses, the MIT license and the +# University of Illinois/NCSA Open Source License. Both these licenses can be +# found in the LICENSE file. +# +# Entry point for running python scripts on UNIX systems. +# +# Automatically generated by `create_entry_points.py`; DO NOT EDIT. +# +# To make modifications to this file, edit `tools/run_python.sh` and then run +# `tools/create_entry_points.py` + +if [ -z "$PYTHON" ]; then + PYTHON=$EMSDK_PYTHON +fi + +if [ -z "$PYTHON" ]; then + PYTHON=$(which python3 2> /dev/null) +fi + +if [ -z "$PYTHON" ]; then + PYTHON=$(which python 2> /dev/null) +fi + +if [ -z "$PYTHON" ]; then + echo 'unable to find python in $PATH' + exit 1 +fi + +exec "$PYTHON" "$0.py" "$@" diff --git a/em-dwp.bat b/em-dwp.bat new file mode 100644 index 0000000000000..f9ce949e613f0 --- /dev/null +++ b/em-dwp.bat @@ -0,0 +1,14 @@ +:: Entry point for running python scripts on windows systems. +:: +:: Automatically generated by `create_entry_points.py`; DO NOT EDIT. +:: +:: To make modifications to this file, edit `tools/run_python.bat` and then run +:: `tools/create_entry_points.py` + +@setlocal +@set EM_PY=%EMSDK_PYTHON% +@if "%EM_PY%"=="" ( + set EM_PY=python +) + +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emar.py b/emar.py index b8806855b41de..23147feb1f2dd 100755 --- a/emar.py +++ b/emar.py @@ -4,23 +4,11 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -"""Archive helper script - -This script acts as a frontend replacement for `llvm-ar`. +"""Wrapper scripte around `llvm-ar`. """ import sys - from tools import shared - -# -# Main run() function -# -def run(): - cmd = [shared.LLVM_AR] + sys.argv[1:] - return shared.run_process(cmd, stdin=sys.stdin, check=False).returncode - - -if __name__ == '__main__': - sys.exit(run()) +cmd = [shared.LLVM_AR] + sys.argv[1:] +sys.exit(shared.run_process(cmd, stdin=sys.stdin, check=False).returncode) diff --git a/emdwp b/emdwp new file mode 100755 index 0000000000000..727b147d32232 --- /dev/null +++ b/emdwp @@ -0,0 +1,31 @@ +#!/bin/sh +# Copyright 2020 The Emscripten Authors. All rights reserved. +# Emscripten is available under two separate licenses, the MIT license and the +# University of Illinois/NCSA Open Source License. Both these licenses can be +# found in the LICENSE file. +# +# Entry point for running python scripts on UNIX systems. +# +# Automatically generated by `create_entry_points.py`; DO NOT EDIT. +# +# To make modifications to this file, edit `tools/run_python.sh` and then run +# `tools/create_entry_points.py` + +if [ -z "$PYTHON" ]; then + PYTHON=$EMSDK_PYTHON +fi + +if [ -z "$PYTHON" ]; then + PYTHON=$(which python3 2> /dev/null) +fi + +if [ -z "$PYTHON" ]; then + PYTHON=$(which python 2> /dev/null) +fi + +if [ -z "$PYTHON" ]; then + echo 'unable to find python in $PATH' + exit 1 +fi + +exec "$PYTHON" "$(dirname $0)/tools/emdwp.py" "$@" diff --git a/emdwp.bat b/emdwp.bat new file mode 100644 index 0000000000000..b16d072111f81 --- /dev/null +++ b/emdwp.bat @@ -0,0 +1,14 @@ +:: Entry point for running python scripts on windows systems. +:: +:: Automatically generated by `create_entry_points.py`; DO NOT EDIT. +:: +:: To make modifications to this file, edit `tools/run_python.bat` and then run +:: `tools/create_entry_points.py` + +@setlocal +@set EM_PY=%EMSDK_PYTHON% +@if "%EM_PY%"=="" ( + set EM_PY=python +) + +@"%EM_PY%" "%~dp0\tools\emdwp.py" %* diff --git a/emnm b/emnm new file mode 100755 index 0000000000000..e662d746e7839 --- /dev/null +++ b/emnm @@ -0,0 +1,31 @@ +#!/bin/sh +# Copyright 2020 The Emscripten Authors. All rights reserved. +# Emscripten is available under two separate licenses, the MIT license and the +# University of Illinois/NCSA Open Source License. Both these licenses can be +# found in the LICENSE file. +# +# Entry point for running python scripts on UNIX systems. +# +# Automatically generated by `create_entry_points.py`; DO NOT EDIT. +# +# To make modifications to this file, edit `tools/run_python.sh` and then run +# `tools/create_entry_points.py` + +if [ -z "$PYTHON" ]; then + PYTHON=$EMSDK_PYTHON +fi + +if [ -z "$PYTHON" ]; then + PYTHON=$(which python3 2> /dev/null) +fi + +if [ -z "$PYTHON" ]; then + PYTHON=$(which python 2> /dev/null) +fi + +if [ -z "$PYTHON" ]; then + echo 'unable to find python in $PATH' + exit 1 +fi + +exec "$PYTHON" "$(dirname $0)/tools/emnm.py" "$@" diff --git a/emnm.bat b/emnm.bat new file mode 100644 index 0000000000000..2f350f34a8f24 --- /dev/null +++ b/emnm.bat @@ -0,0 +1,14 @@ +:: Entry point for running python scripts on windows systems. +:: +:: Automatically generated by `create_entry_points.py`; DO NOT EDIT. +:: +:: To make modifications to this file, edit `tools/run_python.bat` and then run +:: `tools/create_entry_points.py` + +@setlocal +@set EM_PY=%EMSDK_PYTHON% +@if "%EM_PY%"=="" ( + set EM_PY=python +) + +@"%EM_PY%" "%~dp0\tools\emnm.py" %* diff --git a/tests/test_other.py b/tests/test_other.py index 8ac7487405125..f30f0d694c146 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -6771,7 +6771,7 @@ def test_disable_inlining(self): # To this test to be successful, foo() shouldn't have been inlined above and # foo() should be in the function list - output = self.run_process([shared.LLVM_NM, 'test2.o'], stdout=PIPE).stdout + output = self.run_process([shared.EM_NM, 'test2.o'], stdout=PIPE).stdout self.assertContained('foo', output) def test_output_eol(self): diff --git a/tools/create_entry_points.py b/tools/create_entry_points.py index 84e9ab6f183df..79911556900e8 100755 --- a/tools/create_entry_points.py +++ b/tools/create_entry_points.py @@ -35,6 +35,8 @@ emsize emdump emprofile +emdwp +emnm tools/file_packager tools/webidl_binder tests/runner @@ -46,6 +48,8 @@ entry_remap = { 'emdump': 'tools/emdump', 'emprofile': 'tools/emprofile', + 'emdwp': 'tools/emdwp', + 'emnm': 'tools/emnm', } tools_dir = os.path.dirname(os.path.abspath(__file__)) diff --git a/tools/emdwp.py b/tools/emdwp.py new file mode 100755 index 0000000000000..27f99e4bfd69c --- /dev/null +++ b/tools/emdwp.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# Copyright 2016 The Emscripten Authors. All rights reserved. +# Emscripten is available under two separate licenses, the MIT license and the +# University of Illinois/NCSA Open Source License. Both these licenses can be +# found in the LICENSE file. + +"""Wrapper scripte around `llvm-dwp`. +""" + +import sys +import os +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from tools import shared + +cmd = [shared.LLVM_DWP] + sys.argv[1:] +sys.exit(shared.run_process(cmd, stdin=sys.stdin, check=False).returncode) diff --git a/tools/emnm.py b/tools/emnm.py new file mode 100755 index 0000000000000..41fc53cff7edd --- /dev/null +++ b/tools/emnm.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# Copyright 2016 The Emscripten Authors. All rights reserved. +# Emscripten is available under two separate licenses, the MIT license and the +# University of Illinois/NCSA Open Source License. Both these licenses can be +# found in the LICENSE file. + +"""Wrapper scripte around `llvm-nm`. +""" + +import os +import sys +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from tools import shared + +cmd = [shared.LLVM_NM] + sys.argv[1:] +sys.exit(shared.run_process(cmd, stdin=sys.stdin, check=False).returncode) diff --git a/tools/shared.py b/tools/shared.py index abf7cd7c22db6..24e39dba9da07 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -823,6 +823,7 @@ def do_replace(input_, pattern, replacement): CLANG_CXX = os.path.expanduser(build_clang_tool_path(exe_suffix('clang++'))) LLVM_LINK = build_llvm_tool_path(exe_suffix('llvm-link')) LLVM_AR = build_llvm_tool_path(exe_suffix('llvm-ar')) +LLVM_DWP = build_llvm_tool_path(exe_suffix('llvm-dwp')) LLVM_RANLIB = build_llvm_tool_path(exe_suffix('llvm-ranlib')) LLVM_OPT = os.path.expanduser(build_llvm_tool_path(exe_suffix('opt'))) LLVM_NM = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-nm'))) @@ -838,6 +839,7 @@ def do_replace(input_, pattern, replacement): EMRANLIB = bat_suffix(path_from_root('emranlib')) EMCMAKE = bat_suffix(path_from_root('emcmake')) EMCONFIGURE = bat_suffix(path_from_root('emconfigure')) +EM_NM = bat_suffix(path_from_root('emnm')) FILE_PACKAGER = bat_suffix(path_from_root('tools', 'file_packager')) apply_configuration()