Merge pull request #102676 from adamscott/add-web-library-emitter
[Web] Add library emitter to make sources dependent of compiler version
This commit is contained in:
commit
77e9f55c51
19
methods.py
19
methods.py
@ -17,6 +17,8 @@ from misc.utility.color import print_error, print_info, print_warning
|
|||||||
base_folder_path = str(os.path.abspath(Path(__file__).parent)) + "/"
|
base_folder_path = str(os.path.abspath(Path(__file__).parent)) + "/"
|
||||||
base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
|
base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
|
||||||
|
|
||||||
|
compiler_version_cache = None
|
||||||
|
|
||||||
# Listing all the folders we have converted
|
# Listing all the folders we have converted
|
||||||
# for SCU in scu_builders.py
|
# for SCU in scu_builders.py
|
||||||
_scu_folders = set()
|
_scu_folders = set()
|
||||||
@ -635,6 +637,11 @@ def get_compiler_version(env):
|
|||||||
- metadata1, metadata2: Extra information
|
- metadata1, metadata2: Extra information
|
||||||
- date: Date of the build
|
- date: Date of the build
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
global compiler_version_cache
|
||||||
|
if compiler_version_cache is not None:
|
||||||
|
return compiler_version_cache
|
||||||
|
|
||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
ret = {
|
ret = {
|
||||||
@ -681,7 +688,7 @@ def get_compiler_version(env):
|
|||||||
ret["metadata1"] = split[1]
|
ret["metadata1"] = split[1]
|
||||||
except (subprocess.CalledProcessError, OSError):
|
except (subprocess.CalledProcessError, OSError):
|
||||||
print_warning("Couldn't find vswhere to determine compiler version.")
|
print_warning("Couldn't find vswhere to determine compiler version.")
|
||||||
return ret
|
return update_compiler_version_cache(ret)
|
||||||
|
|
||||||
# Not using -dumpversion as some GCC distros only return major, and
|
# Not using -dumpversion as some GCC distros only return major, and
|
||||||
# Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803
|
# Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803
|
||||||
@ -691,7 +698,7 @@ def get_compiler_version(env):
|
|||||||
).strip()
|
).strip()
|
||||||
except (subprocess.CalledProcessError, OSError):
|
except (subprocess.CalledProcessError, OSError):
|
||||||
print_warning("Couldn't parse CXX environment variable to infer compiler version.")
|
print_warning("Couldn't parse CXX environment variable to infer compiler version.")
|
||||||
return ret
|
return update_compiler_version_cache(ret)
|
||||||
|
|
||||||
match = re.search(
|
match = re.search(
|
||||||
r"(?:(?<=version )|(?<=\) )|(?<=^))"
|
r"(?:(?<=version )|(?<=\) )|(?<=^))"
|
||||||
@ -734,7 +741,13 @@ def get_compiler_version(env):
|
|||||||
"apple_patch3",
|
"apple_patch3",
|
||||||
]:
|
]:
|
||||||
ret[key] = int(ret[key] or -1)
|
ret[key] = int(ret[key] or -1)
|
||||||
return ret
|
return update_compiler_version_cache(ret)
|
||||||
|
|
||||||
|
|
||||||
|
def update_compiler_version_cache(value):
|
||||||
|
global compiler_version_cache
|
||||||
|
compiler_version_cache = value
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
def using_gcc(env):
|
def using_gcc(env):
|
||||||
|
@ -89,7 +89,17 @@ def get_flags():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def library_emitter(target, source, env):
|
||||||
|
# Make every source file dependent on the compiler version.
|
||||||
|
# This makes sure that when emscripten is updated, that the cached files
|
||||||
|
# aren't used and are recompiled instead.
|
||||||
|
env.Depends(source, env.Value(get_compiler_version(env)))
|
||||||
|
return target, source
|
||||||
|
|
||||||
|
|
||||||
def configure(env: "SConsEnvironment"):
|
def configure(env: "SConsEnvironment"):
|
||||||
|
env.Append(LIBEMITTER=library_emitter)
|
||||||
|
|
||||||
# Validate arch.
|
# Validate arch.
|
||||||
supported_arches = ["wasm32"]
|
supported_arches = ["wasm32"]
|
||||||
validate_arch(env["arch"], get_name(), supported_arches)
|
validate_arch(env["arch"], get_name(), supported_arches)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user