aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-24 09:47:20 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-24 09:47:20 -0800
commit48dbd4de6e7c02ce3dca15277bdf9e0a9617f5b3 (patch)
tree765092eddd8ce5e56bef3b6eb9821469a8bade87
parentb1f10031a3a50c22f2d39fa4ebe0117a9a43d4be (diff)
differentiate suffixes from endings in filename_type_ending as well
-rwxr-xr-xemcc36
1 files changed, 20 insertions, 16 deletions
diff --git a/emcc b/emcc
index 872c0c57..4803b813 100755
--- a/emcc
+++ b/emcc
@@ -765,9 +765,13 @@ def in_temp(name):
def filename_type_suffix(filename):
for i in reversed(filename.split('.')[1:]):
if not i.isdigit():
- return '.' + i
+ return i
return ''
+def filename_type_ending(filename):
+ suffix = filename_type_suffix(filename)
+ return '' if not suffix else ('.' + suffix)
+
try:
call = CXX if use_cxx else CC
@@ -1064,15 +1068,15 @@ try:
logging.error(arg + ': No such file or directory')
exit(1)
- arg_suffix = filename_type_suffix(arg)
- if arg_suffix.endswith(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS) or shared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs
+ arg_ending = filename_type_ending(arg)
+ if arg_ending.endswith(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS) or shared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs
newargs[i] = ''
- if arg_suffix.endswith(SOURCE_ENDINGS):
+ if arg_ending.endswith(SOURCE_ENDINGS):
input_files.append(arg)
has_source_inputs = True
- elif arg_suffix.endswith(ASSEMBLY_ENDINGS) or shared.Building.is_bitcode(arg): # this should be bitcode, make sure it is valid
+ elif arg_ending.endswith(ASSEMBLY_ENDINGS) or shared.Building.is_bitcode(arg): # this should be bitcode, make sure it is valid
input_files.append(arg)
- elif arg_suffix.endswith(STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS):
+ elif arg_ending.endswith(STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS):
# if it's not, and it's a library, just add it to libs to find later
l = unsuffixed_basename(arg)
for prefix in LIB_PREFIXES:
@@ -1084,7 +1088,7 @@ try:
newargs[i] = ''
else:
logging.warning(arg + ' is not valid LLVM bitcode')
- elif arg_suffix.endswith(STATICLIB_ENDINGS):
+ elif arg_ending.endswith(STATICLIB_ENDINGS):
if not shared.Building.is_ar(arg):
if shared.Building.is_bitcode(arg):
logging.error(arg + ': File has a suffix of a static library ' + str(STATICLIB_ENDINGS) + ', but instead is an LLVM bitcode file! When linking LLVM bitcode files, use one of the suffixes ' + str(BITCODE_ENDINGS))
@@ -1131,7 +1135,7 @@ try:
# If not compiling to JS, then we are compiling to an intermediate bitcode objects or library, so
# ignore dynamic linking, since multiple dynamic linkings can interfere with each other
- if not filename_type_suffix(target)[1:] in JS_CONTAINING_SUFFIXES or ignore_dynamic_linking:
+ if not filename_type_suffix(target) in JS_CONTAINING_SUFFIXES or ignore_dynamic_linking:
def check(input_file):
if input_file.endswith(DYNAMICLIB_ENDINGS):
if not ignore_dynamic_linking: logging.warning('ignoring dynamic library %s because not compiling to JS or HTML, remember to link it when compiling to JS or HTML at the end' % os.path.basename(input_file))
@@ -1278,14 +1282,14 @@ try:
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
for input_file in input_files:
- file_suffix = filename_type_suffix(input_file)
- if file_suffix.endswith(SOURCE_ENDINGS):
+ file_ending = filename_type_ending(input_file)
+ if file_ending.endswith(SOURCE_ENDINGS):
logging.debug('compiling source file: ' + input_file)
input_file = shared.Building.preprocess(input_file, in_temp(uniquename(input_file)))
output_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
temp_files.append(output_file)
args = newargs + ['-emit-llvm', '-c', input_file, '-o', output_file]
- if file_suffix.endswith(CXX_ENDINGS):
+ if file_ending.endswith(CXX_ENDINGS):
args += shared.EMSDK_CXX_OPTS
logging.debug("running: " + call + ' ' + ' '.join(args))
execute([call] + args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
@@ -1293,17 +1297,17 @@ try:
logging.error('compiler frontend failed to generate LLVM bitcode, halting')
sys.exit(1)
else: # bitcode
- if file_suffix.endswith(BITCODE_ENDINGS):
+ if file_ending.endswith(BITCODE_ENDINGS):
logging.debug('copying bitcode file: ' + input_file)
temp_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
shutil.copyfile(input_file, temp_file)
temp_files.append(temp_file)
- elif file_suffix.endswith(DYNAMICLIB_ENDINGS) or shared.Building.is_ar(input_file):
+ elif file_ending.endswith(DYNAMICLIB_ENDINGS) or shared.Building.is_ar(input_file):
logging.debug('copying library file: ' + input_file)
temp_file = in_temp(uniquename(input_file))
shutil.copyfile(input_file, temp_file)
temp_files.append(temp_file)
- elif file_suffix.endswith(ASSEMBLY_ENDINGS):
+ elif file_ending.endswith(ASSEMBLY_ENDINGS):
if not LEAVE_INPUTS_RAW:
# Note that by assembling the .ll file, then disassembling it later, we will
# remove annotations which is a good thing for compilation time
@@ -1321,8 +1325,8 @@ try:
# Optimize source files
if llvm_opts > 0:
for i, input_file in enumerate(input_files):
- file_suffix = filename_type_suffix(input_file)
- if file_suffix.endswith(SOURCE_ENDINGS):
+ file_ending = filename_type_ending(input_file)
+ if file_ending.endswith(SOURCE_ENDINGS):
temp_file = temp_files[i]
logging.debug('optimizing %s with -O%s' % (input_file, llvm_opts))
shared.Building.llvm_opt(temp_file, llvm_opts)