You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2020/02/08 02:45:10 UTC

[couchdb] 01/01: Fix Windows build

This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch windows-build-3.0.0
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit f9ce69727180bb725497eb25c018c5adbcfa9dc3
Author: Joan Touzet <wo...@apache.org>
AuthorDate: Fri Feb 7 21:40:49 2020 -0500

    Fix Windows build
---
 .gitignore                          |  1 +
 Makefile                            |  2 +-
 configure.ps1                       | 15 +++++++++++++++
 src/couch/priv/couch_js/60/main.cpp |  1 +
 src/couch/rebar.config.script       | 23 +++++++++++++++--------
 5 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/.gitignore b/.gitignore
index 78eccc1..60e6d14 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
 *.so
 *.pyc
 *.swp
+*.pdb
 *~
 .venv
 .DS_Store
diff --git a/Makefile b/Makefile
index da5d003..6f704be 100644
--- a/Makefile
+++ b/Makefile
@@ -504,7 +504,7 @@ endif
 
 share/www:
 ifeq ($(with_fauxton), 1)
-	@echo "Building Fauxton"
+	@echo 'Building Fauxton'
 	@cd src/fauxton && npm install --production && ./node_modules/grunt-cli/bin/grunt couchdb
 endif
 
diff --git a/configure.ps1 b/configure.ps1
index 9888a9f..c74fbcf 100644
--- a/configure.ps1
+++ b/configure.ps1
@@ -190,6 +190,21 @@ $ConfigERL = @"
 "@
 $ConfigERL | Out-File "$rootdir\config.erl" -encoding ascii
 
+# check for rebar; if not found, build it and add it to our path
+if ((Get-Command "rebar.cmd" -ErrorAction SilentlyContinue) -eq $null)
+{
+   Write-Verbose "==> rebar.cmd not found; bootstrapping..."
+   if (-Not (Test-Path "src\rebar"))
+   {
+      git clone --depth 1 https://github.com/apache/couchdb-rebar.git $rootdir\src\rebar
+   }
+   cmd /c "cd src\rebar && $rootdir\src\rebar\bootstrap.bat"
+   cp $rootdir\src\rebar\rebar $rootdir\bin\rebar
+   cp $rootdir\src\rebar\rebar.cmd $rootdir\bin\rebar.cmd
+   make -C $rootdir\src\rebar clean
+   $env:Path += ";$rootdir\bin"
+}
+
 # only update dependencies, when we are not in a release tarball
 if ( (Test-Path .git -PathType Container) -and (-not $SkipDeps) ) {
     Write-Verbose "==> updating dependencies"
diff --git a/src/couch/priv/couch_js/60/main.cpp b/src/couch/priv/couch_js/60/main.cpp
index e78dbb4..b6157ed 100644
--- a/src/couch/priv/couch_js/60/main.cpp
+++ b/src/couch/priv/couch_js/60/main.cpp
@@ -15,6 +15,7 @@
 #include <string.h>
 
 #ifdef XP_WIN
+#define NOMINMAX
 #include <windows.h>
 #else
 #include <unistd.h>
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script
index c0889ce..91e24d9 100644
--- a/src/couch/rebar.config.script
+++ b/src/couch/rebar.config.script
@@ -100,8 +100,8 @@ end,
 {JS_CFLAGS, JS_LDFLAGS} = case os:type() of
     {win32, _} when SMVsn == "1.8.5" ->
         {
-            "/DXP_WIN /IC:\\relax\\js-1.8.5\\js\\src",
-            "/LIBPATH:C:\\relax\\js-1.8.5\\js\\src mozjs185-1.0.lib"
+            "/DXP_WIN",
+            "mozjs185-1.0.lib"
         };
     {unix, _} when SMVsn == "1.8.5" ->
         {
@@ -110,8 +110,8 @@ end,
         };
     {win32, _} when SMVsn == "60" ->
         {
-            "/DXP_WIN /IC:\\relax\\js-60\\js\\src",
-            "/LIBPATH:C:\\relax\\js-60\\js\\src mozjs-60.lib"
+            "/DXP_WIN",
+            "mozjs-60.lib"
         };
     {unix, darwin} when SMVsn == "60" ->
         {
@@ -130,8 +130,8 @@ end.
         case os:type() of
             {win32, _} ->
                 {
-                    "/DHAVE_CURL /IC:\\relax\\curl\\include",
-                    "/LIBPATH:C:\\Relax\\curl\\lib\\release-ssl libcurl_imp.lib"
+                    "/DHAVE_CURL",
+                    "/DHAVE_CURL libcurl.lib"
                 };
             {unix, freebsd} ->
                 {
@@ -174,8 +174,8 @@ IcuDarwinEnv = [{"CFLAGS", "-DXP_UNIX -I/usr/local/opt/icu4c/include"},
                 {"LDFLAGS", "-L/usr/local/opt/icu4c/lib"}],
 IcuBsdEnv = [{"CFLAGS", "-DXP_UNIX -I/usr/local/include"},
              {"LDFLAGS", "-L/usr/local/lib"}],
-IcuWinEnv = [{"CFLAGS", "/DXP_WIN /IC:\\relax\\icu\\include"},
-             {"LDFLAGS", "/LIBPATH:C:\\relax\\icu\\lib64 icuin.lib icudt.lib icuuc.lib"}],
+IcuWinEnv = [{"CFLAGS", "$DRV_CFLAGS /DXP_WIN"},
+             {"LDFLAGS", "icuin.lib icudt.lib icuuc.lib"}],
 
 ComparePath = "priv/couch_ejson_compare.so",
 CompareSrc = ["priv/couch_ejson_compare/*.c"],
@@ -199,6 +199,12 @@ SpawnSpec = [
     {"priv/couchspawnkillable", ["priv/spawnkillable/*.c"]}
 ],
 
+%% hack required until switch to enc/rebar3
+PortEnvOverrides = [
+    {"win32", "EXE_LINK_CXX_TEMPLATE",
+    "$LINKER $PORT_IN_FILES $LDFLAGS $EXE_LDFLAGS /OUT:$PORT_OUT_FILE"}
+],
+
 PortSpecs = case os:type() of
     {win32, _} ->
         BaseSpecs ++ SpawnSpec;
@@ -218,6 +224,7 @@ AddConfig = [
         {d, 'COUCHDB_GIT_SHA', GitSha},
         {i, "../"}
     ] ++ MD5Config ++ ProperConfig},
+    {port_env, PortEnvOverrides},
     {eunit_compile_opts, PlatformDefines}
 ].