Skip to content

Commit

Permalink
Don't print help message needlessly in emconfigure.py (emscripten-cor…
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Sep 17, 2019
1 parent 755d5b4 commit 3cafd67
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
8 changes: 5 additions & 3 deletions emconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# Main run() function
#
def run():
if len(sys.argv) < 2 or ('configure' not in sys.argv[1] and 'cmake' not in sys.argv[1]):
if len(sys.argv) < 2 or sys.argv[1] in ('--version', '--help'):
print('''
emconfigure is a helper for configure, setting various environment
variables so that emcc etc. are used. Typical usage:
Expand All @@ -41,6 +41,7 @@ def run():
(but you can run any command instead of configure)
''', file=sys.stderr)
return 1
elif 'cmake' in sys.argv[1]:
node_js = shared.NODE_JS
if type(node_js) is list:
Expand All @@ -51,9 +52,10 @@ def run():

try:
shared.Building.configure(sys.argv[1:])
return 0
except CalledProcessError as e:
sys.exit(e.returncode)
return e.returncode


if __name__ == '__main__':
run()
sys.exit(run())
9 changes: 6 additions & 3 deletions emmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# Main run() function
#
def run():
if len(sys.argv) < 2 or sys.argv[1] != 'make':
if len(sys.argv) < 2 or sys.argv[1] in ('--version', '--help'):
print('''
emmake is a helper for make, setting various environment
variables so that emcc etc. are used. Typical usage:
Expand All @@ -41,12 +41,15 @@ def run():
(but you can run any command instead of make)
''', file=sys.stderr)
return 1

try:
shared.Building.make(sys.argv[1:])
except CalledProcessError as e:
sys.exit(e.returncode)
return e.returncode

return 0


if __name__ == '__main__':
run()
sys.exit(run())
14 changes: 7 additions & 7 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,15 +944,15 @@ def test_emulate_function_pointer_casts_assertions_2(self):
def test_wl_linkflags(self):
# Test path -L and -l via -Wl, arguments and -Wl, response files
create_test_file('main.cpp', '''
extern void printey();
extern "C" void printey();
int main() {
printey();
return 0;
}
''')
create_test_file('libfile.cpp', '''
#include <stdio.h>
void printey() {
extern "C" void printey() {
printf("hello from lib\\n");
}
''')
Expand All @@ -961,7 +961,7 @@ def test_wl_linkflags(self):
-lfoo
''')
run_process([PYTHON, EMCC, '-o', 'libfile.o', 'libfile.cpp'])
run_process([PYTHON, EMAR, 'rv', 'libfoo.a', 'libfile.o'])
run_process([PYTHON, EMAR, 'cr', 'libfoo.a', 'libfile.o'])
run_process([PYTHON, EMCC, 'main.cpp', '-L.', '-lfoo'])
run_process([PYTHON, EMCC, 'main.cpp', '-Wl,-L.', '-Wl,-lfoo'])
run_process([PYTHON, EMCC, 'main.cpp', '-Wl,@linkflags.txt'])
Expand Down Expand Up @@ -5948,7 +5948,7 @@ def test_emconfigure_js_o(self):
for f in ['hello_world.c', 'files.cpp']:
print(i, f)
self.clear()
run_process([PYTHON, path_from_root('emconfigure'), PYTHON, EMCC, '-c', '-o', 'a.o', path_from_root('tests', f)], stderr=PIPE)
run_process([PYTHON, path_from_root('emconfigure'), PYTHON, EMCC, '-c', '-o', 'a.o', path_from_root('tests', f)])
run_process([PYTHON, EMCC, 'a.o'], check=False, stderr=PIPE)
if f == 'hello_world.c':
if i == 0:
Expand Down Expand Up @@ -6090,14 +6090,14 @@ def check(what, args, fail=True, expect=''):
import os
print(os.environ.get('CROSS_COMPILE'))
''')
check('emconfigure', [PYTHON, 'test.py'], expect=path_from_root('em'))
check('emmake', [PYTHON, 'test.py'], expect=path_from_root('em'))
check('emconfigure', [PYTHON, 'test.py'], expect=path_from_root('em'), fail=False)
check('emmake', [PYTHON, 'test.py'], expect=path_from_root('em'), fail=False)

create_test_file('test.py', '''
import os
print(os.environ.get('NM'))
''')
check('emconfigure', [PYTHON, 'test.py'], expect=shared.LLVM_NM)
check('emconfigure', [PYTHON, 'test.py'], expect=shared.LLVM_NM, fail=False)

@no_windows('This test is broken, https://github.com/emscripten-core/emscripten/issues/8872')
def test_emmake_python(self):
Expand Down

0 comments on commit 3cafd67

Please sign in to comment.