From: Jay Freeman (saurik) Date: Mon, 4 Jan 2016 00:19:02 +0000 (-0800) Subject: Package everything for Android in simple zip file. X-Git-Tag: v0.9.590~70 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/f57a1abfff018977638649483e0bf259c830daf2?ds=inline Package everything for Android in simple zip file. --- diff --git a/Execute.cpp b/Execute.cpp index f02df3e..57f3721 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -2143,10 +2143,35 @@ JSGlobalContextRef CYGetJSContext(JSContextRef context) { return reinterpret_cast(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(&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(&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) diff --git a/android-push.sh b/android-push.sh index 95a8e46..b7f82d4 100755 --- a/android-push.sh +++ b/android-push.sh @@ -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 index 0000000..9a50a84 --- /dev/null +++ b/android-zip.sh @@ -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 diff --git a/apple.mk b/apple.mk index 1bffa46..a65e9ae 100644 --- 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 index 0000000..d0638e3 --- /dev/null +++ b/cycript.and.in @@ -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 . +# }}} + +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 index 0f6d005..0000000 --- a/cycript.in +++ /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 . -# }}} - -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 index 0000000..0f6d005 --- /dev/null +++ b/cycript.ios.in @@ -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 . +# }}} + +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 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 index 0000000..0b36f01 Binary files /dev/null and b/terminfo/u/unknown differ