summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-03-06 15:52:33 +0100
committerLuboš Luňák <l.lunak@collabora.com>2020-03-23 14:31:33 +0100
commita1a62a70411cb6041b5930ead08280d5e1e7b5f9 (patch)
treedd83ae0cd12fb6593f9a8f4dd9e425722b007f1e
parent532ffb7a297d55b495141ce33692df5d9917b54f (diff)
build nss using gyp+ninja also on Windows
Change-Id: I3acb0f2a93cee85e382e03c2b2fdd68273e12516 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90117 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--external/nss/ExternalProject_nss.mk42
-rw-r--r--external/nss/UnpackedTarball_gyp.mk6
-rw-r--r--external/nss/UnpackedTarball_nss.mk6
-rw-r--r--external/nss/buildsystem-windows.patch.0135
-rw-r--r--external/nss/gyp-buildsystem-windows.patch.010
-rwxr-xr-x[-rw-r--r--]external/nss/nsinstall.py1
-rw-r--r--external/nss/python-cygwin-template24
-rw-r--r--solenv/gcc-wrappers/wrapper.cxx45
8 files changed, 238 insertions, 31 deletions
diff --git a/external/nss/ExternalProject_nss.mk b/external/nss/ExternalProject_nss.mk
index daee76fc8fa9..f48d5b22dbde 100644
--- a/external/nss/ExternalProject_nss.mk
+++ b/external/nss/ExternalProject_nss.mk
@@ -16,22 +16,38 @@ $(eval $(call gb_ExternalProject_register_targets,nss,\
))
ifeq ($(OS),WNT)
-$(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalExecutable_get_dependencies,python)
+
+$(eval $(call gb_ExternalProject_use_autoconf,nss,build))
+
+# The nss build system uses 'python', even recursively, so make it find our internal python if necessary.
+nss_PYTHON := $(call gb_UnpackedTarball_get_dir,nss)/python
+nss_SETUP_PYTHON := $(call gb_UnpackedTarball_get_dir,nss)/setup-python
+
+$(call gb_ExternalProject_get_state_target,nss,build): \
+ $(call gb_ExternalExecutable_get_dependencies,python) \
+ $(call gb_UnpackedTarball_get_target,gyp) | $(dir $(call gb_ExternalProject_get_target,gyp)).dir
$(call gb_Trace_StartRange,nss,EXTERNAL)
+ cp $(SRCDIR)/external/nss/python-cygwin-template $(nss_PYTHON)
+ pythondir=$$($(call gb_ExternalExecutable_get_command,python) -c 'import sys; import os; sys.stdout.write(os.path.dirname(sys.executable))') \
+ && echo PATH=\"$$pythondir:\$$PATH\" >>$(nss_PYTHON)
+ echo '$(call gb_ExternalExecutable_get_command,python)' \"$$\{args[@]\}\" >>$(nss_PYTHON)
+ chmod +x $(nss_PYTHON)
+ cp $(SRCDIR)/external/nss/setup-python $(nss_SETUP_PYTHON)
+ chmod +x $(nss_SETUP_PYTHON)
$(call gb_ExternalProject_run,build,\
- $(if $(MSVC_USE_DEBUG_RUNTIME),USE_DEBUG_RTL=1,BUILD_OPT=1) \
- $(if $(gb_Module_CURRENTMODULE_SYMBOLS_ENABLED), \
- MOZ_DEBUG_SYMBOLS=1 \
- MOZ_DEBUG_FLAGS=" " \
- OPT_CODE_SIZE=0) \
- MOZ_MSVCVERSION=9 OS_TARGET=WIN95 \
- $(if $(filter X86_64,$(CPUNAME)),USE_64=1) \
- LIB="$(ILIB)" \
- XCFLAGS="-arch:SSE $(SOLARINC)" \
- $(MAKE) -j1 nss_build_all RC="rc.exe $(SOLARINC)" \
- NSINSTALL='$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/external/nss/nsinstall.py' \
- NSS_DISABLE_GTESTS=1 \
+ COMMA=$(COMMA) \
+ PATH=$$(cygpath $(call gb_UnpackedTarball_get_dir,nss)):$$(cygpath $(call gb_UnpackedTarball_get_dir,gyp)):$$PATH \
+ MAKE=$(MAKE) \
+ NSINSTALL='$(SRCDIR)/external/nss/nsinstall.py' \
+ LIB="$(ILIB)" \
+ RC="rc.exe $(SOLARINC)" \
+ CL="-arch:SSE" \
+ ./build.sh -v --disable-tests --enable-libpkix \
+ $(if $(filter X86_64,$(CPUNAME)),--target=x64,--target=ia32) \
+ $(if $(ENABLE_DBGUTIL),,--opt) \
+ && rm -f $(call gb_UnpackedTarball_get_dir,nss)/dist/out/lib/*.a \
,nss)
+ for f in $(call gb_UnpackedTarball_get_dir,nss)/dist/out/lib/*.dll.lib; do mv "$$f" "$${f%.dll.lib}".lib; done
$(call gb_Trace_EndRange,nss,EXTERNAL)
else ifneq (,$(filter FREEBSD LINUX NETBSD OPENBSD SOLARIS,$(OS))) # non-WNT gyp-based
diff --git a/external/nss/UnpackedTarball_gyp.mk b/external/nss/UnpackedTarball_gyp.mk
index 50f7ba9c52b2..ce44ae51f996 100644
--- a/external/nss/UnpackedTarball_gyp.mk
+++ b/external/nss/UnpackedTarball_gyp.mk
@@ -15,4 +15,10 @@ $(eval $(call gb_UnpackedTarball_add_patches,gyp,\
external/nss/gyp-buildsystem.patch.0 \
))
+ifeq ($(OS),WNT)
+$(eval $(call gb_UnpackedTarball_add_patches,gyp,\
+ external/nss/gyp-buildsystem-windows.patch.0 \
+))
+endif
+
# vim: set noet sw=4 ts=4:
diff --git a/external/nss/UnpackedTarball_nss.mk b/external/nss/UnpackedTarball_nss.mk
index 4c6aa3db2030..2cffb09212d7 100644
--- a/external/nss/UnpackedTarball_nss.mk
+++ b/external/nss/UnpackedTarball_nss.mk
@@ -38,6 +38,12 @@ $(eval $(call gb_UnpackedTarball_add_patches,nss,\
external/nss/fix-cc-detect-with-ccache.patch.0 \
))
+ifeq ($(OS),WNT)
+$(eval $(call gb_UnpackedTarball_add_patches,nss,\
+ external/nss/buildsystem-windows.patch.0 \
+))
+endif
+
ifeq ($(COM_IS_CLANG),TRUE)
ifneq ($(filter -fsanitize=%,$(CC)),)
$(eval $(call gb_UnpackedTarball_add_patches,nss,\
diff --git a/external/nss/buildsystem-windows.patch.0 b/external/nss/buildsystem-windows.patch.0
new file mode 100644
index 000000000000..7acda26fae45
--- /dev/null
+++ b/external/nss/buildsystem-windows.patch.0
@@ -0,0 +1,135 @@
+--- ./nss/coreconf/nspr.sh.sav 2019-11-19 20:55:30.000000000 +0100
++++ ./nss/coreconf/nspr.sh 2020-02-19 22:25:05.863542364 +0100
+@@ -31,10 +31,13 @@
+ extra_params=(--prefix="$dist_dir"/out --libdir="$dist_dir"/out/lib --includedir="$dist_dir"/out/include)
+ if [ "$opt_build" = 1 ]; then
+ extra_params+=(--disable-debug --enable-optimize)
++ else
++ extra_params+=(--enable-debug-rtl)
+ fi
+ if [ "$target_arch" = "x64" ]; then
+ extra_params+=(--enable-64bit)
+ fi
++ extra_params+=(--enable-win32-target=WIN95)
+
+ echo "NSPR [1/5] configure ..."
+ pushd "$nspr_dir" >/dev/null
+@@ -43,24 +46,24 @@
+ run_verbose ../configure "${extra_params[@]}" "$@"
+ popd >/dev/null
+ echo "NSPR [2/5] make ..."
+- run_verbose make -C "$nspr_dir"
++ run_verbose $MAKE -C $(cygpath -w "$nspr_dir") NSINSTALL=$NSINSTALL RC="$RC"
+
+ if [ "$build_nspr_tests" = 1 ]; then
+ echo "NSPR [3/5] build tests ..."
+- run_verbose make -C "$nspr_dir/pr/tests"
++ run_verbose $MAKE -C $(cygpath -w "$nspr_dir/pr/tests")
+ else
+ echo "NSPR [3/5] NOT building tests"
+ fi
+
+ if [[ "$build_nspr_tests" = 1 && "$run_nspr_tests" = 1 ]]; then
+ echo "NSPR [4/5] run tests ..."
+- run_verbose make -C "$nspr_dir/pr/tests" runtests
++ run_verbose $MAKE -C $(cygpath -w "$nspr_dir/pr/tests") runtests
+ else
+ echo "NSPR [4/5] NOT running tests"
+ fi
+
+ echo "NSPR [5/5] install ..."
+- run_verbose make -C "$nspr_dir" install
++ run_verbose $MAKE -C $(cygpath -w "$nspr_dir") install NSINSTALL=$NSINSTALL
+ }
+
+ nspr_clean()
+--- ./nss/build.sh.sav 2019-11-19 20:55:30.000000000 +0100
++++ ./nss/build.sh 2020-02-19 22:28:30.976068194 +0100
+@@ -155,9 +155,10 @@
+ gyp_params+=(-Dsanitizer_flags="$sanitizer_flags")
+ fi
+
+-if [ "$msvc" = 1 ]; then
+- source "$cwd/coreconf/msvc.sh"
+-fi
++# this breaks nspr
++#if [ "$msvc" = 1 ]; then
++# source "$cwd/coreconf/msvc.sh"
++#fi
+
+ # -c = clean first
+ if [ "$clean" = 1 -o "$clean_only" = 1 ]; then
+@@ -236,6 +237,9 @@
+ exit 0
+ fi
+
++# set up for gyp
++source "$cwd/coreconf/msvc.sh"
++
+ # gyp.
+ if [ "$rebuild_gyp" = 1 ]; then
+ if ! hash "$GYP" 2> /dev/null; then
+@@ -263,4 +267,4 @@
+ echo "Building NSS requires an installation of ninja: https://ninja-build.org/" 1>&2
+ exit 3
+ fi
+-run_scanbuild setup-python "$ninja" -C "$target_dir" "${ninja_params[@]}"
++run_scanbuild setup-python $(cygpath -w $(which "$ninja")) -C $(cygpath -w "$target_dir") "${ninja_params[@]}"
+--- ./nss/coreconf/msvc.sh.sav 2019-11-19 20:55:30.000000000 +0100
++++ ./nss/coreconf/msvc.sh 2020-02-21 17:42:32.344129200 +0100
+@@ -2,6 +2,9 @@
+ # This configures the environment for running MSVC. It uses vswhere, the
+ # registry, and a little knowledge of how MSVC is laid out.
+
++PATH="$PATH:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/Installer/"
++set -o igncr
++
+ if ! hash vswhere 2>/dev/null; then
+ echo "Can't find vswhere on the path, aborting" 1>&2
+ exit 1
+@@ -17,11 +17,7 @@
+
+ # Turn a unix-y path into a windows one.
+ fixpath() {
+- if hash cygpath 2>/dev/null; then
+- cygpath --unix "$1"
+- else # haxx
+- echo "$1" | sed -e 's,\\,/,g;s,^\(.\):,/\L\1,;s,/$,,'
+- fi
++ echo "$1"
+ }
+
+ # Query the registry. This takes $1 and tags that on the end of several
+@@ -94,6 +89,8 @@
+ INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/um"
+ INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/winrt"
+ INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/cppwinrt"
++ # : -> ; as the separator
++ INCLUDE=$(echo "$INCLUDE" | sed 's/:C/;C/g')
+ export INCLUDE
+
+ LIB="${VCINSTALLDIR}/lib/${m}"
+--- ./nspr/configure.sav 2020-02-21 21:40:01.218554800 +0100
++++ ./nspr/configure 2020-02-21 21:41:32.434189100 +0100
+@@ -5977,10 +5977,6 @@
+ NSINSTALL=nsinstall
+ ;;
+ *-cygwin*|*-mks*)
+- NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
+- if test `echo "${PATH}" | grep -c \;` = 0; then
+- CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
+- fi
+ ;;
+ *os2*)
+ ;;
+--- nss/coreconf/config.gypi.sav 2019-11-19 20:55:30.000000000 +0100
++++ nss/coreconf/config.gypi 2020-03-04 16:28:46.512443300 +0100
+@@ -44,7 +44,7 @@
+ }],
+ ['OS=="win"', {
+ 'use_system_zlib%': 0,
+- 'nspr_libs%': ['libnspr4.lib', 'libplc4.lib', 'libplds4.lib'],
++ 'nspr_libs%': ['nspr4.lib', 'plc4.lib', 'plds4.lib'],
+ 'zlib_libs%': [],
+ #TODO
+ 'moz_debug_flags%': '',
diff --git a/external/nss/gyp-buildsystem-windows.patch.0 b/external/nss/gyp-buildsystem-windows.patch.0
new file mode 100644
index 000000000000..645690cdf10d
--- /dev/null
+++ b/external/nss/gyp-buildsystem-windows.patch.0
@@ -0,0 +1,10 @@
+--- pylib/gyp/msvs_emulation.py.sav 2020-02-19 21:45:13.150161000 +0100
++++ pylib/gyp/msvs_emulation.py 2020-02-21 23:51:56.815937600 +0100
+@@ -996,6 +996,7 @@
+ setting = os.path.dirname(sys.executable) + os.pathsep + setting
+ env[var.upper()] = setting
+ break
++ env['CL'] = '-arch:SSE'
+ for required in ('SYSTEMROOT', 'TEMP', 'TMP'):
+ if required not in env:
+ raise Exception('Environment variable "%s" '
diff --git a/external/nss/nsinstall.py b/external/nss/nsinstall.py
index 31b3de3450c5..b73587dd9745 100644..100755
--- a/external/nss/nsinstall.py
+++ b/external/nss/nsinstall.py
@@ -1,3 +1,4 @@
+#! /usr/bin/env python
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
diff --git a/external/nss/python-cygwin-template b/external/nss/python-cygwin-template
new file mode 100644
index 000000000000..baf437f5960c
--- /dev/null
+++ b/external/nss/python-cygwin-template
@@ -0,0 +1,24 @@
+#! /bin/bash
+args=()
+# convert to Windows paths
+while test -n "$1"; do
+ # convert path in each argument, if needed
+ if [[ "$1" =~ -(.*)=(.*) ]]; then # -option=value
+ arg=$(cygpath -w -- "${BASH_REMATCH[2]}" 2>/dev/null)
+ if test -n "$arg"; then # value is a path
+ args+=("-${BASH_REMATCH[1]}=$arg")
+ else
+ args+=("$1")
+ fi
+ else
+ arg=$(cygpath -w -- "$1" 2>/dev/null)
+ if test -n "$arg"; then
+ args+=("$arg")
+ else
+ args+=("$1")
+ fi
+ fi
+ shift
+done
+PATH=$(cygpath -w -p "$PATH")
+# here belongs a line invoking python with ${args[@]} as arguments
diff --git a/solenv/gcc-wrappers/wrapper.cxx b/solenv/gcc-wrappers/wrapper.cxx
index b156c89dc220..c320c722cc42 100644
--- a/solenv/gcc-wrappers/wrapper.cxx
+++ b/solenv/gcc-wrappers/wrapper.cxx
@@ -83,8 +83,7 @@ void setupccenv() {
}
string processccargs(vector<string> rawargs) {
- // suppress the msvc banner
- string args=" -nologo";
+ string args;
// TODO: should these options be enabled globally?
args.append(" -EHsc");
const char *const pDebugRuntime(getenv("MSVC_USE_DEBUG_RUNTIME"));
@@ -100,9 +99,15 @@ string processccargs(vector<string> rawargs) {
// note: always use -debug so a PDB file is created
string linkargs(" -link -debug");
+ bool hasv = false;
+
for(vector<string>::iterator i = rawargs.begin(); i != rawargs.end(); ++i) {
args.append(" ");
- if(*i == "-o") {
+ string a = *i;
+ // When building nss, there are strange trailing \'s (because of windows->cygwin?).
+ while( a.size() > 0 && a[a.size() - 1 ] == '\\')
+ a.resize(a.size() - 1 );
+ if(a == "-o") {
// TODO: handle more than just exe output
++i;
size_t dot=(*i).find_last_of(".");
@@ -128,40 +133,44 @@ string processccargs(vector<string> rawargs) {
exit(1);
}
}
- else if(*i == "-g" || !(*i).compare(0,5,"-ggdb")) {
+ else if(a == "-g" || !a.compare(0,5,"-ggdb")) {
args.append("-Zi");
args.append(" -FS");
}
- else if(!(*i).compare(0,2,"-D")) {
+ else if(!a.compare(0,2,"-D")) {
// need to re-escape strings for preprocessor
- for(size_t pos=(*i).find("\""); pos!=string::npos; pos=(*i).find("\"",pos)) {
- (*i).replace(pos,0,"\\");
+ for(size_t pos=a.find("\""); pos!=string::npos; pos=a.find("\"",pos)) {
+ a.replace(pos,0,"\\");
pos+=2;
}
- args.append(*i);
+ args.append(a);
}
- else if(!(*i).compare(0,2,"-L")) {
- linkargs.append(" -LIBPATH:"+(*i).substr(2));
+ else if(!a.compare(0,2,"-L")) {
+ linkargs.append(" -LIBPATH:"+a.substr(2));
}
- else if(!(*i).compare(0,2,"-l") && (*i).compare(0,5,"-link")) {
- linkargs.append(" "+(*i).substr(2)+".lib");
+ else if(!a.compare(0,2,"-l") && a.compare(0,5,"-link")) {
+ linkargs.append(" "+a.substr(2)+".lib");
}
- else if(!(*i).compare(0,5,"-def:") || !(*i).compare(0,5,"/def:")) {
+ else if(!a.compare(0,5,"-def:") || !a.compare(0,5,"/def:")) {
// why are we invoked with /def:? cl.exe should handle plain
// "foo.def" by itself
- linkargs.append(" " + *i);
+ linkargs.append(" " + a);
}
- else if(!(*i).compare(0,12,"-fvisibility") || *i == "-fPIC") {
+ else if(!a.compare(0,12,"-fvisibility") || a == "-fPIC") {
//TODO: drop other gcc-specific options
}
- else if(!(*i).compare(0,4,"-Wl,")) {
+ else if(!a.compare(0,4,"-Wl,")) {
//TODO: drop other gcc-specific options
}
- else if(*i == "-Werror")
+ else if(a == "-Werror")
args.append("-WX");
+ else if(a == "-v")
+ hasv = true;
else
- args.append(*i);
+ args.append(a);
}
+ if(!hasv) // suppress the msvc banner
+ args.append(" -nologo");
args.append(linkargs);
return args;
}