support multiple inputs to emcc -E

This commit is contained in:
Alon Zakai 2015-04-20 15:44:15 -07:00
Родитель b57ccfef1a
Коммит d1404ba742
2 изменённых файлов: 12 добавлений и 9 удалений

13
emcc
Просмотреть файл

@ -1067,9 +1067,9 @@ try:
debug_level = 4 debug_level = 4
# Bitcode args generation code # Bitcode args generation code
def get_bitcode_args(input_file): def get_bitcode_args(input_files):
file_ending = filename_type_ending(input_file) file_ending = filename_type_ending(input_files[0])
args = [call] + newargs + [input_file] args = [call] + newargs + input_files
if file_ending.endswith(CXX_ENDINGS): if file_ending.endswith(CXX_ENDINGS):
args += shared.EMSDK_CXX_OPTS args += shared.EMSDK_CXX_OPTS
args = system_libs.process_args(args, shared.Settings) args = system_libs.process_args(args, shared.Settings)
@ -1077,9 +1077,8 @@ try:
# -E preprocessor-only support # -E preprocessor-only support
if '-E' in newargs: if '-E' in newargs:
assert len(input_files) == 1 input_files = map(lambda x: x[1], input_files)
input_file = input_files[0][1] cmd = get_bitcode_args(input_files)
cmd = get_bitcode_args(input_file)
logging.debug('just preprocessor ' + ' '.join(cmd)) logging.debug('just preprocessor ' + ' '.join(cmd))
exit(subprocess.call(cmd)) exit(subprocess.call(cmd))
@ -1090,7 +1089,7 @@ try:
logging.debug('compiling source file: ' + input_file) logging.debug('compiling source file: ' + input_file)
output_file = get_bitcode_file(input_file) output_file = get_bitcode_file(input_file)
temp_files.append((i, output_file)) temp_files.append((i, output_file))
args = get_bitcode_args(input_file) + ['-emit-llvm', '-c', '-o', output_file] args = get_bitcode_args([input_file]) + ['-emit-llvm', '-c', '-o', output_file]
logging.debug("running: " + ' '.join(args)) logging.debug("running: " + ' '.join(args))
execute(args) # let compiler frontend print directly, so colors are saved (PIPE kills that) execute(args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
if not os.path.exists(output_file): if not os.path.exists(output_file):

Просмотреть файл

@ -3517,8 +3517,12 @@ tiny: %d
open('src.cpp', 'w').write(r'''#include <emscripten.h> open('src.cpp', 'w').write(r'''#include <emscripten.h>
EMSCRIPTEN_KEEPALIVE __EMSCRIPTEN_major__ __EMSCRIPTEN_minor__ __EMSCRIPTEN_tiny__ EMSCRIPTEN_KEEPALIVE EMSCRIPTEN_KEEPALIVE __EMSCRIPTEN_major__ __EMSCRIPTEN_minor__ __EMSCRIPTEN_tiny__ EMSCRIPTEN_KEEPALIVE
''') ''')
out = Popen([PYTHON, EMCC, 'src.cpp', '-E'], stdout=PIPE).communicate()[0] def test(args=[]):
print args
out = Popen([PYTHON, EMCC, 'src.cpp', '-E'] + args, stdout=PIPE).communicate()[0]
self.assertContained(r'''__attribute__((used)) %d %d %d __attribute__((used))''' % (EMSCRIPTEN_VERSION_MAJOR, EMSCRIPTEN_VERSION_MINOR, EMSCRIPTEN_VERSION_TINY), out) self.assertContained(r'''__attribute__((used)) %d %d %d __attribute__((used))''' % (EMSCRIPTEN_VERSION_MAJOR, EMSCRIPTEN_VERSION_MINOR, EMSCRIPTEN_VERSION_TINY), out)
test()
test(['--bind'])
def test_dashE_consistent(self): # issue #3365 def test_dashE_consistent(self): # issue #3365
normal = Popen([PYTHON, EMXX, '-v', '-Wno-warn-absolute-paths', path_from_root('tests', 'hello_world.cpp'), '-c'], stdout=PIPE, stderr=PIPE).communicate()[1] normal = Popen([PYTHON, EMXX, '-v', '-Wno-warn-absolute-paths', path_from_root('tests', 'hello_world.cpp'), '-c'], stdout=PIPE, stderr=PIPE).communicate()[1]