couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "AndroidCouchPatch" by MattAdams
Date Sun, 30 Jan 2011 04:27:38 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "AndroidCouchPatch" page has been changed by MattAdams.
http://wiki.apache.org/couchdb/AndroidCouchPatch

--------------------------------------------------

New page:
For use with [[Installing_on_Android]]

{{{
diff --git a/configure.ac b/configure.ac
index c609a08..98bbfc2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -189,6 +189,13 @@ AC_COMPILE_IFELSE(
 CFLAGS="$OLD_CFLAGS"
 AC_LANG_POP(C)
 
+AC_ARG_WITH([android], [AC_HELP_STRING([--with-android=PATH]
+    [set Android system build path])],[
+    ICU_CONFIG="" 
+    ICU_LOCAL_CFLAGS="-I$withval/external/icu4c/common -I$withval/external/icu4c/i18n"
+    ICU_LOCAL_LDFLAGS="-L$withval/out/target/product/generic/system/lib"
+    ICU_LOCAL_BIN=
+], [
 AC_ARG_WITH([win32-icu-binaries], [AC_HELP_STRING([--with-win32-icu-binaries=PATH],
     [set PATH to the Win32 native ICU binaries directory])], [
     ICU_CONFIG="" # supposed to be a command to query options...
@@ -200,13 +207,19 @@ AC_ARG_WITH([win32-icu-binaries], [AC_HELP_STRING([--with-win32-icu-binaries=PAT
     ICU_LOCAL_CFLAGS=`$ICU_CONFIG --cppflags-searchpath`
     ICU_LOCAL_LDFLAGS=`$ICU_CONFIG --ldflags-searchpath`
     ICU_LOCAL_BIN=
-])
+])])
 
 AC_SUBST(ICU_CONFIG)
 AC_SUBST(ICU_LOCAL_CFLAGS)
 AC_SUBST(ICU_LOCAL_LDFLAGS)
 AC_SUBST(ICU_LOCAL_BIN)
 
+AC_ARG_WITH([android-curl], [AC_HELP_STRING([--with-android-curl=PATH]
+    [set PATH to directory where curl is built for android])], [
+    CURL_CFLAGS="-I$withval/include -DCURL_STATICLIB"
+    CURL_LIBDIR="$withval/lib"
+    CURL_LDFLAGS="-L$CURL_LIBDIR -lcurl"
+], [
 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
@@ -216,12 +229,15 @@ AC_ARG_WITH([win32-curl], [AC_HELP_STRING([--with-win32-curl=PATH],
 ], [
     AC_CHECK_CURL([7.18.0])
     CURL_LDFLAGS=-lcurl
-])
+])])
 
 AC_SUBST(CURL_CFLAGS)
 AC_SUBST(CURL_LIBS)
 AC_SUBST(CURL_LDFLAGS)
 
+#Probably should fix this up better in the future for cross-compiles in general
+#instead of just keeping this exception for android
+if test "x$CC" != "xagcc"; then
 case "$(uname -s)" in
   Linux)
     LIBS="$LIBS -lcrypt"
@@ -234,6 +250,7 @@ case "$(uname -s)" in
     LIBS="$LIBS -lcrypto"
   ;;
 esac
+fi
 
 AC_PATH_PROG([ERL], [erl])
 
diff --git a/src/couchdb/priv/couch_js/main.c b/src/couchdb/priv/couch_js/main.c
index 376aa15..63c12c1 100644
--- a/src/couchdb/priv/couch_js/main.c
+++ b/src/couchdb/priv/couch_js/main.c
@@ -64,7 +64,7 @@ evalcx(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 
     if(!sandbox)
     {
-        sandbox = JS_NewObject(subcx, NULL, NULL, NULL);
+        sandbox = JS_NewGlobalObject(subcx, NULL);
         if(!sandbox || !JS_InitStandardClasses(subcx, sandbox)) goto done;
     }
 
@@ -127,12 +127,22 @@ readfp(JSContext* cx, FILE* fp, size_t* buflen)
     size_t used = 0;
     size_t byteslen = 256;
     size_t readlen = 0;
+    int c;
 
     bytes = JS_malloc(cx, byteslen);
     if(bytes == NULL) return NULL;
     
-    while((readlen = js_fgets(bytes+used, byteslen-used, stdin)) > 0)
+    while(JS_TRUE)
     {
+	//js_fgets is no longer an external API in libjs (in hg).
+	while(used < byteslen && (c = getc(stdin)) != EOF) 
+	{ 
+		bytes[used] = c;
+		used++;
+	}
+	bytes[used] = '\0';
+	if (c == EOF) break;
+
         used += readlen;
 
         if(bytes[used-1] == '\n')
@@ -291,7 +301,7 @@ main(int argc, const char * argv[])
     
     SETUP_REQUEST(cx);
 
-    global = JS_NewObject(cx, &global_class, NULL, NULL);
+    global = JS_NewGlobalObject(cx, &global_class);
     if (!global) return 1;
     if (!JS_InitStandardClasses(cx, global)) return 1;
     
}}}

Mime
View raw message