]> git.saurik.com Git - cycript.git/commitdiff
Package everything for Android in simple zip file.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 4 Jan 2016 00:19:02 +0000 (16:19 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 4 Jan 2016 00:19:02 +0000 (16:19 -0800)
Execute.cpp
android-push.sh
android-zip.sh [new file with mode: 0755]
apple.mk
cycript.and.in [new file with mode: 0644]
cycript.in [deleted file]
cycript.ios.in [new file with mode: 0644]
terminfo/l/linux [new file with mode: 0755]
terminfo/u/unknown [new file with mode: 0755]

index f02df3e099e88aed1cc68fe680c1fa5187b6a690..57f3721580e7de2179b3c7118624e019b01ffb5b 100644 (file)
@@ -2143,10 +2143,35 @@ JSGlobalContextRef CYGetJSContext(JSContextRef context) {
     return reinterpret_cast<Context *>(JSObjectGetPrivate(CYCastJSObject(context, CYGetProperty(context, CYGetGlobalObject(context), cy_s))))->context_;
 }
 
-const char *CYPoolLibraryPath(CYPool &pool) {
+#ifdef __ANDROID__
+char *CYPoolLibraryPath_(CYPool &pool) {
+    FILE *maps(fopen("/proc/self/maps", "r"));
+    struct F { FILE *f; F(FILE *f) : f(f) {}
+        ~F() { fclose(f); } } f(maps);
+
+    size_t function(reinterpret_cast<size_t>(&CYPoolLibraryPath));
+
+    for (;;) {
+        size_t start; size_t end; char flags[8]; unsigned long long offset;
+        int major; int minor; unsigned long long inode; char file[1024];
+        int count(fscanf(maps, "%zx-%zx %7s %llx %x:%x %llu%[ ]%1024[^\n]\n",
+            &start, &end, flags, &offset, &major, &minor, &inode, file, file));
+        if (count < 8) break; else if (start <= function && function < end)
+            return pool.strdup(file);
+    }
+
+    _assert(false);
+}
+#else
+char *CYPoolLibraryPath_(CYPool &pool) {
     Dl_info addr;
     _assert(dladdr(reinterpret_cast<void *>(&CYPoolLibraryPath), &addr) != 0);
-    char *lib(pool.strdup(addr.dli_fname));
+    return pool.strdup(addr.dli_fname);
+}
+#endif
+
+const char *CYPoolLibraryPath(CYPool &pool) {
+    char *lib(CYPoolLibraryPath_(pool));
 
     char *slash(strrchr(lib, '/'));
     if (slash == NULL)
index 95a8e46df2a795d828cc09752a3b70e2ddbe3645..b7f82d4c1640fe332524f7e1ea4ff3cf237f2c40 100755 (executable)
@@ -1,5 +1,22 @@
 #!/bin/bash
 set -e
-for file in .libs/cycript .libs/libcycript.so libcycript.jar libcycript.db ../libcycript.cy; do
-    adb push build.and-armeabi/"${file}" /data/local/tmp/
+
+adb shell mkdir -p /data/local/tmp/Cycript.lib/{l,u}
+adb push cycript.and.in /data/local/tmp/cycript
+adb shell chmod 755 /data/local/tmp/cycript
+
+files=()
+files+=(.libs/cycript)
+files+=(.libs/libcycript.so)
+files+=(libcycript.jar)
+files+=(libcycript.db)
+files+=(../libcycript.cy)
+files+=(../android/armeabi/libJavaScriptCore.so)
+
+for file in "${files[@]}"; do
+    adb push build.and-armeabi/"${file}" /data/local/tmp/Cycript.lib
+done
+
+for term in linux unknown; do
+    adb push {terminfo,/data/local/tmp/Cycript.lib}/"${term:0:1}/${term}"
 done
diff --git a/android-zip.sh b/android-zip.sh
new file mode 100755 (executable)
index 0000000..9a50a84
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+set -e
+
+version=$(git describe --always --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@;s@%@~@g')
+
+for abi in armeabi; do
+    cd "build.and-${abi}"
+
+    rm -rf Cycript.lib
+    mkdir Cycript.lib
+    cp -a ../cycript.and.in Cycript.lib/cycript
+    chmod 755 Cycript.lib/cycript
+
+    files=()
+    files+=(.libs/cycript)
+    files+=(.libs/libcycript.so)
+    files+=(libcycript.jar)
+    files+=(libcycript.db)
+    files+=(../libcycript.cy)
+    files+=(../android/armeabi/libJavaScriptCore.so)
+
+    for file in "${files[@]}"; do
+        cp -a "${file}" Cycript.lib
+    done
+
+    for term in linux unknown; do
+        mkdir -p Cycript.lib/"${term:0:1}"
+        cp -a {../terminfo,Cycript.lib}/"${term:0:1}/${term}"
+    done
+
+    cp -af ../cycript.and.in cycript
+    chmod 755 cycript
+
+    zip=Cycript_${version}_${abi}.zip
+    rm -f "${zip}"
+    zip -r9y "${zip}" cycript Cycript.lib
+done
index 1bffa46193ab6b6c5e7cc8389935a967f92649dc..a65e9ae06b5aee5ddfdccf4e30d873e9eec3c692 100644 (file)
--- a/apple.mk
+++ b/apple.mk
@@ -220,7 +220,7 @@ Cycript.lib/cycript0.9:
        @mkdir -p $(dir $@)
        ln -s ../modules $@
 
-cycript: cycript.in
+cycript: cycript.ios.in
        cp -af $< $@
        chmod 755 $@
 
diff --git a/cycript.and.in b/cycript.and.in
new file mode 100644 (file)
index 0000000..d0638e3
--- /dev/null
@@ -0,0 +1,24 @@
+#!/system/bin/sh
+
+# Cycript - The Truly Universal Scripting Language
+# Copyright (C) 2009-2016  Jay Freeman (saurik)
+
+# GNU Affero General Public License, Version 3 {{{
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# }}}
+
+dir=${0%/*}; if [[ ${dir} != /* ]]; then dir=$(pwd)/${dir}; fi
+export TERMINFO="${dir}"/Cycript.lib; export TERM=linux
+LD_LIBRARY_PATH="${dir}"/Cycript.lib exec "${dir}"/Cycript.lib/cycript "$@"
diff --git a/cycript.in b/cycript.in
deleted file mode 100644 (file)
index 0f6d005..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env bash
-
-# Cycript - The Truly Universal Scripting Language
-# Copyright (C) 2009-2016  Jay Freeman (saurik)
-
-# GNU Affero General Public License, Version 3 {{{
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-# }}}
-
-dir=$(dirname "${BASH_SOURCE[0]}")
-DYLD_LIBRARY_PATH="${dir}"/Cycript.lib exec "${dir}"/Cycript.lib/cycript "$@"
diff --git a/cycript.ios.in b/cycript.ios.in
new file mode 100644 (file)
index 0000000..0f6d005
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+# Cycript - The Truly Universal Scripting Language
+# Copyright (C) 2009-2016  Jay Freeman (saurik)
+
+# GNU Affero General Public License, Version 3 {{{
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# }}}
+
+dir=$(dirname "${BASH_SOURCE[0]}")
+DYLD_LIBRARY_PATH="${dir}"/Cycript.lib exec "${dir}"/Cycript.lib/cycript "$@"
diff --git a/terminfo/l/linux b/terminfo/l/linux
new file mode 100755 (executable)
index 0000000..0b36f01
Binary files /dev/null and b/terminfo/l/linux differ
diff --git a/terminfo/u/unknown b/terminfo/u/unknown
new file mode 100755 (executable)
index 0000000..0b36f01
Binary files /dev/null and b/terminfo/u/unknown differ