client.cc iOS build

This commit is contained in:
Reuben Morais 2020-06-09 20:41:36 +02:00
parent c85f95f781
commit 4ca0f94d78
2 changed files with 27 additions and 5 deletions

View File

@ -12,7 +12,11 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#if defined(__ANDROID__) || defined(_MSC_VER) #ifdef __APPLE__
#include <TargetConditionals.h>
#endif
#if defined(__ANDROID__) || defined(_MSC_VER) || TARGET_OS_IPHONE
#define NO_SOX #define NO_SOX
#endif #endif
@ -244,7 +248,7 @@ GetAudioBuffer(const char* path, int desired_sample_rate)
sox_false // Reverse endianness sox_false // Reverse endianness
}; };
#ifdef __APPLE__ #if TARGET_OS_OSX
// It would be preferable to use sox_open_memstream_write here, but OS-X // It would be preferable to use sox_open_memstream_write here, but OS-X
// doesn't support POSIX 2008, which it requires. See Issue #461. // doesn't support POSIX 2008, which it requires. See Issue #461.
// Instead, we write to a temporary file. // Instead, we write to a temporary file.
@ -348,7 +352,7 @@ GetAudioBuffer(const char* path, int desired_sample_rate)
fclose(wave); fclose(wave);
#endif // NO_SOX #endif // NO_SOX
#ifdef __APPLE__ #if TARGET_OS_OSX
res.buffer_size = (size_t)(output->olength * 2); res.buffer_size = (size_t)(output->olength * 2);
res.buffer = (char*)malloc(sizeof(char) * res.buffer_size); res.buffer = (char*)malloc(sizeof(char) * res.buffer_size);
FILE* output_file = fopen(output_name, "rb"); FILE* output_file = fopen(output_name, "rb");

View File

@ -101,6 +101,20 @@ NODE_PLATFORM_TARGET := --target_arch=arm64 --target_platform=linux
TOOLCHAIN_LDD_OPTS := --root $(RASPBIAN)/ TOOLCHAIN_LDD_OPTS := --root $(RASPBIAN)/
endif # ($(TARGET),rpi3-armv8) endif # ($(TARGET),rpi3-armv8)
ifeq ($(TARGET),ios-simulator)
CFLAGS := -isysroot $(shell xcrun -sdk iphonesimulator13.5 -show-sdk-path)
SOX_CFLAGS :=
SOX_LDFLAGS :=
LDFLAGS :=
endif
ifeq ($(TARGET),ios-arm64)
CFLAGS := -target arm64-apple-ios -isysroot $(shell xcrun -sdk iphoneos13.5 -show-sdk-path)
SOX_CFLAGS :=
SOX_LDFLAGS :=
LDFLAGS :=
endif
# -Wl,--no-as-needed is required to force linker not to evict libs it thinks we # -Wl,--no-as-needed is required to force linker not to evict libs it thinks we
# dont need ; will fail the build on OSX because that option does not exists # dont need ; will fail the build on OSX because that option does not exists
ifeq ($(OS),Linux) ifeq ($(OS),Linux)
@ -108,9 +122,13 @@ LDFLAGS_NEEDED := -Wl,--no-as-needed
LDFLAGS_RPATH := -Wl,-rpath,\$$ORIGIN LDFLAGS_RPATH := -Wl,-rpath,\$$ORIGIN
endif endif
ifeq ($(OS),Darwin) ifeq ($(OS),Darwin)
CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.10 CXXFLAGS += -stdlib=libc++
LDFLAGS_NEEDED := -stdlib=libc++ -mmacosx-version-min=10.10 LDFLAGS_NEEDED := -stdlib=libc++
LDFLAGS_RPATH := -Wl,-rpath,@executable_path LDFLAGS_RPATH := -Wl,-rpath,@executable_path
ifeq ($(TARGET),host)
CXXFLAGS += -mmacosx-version-min=10.10
LDFLAGS_NEEDED += -mmacosx-version-min=10.10
endif
endif endif
CFLAGS += $(EXTRA_CFLAGS) CFLAGS += $(EXTRA_CFLAGS)