<commit_before>.SUFFIXES: .haml .html
.haml.html:
	haml -f html5 -t ugly $< $@

.SUFFIXES: .sass .css
.sass.css:
	compass compile $< -c $(CSS_DIR)/config.rb

.SUFFIXES: .sass .min.css
.sass.min.css:
	compass compile --environment production $< -c $(CSS_DIR)/config.rb
	mv $*.css $@

.SUFFIXES: .yaml .json
.yaml.json:
	cat $< |python -c "import json,yaml,sys; print(json.dumps(yaml.load(sys.stdin.read()), indent=2))" > $@


CORDOVA_DIR=cordova
CORDOVA_IOS=$(CORDOVA_DIR)/ios
all: chrome-apps $(CORDOVA_IOS)


ENDPOINTS_LIB=submodule/dart_timecard_dev_api_client
RESOURCE_DIR_PATH=web lib
RESOURCE_DIR=$(foreach dir,$(shell find $(RESOURCE_DIR_PATH) -type d),$(dir))
HAML=$(foreach dir,$(RESOURCE_DIR),$(wildcard $(dir)/*.haml))
HTML=$(HAML:.haml=.html)
SASS=$(foreach dir,$(RESOURCE_DIR),$(wildcard $(dir)/*.sass))
CSS=$(SASS:.sass=.css)
MINCSS=$(SASS:.sass=.min.css)
YAML=$(shell find web -type f -name "[^.]*.yaml")
JSON=$(YAML:.yaml=.json)
RESOURCE=$(HTML) $(CSS) $(MINCSS) $(JSON)
VERSION_HTML=lib/component/version
pubserve: $(ENDPOINTS_LIB) $(RESOURCE) $(VERSION_HTML)
	-patch -p1 --forward --reverse -i pubbuild.patch
	pub serve --port 8080 --no-dart2js --force-poll

$(ENDPOINTS_LIB):
	cd submodule/discovery_api_dart_client_generator; pub install
	submodule/discovery_api_dart_client_generator/bin/generate.dart --no-prefix -i timecard-dev.discovery -o submodule

VERSION=$(shell git describe --always --dirty=+)
$(VERSION_HTML):
	@if [ "$(VERSION)" != "$(strip $(shell [ -f $@ ] && cat $@))" ] ; then\
		echo 'echo $(VERSION) > $@' ;\
		echo $(VERSION) > $@ ;\
	fi;


chrome-apps: $(VERSION_HTML) $(DART_JS) $(CHROME_APPS_DIR) $(RELEASE_RESOURCE_DST)

BUILD_DIR=build
DART_JS=$(BUILD_DIR)/web/main.dart.precompiled.js
DART=$(foreach dir,$(RESOURCE_DIR),$(wildcard $(dir)/*.dart))
$(DART_JS): $(DART)
	-patch -p1 --forward --reverse -i pubbuild.patch
	pub build --mode=debug

CHROME_APPS_DIR=$(BUILD_DIR)/chrome-apps
$(CHROME_APPS_DIR):
	mkdir -p $@

RELEASE_RESOURCE_DST=$(foreach path,$(RELEASE_RESOURCE_SRC),$(subst $(RELEASE_RESOURCE_SRC_DIR),$(CHROME_APPS_DIR),$(path)))
RELEASE_RESOURCE_SRC=$(addprefix $(RELEASE_RESOURCE_SRC_DIR)/,$(RELEASE_RESOURCE))
RELEASE_RESOURCE_SRC_DIR = $(BUILD_DIR)/web
RELEASE_RESOURCE =\
	index.html\
	js/browser_dart_csp_safe.js\
	js/main.js\
	main.dart.precompiled.js\
	main.dart\
	manifest.json\
	manifest.mobile.json\
	packages/angular_ui/modal/window.html\
	packages/browser/dart.js\
	packages/chrome/bootstrap.js\
	packages/shadow_dom/shadow_dom.min.js\
	packages/timecard_client/component/edit_user.html\
	packages/timecard_client/component/feedback_form.html\
	packages/timecard_client/component/feedback_link.html\
	packages/timecard_client/component/footer.html\
	packages/timecard_client/component/nav.html\
	packages/timecard_client/component/remember_me.html\
	packages/timecard_client/component/version\
	view/leave.html\
	view/logout.html\
	view/settings.html\
	view/signup.html\
	view/top.html\

$(RELEASE_RESOURCE_DST): $(RELEASE_RESOURCE_SRC)
	@if [ ! -d $(dir $@) ]; then\
		mkdir -p $(dir $@);\
	fi;
	cp $(subst $(CHROME_APPS_DIR),$(RELEASE_RESOURCE_SRC_DIR),$@) $@


ios-sim: $(CORDOVA_IOS)
	cd $<; cca emulate $@

BUILD_RESOURCE=$(addprefix $(BUILD_DIR)/,$(RESOURCE_FOR_BUILD))
RESOURCE_FOR_BUILD=$(foreach suffix,$(RESOURCE_SUFFIX_FOR_BUILD),$(foreach dir,$(RESOURCE_DIR_FOR_BUILD),$(wildcard $(dir)/*.$(suffix))))
RESOURCE_SUFFIX_FOR_BUILD=html css json js
RESOURCE_DIR_FOR_BUILD=web web/js web/view web/packages/timecard_client/component web/packages/timecard_client/routing web/packages/timecard_client/service
$(CORDOVA_IOS): $(ENDPOINTS_LIB) $(RESOURCE) $(VERSION_HTML) $(YAML) $(DART_JS) $(BUILD_RESOURCE) $(RELEASE_RESOURCE_DST) $(CHROME_APPS_DIR) $(RELEASE_RESOURCE_DIR) $(CORDOVA_DIR)
	if [ -d $@ ]; then\
		cd $@; cca prepare;\
	else\
		cca create $@ --link-to=$(CHROME_APPS_DIR)/manifest.json;\
	fi;

$(CORDOVA_DIR):
	mkdir $@

$(BUILD_DIR)/%: %
	@mkdir -p $(dir $@)
	cp $< $@

RELEASE_RESOURCE_DIR=$(addprefix $(CHROME_APPS_DIR)/,bootstrap-3.1.1)
$(RELEASE_RESOURCE_DIR): $(addprefix $(RELEASE_RESOURCE_SRC_DIR)/,bootstrap-3.1.1)
	cp -r $< $@


xcode: $(CORDOVA_IOS)<commit_msg>passed `make chrome-apps`<commit_after>.SUFFIXES: .haml .html
.haml.html:
	haml -f html5 -t ugly $< $@

.SUFFIXES: .sass .css
.sass.css:
	compass compile $< -c $(CSS_DIR)/config.rb

.SUFFIXES: .sass .min.css
.sass.min.css:
	compass compile --environment production $< -c $(CSS_DIR)/config.rb
	mv $*.css $@

.SUFFIXES: .yaml .json
.yaml.json:
	cat $< |python -c "import json,yaml,sys; print(json.dumps(yaml.load(sys.stdin.read()), indent=2))" > $@


CORDOVA_DIR=cordova
CORDOVA_IOS=$(CORDOVA_DIR)/ios
all: chrome-apps $(CORDOVA_IOS)


ENDPOINTS_LIB=submodule/dart_timecard_dev_api_client
RESOURCE_DIR_PATH=web lib
RESOURCE_DIR=$(foreach dir,$(shell find $(RESOURCE_DIR_PATH) -type d),$(dir))
HAML=$(foreach dir,$(RESOURCE_DIR),$(wildcard $(dir)/*.haml))
HTML=$(HAML:.haml=.html)
SASS=$(foreach dir,$(RESOURCE_DIR),$(wildcard $(dir)/*.sass))
CSS=$(SASS:.sass=.css)
MINCSS=$(SASS:.sass=.min.css)
YAML=$(shell find web -type f -name "[^.]*.yaml")
JSON=$(YAML:.yaml=.json)
RESOURCE=$(HTML) $(CSS) $(MINCSS) $(JSON)
VERSION_HTML=lib/component/version
pubserve: $(ENDPOINTS_LIB) $(RESOURCE) $(VERSION_HTML)
	-patch -p1 --forward --reverse -i pubbuild.patch
	pub serve --port 8080 --no-dart2js --force-poll

$(ENDPOINTS_LIB):
	cd submodule/discovery_api_dart_client_generator; pub install
	submodule/discovery_api_dart_client_generator/bin/generate.dart --no-prefix -i timecard-dev.discovery -o submodule

VERSION=$(shell git describe --always --dirty=+)
$(VERSION_HTML):
	@if [ "$(VERSION)" != "$(strip $(shell [ -f $@ ] && cat $@))" ] ; then\
		echo 'echo $(VERSION) > $@' ;\
		echo $(VERSION) > $@ ;\
	fi;


RELEASE_RESOURCE=\
	index.html\
	js/browser_dart_csp_safe.js\
	js/main.js\
	main.dart.precompiled.js\
	main.dart\
	manifest.json\
	manifest.mobile.json\
	packages/angular_ui/modal/window.html\
	packages/browser/dart.js\
	packages/chrome/bootstrap.js\
	packages/shadow_dom/shadow_dom.min.js\
	packages/timecard_client/component/edit_user.html\
	packages/timecard_client/component/feedback_form.html\
	packages/timecard_client/component/feedback_link.html\
	packages/timecard_client/component/footer.html\
	packages/timecard_client/component/nav.html\
	packages/timecard_client/component/remember_me.html\
	packages/timecard_client/component/version\
	view/leave.html\
	view/logout.html\
	view/settings.html\
	view/signup.html\
	view/top.html\

BUILD_DIR=build
DART_JS=$(BUILD_DIR)/web/main.dart.precompiled.js
CHROME_APPS_DIR=$(BUILD_DIR)/chrome-apps
RELEASE_RESOURCE_DIR=$(addprefix $(CHROME_APPS_DIR)/,bootstrap-3.1.1)
RELEASE_RESOURCE_SRC_DIR=$(BUILD_DIR)/web
RELEASE_RESOURCE_SRC=$(addprefix $(RELEASE_RESOURCE_SRC_DIR)/,$(RELEASE_RESOURCE))
RELEASE_RESOURCE_DST=$(foreach path,$(RELEASE_RESOURCE_SRC),$(subst $(RELEASE_RESOURCE_SRC_DIR),$(CHROME_APPS_DIR),$(path)))
chrome-apps: $(ENDPOINTS_LIB) $(RESOURCE) $(VERSION_HTML) $(DART_JS) $(CHROME_APPS_DIR) $(RELEASE_RESOURCE_DIR) $(RELEASE_RESOURCE_DST)

DART=$(foreach dir,$(RESOURCE_DIR),$(wildcard $(dir)/*.dart))
$(DART_JS): $(DART)
	-patch -p1 --forward --reverse -i pubbuild.patch
	pub build --mode=debug

$(CHROME_APPS_DIR):
	mkdir -p $@

$(RELEASE_RESOURCE_DIR): $(addprefix $(RELEASE_RESOURCE_SRC_DIR)/,bootstrap-3.1.1)
	cp -r $< $@

$(RELEASE_RESOURCE_DST): $(RELEASE_RESOURCE_SRC)
	@if [ ! -d $(dir $@) ]; then\
		mkdir -p $(dir $@);\
	fi;
	cp $(subst $(CHROME_APPS_DIR),$(RELEASE_RESOURCE_SRC_DIR),$@) $@


ios-sim: $(CORDOVA_IOS)
	cd $<; cca emulate $@

BUILD_RESOURCE=$(addprefix $(BUILD_DIR)/,$(RESOURCE_FOR_BUILD))
RESOURCE_FOR_BUILD=$(foreach suffix,$(RESOURCE_SUFFIX_FOR_BUILD),$(foreach dir,$(RESOURCE_DIR_FOR_BUILD),$(wildcard $(dir)/*.$(suffix))))
RESOURCE_SUFFIX_FOR_BUILD=html css json js
RESOURCE_DIR_FOR_BUILD=web web/js web/view web/packages/timecard_client/component web/packages/timecard_client/routing web/packages/timecard_client/service
$(CORDOVA_IOS): $(ENDPOINTS_LIB) $(RESOURCE) $(VERSION_HTML) $(YAML) $(DART_JS) $(BUILD_RESOURCE) $(RELEASE_RESOURCE_DST) $(CHROME_APPS_DIR) $(RELEASE_RESOURCE_DIR) $(CORDOVA_DIR)
	if [ -d $@ ]; then\
		cd $@; cca prepare;\
	else\
		cca create $@ --link-to=$(CHROME_APPS_DIR)/manifest.json;\
	fi;

$(CORDOVA_DIR):
	mkdir $@

$(BUILD_DIR)/%: %
	@mkdir -p $(dir $@)
	cp $< $@


xcode: $(CORDOVA_IOS)
{'fraction_non_alphanumeric': 0.18071138696586297, 'fraction_numerical': 0.0035808068751492002, 'mean_word_length': 5.7032, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1574352', 'n_tokens_mistral': 3460, 'n_tokens_neox': 3250, 'n_words': 503}