From f57a1abfff018977638649483e0bf259c830daf2 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 3 Jan 2016 16:19:02 -0800 Subject: [PATCH] Package everything for Android in simple zip file. --- Execute.cpp | 29 +++++++++++++++++++++++++-- android-push.sh | 21 ++++++++++++++++++-- android-zip.sh | 37 +++++++++++++++++++++++++++++++++++ apple.mk | 2 +- cycript.and.in | 24 +++++++++++++++++++++++ cycript.in => cycript.ios.in | 0 terminfo/l/linux | Bin 0 -> 1672 bytes terminfo/u/unknown | Bin 0 -> 1672 bytes 8 files changed, 108 insertions(+), 5 deletions(-) create mode 100755 android-zip.sh create mode 100644 cycript.and.in rename cycript.in => cycript.ios.in (100%) create mode 100755 terminfo/l/linux create mode 100755 terminfo/u/unknown 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.ios.in similarity index 100% rename from cycript.in rename to cycript.ios.in diff --git a/terminfo/l/linux b/terminfo/l/linux new file mode 100755 index 0000000000000000000000000000000000000000..0b36f01d2cf159127cbc09e3fc116d1cb987d205 GIT binary patch literal 1672 zcmbtUO-NKx6h8NkpoM})ML7i(J}4`F@4oluhml4rb?_&&7Nvt&%$QC-$N$vEnTQr4 zNFhXaZfw!QoMfJ3`&j{%)%cfZ-2AJ}Htau}UU$FjjhUpd2>f7yySX*aU^J6BO8k ziUE~S4YhC_c@wlDMxYBuAdW1Vya1PAT(SwcCi8W;1$ST)rr@EhXW#|Agx8X%SN;f} zu>PFVzF?kT9AAK+z*#oSWd&?A+s1aW-K>P^ESdCRl(7m{g_)k3RJN<-cm&5ASuf{n3pc9~7EIn=)W(Z8@*{Xka6X|-}*CG+x?>sHY-I~)J8FY~>0eT+Bp zR^G-tc`qO0aek4H{pXD7nKSd1HO_mL-{iOXB)`ia@JDNWH*@W^*0~P*jeJL8iv4|t zB1f?!8}h&zR3b``ri6V;k5IyWDCq470cWrVQ!NJNR8#d5wfh6G9;E<=Uzir67J?kR z>cC13AwPssv7~uOYrv?-(6lZ@lRz>-%;-RH6O&*NlY2aYL{q6$eRei1EQD+mvd?eQ zx~5fBCRDZb0FIVp)WLZ~J%Ml#LvBZCRN6IdF?g7u5i-<{J zA25%cklUogNm8FCvDYo-raJtDx>ZWrkerg@?xfLH#fz+_6zN8vR zO^tE9^UE9BB1A)OM^P9g2orS-a?9$oh9vR|X?hOXdc45LRuR}{hTq6}QdWKT?(uDDXH#57e^<4UQb3e@#gbYn#wXD9o0`H^smps~p8D@xbxH$8kr AyZ`_I literal 0 HcmV?d00001 diff --git a/terminfo/u/unknown b/terminfo/u/unknown new file mode 100755 index 0000000000000000000000000000000000000000..0b36f01d2cf159127cbc09e3fc116d1cb987d205 GIT binary patch literal 1672 zcmbtUO-NKx6h8NkpoM})ML7i(J}4`F@4oluhml4rb?_&&7Nvt&%$QC-$N$vEnTQr4 zNFhXaZfw!QoMfJ3`&j{%)%cfZ-2AJ}Htau}UU$FjjhUpd2>f7yySX*aU^J6BO8k ziUE~S4YhC_c@wlDMxYBuAdW1Vya1PAT(SwcCi8W;1$ST)rr@EhXW#|Agx8X%SN;f} zu>PFVzF?kT9AAK+z*#oSWd&?A+s1aW-K>P^ESdCRl(7m{g_)k3RJN<-cm&5ASuf{n3pc9~7EIn=)W(Z8@*{Xka6X|-}*CG+x?>sHY-I~)J8FY~>0eT+Bp zR^G-tc`qO0aek4H{pXD7nKSd1HO_mL-{iOXB)`ia@JDNWH*@W^*0~P*jeJL8iv4|t zB1f?!8}h&zR3b``ri6V;k5IyWDCq470cWrVQ!NJNR8#d5wfh6G9;E<=Uzir67J?kR z>cC13AwPssv7~uOYrv?-(6lZ@lRz>-%;-RH6O&*NlY2aYL{q6$eRei1EQD+mvd?eQ zx~5fBCRDZb0FIVp)WLZ~J%Ml#LvBZCRN6IdF?g7u5i-<{J zA25%cklUogNm8FCvDYo-raJtDx>ZWrkerg@?xfLH#fz+_6zN8vR zO^tE9^UE9BB1A)OM^P9g2orS-a?9$oh9vR|X?hOXdc45LRuR}{hTq6}QdWKT?(uDDXH#57e^<4UQb3e@#gbYn#wXD9o0`H^smps~p8D@xbxH$8kr AyZ`_I literal 0 HcmV?d00001 -- 2.45.2