Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CouchDB no longer requires cURL to build.

cURL is only used by the command line JavaScript test suite
which is not run by a large number of users. This change
no longer requires cURL to be available for all CouchDB
installations.

Thanks to Randall Leeds for the patch.
Closes COUCHDB-1042



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1064399 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit df7ac1368da214ef114d7716421d6e03011af947 1 parent bc7b57d
@davisp davisp authored
View
7 CHANGES
@@ -6,6 +6,13 @@ Version 1.2.0
This version has not been released yet.
+Build System:
+
+ * cURL is no longer required to build CouchDB as it is only
+ used by the command line JS test runner. If cURL is available
+ when building CouchJS you can enable the HTTP bindings by
+ passing -H on the command line.
+
OAuth:
* Updated budled erlang_oauth library to the latest version.
View
8 INSTALL.Unix
@@ -12,11 +12,17 @@ You will need the following installed:
* ICU (http://icu.sourceforge.net/)
* OpenSSL (http://www.openssl.org/)
* Mozilla SpiderMonkey (1.8) (http://www.mozilla.org/js/spidermonkey/)
- * libcurl (http://curl.haxx.se/libcurl/)
* GNU Make (http://www.gnu.org/software/make/)
* GNU Compiler Collection (http://gcc.gnu.org/)
It is recommended that you install Erlang OTP R12B-5 or above where possible.
+
+Optional dependencies:
+
+ * libcurl (http://curl.haxx.se/libcurl/)
+
+This only affects the command line JavaScript test suite which
+most users do not use.
Ubuntu
~~~~~~
View
2  NEWS
@@ -13,6 +13,8 @@ Version 1.2.0
This version has not been released yet.
* Updated budled erlang_oauth library to the latest version.
+ * cURL is no longer required to build CouchDB as it is only
+ required by the command line JS test runner.
Version 1.0.1
-------------
View
11 bin/couchjs.tpl.in
@@ -48,6 +48,8 @@ Options:
-h display a short help message and exit
-V display version information and exit
+ -H install couchjs cURL bindings (only avaiable
+ if CouchDB was built with cURL available)
Report bugs at <%bug_uri%>.
EOF
@@ -68,7 +70,7 @@ run_couchjs () {
parse_script_option_list () {
set +e
- options=`getopt hV $@`
+ options=`getopt hVH $@`
if test ! $? -eq 0; then
display_error
fi
@@ -82,11 +84,12 @@ parse_script_option_list () {
*) break;;
esac
done
- option_list=`echo $@ | sed 's/--//'`
- if test -z "$option_list"; then
+ script_name=`echo $@ | sed -e 's/.*--[[:blank:]]*//'`
+ if test -z "$script_name"; then
display_error "You must specify a FILE."
fi
- run_couchjs $option_list
+ options=`echo $@ | sed -e 's/--//'`
+ run_couchjs $options
}
parse_script_option_list $@
View
8 configure.ac
@@ -207,6 +207,7 @@ AC_SUBST(ICU_LOCAL_CFLAGS)
AC_SUBST(ICU_LOCAL_LDFLAGS)
AC_SUBST(ICU_LOCAL_BIN)
+use_curl=yes
AC_ARG_WITH([win32-curl], [AC_HELP_STRING([--with-win32-curl=PATH],
[set PATH to the Win32 native curl directory])], [
# default build on windows is a static lib, and that's what we want too
@@ -214,7 +215,11 @@ AC_ARG_WITH([win32-curl], [AC_HELP_STRING([--with-win32-curl=PATH],
CURL_LIBS="$withval/lib/libcurl"
CURL_LDFLAGS="-l$CURL_LIBS -lWs2_32 -lkernel32 -luser32 -ladvapi32 -lWldap32"
], [
- AC_CHECK_CURL([7.18.0])
+ AC_CHECK_CURL([7.18.0],
+ [AC_DEFINE([HAVE_CURL], [1], ["Provide HTTP support to couchjs"])], [
+ AC_MSG_WARN([You will be unable to run some JavaScript unit tests.])
+ use_curl=no
+ ])
CURL_LDFLAGS=-lcurl
])
@@ -351,6 +356,7 @@ AM_CONDITIONAL([INIT], [test x${init_enabled} = xtrue])
AM_CONDITIONAL([LAUNCHD], [test x${launchd_enabled} = xtrue])
AM_CONDITIONAL([HELP2MAN], [test x${help2man_enabled} = xtrue])
AM_CONDITIONAL([USE_NATIVE_MOCHIJSON], [test x${native_mochijson_enabled} = xyes])
+AM_CONDITIONAL([USE_CURL], [test x${use_curl} = xyes])
AC_SUBST([package_author_name], ["LOCAL_PACKAGE_AUTHOR_NAME"])
AC_SUBST([package_author_address], ["LOCAL_PACKAGE_AUTHOR_ADDRESS"])
View
19 src/couchdb/priv/couch_js/http.c
@@ -10,10 +10,27 @@
// License for the specific language governing permissions and limitations under
// the License.
+#include "config.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <jsapi.h>
+
+#ifndef HAVE_CURL
+
+// Soft dependency on cURL bindings because they're
+// only used when running the JS tests from the
+// command line which is rare.
+JSObject*
+install_http(JSContext* cx, JSObject* glbl)
+{
+ fprintf(stderr, "ERROR: couchjs was not built with cURL support.\n");
+ return NULL;
+}
+
+#else
+
#include <curl/curl.h>
#include "utf8.h"
@@ -673,3 +690,5 @@ str_from_binary(JSContext* cx, char* data, size_t length)
return ret;
}
+
+#endif /* HAVE_CURL */
View
57 src/couchdb/priv/couch_js/main.c
@@ -272,14 +272,48 @@ static JSClass global_class = {
};
int
+usage()
+{
+ fprintf(stderr, "usage: couchjs [-H] [script_name]\n");
+ return 1;
+}
+
+int
main(int argc, const char * argv[])
{
JSRuntime* rt = NULL;
JSContext* cx = NULL;
JSObject* global = NULL;
JSFunctionSpec* sp = NULL;
+ char* script_name = NULL;
+ int use_http = 0;
int i = 0;
-
+
+ if(argc > 3)
+ {
+ fprintf(stderr, "ERROR: Too many arguments.\n");
+ return usage();
+ }
+ else if(argc == 3)
+ {
+ if(strcmp(argv[1], "-H"))
+ {
+ fprintf(stderr, "ERROR: Invalid option: %s\n", argv[1]);
+ return usage();
+ }
+ use_http = 1;
+ script_name = argv[2];
+ }
+ else if(argc == 2 && strcmp(argv[1], "-H") == 0)
+ {
+ use_http = 1;
+ }
+ else if (argc == 2)
+ {
+ script_name = argv[1];
+ }
+ // else argc == 1, use defaults
+
rt = JS_NewRuntime(64L * 1024L * 1024L);
if (!rt) return 1;
@@ -305,28 +339,13 @@ main(int argc, const char * argv[])
}
}
- if(!install_http(cx, global))
- {
- return 1;
- }
-
- JS_SetGlobalObject(cx, global);
-
- if(argc > 2)
+ if(use_http && !install_http(cx, global))
{
- fprintf(stderr, "incorrect number of arguments\n\n");
- fprintf(stderr, "usage: %s <scriptfile>\n", argv[0]);
return 2;
}
- if(argc == 0)
- {
- execute_script(cx, global, NULL);
- }
- else
- {
- execute_script(cx, global, argv[1]);
- }
+ JS_SetGlobalObject(cx, global);
+ execute_script(cx, global, script_name);
FINISH_REQUEST(cx);
View
2  test/javascript/run.tpl
@@ -27,4 +27,4 @@ cat $SCRIPT_DIR/json2.js \
$SCRIPT_DIR/test/*.js \
$JS_TEST_DIR/couch_http.js \
$JS_TEST_DIR/cli_runner.js \
- | $COUCHJS -
+ | $COUCHJS -H -
Please sign in to comment.
Something went wrong with that request. Please try again.