<commit_before>all: android osx ios

.PHONY: clean
.PHONY: clean-android
.PHONY: clean-osx
.PHONY: clean-ios
.PHONY: android
.PHONY: osx
.PHONY: ios
.PHONY: check-ndk
.PHONY: cmake-osx
.PHONY: cmake-android
.PHONY: cmake-ios
.PHONY: install-android

ANDROID_BUILD_DIR = build/android
OSX_BUILD_DIR = build/osx
IOS_BUILD_DIR = build/ios

TOOLCHAIN_DIR = build/toolchains
OSX_TARGET = tangram
IOS_TARGET = tangram
OSX_XCODE_PROJ = tangram.xcodeproj
IOS_XCODE_PROJ = tangram.xcodeproj

ifndef ANDROID_ARCH
	ANDROID_ARCH = x86
endif

ANDROID_CMAKE_PARAMS = \
	-DPLATFORM_TARGET=android \
	-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_DIR}/android.toolchain.cmake \
	-DMAKE_BUILD_TOOL=$$ANDROID_NDK/prebuilt/darwin-x86_64/bin/make \
	-DANDROID_ABI=${ANDROID_ARCH} \
	-DANDROID_STL=c++_shared \
	-DANDROID_NATIVE_API_LEVEL=android-19 

IOS_CMAKE_PARAMS = \
	-DPLATFORM_TARGET=ios \
	-DIOS_PLATFORM=SIMULATOR \
	-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_DIR}/iOS.toolchain.cmake \
	-G Xcode

DARWIN_CMAKE_PARAMS = \
	-DPLATFORM_TARGET=darwin \
	-G Xcode

clean: clean-android clean-osx clean-ios

clean-android:
	ndk-build -C android/jni clean
	ant -f android/build.xml clean
	rm -rf ${ANDROID_BUILD_DIR}
	rm -rf android/libs android/obj

clean-osx:
	rm -rf ${OSX_BUILD_DIR}

clean-ios:
	rm -rf ${IOS_BUILD_DIR}

android: install-android android/libs/${ANDROID_ARCH}/libtangram.so android/build.xml
	ant -f android/build.xml debug

install-android: check-ndk cmake-android ${ANDROID_BUILD_DIR}/Makefile
	cd ${ANDROID_BUILD_DIR} && \
	${MAKE} && \
	${MAKE} install

cmake-android:
	mkdir -p ${ANDROID_BUILD_DIR} 
	cd ${ANDROID_BUILD_DIR} && \
	cmake ../.. ${ANDROID_CMAKE_PARAMS}

osx: cmake-osx ${OSX_BUILD_DIR}/${OSX_XCODE_PROJ}
	xcodebuild -target ${OSX_TARGET} -project ${OSX_BUILD_DIR}/${OSX_XCODE_PROJ}

cmake-osx: 
	mkdir -p ${OSX_BUILD_DIR} 
	cd ${OSX_BUILD_DIR} && \
	cmake ../.. ${DARWIN_CMAKE_PARAMS}

ios: cmake-ios ${IOS_BUILD_DIR}/${IOS_XCODE_PROJ}
	xcodebuild -target ${IOS_TARGET} -project ${IOS_BUILD_DIR}/${IOS_XCODE_PROJ}

cmake-ios:
ifeq ($(wildcard ${IOS_BUILD_DIR}/${IOS_XCODE_PROJ}/.*),)
	mkdir -p ${IOS_BUILD_DIR}
	cd ${IOS_BUILD_DIR} && \
	cmake ../.. ${IOS_CMAKE_PARAMS}
endif

check-ndk:
ifndef ANDROID_NDK
	$(error ANDROID_NDK is undefined)
endif<commit_msg>update makefile for unit tests<commit_after>all: android osx ios

.PHONY: clean
.PHONY: clean-android
.PHONY: clean-osx
.PHONY: clean-ios
.PHONY: android
.PHONY: osx
.PHONY: ios
.PHONY: check-ndk
.PHONY: cmake-osx
.PHONY: cmake-android
.PHONY: cmake-ios
.PHONY: install-android

ANDROID_BUILD_DIR = build/android
OSX_BUILD_DIR = build/osx
IOS_BUILD_DIR = build/ios
TEST_BUILD_DIR = build/tests

TOOLCHAIN_DIR = build/toolchains
OSX_TARGET = tangram
IOS_TARGET = tangram
OSX_XCODE_PROJ = tangram.xcodeproj
IOS_XCODE_PROJ = tangram.xcodeproj

ifndef ANDROID_ARCH
	ANDROID_ARCH = x86
endif

TEST_CMAKE_PARAMS = \
	-DTEST=1

ANDROID_CMAKE_PARAMS = \
	-DPLATFORM_TARGET=android \
	-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_DIR}/android.toolchain.cmake \
	-DMAKE_BUILD_TOOL=$$ANDROID_NDK/prebuilt/darwin-x86_64/bin/make \
	-DANDROID_ABI=${ANDROID_ARCH} \
	-DANDROID_STL=c++_shared \
	-DANDROID_NATIVE_API_LEVEL=android-19 

IOS_CMAKE_PARAMS = \
	-DPLATFORM_TARGET=ios \
	-DIOS_PLATFORM=SIMULATOR \
	-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_DIR}/iOS.toolchain.cmake \
	-G Xcode

DARWIN_CMAKE_PARAMS = \
	-DPLATFORM_TARGET=darwin \
	-G Xcode

clean: clean-android clean-osx clean-ios clean-test

clean-android:
	ndk-build -C android/jni clean
	ant -f android/build.xml clean
	rm -rf ${ANDROID_BUILD_DIR}
	rm -rf android/libs android/obj

clean-osx:
	rm -rf ${OSX_BUILD_DIR}

clean-ios:
	rm -rf ${IOS_BUILD_DIR}

clean-test:
	rm -rf ${TEST_BUILD_DIR}

android: install-android android/libs/${ANDROID_ARCH}/libtangram.so android/build.xml
	ant -f android/build.xml debug

install-android: check-ndk cmake-android ${ANDROID_BUILD_DIR}/Makefile
	cd ${ANDROID_BUILD_DIR} && \
	${MAKE} && \
	${MAKE} install

cmake-android:
	mkdir -p ${ANDROID_BUILD_DIR} 
	cd ${ANDROID_BUILD_DIR} && \
	cmake ../.. ${ANDROID_CMAKE_PARAMS}

osx: cmake-osx ${OSX_BUILD_DIR}/${OSX_XCODE_PROJ}
	xcodebuild -target ${OSX_TARGET} -project ${OSX_BUILD_DIR}/${OSX_XCODE_PROJ}

cmake-osx: 
	mkdir -p ${OSX_BUILD_DIR} 
	cd ${OSX_BUILD_DIR} && \
	cmake ../.. ${DARWIN_CMAKE_PARAMS}

ios: cmake-ios ${IOS_BUILD_DIR}/${IOS_XCODE_PROJ}
	xcodebuild -target ${IOS_TARGET} -project ${IOS_BUILD_DIR}/${IOS_XCODE_PROJ}

cmake-ios:
ifeq ($(wildcard ${IOS_BUILD_DIR}/${IOS_XCODE_PROJ}/.*),)
	mkdir -p ${IOS_BUILD_DIR}
	cd ${IOS_BUILD_DIR} && \
	cmake ../.. ${IOS_CMAKE_PARAMS}
endif

test:
	mkdir -p ${TEST_BUILD_DIR} 
	cd ${TEST_BUILD_DIR} && \
	cmake ../.. ${TEST_CMAKE_PARAMS} && \
	${MAKE}

check-ndk:
ifndef ANDROID_NDK
	$(error ANDROID_NDK is undefined)
endif
{'fraction_non_alphanumeric': 0.13565728685426293, 'fraction_numerical': 0.0035699286014279717, 'mean_word_length': 4.690561529271207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7399261', 'n_tokens_mistral': 2205, 'n_tokens_neox': 2130, 'n_words': 347}