Skip to content

Commit 77e9f55

Browse files
committed
Merge pull request #102676 from adamscott/add-web-library-emitter
[Web] Add library emitter to make sources dependent of compiler version
2 parents 1186514 + 02cc1ec commit 77e9f55

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

methods.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
base_folder_path = str(os.path.abspath(Path(__file__).parent)) + "/"
1818
base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
1919

20+
compiler_version_cache = None
21+
2022
# Listing all the folders we have converted
2123
# for SCU in scu_builders.py
2224
_scu_folders = set()
@@ -635,6 +637,11 @@ def get_compiler_version(env):
635637
- metadata1, metadata2: Extra information
636638
- date: Date of the build
637639
"""
640+
641+
global compiler_version_cache
642+
if compiler_version_cache is not None:
643+
return compiler_version_cache
644+
638645
import shlex
639646

640647
ret = {
@@ -681,7 +688,7 @@ def get_compiler_version(env):
681688
ret["metadata1"] = split[1]
682689
except (subprocess.CalledProcessError, OSError):
683690
print_warning("Couldn't find vswhere to determine compiler version.")
684-
return ret
691+
return update_compiler_version_cache(ret)
685692

686693
# Not using -dumpversion as some GCC distros only return major, and
687694
# Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803
@@ -691,7 +698,7 @@ def get_compiler_version(env):
691698
).strip()
692699
except (subprocess.CalledProcessError, OSError):
693700
print_warning("Couldn't parse CXX environment variable to infer compiler version.")
694-
return ret
701+
return update_compiler_version_cache(ret)
695702

696703
match = re.search(
697704
r"(?:(?<=version )|(?<=\) )|(?<=^))"
@@ -734,7 +741,13 @@ def get_compiler_version(env):
734741
"apple_patch3",
735742
]:
736743
ret[key] = int(ret[key] or -1)
737-
return ret
744+
return update_compiler_version_cache(ret)
745+
746+
747+
def update_compiler_version_cache(value):
748+
global compiler_version_cache
749+
compiler_version_cache = value
750+
return value
738751

739752

740753
def using_gcc(env):

platform/web/detect.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ def get_flags():
8989
}
9090

9191

92+
def library_emitter(target, source, env):
93+
# Make every source file dependent on the compiler version.
94+
# This makes sure that when emscripten is updated, that the cached files
95+
# aren't used and are recompiled instead.
96+
env.Depends(source, env.Value(get_compiler_version(env)))
97+
return target, source
98+
99+
92100
def configure(env: "SConsEnvironment"):
101+
env.Append(LIBEMITTER=library_emitter)
102+
93103
# Validate arch.
94104
supported_arches = ["wasm32"]
95105
validate_arch(env["arch"], get_name(), supported_arches)

0 commit comments

Comments
 (0)