Skip to content

Commit b263c65

Browse files
committed
Add --force-output-type option
1 parent 8d9b3b1 commit b263c65

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

emcc.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757

5858
JS_CONTAINING_SUFFIXES = ('js', 'html')
5959

60+
EXPLICIT_OUTPUT_TYPES = ('js', 'html', 'bc')
61+
6062
DEFERRED_REPONSE_FILES = ('EMTERPRETIFY_BLACKLIST', 'EMTERPRETIFY_WHITELIST')
6163

6264
# Mapping of emcc opt levels to llvm opt levels. We use llvm opt level 3 in emcc opt
@@ -362,11 +364,6 @@ def uniquename(name):
362364
target = specified_target if specified_target is not None else 'a.out.js' # specified_target is the user-specified one, target is what we will generate
363365
target_basename = unsuffixed_basename(target)
364366

365-
if '.' in target:
366-
final_suffix = target.split('.')[-1]
367-
else:
368-
final_suffix = ''
369-
370367
if TEMP_DIR:
371368
temp_dir = TEMP_DIR
372369
if os.path.exists(temp_dir):
@@ -466,6 +463,7 @@ def log_time(name):
466463
# Specifies the line ending format to use for all generated text files.
467464
# Defaults to using the native EOL on each platform (\r\n on Windows, \n on Linux&OSX)
468465
output_eol = os.linesep
466+
target_output_type = None
469467

470468
def is_valid_abspath(path_name):
471469
# Any path that is underneath the emscripten repository root must be ok.
@@ -761,6 +759,14 @@ def detect_fixed_language_mode(args):
761759
exit(1)
762760
newargs[i] = ''
763761
newargs[i+1] = ''
762+
elif newargs[i] == '--force-output-type':
763+
if newargs[i+1] in EXPLICIT_OUTPUT_TYPES:
764+
target_output_type = newargs[i+1]
765+
else:
766+
logging.error('Invalid value "' + newargs[i+1] + '" to --force-output-type')
767+
exit(1)
768+
newargs[i] = ''
769+
newargs[i+1] = ''
764770

765771
if should_exit:
766772
sys.exit(0)
@@ -913,6 +919,7 @@ def detect_fixed_language_mode(args):
913919

914920
newargs = [arg for arg in newargs if arg is not '']
915921

922+
final_suffix = None
916923
# -c means do not link in gcc, and for us, the parallel is to not go all the way to JS, but stop at bitcode
917924
has_dash_c = '-c' in newargs
918925
if has_dash_c:
@@ -923,6 +930,15 @@ def detect_fixed_language_mode(args):
923930
final_suffix = 'eout' # not bitcode, not js; but just result from preprocessing stage of the input file
924931
if '-M' in newargs or '-MM' in newargs:
925932
final_suffix = 'mout' # not bitcode, not js; but just dependency rule of the input file
933+
934+
if final_suffix == None:
935+
if target_output_type != None:
936+
final_suffix = target_output_type
937+
elif '.' in target:
938+
final_suffix = target.split('.')[-1]
939+
else:
940+
final_suffix = ''
941+
926942
final_ending = ('.' + final_suffix) if len(final_suffix) > 0 else ''
927943

928944
# target is now finalized, can finalize other _target s

0 commit comments

Comments
 (0)