57
57
58
58
JS_CONTAINING_SUFFIXES = ('js' , 'html' )
59
59
60
+ EXPLICIT_OUTPUT_TYPES = ('js' , 'html' , 'bc' )
61
+
60
62
DEFERRED_REPONSE_FILES = ('EMTERPRETIFY_BLACKLIST' , 'EMTERPRETIFY_WHITELIST' )
61
63
62
64
# 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):
362
364
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
363
365
target_basename = unsuffixed_basename (target )
364
366
365
- if '.' in target :
366
- final_suffix = target .split ('.' )[- 1 ]
367
- else :
368
- final_suffix = ''
369
-
370
367
if TEMP_DIR :
371
368
temp_dir = TEMP_DIR
372
369
if os .path .exists (temp_dir ):
@@ -466,6 +463,7 @@ def log_time(name):
466
463
# Specifies the line ending format to use for all generated text files.
467
464
# Defaults to using the native EOL on each platform (\r\n on Windows, \n on Linux&OSX)
468
465
output_eol = os .linesep
466
+ target_output_type = None
469
467
470
468
def is_valid_abspath (path_name ):
471
469
# Any path that is underneath the emscripten repository root must be ok.
@@ -761,6 +759,14 @@ def detect_fixed_language_mode(args):
761
759
exit (1 )
762
760
newargs [i ] = ''
763
761
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 ] = ''
764
770
765
771
if should_exit :
766
772
sys .exit (0 )
@@ -913,6 +919,7 @@ def detect_fixed_language_mode(args):
913
919
914
920
newargs = [arg for arg in newargs if arg is not '' ]
915
921
922
+ final_suffix = None
916
923
# -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
917
924
has_dash_c = '-c' in newargs
918
925
if has_dash_c :
@@ -923,6 +930,15 @@ def detect_fixed_language_mode(args):
923
930
final_suffix = 'eout' # not bitcode, not js; but just result from preprocessing stage of the input file
924
931
if '-M' in newargs or '-MM' in newargs :
925
932
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
+
926
942
final_ending = ('.' + final_suffix ) if len (final_suffix ) > 0 else ''
927
943
928
944
# target is now finalized, can finalize other _target s
0 commit comments