check return codes when building system libs

This commit is contained in:
Alon Zakai 2014-07-02 16:54:25 -07:00
Родитель 7607ee10c2
Коммит 4d33d8c730
2 изменённых файлов: 12 добавлений и 4 удалений

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

@ -1887,6 +1887,14 @@ def check_execute(cmd, *args, **kw):
logging.error("'%s' failed with output:\n%s" % (" ".join(e.cmd), e.output))
raise
def check_call(cmd, *args, **kw):
try:
subprocess.check_call(cmd, *args, **kw)
logging.debug("Successfuly executed %s" % " ".join(cmd))
except subprocess.CalledProcessError as e:
logging.error("'%s' failed" % " ".join(cmd))
raise
def suffix(name):
parts = name.split('.')
if len(parts) > 1:

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

@ -1,6 +1,6 @@
import os, json, logging
import shared
from tools.shared import execute
from tools.shared import check_call
def calculate(temp_files, in_temp, stdout, stderr):
# Check if we need to include some libraries that we compile. (We implement libc ourselves in js, but
@ -31,7 +31,7 @@ def calculate(temp_files, in_temp, stdout, stderr):
musl_internal_includes = ['-I', shared.path_from_root('system', 'lib', 'libc', 'musl', 'src', 'internal'), '-I', shared.path_from_root('system', 'lib', 'libc', 'musl', 'arch', 'js')]
for src in files:
o = in_temp(os.path.basename(src) + '.o')
execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-o', o] + musl_internal_includes + lib_opts, stdout=stdout, stderr=stderr)
check_call([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-o', o] + musl_internal_includes + lib_opts, stdout=stdout, stderr=stderr)
o_s.append(o)
if prev_cxx: os.environ['EMMAKEN_CXX'] = prev_cxx
shared.Building.link(o_s, in_temp(lib_filename))
@ -42,7 +42,7 @@ def calculate(temp_files, in_temp, stdout, stderr):
for src in files:
o = in_temp(src + '.o')
srcfile = shared.path_from_root(src_dirname, src)
execute([shared.PYTHON, shared.EMXX, srcfile, '-o', o, '-std=c++11'] + lib_opts, stdout=stdout, stderr=stderr)
check_call([shared.PYTHON, shared.EMXX, srcfile, '-o', o, '-std=c++11'] + lib_opts, stdout=stdout, stderr=stderr)
o_s.append(o)
shared.Building.link(o_s, in_temp(lib_filename))
return in_temp(lib_filename)
@ -406,7 +406,7 @@ def calculate(temp_files, in_temp, stdout, stderr):
prev_cxx = os.environ.get('EMMAKEN_CXX')
if prev_cxx: os.environ['EMMAKEN_CXX'] = ''
o = in_temp('gl.o')
execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', 'gl.c'), '-o', o])
check_call([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', 'gl.c'), '-o', o])
if prev_cxx: os.environ['EMMAKEN_CXX'] = prev_cxx
return o