forked from mirrors/gecko-dev
Bug 1725895: Add support for MSYS2 MozillaBuild r=glandium
MSYS2 has a slightly different directory structure (binaries are now under "/usr/bin/" instead of "/bin/"), and we're now plonking it in `%MOZILLABUILD%\msys2` instead of `%MOZILLABUILD%\msys` so that MSYS1 files don't interfere with MSYS2 after a pave-over install. Speaking of pave-over installs: if both `msys2` and `msys` are available, this patch prefers `msys2`. This is because MozillaBuild installations with MSYS2 are going to _assume_ they're using MSYS2, and therefore be most compatible with the versions of packages shipped with MSYS2. Differential Revision: https://phabricator.services.mozilla.com/D133549
This commit is contained in:
parent
92a19e0eb9
commit
47520dab98
6 changed files with 42 additions and 10 deletions
|
|
@ -104,11 +104,15 @@ option(env="CONFIG_SHELL", nargs=1, help="Path to a POSIX shell")
|
||||||
@depends("CONFIG_SHELL", "MOZILLABUILD")
|
@depends("CONFIG_SHELL", "MOZILLABUILD")
|
||||||
@checking("for a shell")
|
@checking("for a shell")
|
||||||
@imports("sys")
|
@imports("sys")
|
||||||
|
@imports(_from="pathlib", _import="Path")
|
||||||
def shell(value, mozillabuild):
|
def shell(value, mozillabuild):
|
||||||
if value:
|
if value:
|
||||||
return find_program(value[0])
|
return find_program(value[0])
|
||||||
shell = "sh"
|
shell = "sh"
|
||||||
if mozillabuild:
|
if mozillabuild:
|
||||||
|
if (Path(mozillabuild[0]) / "msys2").exists():
|
||||||
|
shell = mozillabuild[0] + "/msys2/usr/bin/sh"
|
||||||
|
else:
|
||||||
shell = mozillabuild[0] + "/msys/bin/sh"
|
shell = mozillabuild[0] + "/msys/bin/sh"
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
shell = shell + ".exe"
|
shell = shell + ".exe"
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ def FixupMsysPath(path):
|
||||||
trying to pass an absolute path on a remote server. This function attempts
|
trying to pass an absolute path on a remote server. This function attempts
|
||||||
to un-mangle such paths."""
|
to un-mangle such paths."""
|
||||||
if "OSTYPE" in os.environ and os.environ["OSTYPE"] == "msys":
|
if "OSTYPE" in os.environ and os.environ["OSTYPE"] == "msys":
|
||||||
# sort of awful, find out where our shell is (should be in msys/bin)
|
# sort of awful, find out where our shell is (should be in msys2/usr/bin
|
||||||
# and strip the first part of that path out of the other path
|
# or msys/bin) and strip the first part of that path out of the other path
|
||||||
if "SHELL" in os.environ:
|
if "SHELL" in os.environ:
|
||||||
sh = os.environ["SHELL"]
|
sh = os.environ["SHELL"]
|
||||||
msys = sh[: sh.find("/bin")]
|
msys = sh[: sh.find("/bin")]
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import os
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from mozprocess.processhandler import ProcessHandlerMixin
|
from mozprocess.processhandler import ProcessHandlerMixin
|
||||||
|
|
@ -24,7 +25,11 @@ from .logging import LoggingMixin
|
||||||
if "SHELL" in os.environ:
|
if "SHELL" in os.environ:
|
||||||
_current_shell = os.environ["SHELL"]
|
_current_shell = os.environ["SHELL"]
|
||||||
elif "MOZILLABUILD" in os.environ:
|
elif "MOZILLABUILD" in os.environ:
|
||||||
_current_shell = os.environ["MOZILLABUILD"] + "/msys/bin/sh.exe"
|
mozillabuild = os.environ["MOZILLABUILD"]
|
||||||
|
if (Path(mozillabuild) / "msys2").exists():
|
||||||
|
_current_shell = mozillabuild + "/msys2/usr/bin/sh.exe"
|
||||||
|
else:
|
||||||
|
_current_shell = mozillabuild + "/msys/bin/sh.exe"
|
||||||
elif "COMSPEC" in os.environ:
|
elif "COMSPEC" in os.environ:
|
||||||
_current_shell = os.environ["COMSPEC"]
|
_current_shell = os.environ["COMSPEC"]
|
||||||
elif sys.platform != "win32":
|
elif sys.platform != "win32":
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from xml.dom import getDOMImplementation
|
from xml.dom import getDOMImplementation
|
||||||
|
|
||||||
|
|
@ -466,11 +467,16 @@ class VisualStudioBackend(CommonBackend):
|
||||||
fh.write(b"$expanded = $bashargs -join ' '\r\n")
|
fh.write(b"$expanded = $bashargs -join ' '\r\n")
|
||||||
fh.write(b'$procargs = "-c", $expanded\r\n')
|
fh.write(b'$procargs = "-c", $expanded\r\n')
|
||||||
|
|
||||||
|
if (Path(os.environ["MOZILLABUILD"]) / "msys2").exists():
|
||||||
|
bash_path = rb"msys2\usr\bin\bash"
|
||||||
|
else:
|
||||||
|
bash_path = rb"msys\bin\bash"
|
||||||
|
|
||||||
fh.write(
|
fh.write(
|
||||||
b"Start-Process -WorkingDirectory $env:TOPOBJDIR "
|
b"Start-Process -WorkingDirectory $env:TOPOBJDIR "
|
||||||
b"-FilePath $env:MOZILLABUILD\\msys\\bin\\bash "
|
b"-FilePath $env:MOZILLABUILD\\%b "
|
||||||
b"-ArgumentList $procargs "
|
b"-ArgumentList $procargs "
|
||||||
b"-Wait -NoNewWindow\r\n"
|
b"-Wait -NoNewWindow\r\n" % bash_path
|
||||||
)
|
)
|
||||||
|
|
||||||
def _write_mach_batch(self, fh):
|
def _write_mach_batch(self, fh):
|
||||||
|
|
@ -492,12 +498,17 @@ class VisualStudioBackend(CommonBackend):
|
||||||
self.environment.topsrcdir, self.environment.topobjdir
|
self.environment.topsrcdir, self.environment.topobjdir
|
||||||
).replace("\\", "/")
|
).replace("\\", "/")
|
||||||
|
|
||||||
|
if (Path(os.environ["MOZILLABUILD"]) / "msys2").exists():
|
||||||
|
bash_path = rb"msys2\usr\bin\bash"
|
||||||
|
else:
|
||||||
|
bash_path = rb"msys\bin\bash"
|
||||||
|
|
||||||
# We go through mach because it has the logic for choosing the most
|
# We go through mach because it has the logic for choosing the most
|
||||||
# appropriate build tool.
|
# appropriate build tool.
|
||||||
fh.write(
|
fh.write(
|
||||||
b'"%%MOZILLABUILD%%\\msys\\bin\\bash" '
|
b'"%%MOZILLABUILD%%\\%b" '
|
||||||
b'-c "%s/mach --log-no-times %%1 %%2 %%3 %%4 %%5 %%6 %%7"'
|
b'-c "%s/mach --log-no-times %%1 %%2 %%3 %%4 %%5 %%6 %%7"'
|
||||||
% relpath.encode("utf-8")
|
% (bash_path, relpath.encode("utf-8"))
|
||||||
)
|
)
|
||||||
|
|
||||||
def _write_vs_project(self, out_dir, basename, name, **kwargs):
|
def _write_vs_project(self, out_dir, basename, name, **kwargs):
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import six
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import traceback
|
import traceback
|
||||||
|
from pathlib import Path
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
from mozboot.mozconfig import find_mozconfig
|
from mozboot.mozconfig import find_mozconfig
|
||||||
|
|
@ -132,7 +133,11 @@ class MozconfigLoader(object):
|
||||||
# directly calling sh mozconfig_loader.
|
# directly calling sh mozconfig_loader.
|
||||||
shell = "sh"
|
shell = "sh"
|
||||||
if "MOZILLABUILD" in os.environ:
|
if "MOZILLABUILD" in os.environ:
|
||||||
shell = os.environ["MOZILLABUILD"] + "/msys/bin/sh"
|
mozillabuild = os.environ["MOZILLABUILD"]
|
||||||
|
if (Path(mozillabuild) / "msys2").exists():
|
||||||
|
shell = mozillabuild + "/msys2/usr/bin/sh"
|
||||||
|
else:
|
||||||
|
shell = mozillabuild + "/msys/bin/sh"
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
shell = shell + ".exe"
|
shell = shell + ".exe"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import shutil
|
||||||
import zipfile
|
import zipfile
|
||||||
import tarfile
|
import tarfile
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import mozpack.path as mozpath
|
import mozpack.path as mozpath
|
||||||
from mozbuild.repackaging.application_ini import get_application_ini_value
|
from mozbuild.repackaging.application_ini import get_application_ini_value
|
||||||
from mozbuild.util import ensureParentDir
|
from mozbuild.util import ensureParentDir
|
||||||
|
|
@ -83,7 +85,12 @@ def repackage_mar(topsrcdir, package, mar, output, arch=None, mar_channel_id=Non
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
# make_full_update.sh is a bash script, and Windows needs to
|
# make_full_update.sh is a bash script, and Windows needs to
|
||||||
# explicitly call out the shell to execute the script from Python.
|
# explicitly call out the shell to execute the script from Python.
|
||||||
cmd.insert(0, env["MOZILLABUILD"] + "/msys/bin/bash.exe")
|
|
||||||
|
mozillabuild = os.environ["MOZILLABUILD"]
|
||||||
|
if (Path(mozillabuild) / "msys2").exists():
|
||||||
|
cmd.insert(0, mozillabuild + "/msys2/usr/bin/bash.exe")
|
||||||
|
else:
|
||||||
|
cmd.insert(0, mozillabuild + "/msys/bin/bash.exe")
|
||||||
subprocess.check_call(cmd, env=env)
|
subprocess.check_call(cmd, env=env)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue