Bug 679359 - Autodetect WIN32_REDIST_DIR. r=firefox-build-system-reviewers,sergesanspaille,nalexander

Differential Revision: https://phabricator.services.mozilla.com/D202191
This commit is contained in:
Mike Hommey 2024-02-21 22:18:10 +00:00
Родитель 866c9cfcc3
Коммит c7fe957839
7 изменённых файлов: 56 добавлений и 45 удалений

Просмотреть файл

@ -34,9 +34,7 @@ Build process
.. note::
If you intend to distribute your build to others, you'll want to add
``export WIN32_REDIST_DIR=<CRT_LOCATION>`` in your ``mozconfig``. The CRT location
will vary depending on your Visual Studio version. At the time of writing, this would look like:
``export WIN32_REDIST_DIR="/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Redist/MSVC/14.28.29325/x86/Microsoft.VC142.CRT"``.
``ac_add_options --with-redist`` in your ``mozconfig``.
Both the full and stub installers are built through a similar process, which is summarized here along with references to the relevant bits of code.

Просмотреть файл

@ -25,6 +25,14 @@ set_define("MOZ_MEMORY", True, when="--enable-jemalloc")
add_old_configure_assignment("MOZ_MEMORY", True, when="--enable-jemalloc")
@depends("--enable-jemalloc", moz_debug, win32_redist_dir)
def check_redist(jemalloc, debug, win32_redist_dir):
if not jemalloc and not win32_redist_dir and not debug:
log.warning(
"When not building jemalloc, you need to build with --with-redist or set WIN32_REDIST_DIR."
)
@depends(milestone, build_project)
def replace_malloc_default(milestone, build_project):
if build_project == "memory":

Просмотреть файл

@ -383,7 +383,7 @@ def lib_path_for(host_or_target):
compiler.compiler,
"/clang:--print-runtime-dir",
*compiler.flags,
onerror=lambda: None
onerror=lambda: None,
).strip()
if runtime_dir and os.path.exists(runtime_dir):
# Put the clang runtime directory first, in case there is
@ -479,3 +479,48 @@ host_link = check_prog(
)
add_old_configure_assignment("LINKER", link)
option(
"--with-redist",
env="WIN32_REDIST_DIR",
default=depends("MOZ_AUTOMATION")(lambda x: bool(x)),
nargs="?",
help="{Package|Don't package} redistributable MSVCRT",
)
@depends("--with-redist", vc_path, target)
@imports("os")
def win32_redist_dir(redist, vc_path, target):
if len(redist):
if os.path.isdir(redist[0]):
return redist[0]
configure_error(f"Invalid Win32 Redist directory: {redist[0]}")
if redist:
if not vc_path:
configure_error("Cannot ship redistributable MSVCRT without MSVC")
# It would be too simple if the Redist dir had the same version number as
# the MSVC one.
base_redist_path = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(vc_path))), "Redist", "MSVC"
)
redist_target = {
"x86": "x86",
"x86_64": "x64",
"aarch64": "arm64",
}.get(target.cpu)
if redist_target and os.path.isdir(base_redist_path):
versions = [Version(v) for v in os.listdir(base_redist_path)]
redist_path = os.path.join(
base_redist_path,
str(max(v for v in versions if v.major)),
redist_target,
)
if os.path.isdir(redist_path):
crt_path = max(p for p in os.listdir(redist_path) if p.endswith("CRT"))
if crt_path:
return os.path.join(redist_path, crt_path)
configure_error("Could not find redistributable MSVCRT files")
set_config("WIN32_REDIST_DIR", win32_redist_dir)

Просмотреть файл

@ -1,9 +1 @@
if [ -z "${VSPATH}" ]; then
VSPATH="$(cd ${MOZ_FETCHES_DIR} && pwd)/vs"
fi
if [ -d "${VSPATH}" ]; then
export WIN32_REDIST_DIR="${VSPATH}/VC/Redist/MSVC/14.29.30133/x86/Microsoft.VC142.CRT"
fi
ac_add_options --target=i686-pc-windows-msvc

Просмотреть файл

@ -1,7 +0,0 @@
if [ -z "${VSPATH}" ]; then
VSPATH="$(cd ${MOZ_FETCHES_DIR} && pwd)/vs"
fi
if [ -d "${VSPATH}" ]; then
export WIN32_REDIST_DIR="${VSPATH}/VC/Redist/MSVC/14.29.30133/arm64/Microsoft.VC142.CRT"
fi

Просмотреть файл

@ -1,7 +0,0 @@
if [ -z "${VSPATH}" ]; then
VSPATH="$(cd ${MOZ_FETCHES_DIR} && pwd)/vs"
fi
if [ -d "${VSPATH}" ]; then
export WIN32_REDIST_DIR=${VSPATH}/VC/Redist/MSVC/14.29.30133/x64/Microsoft.VC142.CRT
fi

Просмотреть файл

@ -113,13 +113,6 @@ case "$target" in
AC_SUBST(MSVC_CXX_RUNTIME_DLL)
AC_DEFINE(HAVE_SEH_EXCEPTIONS)
if test -n "$WIN32_REDIST_DIR"; then
if test ! -d "$WIN32_REDIST_DIR"; then
AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
fi
WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
fi
else
# Check w32api version
_W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
@ -951,15 +944,7 @@ esac
dnl ========================================================
dnl = Jemalloc build setup
dnl ========================================================
if test -z "$MOZ_MEMORY"; then
case "${target}" in
*-mingw*)
if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR/redist/x86/Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
fi
;;
esac
else
if test -n "$MOZ_MEMORY"; then
case "${target}" in
*-mingw*)
export MOZ_NO_DEBUG_RTL=1
@ -1169,9 +1154,6 @@ AC_SUBST(MOZ_SOURCE_REPO)
AC_SUBST(MOZ_SOURCE_CHANGESET)
AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
dnl win32 options
AC_SUBST(WIN32_REDIST_DIR)
dnl Echo the CFLAGS to remove extra whitespace.
CFLAGS=`echo \
$_COMPILATION_CFLAGS \