forked from mirrors/gecko-dev
Bug 1802405 - Prepend mozillabuild msys2 to path only for the build. r=glandium
This reverts bug 1801826 and instead prepends the msys2 path only for the build, which is a bit more sensible. This allows us to remove the existing warning from old_configure, since that can't happen now. Differential Revision: https://phabricator.services.mozilla.com/D163073
This commit is contained in:
parent
280201b26e
commit
de7acc6e32
5 changed files with 53 additions and 37 deletions
|
|
@ -116,11 +116,9 @@ def _maybe_activate_mozillabuild_environment():
|
||||||
|
|
||||||
paths_to_add = [mozillabuild_msys_tools_path, mozillabuild / "bin"]
|
paths_to_add = [mozillabuild_msys_tools_path, mozillabuild / "bin"]
|
||||||
existing_paths = [Path(p) for p in os.environ.get("PATH", "").split(os.pathsep)]
|
existing_paths = [Path(p) for p in os.environ.get("PATH", "").split(os.pathsep)]
|
||||||
# It's important that we prepend to the path rather than append,
|
|
||||||
# in case mach is getting called from another msys2 environment.
|
|
||||||
for new_path in paths_to_add:
|
for new_path in paths_to_add:
|
||||||
if new_path not in existing_paths:
|
if new_path not in existing_paths:
|
||||||
os.environ["PATH"] = f"{new_path}{os.pathsep}" + os.environ["PATH"]
|
os.environ["PATH"] += f"{os.pathsep}{new_path}"
|
||||||
|
|
||||||
|
|
||||||
def initialize(topsrcdir):
|
def initialize(topsrcdir):
|
||||||
|
|
|
||||||
|
|
@ -794,6 +794,12 @@ def target_is_windows(target):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@depends(host)
|
||||||
|
def host_is_windows(host):
|
||||||
|
if host.kernel == "WINNT":
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
set_define("_WINDOWS", target_is_windows)
|
set_define("_WINDOWS", target_is_windows)
|
||||||
set_define("WIN32", target_is_windows)
|
set_define("WIN32", target_is_windows)
|
||||||
set_define("XP_WIN", target_is_windows)
|
set_define("XP_WIN", target_is_windows)
|
||||||
|
|
@ -823,6 +829,12 @@ def target_is_osx(target):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@depends(host)
|
||||||
|
def host_is_osx(host):
|
||||||
|
if host.os == "OSX":
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
set_define("XP_MACOSX", target_is_osx)
|
set_define("XP_MACOSX", target_is_osx)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1120,6 +1132,23 @@ def mozbuild_state_path(path, _):
|
||||||
return normalize_path(os.path.expanduser(os.path.join("~", ".mozbuild")))
|
return normalize_path(os.path.expanduser(os.path.join("~", ".mozbuild")))
|
||||||
|
|
||||||
|
|
||||||
|
@depends("MOZILLABUILD", shell, host_is_windows)
|
||||||
|
@imports(_from="pathlib", _import="Path")
|
||||||
|
def mozillabuild_bin_paths(mozillabuild, shell, host_is_windows):
|
||||||
|
paths = []
|
||||||
|
if not mozillabuild or not host_is_windows:
|
||||||
|
return paths
|
||||||
|
paths.append(os.path.dirname(shell))
|
||||||
|
paths.append(str(Path(mozillabuild[0]) / "bin"))
|
||||||
|
return paths
|
||||||
|
|
||||||
|
|
||||||
|
@depends(mozillabuild_bin_paths)
|
||||||
|
@imports("os")
|
||||||
|
def prefer_mozillabuild_path(mozillabuild_bin_paths):
|
||||||
|
return mozillabuild_bin_paths + os.environ["PATH"].split(os.pathsep)
|
||||||
|
|
||||||
|
|
||||||
# A template providing a shorthand for setting a variable. The created
|
# A template providing a shorthand for setting a variable. The created
|
||||||
# option will only be settable with imply_option.
|
# option will only be settable with imply_option.
|
||||||
# It is expected that a project-specific moz.configure will call imply_option
|
# It is expected that a project-specific moz.configure will call imply_option
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ m4 = check_prog(
|
||||||
"gm4",
|
"gm4",
|
||||||
"m4",
|
"m4",
|
||||||
),
|
),
|
||||||
|
paths=prefer_mozillabuild_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -121,11 +122,11 @@ def old_configure_for(old_configure_path, extra_env=None):
|
||||||
@depends(
|
@depends(
|
||||||
prepare_configure,
|
prepare_configure,
|
||||||
prepare_configure_options,
|
prepare_configure_options,
|
||||||
|
prefer_mozillabuild_path,
|
||||||
altered_path,
|
altered_path,
|
||||||
extra_env,
|
extra_env,
|
||||||
build_environment,
|
build_environment,
|
||||||
old_configure_path,
|
old_configure_path,
|
||||||
"MOZILLABUILD",
|
|
||||||
awk,
|
awk,
|
||||||
m4,
|
m4,
|
||||||
shell,
|
shell,
|
||||||
|
|
@ -147,17 +148,23 @@ def old_configure_for(old_configure_path, extra_env=None):
|
||||||
def old_configure(
|
def old_configure(
|
||||||
prepare_configure,
|
prepare_configure,
|
||||||
prepare_configure_options,
|
prepare_configure_options,
|
||||||
|
prefer_mozillabuild_path,
|
||||||
altered_path,
|
altered_path,
|
||||||
extra_env,
|
extra_env,
|
||||||
build_env,
|
build_env,
|
||||||
old_configure,
|
old_configure,
|
||||||
mozillabuild,
|
|
||||||
awk,
|
awk,
|
||||||
m4,
|
m4,
|
||||||
shell,
|
shell,
|
||||||
):
|
):
|
||||||
# Use prepare_configure to make lint happy
|
# Use prepare_configure to make lint happy
|
||||||
prepare_configure
|
prepare_configure
|
||||||
|
|
||||||
|
if altered_path:
|
||||||
|
path = altered_path
|
||||||
|
else:
|
||||||
|
path = os.pathsep.join(prefer_mozillabuild_path)
|
||||||
|
|
||||||
refresh = True
|
refresh = True
|
||||||
if os.path.exists(old_configure):
|
if os.path.exists(old_configure):
|
||||||
mtime = os.path.getmtime(old_configure)
|
mtime = os.path.getmtime(old_configure)
|
||||||
|
|
@ -183,6 +190,7 @@ def old_configure_for(old_configure_path, extra_env=None):
|
||||||
env["M4"] = m4
|
env["M4"] = m4
|
||||||
env["AWK"] = awk
|
env["AWK"] = awk
|
||||||
env["AC_MACRODIR"] = os.path.join(build_env.topsrcdir, "build", "autoconf")
|
env["AC_MACRODIR"] = os.path.join(build_env.topsrcdir, "build", "autoconf")
|
||||||
|
env["PATH"] = path
|
||||||
|
|
||||||
try:
|
try:
|
||||||
script = subprocess.check_output(
|
script = subprocess.check_output(
|
||||||
|
|
@ -199,17 +207,6 @@ def old_configure_for(old_configure_path, extra_env=None):
|
||||||
env=env,
|
env=env,
|
||||||
)
|
)
|
||||||
except CalledProcessError as exc:
|
except CalledProcessError as exc:
|
||||||
# Autoconf on win32 may break due to a bad $PATH. Let the user know
|
|
||||||
# their $PATH is suspect.
|
|
||||||
if mozillabuild:
|
|
||||||
mozillabuild_path = normsep(mozillabuild[0])
|
|
||||||
sh_path = normsep(find_program("sh"))
|
|
||||||
if mozillabuild_path not in sh_path:
|
|
||||||
log.warning(
|
|
||||||
"The '{}msys/bin' directory is not first in $PATH. "
|
|
||||||
"This may cause autoconf to fail. ($PATH is currently "
|
|
||||||
"set to: {})".format(mozillabuild_path, os.environ["PATH"])
|
|
||||||
)
|
|
||||||
die("autoconf exited with return code {}".format(exc.returncode))
|
die("autoconf exited with return code {}".format(exc.returncode))
|
||||||
|
|
||||||
if not script:
|
if not script:
|
||||||
|
|
@ -259,8 +256,7 @@ def old_configure_for(old_configure_path, extra_env=None):
|
||||||
log_size = os.path.getsize(config_log.baseFilename)
|
log_size = os.path.getsize(config_log.baseFilename)
|
||||||
break
|
break
|
||||||
|
|
||||||
if altered_path:
|
env["PATH"] = path
|
||||||
env["PATH"] = altered_path
|
|
||||||
|
|
||||||
if extra_env:
|
if extra_env:
|
||||||
env.update(extra_env)
|
env.update(extra_env)
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,6 @@ with only_when(target_is_osx):
|
||||||
return value[0]
|
return value[0]
|
||||||
|
|
||||||
|
|
||||||
@depends(host)
|
|
||||||
def host_is_osx(host):
|
|
||||||
if host.os == "OSX":
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
with only_when(host_is_osx | target_is_osx):
|
with only_when(host_is_osx | target_is_osx):
|
||||||
# MacOS SDK
|
# MacOS SDK
|
||||||
# =========
|
# =========
|
||||||
|
|
@ -531,12 +525,6 @@ def get_vc_paths(topsrcdir):
|
||||||
yield (Version(install["installationVersion"]), tools_path)
|
yield (Version(install["installationVersion"]), tools_path)
|
||||||
|
|
||||||
|
|
||||||
@depends(host)
|
|
||||||
def host_is_windows(host):
|
|
||||||
if host.kernel == "WINNT":
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
option(
|
option(
|
||||||
"--with-visual-studio-version",
|
"--with-visual-studio-version",
|
||||||
nargs=1,
|
nargs=1,
|
||||||
|
|
@ -662,13 +650,17 @@ def rust_search_path(rust_path, search_order, original_path):
|
||||||
|
|
||||||
# As a workaround until bug 1516228 and bug 1516253 are fixed, set the PATH
|
# As a workaround until bug 1516228 and bug 1516253 are fixed, set the PATH
|
||||||
# variable for the build to contain the toolchain search path.
|
# variable for the build to contain the toolchain search path.
|
||||||
@depends(vc_toolchain_search_path)
|
#
|
||||||
|
# FIXME(bug 1802573): The two bugs above are fixed, do we still need that?
|
||||||
|
#
|
||||||
|
# Prepend the mozilla-build msys2 path, since otherwise we can get mismatched
|
||||||
|
# cygwin dll errors during configure if we get called from another msys2
|
||||||
|
# environment, see bug 1801826.
|
||||||
|
@depends(mozillabuild_bin_paths, vc_toolchain_search_path)
|
||||||
@imports("os")
|
@imports("os")
|
||||||
@imports(_from="os", _import="environ")
|
def altered_path(mozillabuild_bin_paths, vc_toolchain_search_path):
|
||||||
def altered_path(vc_toolchain_search_path):
|
altered_path = mozillabuild_bin_paths + list(vc_toolchain_search_path)
|
||||||
path = environ["PATH"].split(os.pathsep)
|
for p in os.environ["PATH"].split(os.pathsep):
|
||||||
altered_path = list(vc_toolchain_search_path)
|
|
||||||
for p in path:
|
|
||||||
if p not in altered_path:
|
if p not in altered_path:
|
||||||
altered_path.append(p)
|
altered_path.append(p)
|
||||||
return os.pathsep.join(altered_path)
|
return os.pathsep.join(altered_path)
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,7 @@ set_config("ENABLE_UNIFIED_BUILD", True, when="--disable-unified-build")
|
||||||
|
|
||||||
include("build/moz.configure/bootstrap.configure")
|
include("build/moz.configure/bootstrap.configure")
|
||||||
|
|
||||||
|
|
||||||
# The execution model of the configure sandbox doesn't allow for
|
# The execution model of the configure sandbox doesn't allow for
|
||||||
# check_prog to use bootstrap_search_path directly because check_prog
|
# check_prog to use bootstrap_search_path directly because check_prog
|
||||||
# comes first, so we use a trick to allow it. Uses of check_prog
|
# comes first, so we use a trick to allow it. Uses of check_prog
|
||||||
|
|
@ -516,7 +517,7 @@ add_old_configure_assignment("CLANG_PLUGIN", clang_plugin_path)
|
||||||
|
|
||||||
# Awk detection
|
# Awk detection
|
||||||
# ==============================================================
|
# ==============================================================
|
||||||
awk = check_prog("AWK", ("gawk", "mawk", "nawk", "awk"))
|
awk = check_prog("AWK", ("gawk", "mawk", "nawk", "awk"), paths=prefer_mozillabuild_path)
|
||||||
|
|
||||||
# Until the AWK variable is not necessary in old-configure
|
# Until the AWK variable is not necessary in old-configure
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue