summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2019-12-02 13:54:26 -0600
committerjiangph <jiangph@cn.ibm.com>2020-02-10 09:12:11 +0800
commite8788b3a1cb43e878945968ef56af3b219ea6c7c (patch)
tree6f28319b43a0cfd1e27c744fcda1330bb5353c78
parent02e4456fb3332260de2b127cfcd29b5debf3fe1f (diff)
downloadcouchdb-e8788b3a1cb43e878945968ef56af3b219ea6c7c.tar.gz
Enable multi-version SpiderMonkey support
-rw-r--r--.gitignore7
-rw-r--r--src/couch/priv/couch_js/1.8.5/help.h (renamed from src/couch/priv/couch_js/help.h)0
-rw-r--r--src/couch/priv/couch_js/1.8.5/http.c (renamed from src/couch/priv/couch_js/http.c)0
-rw-r--r--src/couch/priv/couch_js/1.8.5/http.h (renamed from src/couch/priv/couch_js/http.h)0
-rw-r--r--src/couch/priv/couch_js/1.8.5/main.c (renamed from src/couch/priv/couch_js/main.c)0
-rw-r--r--src/couch/priv/couch_js/1.8.5/utf8.c (renamed from src/couch/priv/couch_js/utf8.c)0
-rw-r--r--src/couch/priv/couch_js/1.8.5/utf8.h (renamed from src/couch/priv/couch_js/utf8.h)0
-rw-r--r--src/couch/priv/couch_js/1.8.5/util.c (renamed from src/couch/priv/couch_js/util.c)0
-rw-r--r--src/couch/priv/couch_js/1.8.5/util.h (renamed from src/couch/priv/couch_js/util.h)0
-rw-r--r--src/couch/rebar.config.script59
10 files changed, 44 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
index 2de464cbd..470d1d4bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,14 +35,11 @@ share/www
src/b64url/
src/bear/
src/config/
-src/couch/priv/couch_js/config.h
+src/couch/priv/couch_js/**/config.h
src/couch/priv/couchjs
src/couch/priv/couchspawnkillable
src/couch/priv/couch_ejson_compare/couch_ejson_compare.d
-src/couch/priv/couch_js/http.d
-src/couch/priv/couch_js/main.d
-src/couch/priv/couch_js/utf8.d
-src/couch/priv/couch_js/util.d
+src/couch/priv/couch_js/**/*.d
src/couch/priv/icu_driver/couch_icu_driver.d
src/mango/src/mango_cursor_text.nocompile
src/docs/
diff --git a/src/couch/priv/couch_js/help.h b/src/couch/priv/couch_js/1.8.5/help.h
index 678651fd3..678651fd3 100644
--- a/src/couch/priv/couch_js/help.h
+++ b/src/couch/priv/couch_js/1.8.5/help.h
diff --git a/src/couch/priv/couch_js/http.c b/src/couch/priv/couch_js/1.8.5/http.c
index c4b389659..c4b389659 100644
--- a/src/couch/priv/couch_js/http.c
+++ b/src/couch/priv/couch_js/1.8.5/http.c
diff --git a/src/couch/priv/couch_js/http.h b/src/couch/priv/couch_js/1.8.5/http.h
index 63d45bd06..63d45bd06 100644
--- a/src/couch/priv/couch_js/http.h
+++ b/src/couch/priv/couch_js/1.8.5/http.h
diff --git a/src/couch/priv/couch_js/main.c b/src/couch/priv/couch_js/1.8.5/main.c
index 986791c90..986791c90 100644
--- a/src/couch/priv/couch_js/main.c
+++ b/src/couch/priv/couch_js/1.8.5/main.c
diff --git a/src/couch/priv/couch_js/utf8.c b/src/couch/priv/couch_js/1.8.5/utf8.c
index 4cdb9c21f..4cdb9c21f 100644
--- a/src/couch/priv/couch_js/utf8.c
+++ b/src/couch/priv/couch_js/1.8.5/utf8.c
diff --git a/src/couch/priv/couch_js/utf8.h b/src/couch/priv/couch_js/1.8.5/utf8.h
index c5cb86c46..c5cb86c46 100644
--- a/src/couch/priv/couch_js/utf8.h
+++ b/src/couch/priv/couch_js/1.8.5/utf8.h
diff --git a/src/couch/priv/couch_js/util.c b/src/couch/priv/couch_js/1.8.5/util.c
index cf676ea33..cf676ea33 100644
--- a/src/couch/priv/couch_js/util.c
+++ b/src/couch/priv/couch_js/1.8.5/util.c
diff --git a/src/couch/priv/couch_js/util.h b/src/couch/priv/couch_js/1.8.5/util.h
index b24d7f76f..b24d7f76f 100644
--- a/src/couch/priv/couch_js/util.h
+++ b/src/couch/priv/couch_js/1.8.5/util.h
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script
index 846e8b469..f4c07057e 100644
--- a/src/couch/rebar.config.script
+++ b/src/couch/rebar.config.script
@@ -54,6 +54,16 @@ CouchConfig = case filelib:is_file(os:getenv("COUCHDB_CONFIG")) of
[]
end.
+SMVsn = case lists:keyfind(spidermonkey_version, 1, CouchConfig) of
+ {_, "1.8.5"} ->
+ "1.8.5";
+ undefined ->
+ "1.8.5";
+ {_, Unsupported} ->
+ io:format(standard_error, "Unsupported SpiderMonkey version: ~s~n", [Unsupported]),
+ erlang:halt(1)
+end.
+
ConfigH = [
{"SM185", ""},
{"HAVE_JS_GET_STRING_CHARS_AND_LENGTH", "1"},
@@ -66,7 +76,7 @@ ConfigH = [
{"PACKAGE_VERSION", "\"" ++ Version ++ "\""}
],
-CouchJSConfig = "priv/couch_js/config.h",
+CouchJSConfig = "priv/couch_js/" ++ SMVsn ++ "/config.h",
ConfigSrc = [["#define ", K, " ", V, $\n] || {K, V} <- ConfigH],
ConfigBin = iolist_to_binary(ConfigSrc),
ok = CopyIfDifferent(CouchJSConfig, ConfigBin),
@@ -78,27 +88,45 @@ MD5Config = case lists:keyfind(erlang_md5, 1, CouchConfig) of
[]
end,
-%% TODO support curl on Windows
-{JS_CFLAGS, JS_LDFLAGS} = case lists:keyfind(with_curl, 1, CouchConfig) of
+{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"
+ };
+ _ when SMVsn == "1.8.5" ->
+ {
+ "-DXP_UNIX -I/usr/inlude/js -I/usr/local/include/js",
+ "-L/usr/local/lib -lmozjs185 -lm"
+ }
+end.
+
+{CURL_CFLAGS, CURL_LDFLAGS} = case lists:keyfind(with_curl, 1, CouchConfig) of
{with_curl, true} ->
case os:type() of
{win32, _} ->
- {"/DHAVE_CURL /IC:\\relax\\curl\\include", "/LIBPATH:C:\\relax\\js-1.8.5\\js\\src /LIBPATH:C:\\Relax\\curl\\lib\\release-ssl mozjs185-1.0.lib libcurl_imp.lib"};
+ {
+ "/DHAVE_CURL /IC:\\relax\\curl\\include",
+ "/LIBPATH:C:\\Relax\\curl\\lib\\release-ssl libcurl_imp.lib"
+ };
{unix, freebsd} ->
- {"-DHAVE_CURL -I/usr/local/include", "-DHAVE_CURL -lmozjs185 -lcurl"};
+ {
+ "-DHAVE_CURL -I/usr/local/include",
+ "-DHAVE_CURL -lcurl"
+ };
_ ->
- {"-DHAVE_CURL", "-DHAVE_CURL -lmozjs185 -lcurl"}
+ {
+ "-DHAVE_CURL",
+ "-DHAVE_CURL -lcurl"
+ }
end;
_ ->
- case os:type() of
- {win32, _} ->
- {"", "/LIBPATH:C:\\relax\\js-1.8.5\\js\\src mozjs185-1.0.lib"};
- _ ->
- {"", "-lmozjs185"}
- end
+ {"", ""}
end,
-CouchJSSrc = ["priv/couch_js/*.c"],
+CouchJSSrc = case SMVsn of
+ "1.8.5" -> ["priv/couch_js/1.8.5/*.c"]
+end.
IcuPath = "priv/couch_icu_driver.so",
IcuSrc = ["priv/icu_driver/*.c"],
@@ -116,10 +144,7 @@ CompareSrc = ["priv/couch_ejson_compare/*.c"],
BaseSpecs = [
%% couchjs
- {"darwin", CouchJSPath, CouchJSSrc, [{env, [{"CFLAGS", JS_CFLAGS ++ " -DXP_UNIX -I/usr/local/include/js"}, {"LDFLAGS", JS_LDFLAGS ++ " -L/usr/local/lib"}]}]},
- {"linux", CouchJSPath, CouchJSSrc, [{env, [{"CFLAGS", JS_CFLAGS ++ " -DXP_UNIX -I/usr/include/js"}, {"LDFLAGS", JS_LDFLAGS ++ " -lm"}]}]},
- {"bsd", CouchJSPath, CouchJSSrc, [{env, [{"CFLAGS", JS_CFLAGS ++ " -DXP_UNIX -I/usr/local/include/js"}, {"LDFLAGS", JS_LDFLAGS ++ " -L/usr/local/lib -lm"}]}]},
- {"win32", CouchJSPath, CouchJSSrc, [{env, [{"CFLAGS", JS_CFLAGS ++ " /DXP_WIN /IC:\\relax\\js-1.8.5\\js\\src"}, {"LDFLAGS", JS_LDFLAGS}]}]},
+ {".*", CouchJSPath, CouchJSSrc, [{env, [{"CFLAGS", JS_CFLAGS ++ " " ++ CURL_CFLAGS}, {"LDFLAGS", JS_LDFLAGS ++ " " ++ CURL_LDFLAGS}]}]},
% ICU
{"darwin", IcuPath, IcuSrc, [{env, IcuEnv ++ IcuDarwinEnv}]},
{"linux", IcuPath, IcuSrc, [{env, IcuEnv}]},