From 9185d5ef70289d99e212f2dd04457b05716e222e Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 22 Oct 2009 09:10:31 +0000 Subject: [PATCH] Further makefile reorganization, header file fixes, code movement, and general massaging on the road to portability. --- Connector.cpp | 2 +- Console.cpp | 4 ++-- Darwin-arm.mk | 7 +++++++ Darwin.mk | 8 ++++++-- FreeBSD.mk | 3 +-- Library.mm | 41 +---------------------------------------- Linux.mk | 3 +++ Parser.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ Pooling.hpp | 4 ++-- Server.cpp | 2 +- cycript.hpp | 2 +- makefile | 38 +++++++++++++++----------------------- sig/ffi_type.hpp | 2 +- sig/parse.cpp | 2 +- sig/parse.hpp | 2 +- 15 files changed, 84 insertions(+), 77 deletions(-) create mode 100644 Linux.mk create mode 100644 Parser.cpp diff --git a/Connector.cpp b/Connector.cpp index f73022f..473309f 100644 --- a/Connector.cpp +++ b/Connector.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include diff --git a/Console.cpp b/Console.cpp index dfc5c8c..503a3e8 100644 --- a/Console.cpp +++ b/Console.cpp @@ -37,8 +37,6 @@ */ /* }}} */ -#define _GNU_SOURCE - #include "cycript.hpp" #include @@ -419,8 +417,10 @@ int main(int argc, char *argv[]) { if (optind == argc) script = NULL; else { +#ifdef CY_EXECUTE // XXX: const_cast?! wtf gcc :( CYSetArgs(argc - optind - 1, const_cast(argv + optind + 1)); +#endif script = argv[optind]; if (strcmp(script, "-") == 0) script = NULL; diff --git a/Darwin-arm.mk b/Darwin-arm.mk index 49139e1..875f25f 100644 --- a/Darwin-arm.mk +++ b/Darwin-arm.mk @@ -3,9 +3,16 @@ flags += -F${PKG_ROOT}/System/Library/PrivateFrameworks all += Cycript.$(dll) #cyrver arch := iphoneos-arm +ldid := ldid -S +link += -framework UIKit Cycript.$(dll): Connector.o $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \ -lobjc -lapr-1 -lsubstrate \ -framework CoreFoundation ldid -S $@ + +cyrver: Server.o + $(target)g++ $(flags) -o $@ $(filter %.o,$^) \ + -lapr-1 -lsubstrate -framework CFNetwork + $(ldid) $@ diff --git a/Darwin.mk b/Darwin.mk index e98526d..a36cdb4 100644 --- a/Darwin.mk +++ b/Darwin.mk @@ -1,11 +1,15 @@ -dll := dylib - # XXX: objective-c exists on non-Darwin +dll := dylib header += Struct.hpp ObjectiveC.hpp code += ObjectiveC.o Library.o filters += ObjC flags += -DCY_ATTACH -DCY_EXECUTE +flags += -lobjc -framework CoreFoundation +link += -framework Foundation +library += -install_name /usr/lib/libcycript.$(dll) +library += -framework Foundation -framework CFNetwork +library += -framework JavaScriptCore -framework WebCore Struct.hpp: $$($(target)gcc -print-prog-name=cc1obj) -print-objc-runtime-info $@ diff --git a/FreeBSD.mk b/FreeBSD.mk index 34e44e9..d079b96 100644 --- a/FreeBSD.mk +++ b/FreeBSD.mk @@ -1,3 +1,2 @@ -export PATH :=/usr/local/bin:$(PATH) - +export PATH := /usr/local/bin:$(PATH) flags += -I/usr/local/include -I/usr/local/include/webkit-1.0 diff --git a/Library.mm b/Library.mm index c33d160..3357080 100644 --- a/Library.mm +++ b/Library.mm @@ -67,7 +67,7 @@ #include "Parser.hpp" #include "Cycript.tab.hh" -#include +#include #undef _assert #undef _trace @@ -1280,10 +1280,6 @@ NSString *NSCFType$cy$toJSON(id self, SEL sel, NSString *key) { @end -CYRange DigitRange_ (0x3ff000000000000LLU, 0x000000000000000LLU); // 0-9 -CYRange WordStartRange_(0x000001000000000LLU, 0x7fffffe87fffffeLLU); // A-Za-z_$ -CYRange WordEndRange_ (0x3ff001000000000LLU, 0x7fffffe87fffffeLLU); // A-Za-z_$0-9 - #define CYTry \ @try #define CYCatch \ @@ -3317,41 +3313,6 @@ static JSStaticFunction Type_staticFunctions[4] = { {NULL, NULL, 0} }; -CYDriver::CYDriver(const std::string &filename) : - state_(CYClear), - data_(NULL), - size_(0), - file_(NULL), - strict_(false), - filename_(filename), - program_(NULL) -{ - ScannerInit(); -} - -CYDriver::~CYDriver() { - ScannerDestroy(); -} - -void CYDriver::Warning(const cy::location &location, const char *message) { - if (!strict_) - return; - - CYDriver::Error error; - error.warning_ = true; - error.location_ = location; - error.message_ = message; - errors_.push_back(error); -} - -void cy::parser::error(const cy::parser::location_type &location, const std::string &message) { - CYDriver::Error error; - error.warning_ = false; - error.location_ = location; - error.message_ = message; - driver.errors_.push_back(error); -} - void CYSetArgs(int argc, const char *argv[]) { JSContextRef context(CYGetJSContext()); JSValueRef args[argc]; diff --git a/Linux.mk b/Linux.mk new file mode 100644 index 0000000..5fcb054 --- /dev/null +++ b/Linux.mk @@ -0,0 +1,3 @@ +export PATH := /usr/local/bin:$(PATH) +flags += -I/usr/include/webkit-1.0 +flags += -fPIC diff --git a/Parser.cpp b/Parser.cpp new file mode 100644 index 0000000..35ac7f7 --- /dev/null +++ b/Parser.cpp @@ -0,0 +1,41 @@ +#include "Parser.hpp" +#include "Cycript.tab.hh" + +CYRange DigitRange_ (0x3ff000000000000LLU, 0x000000000000000LLU); // 0-9 +CYRange WordStartRange_(0x000001000000000LLU, 0x7fffffe87fffffeLLU); // A-Za-z_$ +CYRange WordEndRange_ (0x3ff001000000000LLU, 0x7fffffe87fffffeLLU); // A-Za-z_$0-9 + +CYDriver::CYDriver(const std::string &filename) : + state_(CYClear), + data_(NULL), + size_(0), + file_(NULL), + strict_(false), + filename_(filename), + program_(NULL) +{ + ScannerInit(); +} + +CYDriver::~CYDriver() { + ScannerDestroy(); +} + +void CYDriver::Warning(const cy::location &location, const char *message) { + if (!strict_) + return; + + CYDriver::Error error; + error.warning_ = true; + error.location_ = location; + error.message_ = message; + errors_.push_back(error); +} + +void cy::parser::error(const cy::parser::location_type &location, const std::string &message) { + CYDriver::Error error; + error.warning_ = false; + error.location_ = location; + error.message_ = message; + driver.errors_.push_back(error); +} diff --git a/Pooling.hpp b/Pooling.hpp index 73f1c80..84adad2 100644 --- a/Pooling.hpp +++ b/Pooling.hpp @@ -1,8 +1,8 @@ #ifndef CYPOOLING_HPP #define CYPOOLING_HPP -#include -#include +#include +#include #include diff --git a/Server.cpp b/Server.cpp index bf7c17c..2ecb8bb 100644 --- a/Server.cpp +++ b/Server.cpp @@ -39,7 +39,7 @@ #include -#include +#include #include #include diff --git a/cycript.hpp b/cycript.hpp index 0ff8377..b789731 100644 --- a/cycript.hpp +++ b/cycript.hpp @@ -46,7 +46,7 @@ #include -#include +#include #include #include diff --git a/makefile b/makefile index cdf41e9..2f95a53 100644 --- a/makefile +++ b/makefile @@ -6,12 +6,11 @@ endif #flags := -g3 -O0 -DYYDEBUG=1 flags := -g0 -O3 -flags += -Wall -Werror -I. -fno-common +flags += -Wall -Werror -Wno-parentheses -I. -fno-common +flags += -I$(shell apr-1-config --includedir) svn := $(shell svnversion) -filters := C - all: all := libcycript.plist cycript @@ -21,9 +20,17 @@ arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null) endif header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp -code := ffi_type.o parse.o Replace.o Output.o Cycript.tab.o lex.cy.o Network.o +code := ffi_type.o parse.o +code += Replace.o Output.o +code += Cycript.tab.o lex.cy.o +code += Network.o Parser.o +filters := C +ldid := echo dll := so +apr := $(shell apr-1-config --link-ld) +library := $(apr) -lffi #-lsubstrate +link := $(apr) -lreadline uname_s := $(shell uname -s) uname_p := $(shell uname -p) @@ -102,28 +109,13 @@ lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp %.o: %.mm $(header) $(target)g++ $(flags) -c -o $@ $< -cyrver: Server.o - $(target)g++ $(flags) -o $@ $(filter %.o,$^) \ - -lobjc -lapr-1 -lsubstrate \ - -framework CoreFoundation -framework CFNetwork - ldid -S $@ - libcycript.$(dll): $(code) - $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \ - -install_name /usr/lib/libcycript.$(dll) \ - -lobjc -lapr-1 -lffi -lsubstrate \ - -framework CoreFoundation -framework Foundation \ - -framework CFNetwork \ - -framework JavaScriptCore -framework WebCore - ldid -S $@ + $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) + $(ldid) -S $@ cycript: Console.o libcycript.$(dll) - $(target)g++ $(flags) -o $@ $(filter %.o,$^) \ - -lobjc -lapr-1 -lreadline \ - -L. -lcycript \ - -framework Foundation -framework CoreFoundation \ - -framework JavaScriptCore -framework UIKit - ldid -S cycript + $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(link) + $(ldid) -S cycript package: $(deb) diff --git a/sig/ffi_type.hpp b/sig/ffi_type.hpp index 813386a..0257d27 100644 --- a/sig/ffi_type.hpp +++ b/sig/ffi_type.hpp @@ -40,7 +40,7 @@ #ifndef SIG_FFI_TYPE_H #define SIG_FFI_TYPE_H -#include +#include #include #include "sig/types.hpp" diff --git a/sig/parse.cpp b/sig/parse.cpp index 2f007de..a359e54 100644 --- a/sig/parse.cpp +++ b/sig/parse.cpp @@ -43,7 +43,7 @@ #include "minimal/stdlib.h" -#include +#include #include diff --git a/sig/parse.hpp b/sig/parse.hpp index 5607ad3..c569a07 100644 --- a/sig/parse.hpp +++ b/sig/parse.hpp @@ -42,7 +42,7 @@ #include "sig/types.hpp" -#include +#include namespace sig { -- 2.45.2