Compare commits

...

3 Commits

5 changed files with 17 additions and 340 deletions

View File

@ -227,11 +227,11 @@ $(WINDOWS_TARGETS): CFLAGS += \
-D_WIN32_WINNT=0x0A00 \
-DWINVER=0x0A00 \
-DNTDDI_VERSION=NTDDI_WIN10 \
-Iout/openssl/mingw64/usr/local/include
-Iout/openssl/$(UNAME_S)/mingw64/usr/local/include
$(WINDOWS_TARGETS): LDFLAGS += \
-static \
-lm \
-Lout/openssl/mingw64/usr/local/lib
-Lout/openssl/$(UNAME_S)/mingw64/usr/local/lib
$(AARCH64_TARGETS): CC = aarch64-linux-gnu-gcc
$(AARCH64_TARGETS): AS = $(CC)
$(AARCH64_TARGETS): CFLAGS += -Iout/openssl/Linux/aarch64/usr/local/include
@ -1139,7 +1139,13 @@ iossimdebuggo: out/tildefriends-iossimdebug.app/tildefriends ## Build, install,
ANDROID_DEPS := out/openssl/android/arm64-v8a/usr/local/lib/libssl.a
$(ANDROID_DEPS):
+@ANDROID_NDK_ROOT=$(ANDROID_NDK) tools/ssl-android
+@export ANDROID_NDK_ROOT=$(ANDROID_NDK)
+@export BUILD_PLATFORM=android
+@export TOOLCHAIN=$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64
+@PATH=$$TOOLCHAIN/x86_64-linux-android/bin:$$TOOLCHAIN/bin:$$PATH BUILD_TARGET=x86_64 SSL_TARGET=android-x86_64 OPTIONS="--static -static -ffunction-sections -fdata-sections -D__ANDROID_API__=${ANDROID_MIN_SDK_VERSION} -Wno-macro-redefined" tools/ssl-local
+@PATH=$$TOOLCHAIN/i686-linux-android/bin:$$TOOLCHAIN/bin:$$PATH BUILD_TARGET=x86 SSL_TARGET=android-x86 OPTIONS="--static -static -ffunction-sections -fdata-sections -D__ANDROID_API__=${ANDROID_MIN_SDK_VERSION} -Wno-macro-redefined" tools/ssl-local
+@PATH=$$TOOLCHAIN/arm-linux-androideabi/bin:$$TOOLCHAIN/bin:$$PATH BUILD_TARGET=armeabi-v7a SSL_TARGET=android-arm OPTIONS="--static -static -ffunction-sections -fdata-sections --target=armv7a-linux-androideabi -Wl,--fix-cortex-a8 -D__ANDROID_API__=${ANDROID_MIN_SDK_VERSION} -Wno-macro-redefined" tools/ssl-local
+@PATH=$$TOOLCHAIN/aarch64-linux-android/bin:$$TOOLCHAIN/bin:$$PATH BUILD_TARGET=arm64-v8a SSL_TARGET=android-arm64 OPTIONS="--static -static -ffunction-sections -fdata-sections -D__ANDROID_API__=${ANDROID_MIN_SDK_VERSION} -Wno-macro-redefined" tools/ssl-local
$(filter $(BUILD_DIR)/android%,$(APP_OBJS)): | $(ANDROID_DEPS)
ifeq ($(UNAME_S),Linux)
@ -1181,9 +1187,9 @@ $(filter $(BUILD_DIR)/debug/%,$(APP_OBJS)) $(filter $(BUILD_DIR)/release/%,$(APP
endif
ifeq ($(HAVE_WIN),1)
WINDOWS_DEPS := out/openssl/mingw64/usr/local/lib/libssl.a
WINDOWS_DEPS := out/openssl/$(UNAME_S)/mingw64/usr/local/lib/libssl.a
$(WINDOWS_DEPS):
+@tools/ssl-mingw64
+@BUILD_TARGET=mingw64 SSL_TARGET=mingw64 OPTIONS="--cross-compile-prefix=x86_64-w64-mingw32-" tools/ssl-local
$(filter $(BUILD_DIR)/win%,$(APP_OBJS)): | $(WINDOWS_DEPS)
endif

View File

@ -18,7 +18,6 @@
static JSValue _file_read_file(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
static JSValue _file_read_file_zip(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
static JSValue _file_write_file(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
typedef struct fs_req_t
{
@ -36,7 +35,6 @@ void tf_file_register(JSContext* context)
const char* zip = tf_task_get_zip_path(task);
JS_SetPropertyStr(context, global, "File", file);
JS_SetPropertyStr(context, file, "readFile", JS_NewCFunction(context, zip ? _file_read_file_zip : _file_read_file, "readFile", 1));
JS_SetPropertyStr(context, file, "writeFile", JS_NewCFunction(context, _file_write_file, "writeFile", 2));
JS_FreeValue(context, global);
}
@ -51,105 +49,6 @@ static void _file_async_close_callback(uv_fs_t* req)
tf_free(req);
}
static void _file_write_write_callback(uv_fs_t* req)
{
uv_fs_req_cleanup(req);
fs_req_t* fsreq = (fs_req_t*)req;
tf_task_t* task = req->loop->data;
JSContext* context = tf_task_get_context(task);
promiseid_t promise = (promiseid_t)(intptr_t)req->data;
if (req->result >= 0)
{
tf_task_resolve_promise(task, promise, JS_NewInt64(context, req->result));
}
else
{
tf_task_reject_promise(task, promise, JS_ThrowInternalError(context, "Failed to write %s: %s", req->path, uv_strerror(req->result)));
}
int result = uv_fs_close(req->loop, req, fsreq->file, _file_async_close_callback);
if (result < 0)
{
uv_fs_req_cleanup(req);
tf_free(fsreq);
}
}
static void _file_write_open_callback(uv_fs_t* req)
{
fs_req_t* fsreq = (fs_req_t*)req;
const char* path = tf_strdup(req->path);
uv_fs_req_cleanup(req);
tf_task_t* task = req->loop->data;
JSContext* context = tf_task_get_context(task);
promiseid_t promise = (promiseid_t)(intptr_t)req->data;
if (req->result >= 0)
{
uv_buf_t buf = { .base = fsreq->buffer, .len = fsreq->size };
fsreq->file = req->result;
int result = uv_fs_write(req->loop, req, fsreq->file, &buf, 1, 0, _file_write_write_callback);
if (result < 0)
{
uv_fs_req_cleanup(req);
tf_task_reject_promise(task, promise, JS_ThrowInternalError(context, "Failed to write %s: %s", path, uv_strerror(result)));
result = uv_fs_close(req->loop, req, fsreq->file, _file_async_close_callback);
if (result < 0)
{
uv_fs_req_cleanup(req);
tf_free(fsreq);
}
}
}
else
{
tf_task_reject_promise(task, promise, JS_ThrowInternalError(context, "%s", uv_strerror(req->result)));
tf_free(req);
}
tf_free((void*)path);
}
static JSValue _file_write_file(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
tf_task_t* task = JS_GetContextOpaque(context);
const char* file_name = JS_ToCString(context, argv[0]);
size_t size;
uint8_t* buffer = tf_util_try_get_array_buffer(context, &size, argv[1]);
bool is_array_buffer = false;
if (buffer)
{
is_array_buffer = true;
}
else
{
buffer = (uint8_t*)JS_ToCStringLen(context, &size, argv[1]);
}
promiseid_t promise = -1;
JSValue promise_value = tf_task_allocate_promise(task, &promise);
fs_req_t* req = tf_malloc(sizeof(fs_req_t) + size);
*req = (fs_req_t)
{
.fs =
{
.data = (void*)(intptr_t)promise,
},
.size = size,
};
memcpy(req->buffer, buffer, size);
if (!is_array_buffer)
{
JS_FreeCString(context, (const char*)buffer);
}
int result = uv_fs_open(tf_task_get_loop(task), &req->fs, file_name, UV_FS_O_CREAT | UV_FS_O_WRONLY, 0644, _file_write_open_callback);
if (result < 0)
{
tf_task_reject_promise(task, promise, JS_ThrowInternalError(context, "Failed to open %s for write: %s", file_name, uv_strerror(result)));
}
JS_FreeCString(context, file_name);
return promise_value;
}
static void _file_read_read_callback(uv_fs_t* req)
{
fs_req_t* fsreq = (fs_req_t*)req;

View File

@ -1,136 +0,0 @@
#!/bin/bash
if [ -z $ANDROID_NDK_ROOT ]; then
ANDROID_NDK_ROOT=~/Android/Sdk/ndk/26.1.10909125
fi
API_LEVEL=24
BUILD_DIR=out/openssl_android_build
BUILD_TARGETS="x86_64 x86 arm64-v8a armeabi-v7a"
WORK_DIR=out/openssl-android
rm -rf $WORK_DIR
cp -arf deps/openssl_src/ $WORK_DIR
export ANDROID_NDK_ROOT
echo ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT
build_the_thing() {
TOOLCHAIN=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64
export PATH=$TOOLCHAIN/$TRIBLE/bin:$TOOLCHAIN/bin:$PATH
echo $PATH
export GLOBAL_OPTIONS="
no-apps
no-asm
no-async
no-autoerrinit
no-autoload-config
no-cmp
no-cms
no-comp
no-deprecated
no-dgram
no-docs
no-dsa
no-dso
no-dtls
no-dtls1
no-dtls1-method
no-dynamic-engine
no-ec2m
no-egd
no-engine
no-err
no-filenames
no-gost
no-http
no-idea
no-legacy
no-md2
no-md4
no-module
no-multiblock
no-nextprotoneg
no-ocsp
no-psk
no-shared
no-sock
no-srp
no-ssl
no-ssl3
no-ssl-trace
no-stdio
no-tests
no-thread-pool
no-threads
no-tls1
no-tls1-method
no-trace
no-ui-console
no-uplink
no-whirlpool
no-weak-ssl-ciphers
no-zlib
-Oz
-DOPENSSL_SMALL_FOOTPRINT
-ffunction-sections
-fdata-sections"
pwd
echo "./Configure $SSL_TARGET $OPTIONS $GLOBAL_OPTIONS" && \
./Configure $SSL_TARGET $OPTIONS $GLOBAL_OPTIONS && \
make -s clean && \
make -s build_generated && \
make -s libcrypto.a libssl.a || exit 128
}
for build_target in $BUILD_TARGETS
do
echo "Building $build_target"
pwd
pushd $WORK_DIR || exit 128
case $build_target in
armeabi-v7a)
TRIBLE="arm-linux-androideabi"
OPTIONS="--target=armv7a-linux-androideabi -ffunction-sections -fdata-sections -Wl,--fix-cortex-a8 -fPIC -D__ANDROID_API__=$API_LEVEL -Wno-macro-redefined"
DESTDIR="/tmp/$BUILD_DIR/armeabi-v7a"
SSL_TARGET="android-arm"
CC=clang
;;
x86)
TRIBLE="i686-linux-android"
OPTIONS="-fPIC -ffunction-sections -fdata-sections -D__ANDROID_API__=${API_LEVEL} -Wno-macro-redefined"
DESTDIR="/tmp/$BUILD_DIR/x86"
SSL_TARGET="android-x86"
CC=clang
;;
x86_64)
TRIBLE="x86_64-linux-android"
OPTIONS="--static -static -ffunction-sections -fdata-sections -D__ANDROID_API__=${API_LEVEL} -Wno-macro-redefined"
DESTDIR="/tmp/$BUILD_DIR/x86_64"
SSL_TARGET="android-x86_64"
CC=clang
;;
arm64-v8a)
TRIBLE="aarch64-linux-android"
OPTIONS="--static -static -ffunction-sections -fdata-sections -fPIC -D__ANDROID_API__=${API_LEVEL} -Wno-macro-redefined"
DESTDIR="/tmp/$BUILD_DIR/arm64-v8a"
SSL_TARGET="android-arm64"
CC=clang
;;
esac
rm -rf $DESTDIR
build_the_thing
popd
echo WORK_DIR=$WORK_DIR
rm -rf out/openssl/android/$build_target/
mkdir -p out/openssl/android/$build_target/usr/local/include/
mkdir -p out/openssl/android/$build_target/usr/local/lib/
cp -R $WORK_DIR/include/* out/openssl/android/$build_target/usr/local/include/
cp $WORK_DIR/*.a out/openssl/android/$build_target/usr/local/lib/
done
echo Success

View File

@ -1,13 +1,15 @@
#!/usr/bin/env bash
BUILD_PLATFORM=$(uname -s)
if [[ -z $BUILD_PLATFORM ]]; then
BUILD_PLATFORM=$(uname -s)
fi
if [[ -z $BUILD_TARGET ]]; then
BUILD_TARGET=$(uname -m)
WORK_DIR=out/openssl-local
else
WORK_DIR=out/openssl-$BUILD_TARGET
WORK_DIR=out/openssl-$BUILD_PLATFORM-$BUILD_TARGET
if [[ -z $SSL_TARGET ]]; then
SSL_TARGET=linux-$BUILD_TARGET
SSL_TARGET=linux-$BUILD_PLATFORM-$BUILD_TARGET
fi
fi
@ -69,8 +71,8 @@ no-tls1-method
no-trace
no-ui-console
no-uplink
no-whirlpool
no-weak-ssl-ciphers
no-whirlpool
no-zlib
-Os
-DOPENSSL_SMALL_FOOTPRINT

View File

@ -1,94 +0,0 @@
#!/bin/bash
API_LEVEL=24
BUILD_DIR=out/openssl_mingw64_build
BUILD_TARGETS="mingw64"
WORK_DIR=out/openssl-mingw64
rm -rf $WORK_DIR
cp -arf deps/openssl_src/ $WORK_DIR
build_the_thing() {
export GLOBAL_OPTIONS="
no-apps
no-asm
no-async
no-autoerrinit
no-cmp
no-cms
no-comp
no-deprecated
no-dgram
no-docs
no-dsa
no-dso
no-dtls
no-dynamic-engine
no-ec2m
no-egd
no-engine
no-err
no-filenames
no-gost
no-http
no-idea
no-legacy
no-md2
no-md4
no-module
no-multiblock
no-nextprotoneg
no-ocsp
no-psk
no-shared
no-sock
no-srp
no-ssl-trace
no-ssl3
no-stdio
no-tests
no-thread-pool
no-threads
no-trace
no-ui-console
no-uplink
no-weak-ssl-ciphers
no-zlib
-Os
-ffunction-sections
-fdata-sections
-DOPENSSL_SMALL_FOOTPRINT"
echo "./Configure $SSL_TARGET $OPTIONS $GLOBAL_OPTIONS" && \
./Configure $SSL_TARGET $OPTIONS $GLOBAL_OPTIONS && \
make -s clean && \
make -s build_generated && \
make -s libcrypto.a libssl.a || exit 128
}
for build_target in $BUILD_TARGETS
do
echo "Building $build_target"
pushd $WORK_DIR || exit 128
case $build_target in
mingw64)
OPTIONS="--cross-compile-prefix=x86_64-w64-mingw32-"
DESTDIR="/tmp/$BUILD_DIR/mingw64"
SSL_TARGET="mingw64"
;;
esac
rm -rf $DESTDIR
build_the_thing
popd
echo WORK_DIR=$WORK_DIR
rm -rf out/openssl/$build_target/
mkdir -p out/openssl/$build_target/usr/local/include/
mkdir -p out/openssl/$build_target/usr/local/lib/
cp -R $WORK_DIR/include/* out/openssl/$build_target/usr/local/include/
cp $WORK_DIR/*.a out/openssl/$build_target/usr/local/lib/
done
echo Success