mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-22 12:34:24 +00:00
commit
bbe03165b9
94
doc/build-ios-on-linux.md
Normal file
94
doc/build-ios-on-linux.md
Normal file
@ -0,0 +1,94 @@
|
||||
IOS (iPhoneOS) Build Instructions and Notes
|
||||
===========================================
|
||||
This guide will show you how to build twisterd for IOS on a linux machine.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
* Compilation, made on a linux
|
||||
* Application, tested on iPhone4 with IOS 7.1.2 (jailbroken)
|
||||
* All of the commands should be executed in a Terminal application.
|
||||
|
||||
Preparation
|
||||
-----------
|
||||
|
||||
You need to install clang and llvm from distribution's repo. Then you need IOS toolchain and SDK.
|
||||
You can get them from [iOS toolchain based on clang for linux](https://code.google.com/p/ios-toolchain-based-on-clang-for-linux/).
|
||||
|
||||
You need to install [openssl](http://cydia.saurik.com/package/openssl/) ([view in cydia...](cydia://package/openssl)) to your
|
||||
device and copy headers and libraries to your SDK as well.
|
||||
|
||||
REQUIRMENTS (leveldb, berkeley db and boost) WILL BE DOWNLOADED AND BUILDED BY `runme-ios-onlinux.sh`
|
||||
You need also to build [leveldb](http://github.com/google/leveldb), [Berkeley DB](http://download.oracle.com/otn/berkeley-db/db-5.3.28.tar.gz)
|
||||
for IOS.
|
||||
|
||||
And you need the [boost sources](http://www.boost.org/users/download/#live).
|
||||
|
||||
Instructions:
|
||||
-------------
|
||||
|
||||
#### Setting required variable
|
||||
|
||||
You should check variables set in `runme-ios-onlinux.sh` script.
|
||||
|
||||
|
||||
export IPHONE_IP=""
|
||||
export IOS_SDK=/usr/share/iPhoneOS6.0.sdk
|
||||
export ARCH=armv7
|
||||
export TARGET=arm-apple-darwin11
|
||||
export LINKER_VER=236.3
|
||||
export IPHONEOS_DEPLOYMENT_TARGET=6.0
|
||||
export TARGET_OS=IOS
|
||||
export CC="clang"
|
||||
export CXX="clang++"
|
||||
export PJC=2
|
||||
#### Building dependencies and `twisterd`
|
||||
|
||||
1. Clone the github tree to get the source code and go into the directory.
|
||||
|
||||
git clone https://github.com/miguelfreitas/twister-core.git
|
||||
cd twister-core/src
|
||||
|
||||
2. Building
|
||||
|
||||
|
||||
./runme-ios-onlinux.sh
|
||||
|
||||
3. If things go south, before trying again, make sure you clean it up:
|
||||
|
||||
|
||||
make clean
|
||||
|
||||
If all went well, you should now have a twisterd executable in the twister-core directory.
|
||||
See the Running instructions below.
|
||||
|
||||
Running
|
||||
-------
|
||||
|
||||
If you have been set IPHONE_IP before running script, it's now available at `/usr/bin/twisterd` on your device.
|
||||
We have to first create the RPC configuration file, though.
|
||||
|
||||
Run `/usr/bin/twisterd` from SSH or on [Mobile Terminal](http://cydia.saurik.com/package/mobileterminal/) to get
|
||||
the filename where it should be put, or just try these commands:
|
||||
|
||||
mkdir -p "/User/.twister"
|
||||
echo -e "rpcuser=user\nrpcpassword=pwd\nrpcallowip=127.0.0.1" > "/User/.twister/twister.conf"
|
||||
chmod 600 "/User/.twister/twister.conf"
|
||||
|
||||
When next you run it, it will start downloading the blockchain, but it won't
|
||||
output anything while it's doing this. This process may take several hours. If you see a lonely
|
||||
`connect: Operation timed out`, don't freak out, it seems to work fine.
|
||||
|
||||
Other commands:
|
||||
|
||||
tail -f ~/.twister/debug.log
|
||||
./twisterd --help # for a list of command-line options.
|
||||
./twisterd -daemon # to start it as a daemon.
|
||||
./twisterd help # When the daemon is running, to get a list of RPC commands
|
||||
|
||||
In order to get the HTML interface, you'll have to download it and link it in .twister:
|
||||
|
||||
git clone https://github.com/miguelfreitas/twister-html.git /User/Library/Application\ Support/twister/html
|
||||
|
||||
Once you do that, it will be available at http://localhost:28332/home.html
|
||||
|
38
libtorrent/src/makefile.ios
Executable file
38
libtorrent/src/makefile.ios
Executable file
@ -0,0 +1,38 @@
|
||||
PROJECTNAME:=libtorrent-rasterbar
|
||||
|
||||
libtorrent_INCLUDE:=../include
|
||||
twister_INCLUDE:=../../src
|
||||
boost_SOURCE:=$(twister_INCLUDE)/ios-build/ext/boost_1_58_0
|
||||
leveldb_SOURCE:=$(twister_INCLUDE)/ios-build/ext/leveldb-master
|
||||
|
||||
CXXFLAGS += -fobjc-arc
|
||||
CXXFLAGS += -fblocks
|
||||
CXXFLAGS += -g0 -O2 -DIOS
|
||||
CXXFLAGS += -I"$(libtorrent_INCLUDE)" -I"$(twister_INCLUDE)" -I"$(boost_SOURCE)" -I"$(leveldb_SOURCE)/include"
|
||||
CXXFLAGS += -DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64 -DBOOST_ASIO_SEPARATE_COMPILATION -DBOOST_LOCALE_WITH_ICONV
|
||||
CXXFLAGS += -DBOOST_LOCALE_NO_WINAPI_BACKEND -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE=1 -DBOOST_ASIO_ENABLE_CANCELIO=1
|
||||
CXXFLAGS += -DTORRENT_DISABLE_GEO_IP -DTORRENT_USE_OPENSSL=1
|
||||
|
||||
BLDDIR=ios-build
|
||||
SRCDIR=.
|
||||
OBJS+=$(patsubst $(SRCDIR)/%.cpp,$(BLDDIR)/%.o,$(wildcard $(SRCDIR)/*.cpp))
|
||||
OBJS+=$(patsubst $(SRCDIR)/kademlia/%.cpp,$(BLDDIR)/%.o,$(wildcard $(SRCDIR)/kademlia/*.cpp))
|
||||
|
||||
all: $(BLDDIR)/$(PROJECTNAME)
|
||||
|
||||
$(BLDDIR)/$(PROJECTNAME): $(OBJS) check
|
||||
$(AR) cr $@.a $(OBJS)
|
||||
|
||||
$(BLDDIR)/%.o: %.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/%.o: kademlia/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
check:
|
||||
test -d $(BLDDIR) || mkdir $(BLDDIR)
|
||||
|
||||
clean:
|
||||
rm -fr $(BLDDIR)
|
||||
|
||||
.PHONY: all dist install uninstall clean
|
121
src/makefile.ios
Executable file
121
src/makefile.ios
Executable file
@ -0,0 +1,121 @@
|
||||
PROJECTNAME:=twisterd
|
||||
|
||||
BLDDIR:=ios-build
|
||||
libtorrent_INCLUDE:=../libtorrent/include
|
||||
boost_SOURCE:=$(BLDDIR)/ext/boost_1_58_0
|
||||
leveldb_SOURCE:=$(BLDDIR)/ext/leveldb-master
|
||||
bdb_SOURCE:=$(BLDDIR)/ext/db-5.3.28
|
||||
|
||||
CXXFLAGS += -fobjc-arc
|
||||
CXXFLAGS += -fblocks
|
||||
CXXFLAGS += -g0 -O2 -DIOS
|
||||
CXXFLAGS += -I. -I"$(libtorrent_INCLUDE)" -I"$(boost_SOURCE)" -I"$(leveldb_SOURCE)/include" -I"$(leveldb_SOURCE)/helper" -I"$(bdb_SOURCE)/build_unix"
|
||||
CXXFLAGS += -DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64 -DBOOST_ASIO_SEPARATE_COMPILATION -DBOOST_LOCALE_WITH_ICONV
|
||||
CXXFLAGS += -DBOOST_LOCALE_NO_WINAPI_BACKEND -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE=1 -DBOOST_ASIO_ENABLE_CANCELIO=1
|
||||
CXXFLAGS += -DTORRENT_DISABLE_GEO_IP -DTORRENT_USE_OPENSSL=1 -DHAVE_CXX_STDHEADERS
|
||||
|
||||
LDFLAGS += -lssl -lcrypto -liconv -lz -ldl
|
||||
LDFLAGS += -L$(leveldb_SOURCE) -lleveldb -lmemenv
|
||||
LDFLAGS += -L$(bdb_SOURCE)/build_unix -ldb_cxx-5.3
|
||||
LDFLAGS += -L"../libtorrent/src/ios-build" -ltorrent-rasterbar
|
||||
|
||||
SRCDIR=.
|
||||
OBJS+=$(patsubst $(SRCDIR)/%.cpp,$(BLDDIR)/%.o,$(wildcard $(SRCDIR)/*.cpp))
|
||||
OBJS+=$(patsubst $(SRCDIR)/json/%.cpp,$(BLDDIR)/%.o,$(wildcard $(SRCDIR)/json/*.cpp))
|
||||
|
||||
boostlibs=$(boost_SOURCE)/libs
|
||||
OBJS+=$(BLDDIR)/boost/system/error_code.o
|
||||
OBJS+=$(patsubst $(boostlibs)/filesystem/src/%.cpp,$(BLDDIR)/boost/filesystem/%.o,$(wildcard $(boostlibs)/filesystem/src/*.cpp))
|
||||
OBJS:=$(subst $(BLDDIR)/scrypt-sse2.o,,$(OBJS))
|
||||
OBJS+=$(patsubst $(boostlibs)/program_options/src/%.cpp,$(BLDDIR)/boost/program_options/%.o,$(wildcard $(boostlibs)/program_options/src/*.cpp))
|
||||
OBJS+=$(patsubst $(boostlibs)/thread/src/%.cpp,$(BLDDIR)/boost/thread/%.o,$(wildcard $(boostlibs)/thread/src/*.cpp))
|
||||
OBJS+=$(patsubst $(boostlibs)/thread/src/pthread/%.cpp,$(BLDDIR)/boost/thread/pthread/%.o,$(wildcard $(boostlibs)/thread/src/pthread/*.cpp))
|
||||
OBJS:=$(subst $(BLDDIR)/boost/thread/pthread/once_atomic.o,,$(OBJS))
|
||||
OBJS+=$(patsubst $(boostlibs)/locale/src/encoding/%.cpp,$(BLDDIR)/boost/locale/encoding/%.o,$(wildcard $(boostlibs)/locale/src/encoding/*.cpp))
|
||||
OBJS+=$(patsubst $(boostlibs)/locale/src/posix/%.cpp,$(BLDDIR)/boost/locale/posix/%.o,$(wildcard $(boostlibs)/locale/src/posix/*.cpp))
|
||||
OBJS+=$(patsubst $(boostlibs)/locale/src/shared/%.cpp,$(BLDDIR)/boost/locale/shared/%.o,$(wildcard $(boostlibs)/locale/src/shared/*.cpp))
|
||||
OBJS+=$(patsubst $(boostlibs)/locale/src/std/%.cpp,$(BLDDIR)/boost/locale/std/%.o,$(wildcard $(boostlibs)/locale/src/std/*.cpp))
|
||||
OBJS+=$(patsubst $(boostlibs)/locale/src/util/%.cpp,$(BLDDIR)/boost/locale/util/%.o,$(wildcard $(boostlibs)/locale/src/util/*.cpp))
|
||||
OBJS+=$(patsubst $(boostlibs)/chrono/src/%.cpp,$(BLDDIR)/boost/chrono/%.o,$(wildcard $(boostlibs)/chrono/src/*.cpp))
|
||||
OBJS+=$(patsubst $(boostlibs)/regex/src/%.cpp,$(BLDDIR)/boost/regex/%.o,$(wildcard $(boostlibs)/regex/src/*.cpp))
|
||||
|
||||
all: $(BLDDIR)/$(PROJECTNAME)
|
||||
|
||||
$(BLDDIR)/$(PROJECTNAME): $(OBJS) check
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) -o $@
|
||||
|
||||
$(BLDDIR)/%.o: %.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/%.o: json/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/thread/%.o: $(boostlibs)/thread/src/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/thread/pthread/%.o: $(boostlibs)/thread/src/pthread/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/locale/encoding/%.o: $(boostlibs)/locale/src/encoding/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/locale/shared/%.o: $(boostlibs)/locale/src/shared/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/locale/util/%.o: $(boostlibs)/locale/src/util/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/locale/std/%.o: $(boostlibs)/locale/src/std/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/locale/posix/%.o: $(boostlibs)/locale/src/posix/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/locale/icu/%.o: $(boostlibs)/locale/src/icu/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/system/%.o: $(boostlibs)/system/src/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/filesystem/%.o: $(boostlibs)/filesystem/src/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/program_options/%.o: $(boostlibs)/program_options/src/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/chrono/%.o: $(boostlibs)/chrono/src/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
$(BLDDIR)/boost/regex/%.o: $(boostlibs)/regex/src/%.cpp check
|
||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||
|
||||
check:
|
||||
@test -d $(BLDDIR)/boost/system || mkdir -p $(BLDDIR)/boost/system
|
||||
@test -d $(BLDDIR)/boost/filesystem || mkdir -p $(BLDDIR)/boost/filesystem
|
||||
@test -d $(BLDDIR)/boost/program_options || mkdir -p $(BLDDIR)/boost/program_options
|
||||
@test -d $(BLDDIR)/boost/thread/pthread || mkdir -p $(BLDDIR)/boost/thread/pthread
|
||||
@test -d $(BLDDIR)/boost/locale/encoding || mkdir -p $(BLDDIR)/boost/locale/{encoding,icu,posix,std,shared,util}
|
||||
@test -d $(BLDDIR)/boost/chrono || mkdir -p $(BLDDIR)/boost/chrono
|
||||
@test -d $(BLDDIR)/boost/regex || mkdir -p $(BLDDIR)/boost/regex
|
||||
@if test -z $(boost_SOURCE); then \
|
||||
echo "please set the 'boost_SOURCE' variable";\
|
||||
exit 1;\
|
||||
fi
|
||||
@if ! test -d $(boost_SOURCE); then \
|
||||
echo "please check 'boost_SOURCE=$(boost_SOURCE)', directory not found.";\
|
||||
exit 1;\
|
||||
fi
|
||||
|
||||
clean:
|
||||
rm -fr $(BLDDIR)
|
||||
|
||||
install:
|
||||
ifeq ($(IPHONE_IP),)
|
||||
echo "Please set IPHONE_IP"
|
||||
else
|
||||
ssh root@$(IPHONE_IP) 'rm -fr /usr/bin/twisterd'
|
||||
scp -r $(BLDDIR)/twisterd root@$(IPHONE_IP):/usr/bin/twisterd
|
||||
echo "twisterd installed, now you can run it in 'Mobile Terminal' or via SSH."
|
||||
endif
|
||||
|
||||
.PHONY: all dist install uninstall clean
|
95
src/runme-ios-onlinux.sh
Executable file
95
src/runme-ios-onlinux.sh
Executable file
@ -0,0 +1,95 @@
|
||||
#twister building script for IOS on linux
|
||||
|
||||
export IPHONE_IP=""
|
||||
export IOS_SDK=/usr/share/iPhoneOS6.0.sdk
|
||||
export ARCH=armv7
|
||||
export TARGET=arm-apple-darwin11
|
||||
export LINKER_VER=236.3
|
||||
export IPHONEOS_DEPLOYMENT_TARGET=6.0
|
||||
export IOS_SIGN_CODE_WHEN_BUILD=1
|
||||
export TARGET_OS=IOS
|
||||
export PJC=2
|
||||
|
||||
export CC="clang"
|
||||
export CXX="clang++"
|
||||
export CFLAGS="-target $TARGET -arch $ARCH -isysroot $IOS_SDK -fblocks -fobjc-arc -g0 -O2 -D$TARGET_OS -mlinker-version=$LINKER_VER"
|
||||
export CXXFLAGS="$CFLAGS"
|
||||
export LD="$TARGET-ld"
|
||||
export AR="$TARGET-ar"
|
||||
|
||||
export LDFLAGS="-L$IOS_SDK/System"
|
||||
|
||||
mkdir -p ios-build/ext
|
||||
cd ios-build/ext
|
||||
echo 'Downloading leveldb...'
|
||||
[ -f leveldb.zip ] || wget https://github.com/google/leveldb/archive/master.zip -O leveldb.zip
|
||||
[ -d leveldb-master ] || unzip leveldb.zip
|
||||
cd leveldb-master
|
||||
cat << _EOF > makefile.ios
|
||||
SOURCES=db/builder.cc db/c.cc db/dbformat.cc db/db_impl.cc db/db_iter.cc db/dumpfile.cc db/filename.cc db/log_reader.cc db/log_writer.cc db/memtable.cc db/repair.cc db/table_cache.cc db/version_edit.cc db/version_set.cc db/write_batch.cc table/block_builder.cc table/block.cc table/filter_block.cc table/format.cc table/iterator.cc table/merger.cc table/table_builder.cc table/table.cc table/two_level_iterator.cc util/arena.cc util/bloom.cc util/cache.cc util/coding.cc util/comparator.cc util/crc32c.cc util/env.cc util/env_posix.cc util/filter_policy.cc util/hash.cc util/histogram.cc util/logging.cc util/options.cc util/status.cc port/port_posix.cc
|
||||
MEMENV_SOURCES=helpers/memenv/memenv.cc
|
||||
PLATFORM_CCFLAGS= -DOS_MACOSX -DLEVELDB_PLATFORM_POSIX
|
||||
PLATFORM_CXXFLAGS= -DOS_MACOSX -DLEVELDB_PLATFORM_POSIX
|
||||
CFLAGS += -I. -I./include \$(PLATFORM_CCFLAGS) -O2 -DNDEBUG
|
||||
CXXFLAGS += -I. -I./include \$(PLATFORM_CXXFLAGS) -O2 -DNDEBUG
|
||||
LIBOBJECTS = \$(SOURCES:.cc=.o)
|
||||
MEMENVOBJECTS = \$(MEMENV_SOURCES:.cc=.o)
|
||||
LIBRARY = libleveldb.a
|
||||
MEMENVLIBRARY = libmemenv.a
|
||||
|
||||
default: all
|
||||
|
||||
all: \$(LIBRARY) \$(MEMENVLIBRARY)
|
||||
|
||||
clean:
|
||||
rm -f \$(LIBRARY) \$(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk
|
||||
rm -rf ios-x86/* ios-arm/*
|
||||
|
||||
\$(LIBRARY): \$(LIBOBJECTS)
|
||||
rm -f \$@
|
||||
\$(AR) -rs \$@ \$(LIBOBJECTS)
|
||||
|
||||
\$(MEMENVLIBRARY) : \$(MEMENVOBJECTS)
|
||||
rm -f \$@
|
||||
\$(AR) -rs \$@ \$(MEMENVOBJECTS)
|
||||
|
||||
.cc.o:
|
||||
\$(CXX) \$(CXXFLAGS) -c \$< -o \$@
|
||||
|
||||
.c.o:
|
||||
\$(CC) \$(CFLAGS) -c \$< -o \$@
|
||||
_EOF
|
||||
|
||||
make -f makefile.ios -j$PJC
|
||||
cd ..
|
||||
|
||||
echo 'Downloading berkeley db...'
|
||||
[ -f db-5.3.28.tar.gz ] || wget http://download.oracle.com/berkeley-db/db-5.3.28.tar.gz
|
||||
[ -d db-5.3.28 ] || tar xf db-5.3.28.tar.gz
|
||||
cd db-5.3.28/build_unix
|
||||
export _CFLAGS="$CFLAGS"
|
||||
export _CXXFLAGS="$CXXFLAGS"
|
||||
export CFLAGS="-pipe -gdwarf-2 -no-cpp-precomp -mthumb $_CFLAGS"
|
||||
export CXXFLAGS="-pipe -gdwarf-2 -no-cpp-precomp -mthumb $_CXXFLAGS"
|
||||
../dist/configure --host=$TARGET --prefix=/usr --enable-compat185 --enable-shared=no --enable-static --enable-cxx --enable-dbm --enable-st
|
||||
make -j$PJC
|
||||
|
||||
export CFLAGS="$_CFLAGS"
|
||||
export CXXFLAGS="$_CXXFLAGS"
|
||||
|
||||
cd ../..
|
||||
|
||||
echo 'Downloading boost...'
|
||||
[ -f boost_1_58_0.tar.bz2 ] || wget https://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.tar.bz2
|
||||
[ -d boost_1_58_0 ] || tar xf boost_1_58_0.tar.bz2
|
||||
|
||||
cd ../..
|
||||
|
||||
echo 'Building libtorrent...'
|
||||
[ -f ../libtorrent/src/ios-build/libtorrent-rasterbar.a ] || make -C ../libtorrent/src -f makefile.ios -j$PJC
|
||||
|
||||
echo 'Building twister...'
|
||||
make -f makefile.ios -j$PJC
|
||||
|
||||
echo "Installing twisterd to your device..."
|
||||
[ -n "$IPHONE_IP" ] && make -f makefile.ios install
|
Loading…
x
Reference in New Issue
Block a user