void InjectLibrary(pid_t pid) {
Dl_info addr;
_assert(dladdr(reinterpret_cast<void *>(&CYHandleServer), &addr) != 0);
- const char *library(addr.dli_fname);
+
+ size_t flength(strlen(addr.dli_fname));
+ char library[flength + 4 + 1];
+ memcpy(library, addr.dli_fname, flength);
+ library[flength] = '\0';
+ _assert(strcmp(library + flength - 6, ".dylib") == 0);
+ strcpy(library + flength - 6, "-any.dylib");
mach_port_t self(mach_task_self()), task;
_krncall(task_for_pid(self, pid, &task));
lib_LTLIBRARIES =
+if CY_MACH
lib_LTLIBRARIES += libcycript-any.la
libcycript_any_la_SOURCES = Select.cpp
libcycript_any_la_LDFLAGS = $(CY_LDFLAGS)
libcycript_any_la_LIBADD = -ldl
+endif
lib_LTLIBRARIES += libcycript.la
libcycript_la_LDFLAGS = $(CY_LDFLAGS)
lex.cy.cpp: Cycript.l
$(FLEX) -t $< | $(SED) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
-Console.$(OBJEXT) Execute.lo Handler.lo Highlight.lo Library.lo Parser.lo lex.cy.lo: Cycript.tab.hh
+Console.$(OBJEXT) Execute.lo Handler.lo Highlight.lo Library.lo Output.lo Parser.lo lex.cy.lo: Cycript.tab.hh
CLEANFILES += Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.output
Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.output: Cycript.yy
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
+@CY_MACH_TRUE@am__append_1 = libcycript-any.la
@CY_CONSOLE_TRUE@bin_PROGRAMS = cycript$(EXEEXT)
-@CY_EXECUTE_TRUE@am__append_1 = sig/ffi_type.cpp sig/parse.cpp \
+@CY_EXECUTE_TRUE@am__append_2 = sig/ffi_type.cpp sig/parse.cpp \
@CY_EXECUTE_TRUE@ sig/copy.cpp Bridge.cpp Execute.cpp \
@CY_EXECUTE_TRUE@ JavaScriptCore.cpp Library.cpp
-@CY_EXECUTE_TRUE@am__append_2 = $(LTJAVASCRIPTCORE)
-@CY_EXECUTE_TRUE@am__append_3 = -DCY_EXECUTE
-@CY_EXECUTE_TRUE@am__append_4 = C
-@CY_EXECUTE_TRUE@am__append_5 = Bridge.gperf Bridge.hpp
-@CY_OBJECTIVEC_TRUE@am__append_6 = ObjectiveC
-@CY_OBJECTIVEC_TRUE@am__append_7 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm
-@CY_OBJECTIVEC_TRUE@am__append_8 = $(LTOBJECTIVEC)
-@CY_MACH_TRUE@am__append_9 = Handler.mm
-@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_10 = Mach/Inject.cpp
-@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_11 = -DCY_ATTACH
-@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_12 = Trampoline.t.lo \
+@CY_EXECUTE_TRUE@am__append_3 = $(LTJAVASCRIPTCORE)
+@CY_EXECUTE_TRUE@am__append_4 = -DCY_EXECUTE
+@CY_EXECUTE_TRUE@am__append_5 = C
+@CY_EXECUTE_TRUE@am__append_6 = Bridge.gperf Bridge.hpp
+@CY_OBJECTIVEC_TRUE@am__append_7 = ObjectiveC
+@CY_OBJECTIVEC_TRUE@am__append_8 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm
+@CY_OBJECTIVEC_TRUE@am__append_9 = $(LTOBJECTIVEC)
+@CY_MACH_TRUE@am__append_10 = Handler.mm
+@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_11 = Mach/Inject.cpp
+@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_12 = -DCY_ATTACH
+@CY_CONSOLE_TRUE@@CY_MACH_TRUE@am__append_13 = Trampoline.t.lo \
@CY_CONSOLE_TRUE@@CY_MACH_TRUE@ libTrampoline.t.la \
@CY_CONSOLE_TRUE@@CY_MACH_TRUE@ Trampoline.t.hpp
subdir = .
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libcycript_any_la_DEPENDENCIES =
-am_libcycript_any_la_OBJECTS = Select.lo
+am__libcycript_any_la_SOURCES_DIST = Select.cpp
+@CY_MACH_TRUE@am_libcycript_any_la_OBJECTS = Select.lo
libcycript_any_la_OBJECTS = $(am_libcycript_any_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
$(AM_CXXFLAGS) $(CXXFLAGS) $(libcycript_any_la_LDFLAGS) \
$(LDFLAGS) -o $@
+@CY_MACH_TRUE@am_libcycript_any_la_rpath = -rpath $(libdir)
am__DEPENDENCIES_1 =
@CY_EXECUTE_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
@CY_OBJECTIVEC_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1)
am__v_OBJCXXLD_1 =
SOURCES = $(libcycript_any_la_SOURCES) $(libcycript_la_SOURCES) \
$(cycript_SOURCES)
-DIST_SOURCES = $(libcycript_any_la_SOURCES) \
+DIST_SOURCES = $(am__libcycript_any_la_SOURCES_DIST) \
$(am__libcycript_la_SOURCES_DIST) $(am__cycript_SOURCES_DIST)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = subdir-objects
-CLEANFILES = $(am__append_5) $(am__append_12) Cycript.yy Cycript.l \
+CLEANFILES = $(am__append_6) $(am__append_13) Cycript.yy Cycript.l \
lex.cy.cpp Cycript.tab.cc Cycript.tab.hh location.hh \
position.hh stack.hh Cycript.output
SUBDIRS =
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -I$(srcdir)/include -DYYDEBUG=1 -include config.h \
- -include $(srcdir)/unconfig.h $(am__append_3) $(am__append_11)
+ -include $(srcdir)/unconfig.h $(am__append_4) $(am__append_12)
CY_LDFLAGS = -no-undefined -avoid-version -export-dynamic
-lib_LTLIBRARIES = libcycript-any.la libcycript.la
-libcycript_any_la_SOURCES = Select.cpp
-libcycript_any_la_LDFLAGS = $(CY_LDFLAGS)
-libcycript_any_la_LIBADD = -ldl
+lib_LTLIBRARIES = $(am__append_1) libcycript.la
+@CY_MACH_TRUE@libcycript_any_la_SOURCES = Select.cpp
+@CY_MACH_TRUE@libcycript_any_la_LDFLAGS = $(CY_LDFLAGS)
+@CY_MACH_TRUE@libcycript_any_la_LIBADD = -ldl
libcycript_la_LDFLAGS = $(CY_LDFLAGS)
-libcycript_la_LIBADD = $(LTLIBFFI) -ldl $(am__append_2) \
- $(am__append_8)
+libcycript_la_LIBADD = $(LTLIBFFI) -ldl $(am__append_3) \
+ $(am__append_9)
libcycript_la_SOURCES = ConvertUTF.c Highlight.cpp Network.cpp \
Output.cpp Parser.cpp Replace.cpp Cycript.tab.cc lex.cy.cpp \
- $(am__append_1) $(am__append_7) $(am__append_9)
-filters = $(CY_FILTERS) $(am__append_4) $(am__append_6)
+ $(am__append_2) $(am__append_8) $(am__append_10)
+filters = $(CY_FILTERS) $(am__append_5) $(am__append_7)
@CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp Display.cpp \
-@CY_CONSOLE_TRUE@ $(am__append_10)
+@CY_CONSOLE_TRUE@ $(am__append_11)
@CY_CONSOLE_TRUE@cycript_LDADD = libcycript.la $(LTLIBAPR) $(LTLIBREADLINE) $(LTLIBTERMCAP) -ldl
@CY_CONSOLE_TRUE@ldid = true
@CY_CONSOLE_TRUE@entitle = $(ldid) -S$(srcdir)/cycript.xml
}
libcycript-any.la: $(libcycript_any_la_OBJECTS) $(libcycript_any_la_DEPENDENCIES) $(EXTRA_libcycript_any_la_DEPENDENCIES)
- $(AM_V_CXXLD)$(libcycript_any_la_LINK) -rpath $(libdir) $(libcycript_any_la_OBJECTS) $(libcycript_any_la_LIBADD) $(LIBS)
+ $(AM_V_CXXLD)$(libcycript_any_la_LINK) $(am_libcycript_any_la_rpath) $(libcycript_any_la_OBJECTS) $(libcycript_any_la_LIBADD) $(LIBS)
sig/$(am__dirstamp):
@$(MKDIR_P) sig
@: > sig/$(am__dirstamp)
lex.cy.cpp: Cycript.l
$(FLEX) -t $< | $(SED) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
-Console.o Execute.lo Handler.lo Highlight.lo Library.lo Parser.lo lex.cy.lo: Cycript.tab.hh
+Console.$(OBJEXT) Execute.lo Handler.lo Highlight.lo Library.lo Output.lo Parser.lo lex.cy.lo: Cycript.tab.hh
Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.output: Cycript.yy
$(BISON) -v --report=state $<
! grep -n '^ *$$default reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Cycript.output -B 2 | grep 'shift, and go to state [0-9]*$$'
const char *fname(addr.dli_fname);
size_t length(strlen(fname));
- const char *ext(strrchr(fname, '.'));
- size_t prefix(ext - fname);
-
- const char *addition;
+ const char *target;
#ifdef __APPLE__
// XXX: THIS IS HORRIBLE OMG I NEED TO FIX THIS ASAP
bool simulator(false);
simulator = true;
}
if (simulator)
- addition = "-sim";
+ target = "sim";
else
#endif
// someone threw a fit about dangling #endif + else
// the idea that this bothers someone gives me glee
- addition = "-sys";
+ target = "sys";
- char library[length + 5];
- memcpy(library, fname, prefix);
- memcpy(library + prefix, addition, 4);
- memcpy(library + prefix + 4, fname + prefix, length - prefix);
- library[length + 4] = '\0';
+ char library[length + 1];
+ memcpy(library, fname, length);
+ memcpy(library + length - 6 - 3, target, 3);
+ library[length] = '\0';
void *handle(dlopen(library, RTLD_LOCAL | RTLD_LAZY));
if (handle == NULL) {
--- /dev/null
+#!/bin/bash
+DYLD_LIBRARY_PATH=.libs exec .libs/cycript "$@"
#!/bin/bash
-set -e
-for build in build.*; do
- cd "${build}"
- make
- cd ..
-done
+exec make -f xcode.mk "$@"
--- /dev/null
+# Cycript - Optimizing JavaScript Compiler/Runtime
+# Copyright (C) 2009-2013 Jay Freeman (saurik)
+
+# GNU General Public License, Version 3 {{{
+#
+# Cycript is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation, either version 3 of the License,
+# or (at your option) any later version.
+#
+# Cycript 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Cycript. If not, see <http://www.gnu.org/licenses/>.
+# }}}
+
+.DELETE_ON_ERROR:
+SHELL := /bin/bash
+
+libs :=
+libs += .libs/cycript
+libs += .libs/libcycript.dylib
+libs += .libs/libcycript-any.dylib
+libs += .libs/libcycript-sys.dylib
+libs += .libs/libcycript-sim.dylib
+libs += .libs/libcycript.o
+
+all: cycript $(libs)
+
+clean:
+ rm -rf cycript .libs
+
+build-mac:
+ $(MAKE) -C build.mac
+
+build-ios:
+ $(MAKE) -C build.ios
+
+build-sim:
+ $(MAKE) -C build.sim
+
+# make stubbornly refuses to believe that these @'s are bugs
+# http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html
+
+build.mac/.libs/cycript: build-mac
+ @
+build.mac/.libs/libcycript.dylib: build-mac
+ @
+build.mac/.libs/libcycript-any.dylib: build-mac
+ @
+
+build.ios/.libs/cycript: build-ios
+ @
+build.ios/.libs/libcycript.dylib: build-ios
+ @
+build.ios/.libs/libcycript-any.dylib: build-ios
+ @
+build.ios/.libs/libcycript.a: build-ios
+ @
+
+build.sim/.libs/libcycript.dylib: build-sim
+ @
+build.sim/.libs/libcycript.a: build-sim
+ @
+
+.libs/%: build.mac/.libs/% build.ios/.libs/%
+ @mkdir -p .libs
+ lipo -create -output $@ $^
+
+.libs/%-ios.a: build.ios/.libs/%.a build.sim/.libs/%.a
+ @mkdir -p .libs
+ lipo -create -output $@ $^
+
+.libs/libcycript-sys.dylib:
+ @mkdir -p .libs
+ ln -sf libcycript.dylib $@
+
+.libs/libcycript-sim.dylib: build.sim/.libs/libcycript.dylib
+ @mkdir -p .libs
+ cp -af $< $@
+
+.libs/libcycript-%.o: build.%/.libs/libcycript.a
+ @mkdir -p .libs
+ ld -r -arch $$(lipo -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load $< libffi.a
+
+.libs/libcycript.o: .libs/libcycript-ios.o .libs/libcycript-sim.o
+ lipo -create -output $@ $^
+
+cycript: cycript.in
+ cp -af $< $@
+ chmod 755 $@
+
+.PHONY: all clean build-mac build-ios build-sim
rm -rf build."${dir}"
mkdir build."${dir}"
cd build."${dir}"
- CPP="${cc} -E" CC="${cc} ${flg}" CXXCPP="${cxx} -E" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" ../configure "${flags[@]}" "$@"
+ CPP="${cc} -E" CC="${cc} ${flg}" CXXCPP="${cxx} -E" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" ../configure "${flags[@]}" --prefix="/usr" "$@"
cd ..
}
configure "${dir}" "${sdk}" "${flg}" "$@" --enable-static --with-pic #CPPFLAGS="-idirafter ${mac}/usr/include"
}
-sim="-mios-simulator-version-min=2.0"
-sim="" # gcc does not support this
-
-build sim iphonesimulator "-arch i386 ${sim}" OBJCXXFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch" CPPFLAGS="-I../libffi.i386/include" LDFLAGS="-L.." --disable-console
+build sim iphonesimulator "-arch i386 -mios-simulator-version-min=2.0" OBJCXXFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch" CPPFLAGS="-I../libffi.i386/include" LDFLAGS="-L.." --disable-console
build ios iphoneos5.1 "-arch armv6 -miphoneos-version-min=2.0" --host=arm-apple-darwin10 CPPFLAGS="-I../libffi.armv6/include -I../sysroot.ios/usr/include -I../sysroot.ios/usr/include/apr-1" LTLIBAPR="../sysroot.ios/usr/lib/libapr-1.dylib" LDFLAGS="-L.. -L../sysroot.ios/usr/lib"