forked from cory/tildefriends
This compiles on macos for x86_64, at least.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4485 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
6302565942
commit
31af27529e
52
Makefile
52
Makefile
@ -9,20 +9,18 @@ VERSION_NAME := Be nothing, and you will have everything to give to others.
|
|||||||
|
|
||||||
PROJECT = tildefriends
|
PROJECT = tildefriends
|
||||||
BUILD_DIR ?= out
|
BUILD_DIR ?= out
|
||||||
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 macosdebug macosrelease androiddebug androidrelease androiddebug-x86 androidrelease-x86 androiddebug-x86_64 androidrelease-x86_64 androiddebug-armv7a androidrelease-armv7a
|
||||||
UNAME_M := $(shell uname -m)
|
UNAME_M := $(shell uname -m)
|
||||||
|
|
||||||
CFLAGS += \
|
CFLAGS += \
|
||||||
-Wall \
|
-Wall \
|
||||||
-Wextra \
|
-Wextra \
|
||||||
-Wno-unused-parameter \
|
-Wno-unused-parameter \
|
||||||
-Wno-cast-function-type \
|
|
||||||
-MMD \
|
-MMD \
|
||||||
-ffunction-sections \
|
-ffunction-sections \
|
||||||
-fdata-sections \
|
-fdata-sections \
|
||||||
-fno-exceptions \
|
-fno-exceptions \
|
||||||
-g
|
-g
|
||||||
LDFLAGS += -Wl,--gc-sections
|
|
||||||
|
|
||||||
ANDROID_SDK ?= ~/Android/Sdk
|
ANDROID_SDK ?= ~/Android/Sdk
|
||||||
ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/33.0.1
|
ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/33.0.1
|
||||||
@ -47,10 +45,15 @@ ANDROID_TARGETS := \
|
|||||||
$(ANDROID_X86_64_TARGETS) \
|
$(ANDROID_X86_64_TARGETS) \
|
||||||
$(ANDROID_ARMV7A_TARGETS) \
|
$(ANDROID_ARMV7A_TARGETS) \
|
||||||
$(ANDROID_ARM64_TARGETS)
|
$(ANDROID_ARM64_TARGETS)
|
||||||
|
MACOS_TARGETS := \
|
||||||
|
out/macosdebug/tildefriends \
|
||||||
|
out/macosrelease/tildefriends
|
||||||
|
NONMACOS_TARGETS := $(filter-out $(MACOS_TARGETS),$(DEBUG_TARGETS) $(RELEASE_TARGETS))
|
||||||
|
|
||||||
DEBUG_TARGETS := \
|
DEBUG_TARGETS := \
|
||||||
out/debug/tildefriends \
|
out/debug/tildefriends \
|
||||||
out/windebug/tildefriends \
|
out/windebug/tildefriends \
|
||||||
|
out/macosdebug/tildefriends \
|
||||||
out/androiddebug/tildefriends \
|
out/androiddebug/tildefriends \
|
||||||
out/androiddebug-armv7a/tildefriends \
|
out/androiddebug-armv7a/tildefriends \
|
||||||
out/androiddebug-x86_64/tildefriends \
|
out/androiddebug-x86_64/tildefriends \
|
||||||
@ -58,6 +61,7 @@ DEBUG_TARGETS := \
|
|||||||
RELEASE_TARGETS := \
|
RELEASE_TARGETS := \
|
||||||
out/release/tildefriends \
|
out/release/tildefriends \
|
||||||
out/winrelease/tildefriends \
|
out/winrelease/tildefriends \
|
||||||
|
out/macosrelease/tildefriends \
|
||||||
out/androidrelease/tildefriends \
|
out/androidrelease/tildefriends \
|
||||||
out/androidrelease-armv7a/tildefriends \
|
out/androidrelease-armv7a/tildefriends \
|
||||||
out/androidrelease-x86_64/tildefriends \
|
out/androidrelease-x86_64/tildefriends \
|
||||||
@ -91,6 +95,9 @@ windebug winrelease: LDFLAGS += \
|
|||||||
-static \
|
-static \
|
||||||
-lm \
|
-lm \
|
||||||
-Ldeps/openssl/mingw64/lib
|
-Ldeps/openssl/mingw64/lib
|
||||||
|
$(MACOS_TARGETS): CC = xcrun clang
|
||||||
|
$(NONMACOS_TARGETS): CFLAGS += -Wno-cast-function-type
|
||||||
|
$(NONMACOS_TARGETS): LDFLAGS += -Wl,--gc-sections
|
||||||
$(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
|
||||||
@ -121,6 +128,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,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)
|
||||||
@ -142,7 +150,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%,$(APP_OBJS)): CFLAGS += \
|
$(filter-out $(BUILD_DIR)/android% $(BUILD_DIR)/macos%,$(APP_OBJS)): CFLAGS += \
|
||||||
-fanalyzer
|
-fanalyzer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -220,6 +228,32 @@ UV_SOURCES_win := \
|
|||||||
deps/libuv/src/win/util.c \
|
deps/libuv/src/win/util.c \
|
||||||
deps/libuv/src/win/winapi.c \
|
deps/libuv/src/win/winapi.c \
|
||||||
deps/libuv/src/win/winsock.c
|
deps/libuv/src/win/winsock.c
|
||||||
|
UV_SOURCES_macos := \
|
||||||
|
deps/libuv/src/unix/async.c \
|
||||||
|
deps/libuv/src/unix/bsd-ifaddrs.c \
|
||||||
|
deps/libuv/src/unix/core.c \
|
||||||
|
deps/libuv/src/unix/darwin.c \
|
||||||
|
deps/libuv/src/unix/darwin-proctitle.c \
|
||||||
|
deps/libuv/src/unix/dl.c \
|
||||||
|
deps/libuv/src/unix/fs.c \
|
||||||
|
deps/libuv/src/unix/fsevents.c \
|
||||||
|
deps/libuv/src/unix/getaddrinfo.c \
|
||||||
|
deps/libuv/src/unix/getnameinfo.c \
|
||||||
|
deps/libuv/src/unix/kqueue.c \
|
||||||
|
deps/libuv/src/unix/loop-watcher.c \
|
||||||
|
deps/libuv/src/unix/loop.c \
|
||||||
|
deps/libuv/src/unix/pipe.c \
|
||||||
|
deps/libuv/src/unix/poll.c \
|
||||||
|
deps/libuv/src/unix/process.c \
|
||||||
|
deps/libuv/src/unix/proctitle.c \
|
||||||
|
deps/libuv/src/unix/random-devurandom.c \
|
||||||
|
deps/libuv/src/unix/random-getentropy.c \
|
||||||
|
deps/libuv/src/unix/signal.c \
|
||||||
|
deps/libuv/src/unix/stream.c \
|
||||||
|
deps/libuv/src/unix/tcp.c \
|
||||||
|
deps/libuv/src/unix/thread.c \
|
||||||
|
deps/libuv/src/unix/tty.c \
|
||||||
|
deps/libuv/src/unix/udp.c
|
||||||
UV_OBJS := $(call get_objs,UV_SOURCES)
|
UV_OBJS := $(call get_objs,UV_SOURCES)
|
||||||
$(UV_OBJS): CFLAGS += \
|
$(UV_OBJS): CFLAGS += \
|
||||||
-Ideps/libuv/include \
|
-Ideps/libuv/include \
|
||||||
@ -371,6 +405,12 @@ LIBBACKTRACE_SOURCES_win := \
|
|||||||
deps/libbacktrace/pecoff.c \
|
deps/libbacktrace/pecoff.c \
|
||||||
deps/libbacktrace/posix.c \
|
deps/libbacktrace/posix.c \
|
||||||
deps/libbacktrace/read.c
|
deps/libbacktrace/read.c
|
||||||
|
LIBBACKTRACE_SOURCES_macos := \
|
||||||
|
deps/libbacktrace/dwarf.c \
|
||||||
|
deps/libbacktrace/macho.c \
|
||||||
|
deps/libbacktrace/mmap.c \
|
||||||
|
deps/libbacktrace/mmapio.c \
|
||||||
|
deps/libbacktrace/posix.c
|
||||||
LIBBACKTRACE_OBJS := $(call get_objs,LIBBACKTRACE_SOURCES)
|
LIBBACKTRACE_OBJS := $(call get_objs,LIBBACKTRACE_SOURCES)
|
||||||
$(LIBBACKTRACE_OBJS): CFLAGS += \
|
$(LIBBACKTRACE_OBJS): CFLAGS += \
|
||||||
-Ideps/libbacktrace_config \
|
-Ideps/libbacktrace_config \
|
||||||
@ -400,7 +440,7 @@ $(MINIUNZIP_OBJS): CFLAGS += \
|
|||||||
LDFLAGS += \
|
LDFLAGS += \
|
||||||
-pthread \
|
-pthread \
|
||||||
-lm
|
-lm
|
||||||
debug release: LDFLAGS += \
|
debug release $(MACOS_TARGETS): LDFLAGS += \
|
||||||
-ldl \
|
-ldl \
|
||||||
-lssl \
|
-lssl \
|
||||||
-lcrypto
|
-lcrypto
|
||||||
@ -449,7 +489,7 @@ $(1): $(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe)
|
|||||||
|
|
||||||
$(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe): $(filter $(BUILD_DIR)/$(1)/%,$(ALL_APP_OBJS))
|
$(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe): $(filter $(BUILD_DIR)/$(1)/%,$(ALL_APP_OBJS))
|
||||||
@echo [link] $$@
|
@echo [link] $$@
|
||||||
@$$(CC) -o $$@ -Wl,-Map,$$@.map $$^ $$(LDFLAGS)
|
@$$(CC) -o $$@ $$^ $$(LDFLAGS)
|
||||||
|
|
||||||
$(BUILD_DIR)/$(1)/%.o: %.c
|
$(BUILD_DIR)/$(1)/%.o: %.c
|
||||||
@mkdir -p $$(dir $$@)
|
@mkdir -p $$(dir $$@)
|
||||||
|
@ -44,6 +44,12 @@ 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__)
|
||||||
|
ssize_t bytes = 0;
|
||||||
|
if (getentropy(buffer, sizeof(buffer)) == 0)
|
||||||
|
{
|
||||||
|
bytes = sizeof(buffer);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
ssize_t bytes = getrandom(buffer, sizeof(buffer), 0);
|
ssize_t bytes = getrandom(buffer, sizeof(buffer), 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,10 +16,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__MACH__)
|
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -471,7 +474,7 @@ static int _tf_command_sandbox(const char* file, int argc, char* argv[])
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__MACH__)
|
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||||
prctl(PR_SET_PDEATHSIG, SIGHUP);
|
prctl(PR_SET_PDEATHSIG, SIGHUP);
|
||||||
#endif
|
#endif
|
||||||
tf_task_t* task = tf_task_create();
|
tf_task_t* task = tf_task_create();
|
||||||
@ -591,7 +594,7 @@ int main(int argc, char* argv[])
|
|||||||
_backtrace_error,
|
_backtrace_error,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||||
prctl(PR_SET_PDEATHSIG, SIGKILL);
|
prctl(PR_SET_PDEATHSIG, SIGKILL);
|
||||||
#endif
|
#endif
|
||||||
tf_mem_replace_uv_allocator();
|
tf_mem_replace_uv_allocator();
|
||||||
|
@ -207,7 +207,7 @@ tf_mem_allocation_t* tf_mem_summarize_allocations(int* out_count)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) && !defined(__APPLE__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
|
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
|
||||||
#endif
|
#endif
|
||||||
@ -306,7 +306,7 @@ static void* _tf_realloc(int64_t* total, void* ptr, size_t size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) && !defined(__APPLE__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ static void* _tf_uv_realloc(void* ptr, size_t size)
|
|||||||
return _tf_realloc(&s_uv_malloc_size, ptr, size);
|
return _tf_realloc(&s_uv_malloc_size, ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) && !defined(__APPLE__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
|
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
|
||||||
#endif
|
#endif
|
||||||
@ -372,7 +372,7 @@ static void* _tf_uv_calloc(size_t nmemb, size_t size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) && !defined(__APPLE__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
11
src/task.c
11
src/task.c
@ -25,14 +25,17 @@
|
|||||||
|
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#if !defined(__APPLE__)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#endif
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#if !defined(_countof)
|
#if !defined(_countof)
|
||||||
#define _countof(a) ((int)(sizeof((a)) / sizeof(*(a))))
|
#define _countof(a) ((int)(sizeof((a)) / sizeof(*(a))))
|
||||||
|
Loading…
Reference in New Issue
Block a user