Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support tvOS building #148

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ buildStatic iphonesimulator x86_64 -miphonesimulator-version-min=15.0
buildStatic iphonesimulator arm64 -miphonesimulator-version-min=15.0
mergeStatic iphonesimulator x86_64 arm64

buildStatic macosx x86_64 -mmacosx-version-min=12.0
buildStatic macosx arm64 -mmacosx-version-min=12.0
# keep same with flutter
buildStatic macosx x86_64 -mmacosx-version-min=10.14
buildStatic macosx arm64 -mmacosx-version-min=10.14
mergeStatic macosx x86_64 arm64

buildStatic appletvos arm64 -mappletvos-version-min=17.0
buildStatic appletvsimulator x86_64 -mappletvsimulator-version-min=17.0
buildStatic appletvsimulator arm64 -mappletvsimulator-version-min=17.0
mergeStatic appletvsimulator x86_64 arm64

INCLUDE_DIR="$XCFRAMEWORK_DIR/include"
mkdir -p $INCLUDE_DIR
cp ./src/hev-main.h $INCLUDE_DIR
Expand All @@ -59,6 +65,8 @@ xcodebuild -create-xcframework \
-library ./apple_xcframework/iphoneos-arm64/libhev-socks5-tunnel.a -headers $INCLUDE_DIR \
-library ./apple_xcframework/iphonesimulator-x86_64-arm64/libhev-socks5-tunnel.a -headers $INCLUDE_DIR \
-library ./apple_xcframework/macosx-x86_64-arm64/libhev-socks5-tunnel.a -headers $INCLUDE_DIR \
-library ./apple_xcframework/appletvos-arm64/libhev-socks5-tunnel.a -headers $INCLUDE_DIR \
-library ./apple_xcframework/appletvsimulator-x86_64-arm64/libhev-socks5-tunnel.a -headers $INCLUDE_DIR \
-output ./HevSocks5Tunnel.xcframework

rm -rf ./apple_xcframework
13 changes: 13 additions & 0 deletions src/misc/hev-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@
#include <unistd.h>
#include <sys/wait.h>

#if defined(__APPLE__)
#include <Availability.h>
#include <AvailabilityMacros.h>
#include <TargetConditionals.h>
#endif

#include "hev-logger.h"

#include "hev-exec.h"

#ifndef TARGET_OS_TV
static void
signal_handler (int signum)
{
Expand Down Expand Up @@ -44,3 +51,9 @@ hev_exec_run (const char *script_path, const char *tun_name, int wait)
LOG_E ("exec %s %s", script_path, tun_name);
exit (-1);
}
#else
void
hev_exec_run (const char *script_path, const char *tun_name, int wait)
{
}
#endif
8 changes: 8 additions & 0 deletions src/misc/hev-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
#include <sys/socket.h>
#include <sys/resource.h>

#if defined(__APPLE__)
#include <Availability.h>
#include <AvailabilityMacros.h>
#include <TargetConditionals.h>
#endif

#include "hev-logger.h"

#include "hev-utils.h"
Expand All @@ -30,9 +36,11 @@ run_as_daemon (const char *pid_file)

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#ifndef TARGET_OS_TV
if (daemon (0, 0)) {
/* ignore return value */
}
#endif
#pragma GCC diagnostic pop

fprintf (fp, "%u\n", getpid ());
Expand Down