diff --git a/native_client/client.cc b/native_client/client.cc index 1b335955..46a16115 100644 --- a/native_client/client.cc +++ b/native_client/client.cc @@ -12,7 +12,11 @@ #include #include -#if defined(__ANDROID__) || defined(_MSC_VER) +#ifdef __APPLE__ +#include +#endif + +#if defined(__ANDROID__) || defined(_MSC_VER) || TARGET_OS_IPHONE #define NO_SOX #endif @@ -244,7 +248,7 @@ GetAudioBuffer(const char* path, int desired_sample_rate) sox_false // Reverse endianness }; -#ifdef __APPLE__ +#if TARGET_OS_OSX // 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. // Instead, we write to a temporary file. @@ -348,7 +352,7 @@ GetAudioBuffer(const char* path, int desired_sample_rate) fclose(wave); #endif // NO_SOX -#ifdef __APPLE__ +#if TARGET_OS_OSX res.buffer_size = (size_t)(output->olength * 2); res.buffer = (char*)malloc(sizeof(char) * res.buffer_size); FILE* output_file = fopen(output_name, "rb"); diff --git a/native_client/definitions.mk b/native_client/definitions.mk index 2f6afbf4..0c8ab656 100644 --- a/native_client/definitions.mk +++ b/native_client/definitions.mk @@ -101,6 +101,20 @@ NODE_PLATFORM_TARGET := --target_arch=arm64 --target_platform=linux TOOLCHAIN_LDD_OPTS := --root $(RASPBIAN)/ 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 # dont need ; will fail the build on OSX because that option does not exists ifeq ($(OS),Linux) @@ -108,9 +122,13 @@ LDFLAGS_NEEDED := -Wl,--no-as-needed LDFLAGS_RPATH := -Wl,-rpath,\$$ORIGIN endif ifeq ($(OS),Darwin) -CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.10 -LDFLAGS_NEEDED := -stdlib=libc++ -mmacosx-version-min=10.10 +CXXFLAGS += -stdlib=libc++ +LDFLAGS_NEEDED := -stdlib=libc++ LDFLAGS_RPATH := -Wl,-rpath,@executable_path +ifeq ($(TARGET),host) +CXXFLAGS += -mmacosx-version-min=10.10 +LDFLAGS_NEEDED += -mmacosx-version-min=10.10 +endif endif CFLAGS += $(EXTRA_CFLAGS)