diff options
author | Andreas Bergmeier <andreas.bergmeier@gmx.net> | 2014-03-04 09:10:26 +0100 |
---|---|---|
committer | Andreas Bergmeier <andreas.bergmeier@gmx.net> | 2014-03-17 14:45:26 +0100 |
commit | 47df13e72b43ceba91acbe63c8afac99a6b5f17c (patch) | |
tree | a8fd622eadc2f0c5baeb8cd1405448240efdb7de | |
parent | c09b43507361526e6d53628b45cca68c1b2b8f6d (diff) |
Add option valid-abspath to add absolute path, which should be considered valid.
-rwxr-xr-x | emcc | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -749,6 +749,15 @@ else: def in_temp(name): return os.path.join(temp_dir, os.path.basename(name)) +def in_directory( root, child ): + #make both 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:]): @@ -802,6 +811,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. @@ -1002,9 +1019,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': |