TARGET := iphone:clang:latest:5.0
# INSTALL_TARGET_PROCESSES = YouTube
ARCHS := armv7 arm64

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = TubeReplacerGoogle

GOOGLE_APP = 1

GOOGLE_APP_FILES = $(THEOS_PROJECT_DIR)/googleapp
COMMON = $(THEOS_PROJECT_DIR)/common
LIB_DIR = $(THEOS_PROJECT_DIR)/lib
COMMON_GOOGLE = $(THEOS_PROJECT_DIR)/common-google

TubeReplacerGoogle_FILES = polyfill.x \
	keychainfallback.x \
	v13fixes.x \
	apiaryauth.x \
	signin.x \
	signin12.x \
	channelheader.x \
	signin11.x \
	deviceauth.x \
	frontfeed.x \
	parsing.x \
	categories.x \
	getvideo.x \
	handlevideo.x \
	channels.x \
	channelfeed.x \
	search.x \
	feeds.x \
	myprofile.x \
	subscriptions.x \
	homefeed.x \
	suggestedvideos.x \
	comments.x \
	accountfeeds.x \
	playlist.x \
	likes.x \
	general.x \
	clientconfig.x \
	playerservice.x \
	captions.x \
	plusme.x \
	innertube.x \
	settings.x \
	subtitles.x \
	crashreporter.x \
	infooverflowfix.x \
	videostats.x \
	migration.x \
	$(shell find $(COMMON)/challengesolver -type f -name '*.m') \
	$(shell find $(COMMON)/SABR -type f -name '*.m') \
	Translators/TRJSONUtils.m \
	Translators/TRJSONTranslator.m \
	Translators/TRContiunation.m \
	Translators/Delegates/TRVideoTranslator.m \
	Translators/Delegates/TRChannelTranslator.m \
	Translators/Delegates/TRFeedTranslator.m \
	Translators/Delegates/TRCommentTranslator.m \
	Translators/Delegates/TRSubscriptionTranslator.m \
	Translators/Delegates/TRPlaylistTranslator.m \
	Translators/TRRequestBuilder.m \
	$(LIB_DIR)/protobuf/GPBProtocolBuffers.m \
	$(shell find $(COMMON)/SABR/proto/generated -type f -name '*.m') \
	$(shell find $(LIB_DIR)/cocoahttpserver -type f -name '*.m') \
	$(COMMON)/Protobuf.m $(COMMON)/YoutubeClientType.m general.m ../base64/NSData+Base64.m ../base64/NSString+Base64.m
	
TubeReplacerGoogle_CFLAGS = -fno-objc-arc -ITranslators -DGOOGLE_APP=1
# TubeReplacerGoogle_LDFLAGS = ../lib/libtree-sitter.a
# TubeReplacerGoogle_LDFLAGS = ../lib/libposixshim.a
TubeReplacerGoogle_OBJCFLAGS += -I$(LIB_DIR)/protobuf
TubeReplacerGoogle_OBJCFLAGS += -I$(THEOS_PROJECT_DIR)/common/SABR/proto/generated

before-all::
	rm signinpolyfil.h || true
	xxd -i signinpolyfil.js > signinpolyfil.h

ifeq (, $(shell which xxd))
$(error "You are missing `xxd` from your system, which is required to build.")
endif

include $(THEOS_MAKE_PATH)/tweak.mk
