Skip to content

Commit

Permalink
support tvOS building (#148)
Browse files Browse the repository at this point in the history
Co-authored-by: yiguo <[email protected]>
  • Loading branch information
yiguous and yiguo authored Jul 31, 2024
1 parent a96800f commit d2cf57b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
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

0 comments on commit d2cf57b

Please sign in to comment.