Merge pull request #2232 from abergmeier/empkg_prerequisites
Empkg prerequisites
This commit is contained in:
Коммит
3d43191017
25
emcc
25
emcc
|
@ -522,6 +522,8 @@ Options that are modified or new in %s include:
|
|||
will by default generate an output name 'dir/a.o',
|
||||
but this cmdline param can be passed to generate a
|
||||
file with a custom suffix 'dir/a.ext'.
|
||||
--valid_abspath path Whitelist an absolute path to prevent warnings about
|
||||
absolute include paths.
|
||||
|
||||
The target file, if specified (-o <target>), defines what will
|
||||
be generated:
|
||||
|
@ -757,6 +759,15 @@ else:
|
|||
def in_temp(name):
|
||||
return os.path.join(temp_dir, os.path.basename(name))
|
||||
|
||||
def in_directory(root, child):
|
||||
# make both path absolute
|
||||
root = os.path.realpath(root)
|
||||
child = os.path.realpath(child)
|
||||
|
||||
# return true, if the common prefix of both is equal to directory
|
||||
# e.g. /a/b/c/d.rst and directory is /a/b, the common prefix is /a/b
|
||||
return os.path.commonprefix([root, child]) == root
|
||||
|
||||
# Parses the essential suffix of a filename, discarding Unix-style version numbers in the name. For example for 'libz.so.1.2.8' returns '.so'
|
||||
def filename_type_suffix(filename):
|
||||
for i in reversed(filename.split('.')[1:]):
|
||||
|
@ -811,6 +822,14 @@ try:
|
|||
no_heap_copy = False
|
||||
proxy_to_worker = False
|
||||
default_object_extension = '.o'
|
||||
valid_abspaths = []
|
||||
|
||||
def is_valid_abspath(path_name):
|
||||
for valid_abspath in valid_abspaths:
|
||||
if in_directory(valid_abspath, path_name):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
if use_cxx:
|
||||
default_cxx_std = '-std=c++03' # Enforce a consistent C++ standard when compiling .cpp files, if user does not specify one on the cmdline.
|
||||
|
@ -1014,9 +1033,13 @@ try:
|
|||
elif newargs[i] == '--proxy-to-worker':
|
||||
proxy_to_worker = True
|
||||
newargs[i] = ''
|
||||
elif newargs[i] == '--valid-abspath':
|
||||
valid_abspaths.append(newargs[i+1])
|
||||
newargs[i] = ''
|
||||
newargs[i+1] = ''
|
||||
elif newargs[i].startswith(('-I', '-L')):
|
||||
path_name = newargs[i][2:]
|
||||
if not absolute_warning_shown and os.path.isabs(path_name):
|
||||
if not absolute_warning_shown and os.path.isabs(path_name) and not is_valid_abspath(path_name):
|
||||
logging.warning('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript). Pass \'-Wno-warn-absolute-paths\' to emcc to hide this warning.') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not
|
||||
absolute_warning_shown = True
|
||||
elif newargs[i] == '--emrun':
|
||||
|
|
|
@ -2580,6 +2580,19 @@ int main()
|
|||
out, err = Popen([PYTHON, EMCC, 'a.bc'], stdout=PIPE, stderr=PIPE).communicate()
|
||||
assert 'warning' in err, err
|
||||
assert 'incorrect target triple' in err, err
|
||||
|
||||
def test_valid_abspath(self):
|
||||
# Test whether abspath warning appears
|
||||
abs_include_path = path_from_root('tests')
|
||||
process = Popen([PYTHON, EMCC, '-I%s' % abs_include_path, path_from_root('tests', 'hello_world.c')], stdout=PIPE, stderr=PIPE)
|
||||
out, err = process.communicate()
|
||||
warning = '-I or -L of an absolute path "-I%s" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript). Pass \'-Wno-warn-absolute-paths\' to emcc to hide this warning.' % abs_include_path
|
||||
assert(warning in err)
|
||||
|
||||
# Hide warning for this include path
|
||||
process = Popen([PYTHON, EMCC, '--valid-abspath', abs_include_path,'-I%s' % abs_include_path, path_from_root('tests', 'hello_world.c')], stdout=PIPE, stderr=PIPE)
|
||||
out, err = process.communicate()
|
||||
assert(warning not in err)
|
||||
|
||||
def test_simplify_ifs(self):
|
||||
def test(src, nums):
|
||||
|
|
|
@ -678,18 +678,31 @@ USE_EMSDK = not os.environ.get('EMMAKEN_NO_SDK')
|
|||
if USE_EMSDK:
|
||||
# Disable system C and C++ include directories, and add our own (using -idirafter so they are last, like system dirs, which
|
||||
# allows projects to override them)
|
||||
EMSDK_OPTS = ['-nostdinc', '-Xclang', '-nobuiltininc', '-Xclang', '-nostdsysteminc',
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'local', 'include'),
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'include', 'compat'),
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'include', 'libcxx'),
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'include'),
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'include', 'emscripten'),
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'include', 'bsd'), # posix stuff
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'include', 'libc'),
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'include', 'gfx'),
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'include', 'net'),
|
||||
'-Xclang', '-isystem' + path_from_root('system', 'include', 'SDL'),
|
||||
C_INCLUDE_PATHS = [path_from_root('system', 'local', 'include'),
|
||||
path_from_root('system', 'include', 'compat'),
|
||||
path_from_root('system', 'include'),
|
||||
path_from_root('system', 'include', 'emscripten'),
|
||||
path_from_root('system', 'include', 'bsd'), # posix stuff
|
||||
path_from_root('system', 'include', 'libc'),
|
||||
path_from_root('system', 'include', 'gfx'),
|
||||
path_from_root('system', 'include', 'net'),
|
||||
path_from_root('system', 'include', 'SDL'),
|
||||
]
|
||||
|
||||
CXX_INCLUDE_PATHS = [path_from_root('system', 'include', 'libcxx')
|
||||
]
|
||||
|
||||
C_OPTS = ['-nostdinc', '-Xclang', '-nobuiltininc', '-Xclang', '-nostdsysteminc',
|
||||
]
|
||||
|
||||
def include_directive(paths):
|
||||
result = []
|
||||
for path in paths:
|
||||
result += ['-Xclang', '-isystem' + path]
|
||||
return result
|
||||
|
||||
EMSDK_OPTS = C_OPTS + include_directive(C_INCLUDE_PATHS) + include_directive(CXX_INCLUDE_PATHS)
|
||||
|
||||
EMSDK_OPTS += COMPILER_STANDARDIZATION_OPTS
|
||||
# For temporary compatibility, treat 'le32-unknown-nacl' as 'asmjs-unknown-emscripten'.
|
||||
if LLVM_TARGET != 'asmjs-unknown-emscripten' and \
|
||||
|
|
Загрузка…
Ссылка в новой задаче