forked from cory/tildefriends
This builds an executable for ios.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4511 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
7169f4a6cb
commit
1c621a602f
20
Makefile
20
Makefile
@ -12,7 +12,7 @@ BUILD_DIR ?= out
|
|||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
UNAME_M := $(shell uname -m)
|
UNAME_M := $(shell uname -m)
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
BUILD_TYPES := macosdebug macosrelease
|
BUILD_TYPES := macosdebug macosrelease iosdebug iosrelease
|
||||||
else
|
else
|
||||||
BUILD_TYPES := debug release windebug winrelease androiddebug androidrelease androiddebug-x86 androidrelease-x86 androiddebug-x86_64 androidrelease-x86_64 androiddebug-armv7a androidrelease-armv7a
|
BUILD_TYPES := debug release windebug winrelease androiddebug androidrelease androiddebug-x86 androidrelease-x86 androiddebug-x86_64 androidrelease-x86_64 androiddebug-armv7a androidrelease-armv7a
|
||||||
endif
|
endif
|
||||||
@ -59,10 +59,14 @@ WINDOWS_TARGETS := \
|
|||||||
MACOS_TARGETS := \
|
MACOS_TARGETS := \
|
||||||
out/macosdebug/tildefriends \
|
out/macosdebug/tildefriends \
|
||||||
out/macosrelease/tildefriends
|
out/macosrelease/tildefriends
|
||||||
|
IOS_TARGETS := \
|
||||||
|
out/iosdebug/tildefriends \
|
||||||
|
out/iosrelease/tildefriends
|
||||||
|
|
||||||
DEBUG_TARGETS := \
|
DEBUG_TARGETS := \
|
||||||
out/debug/tildefriends \
|
out/debug/tildefriends \
|
||||||
out/windebug/tildefriends.exe \
|
out/windebug/tildefriends.exe \
|
||||||
|
out/iosdebug/tildefriends \
|
||||||
out/macosdebug/tildefriends \
|
out/macosdebug/tildefriends \
|
||||||
out/androiddebug/tildefriends \
|
out/androiddebug/tildefriends \
|
||||||
out/androiddebug-armv7a/tildefriends \
|
out/androiddebug-armv7a/tildefriends \
|
||||||
@ -71,6 +75,7 @@ DEBUG_TARGETS := \
|
|||||||
RELEASE_TARGETS := \
|
RELEASE_TARGETS := \
|
||||||
out/release/tildefriends \
|
out/release/tildefriends \
|
||||||
out/winrelease/tildefriends.exe \
|
out/winrelease/tildefriends.exe \
|
||||||
|
out/iosrelease/tildefriends \
|
||||||
out/macosrelease/tildefriends \
|
out/macosrelease/tildefriends \
|
||||||
out/androidrelease/tildefriends \
|
out/androidrelease/tildefriends \
|
||||||
out/androidrelease-armv7a/tildefriends \
|
out/androidrelease-armv7a/tildefriends \
|
||||||
@ -79,7 +84,7 @@ RELEASE_TARGETS := \
|
|||||||
ANDROID_RELEASE_TARGETS := $(filter-out $(DEBUG_TARGETS),$(ANDROID_TARGETS))
|
ANDROID_RELEASE_TARGETS := $(filter-out $(DEBUG_TARGETS),$(ANDROID_TARGETS))
|
||||||
NONANDROID_RELEASE_TARGETS := $(filter-out $(ANDROID_ARM64_TARGETS),$(RELEASE_TARGETS))
|
NONANDROID_RELEASE_TARGETS := $(filter-out $(ANDROID_ARM64_TARGETS),$(RELEASE_TARGETS))
|
||||||
NONANDROID_TARGETS := $(filter-out $(ANDROID_TARGETS),$(DEBUG_TARGETS) $(RELEASE_TARGETS))
|
NONANDROID_TARGETS := $(filter-out $(ANDROID_TARGETS),$(DEBUG_TARGETS) $(RELEASE_TARGETS))
|
||||||
NONMACOS_TARGETS := $(filter-out $(MACOS_TARGETS),$(DEBUG_TARGETS) $(RELEASE_TARGETS))
|
NONMACOS_TARGETS := $(filter-out $(MACOS_TARGETS) $(IOS_TARGETS),$(DEBUG_TARGETS) $(RELEASE_TARGETS))
|
||||||
|
|
||||||
$(NONANDROID_TARGETS): CFLAGS += -fno-omit-frame-pointer
|
$(NONANDROID_TARGETS): CFLAGS += -fno-omit-frame-pointer
|
||||||
$(filter-out $(ANDROID_TARGETS) $(WINDOWS_TARGETS),$(DEBUG_TARGETS) $(RELEASE_TARGETS)): LDFLAGS += -rdynamic
|
$(filter-out $(ANDROID_TARGETS) $(WINDOWS_TARGETS),$(DEBUG_TARGETS) $(RELEASE_TARGETS)): LDFLAGS += -rdynamic
|
||||||
@ -107,6 +112,9 @@ $(WINDOWS_TARGETS): LDFLAGS += \
|
|||||||
-lm \
|
-lm \
|
||||||
-Ldeps/openssl/mingw64/lib
|
-Ldeps/openssl/mingw64/lib
|
||||||
$(MACOS_TARGETS): CC = xcrun clang
|
$(MACOS_TARGETS): CC = xcrun clang
|
||||||
|
IOS_SYSROOT := $(shell xcrun --sdk iphoneos --show-sdk-path)
|
||||||
|
$(info $(IOS_SYSROOT))
|
||||||
|
$(IOS_TARGETS): CC = xcrun --sdk iphoneos clang -isysroot $(IOS_SYSROOT) -arch arm64
|
||||||
$(ANDROID_X86_64_TARGETS): ANDROID_NDK_TARGET_TRIPLE := x86_64-linux-android
|
$(ANDROID_X86_64_TARGETS): ANDROID_NDK_TARGET_TRIPLE := x86_64-linux-android
|
||||||
$(ANDROID_X86_TARGETS): ANDROID_NDK_TARGET_TRIPLE := i686-linux-android
|
$(ANDROID_X86_TARGETS): ANDROID_NDK_TARGET_TRIPLE := i686-linux-android
|
||||||
$(ANDROID_ARMV7A_TARGETS): ANDROID_NDK_TARGET_TRIPLE := armv7a-linux-androideabi
|
$(ANDROID_ARMV7A_TARGETS): ANDROID_NDK_TARGET_TRIPLE := armv7a-linux-androideabi
|
||||||
@ -127,6 +135,8 @@ $(ANDROID_X86_64_TARGETS): CFLAGS += -Ideps/openssl/android/x86_64/usr/local/inc
|
|||||||
$(ANDROID_X86_64_TARGETS): LDFLAGS += -Ldeps/openssl/android/x86_64/usr/local/lib
|
$(ANDROID_X86_64_TARGETS): LDFLAGS += -Ldeps/openssl/android/x86_64/usr/local/lib
|
||||||
$(NONMACOS_TARGETS): CFLAGS += -Wno-cast-function-type
|
$(NONMACOS_TARGETS): CFLAGS += -Wno-cast-function-type
|
||||||
$(NONMACOS_TARGETS): LDFLAGS += -Wl,--gc-sections
|
$(NONMACOS_TARGETS): LDFLAGS += -Wl,--gc-sections
|
||||||
|
$(IOS_TARGETS): CFLAGS += -Ideps/openssl/ios/ios64-xcrun/usr/local/include
|
||||||
|
$(IOS_TARGETS): LDFLAGS += -Ldeps/openssl/ios/ios64-xcrun/usr/local/lib
|
||||||
|
|
||||||
ifeq ($(UNAME_M),x86_64)
|
ifeq ($(UNAME_M),x86_64)
|
||||||
debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common
|
debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common
|
||||||
@ -139,7 +149,7 @@ get_objs = \
|
|||||||
$(foreach build_type,windebug winrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_win))))) \
|
$(foreach build_type,windebug winrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_win))))) \
|
||||||
$(foreach build_type,androiddebug androidrelease androiddebug-x86 androidrelease-x86 androiddebug-x86_64 androidrelease-x86_64 androiddebug-armv7a androiddebug-armv7a,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_android))))) \
|
$(foreach build_type,androiddebug androidrelease androiddebug-x86 androidrelease-x86 androiddebug-x86_64 androidrelease-x86_64 androiddebug-armv7a androiddebug-armv7a,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_android))))) \
|
||||||
$(foreach build_type,androiddebug androidrelease androiddebug-x86 androidrelease-x86 androiddebug-x86_64 androidrelease-x86_64 androiddebug-armv7a androidrelease-armv7a,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_unix))))) \
|
$(foreach build_type,androiddebug androidrelease androiddebug-x86 androidrelease-x86 androiddebug-x86_64 androidrelease-x86_64 androiddebug-armv7a androidrelease-armv7a,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_unix))))) \
|
||||||
$(foreach build_type,macosdebug macosrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_macos))))) \
|
$(foreach build_type,macosdebug macosrelease iosdebug iosrelease,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_macos))))) \
|
||||||
$(foreach build_type,androiddebug-x86 androidrelease-x86,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_x86)))))
|
$(foreach build_type,androiddebug-x86 androidrelease-x86,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_x86)))))
|
||||||
|
|
||||||
APP_SOURCES := $(wildcard src/*.c)
|
APP_SOURCES := $(wildcard src/*.c)
|
||||||
@ -161,7 +171,7 @@ $(APP_OBJS): CFLAGS += \
|
|||||||
-Wdouble-promotion \
|
-Wdouble-promotion \
|
||||||
-Werror
|
-Werror
|
||||||
ifeq ($(UNAME_M),x86_64)
|
ifeq ($(UNAME_M),x86_64)
|
||||||
$(filter-out $(BUILD_DIR)/android% $(BUILD_DIR)/macos%,$(APP_OBJS)): CFLAGS += \
|
$(filter-out $(BUILD_DIR)/android% $(BUILD_DIR)/macos% $(BUILD_DIR)/ios%,$(APP_OBJS)): CFLAGS += \
|
||||||
-fanalyzer
|
-fanalyzer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -463,7 +473,7 @@ $(MINIUNZIP_OBJS): CFLAGS += \
|
|||||||
LDFLAGS += \
|
LDFLAGS += \
|
||||||
-pthread \
|
-pthread \
|
||||||
-lm
|
-lm
|
||||||
debug release $(MACOS_TARGETS): LDFLAGS += \
|
debug release $(MACOS_TARGETS) $(IOS_TARGETS): LDFLAGS += \
|
||||||
-ldl \
|
-ldl \
|
||||||
-lssl \
|
-lssl \
|
||||||
-lcrypto
|
-lcrypto
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
extern BOOLEAN NTAPI SystemFunction036(PVOID Buffer, ULONG BufferLength);
|
extern BOOLEAN NTAPI SystemFunction036(PVOID Buffer, ULONG BufferLength);
|
||||||
|
#elif __APPLE__
|
||||||
|
#include <TargetConditionals.h>
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
#include <CommonCrypto/CommonRandom.h>
|
||||||
|
#else
|
||||||
|
#include <sys/random.h>
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <sys/random.h>
|
#include <sys/random.h>
|
||||||
#endif
|
#endif
|
||||||
@ -44,7 +51,9 @@ JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSVa
|
|||||||
char buffer[16];
|
char buffer[16];
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
ssize_t bytes = SystemFunction036(buffer, sizeof(buffer)) ? sizeof(buffer) : 0;
|
ssize_t bytes = SystemFunction036(buffer, sizeof(buffer)) ? sizeof(buffer) : 0;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__) && TARGET_OS_IPHONE
|
||||||
|
ssize_t bytes = CCRandomGenerateBytes(buffer, sizeof(buffer)) == kCCSuccess ? sizeof(buffer) : 0;
|
||||||
|
#elif defined(__APPLE__) && !TARGET_OS_IPHONE
|
||||||
ssize_t bytes = 0;
|
ssize_t bytes = 0;
|
||||||
if (getentropy(buffer, sizeof(buffer)) == 0)
|
if (getentropy(buffer, sizeof(buffer)) == 0)
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
#define WEXITSTATUS(x) (x)
|
#define WEXITSTATUS(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <TargetConditionals.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !TARGET_OS_IPHONE
|
||||||
static void _test_nop(const tf_test_options_t* options)
|
static void _test_nop(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
FILE* file = fopen("out/test.js", "w");
|
FILE* file = fopen("out/test.js", "w");
|
||||||
@ -692,9 +697,11 @@ static void _tf_test_run(const tf_test_options_t* options, const char* name, voi
|
|||||||
#undef RESET
|
#undef RESET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tf_tests(const tf_test_options_t* options)
|
void tf_tests(const tf_test_options_t* options)
|
||||||
{
|
{
|
||||||
|
#if !TARGET_OS_IPHONE
|
||||||
_tf_test_run(options, "ssb", tf_ssb_test_ssb, false);
|
_tf_test_run(options, "ssb", tf_ssb_test_ssb, false);
|
||||||
_tf_test_run(options, "ssb_id", tf_ssb_test_id_conversion, false);
|
_tf_test_run(options, "ssb_id", tf_ssb_test_id_conversion, false);
|
||||||
_tf_test_run(options, "ssb_following", tf_ssb_test_following, false);
|
_tf_test_run(options, "ssb_following", tf_ssb_test_following, false);
|
||||||
@ -719,4 +726,5 @@ void tf_tests(const tf_test_options_t* options)
|
|||||||
_tf_test_run(options, "bench", tf_ssb_test_bench, false);
|
_tf_test_run(options, "bench", tf_ssb_test_bench, false);
|
||||||
_tf_test_run(options, "go-ssb-room", tf_ssb_test_go_ssb_room, true);
|
_tf_test_run(options, "go-ssb-room", tf_ssb_test_go_ssb_room, true);
|
||||||
tf_printf("Tests completed.\n");
|
tf_printf("Tests completed.\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
64
tools/ssl-ios
Executable file
64
tools/ssl-ios
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
OPENSSL_VERSION=3.1.3
|
||||||
|
|
||||||
|
API_LEVEL=28
|
||||||
|
|
||||||
|
BUILD_DIR=out/openssl_ios_build
|
||||||
|
|
||||||
|
BUILD_TARGETS="ios64-xcrun"
|
||||||
|
|
||||||
|
rm -rfv openssl-${OPENSSL_VERSION}
|
||||||
|
|
||||||
|
if [ ! -d openssl-${OPENSSL_VERSION} ]
|
||||||
|
then
|
||||||
|
if [ ! -f openssl-${OPENSSL_VERSION}.tar.gz ]
|
||||||
|
then
|
||||||
|
curl https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -o openssl-${OPENSSL_VERSION}.tar.gz || exit 128
|
||||||
|
fi
|
||||||
|
tar xzf openssl-${OPENSSL_VERSION}.tar.gz || exit 128
|
||||||
|
fi
|
||||||
|
WORK_DIR=openssl-${OPENSSL_VERSION}
|
||||||
|
|
||||||
|
##### export ndk directory. Required by openssl-build-scripts #####
|
||||||
|
|
||||||
|
##### build-function #####
|
||||||
|
build_the_thing() {
|
||||||
|
export PATH=$TOOLCHAIN/$TRIBLE/bin:$TOOLCHAIN/bin:$PATH
|
||||||
|
echo $PATH
|
||||||
|
echo "./Configure $SSL_TARGET $OPTIONS" && \
|
||||||
|
./Configure $SSL_TARGET $OPTIONS no-tests && \
|
||||||
|
make clean && \
|
||||||
|
make build_generated && \
|
||||||
|
make libcrypto.a libssl.a || exit 128
|
||||||
|
}
|
||||||
|
|
||||||
|
##### set variables according to build-tagret #####
|
||||||
|
for build_target in $BUILD_TARGETS
|
||||||
|
do
|
||||||
|
echo "Building $build_target"
|
||||||
|
cd $WORK_DIR || exit 128
|
||||||
|
|
||||||
|
case $build_target in
|
||||||
|
ios64-xcrun)
|
||||||
|
TRIBLE="arm64-darwin-ios"
|
||||||
|
OPTIONS="--static -static -ffunction-sections -fdata-sections -fPIC -Wno-macro-redefined"
|
||||||
|
DESTDIR="/tmp/$BUILD_DIR/arm64-ios"
|
||||||
|
SSL_TARGET="ios64-xcrun"
|
||||||
|
CC=clang
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
rm -rf $DESTDIR
|
||||||
|
build_the_thing
|
||||||
|
cd ..
|
||||||
|
#### copy libraries and includes to output-directory #####
|
||||||
|
echo WORK_DIR=$WORK_DIR
|
||||||
|
rm -rf deps/openssl/ios/$build_target/
|
||||||
|
mkdir -p deps/openssl/ios/$build_target/usr/local/include
|
||||||
|
mkdir -p deps/openssl/ios/$build_target/usr/local/lib/
|
||||||
|
cp -R $WORK_DIR/include/* deps/openssl/ios/$build_target/usr/local/include/
|
||||||
|
cp $WORK_DIR/*.a deps/openssl/ios/$build_target/usr/local/lib/
|
||||||
|
done
|
||||||
|
|
||||||
|
echo Success
|
Loading…
Reference in New Issue
Block a user