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)
#!/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
--- /dev/null
+#!/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
@mkdir -p $(dir $@)
ln -s ../modules $@
-cycript: cycript.in
+cycript: cycript.ios.in
cp -af $< $@
chmod 755 $@
--- /dev/null
+#!/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 "$@"
+++ /dev/null
-#!/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 "$@"
--- /dev/null
+#!/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 "$@"