<commit_before>
COFFEE    := $(shell which coffee 2>/dev/null)
JSDUCKIFY := $(shell which jsduckify 2>/dev/null)
UGLIFYJS  := $(shell which uglifyjs 2>/dev/null)

Q ?= @
TARGET = app.js lib.js
RELEASE = $(TARGET:.js=.min.js)
RUNNER = node
DOCDIR = docs
SOURCES = \
	async.coffee \
	base.coffee \
	port.coffee \
		serialport.coffee \
	memhttprequest.coffee \
	board.coffee \
		peridotboard.coffee \
	editor.coffee \
		rubyeditor.coffee \
		yamleditor.coffee \
	fileutil.coffee \
	builder.coffee \
		mrubybuilder.coffee \
		mrbviewer.coffee \
	sketch.coffee \
	filesystem.coffee \
		localfilesystem.coffee \
		googledrivefilesystem.coffee \
	about.coffee \
#	marshal.coffee \
#	sandbox.coffee
#		de0board.coffee \
#		de0nanoboard.coffee \
#		wakayamarbboard.coffee \

LIB_SOURCES = \
	mruby/build/emscripten/bin/mrbc.js

.PHONY: all
all: $(TARGET)

.PHONY: run
run: all
	@echo "[Running]"
	$(Q)$(RUNNER) $(RELEASE) $(LIB)

.PHONY: release
release: $(RELEASE)

.PHONY: clean
clean:
	@echo "[Cleaning]"
	$(Q)rm -f $(TARGET) $(RELEASE)

%.min.js: %.js $(firstword $(UGLIFYJS) uglifyjs-is-missing)
	@echo "[Minimizing $<]"
	$(Q)$(UGLIFYJS) -o $@ $< || (rm -f $@; false)

%.js: %.coffee $(firstword $(COFFEE) coffee-is-missing) $(MAKEFILE_LIST)
	@echo "[Compiling CoffeeScript files]"
	$(Q)coffee -c $< > $@ || (rm -f $@; false)

app.coffee: $(SOURCES) $(MAKEFILE_LIST)
	$(Q)cat /dev/null $(filter %.coffee,$^) > $@ || (rm -f $@; false)

lib.js: $(LIB_SOURCES) $(MAKEFILE_LIST)
	@echo "[Importing external libraries]"
	$(Q)echo "var Lib;Lib=(function(){function Lib(){}" > $@.tmp
	$(Q)true $(foreach f,$(filter %.js,$^), \
		&& echo "\
		Lib.$(notdir $(basename $(f)))=function(Module){\
		Module['preInit'] = Module['preInit'] || [];\
		Module['preInit'].unshift(function(){\
		  Module['exports'] = {FS: FS, MEMFS: MEMFS};\
		});" >> $@.tmp \
		&& cat $(f) >> $@.tmp \
		&& echo "};" >> $@.tmp)
	$(Q)echo "return Lib;})();" >> $@.tmp
	$(Q)mv $@.tmp $@
#		&& echo "Module.exports={};" >> $@.tmp \
#		&& echo "Module.exports.fs=FS;" >> $@.tmp \

.PHONY: doc
doc: $(TARGET) $(firstword $(JSDUCKIFY) jsduckify-is-missing)
	@echo "[Generating document]"
	$(Q)$(JSDUCKIFY)

.PHONY: uglifyjs-is-missing
uglifyjs-is-missing:
	@echo "**** UglifyJS is required to build this project."
	@echo "**** Please visit https://github.com/mishoo/UglifyJS"
	@false

.PHONY: coffee-is-missing
coffee-is-missing:
	@echo "**** CoffeeScript is required to build this project."
	@echo "**** Please visit http://coffeescript.org/"
	@false

.PHONY: jsduckify-is-missing
jsduckify-is-missing:
	@echo "**** jsduckify is required to generate document for this project."
	@echo "**** Please visit https://github.com/lmaccherone/jsduckify"
	@false

.PHONY: dist
dist: $(TARGET) background.js manifest.json \
	ace-builds/src-noconflict/ace.js ace-builds/src-noconflict/mode-ruby.js \
	bootbox/bootbox.js \
	bootstrap-notify/dist/bootstrap-notify.min.js \
	bootstrap/dist/css/bootstrap.min.css bootstrap/dist/js/bootstrap.min.js \
	bootstrap/dist/fonts/glyphicons-halflings-regular.woff \
	js-yaml/dist/js-yaml.min.js \
	canarium.js \
	jquery-2.1.1.min.js \
	jquery.spin.js \
	spin.min.js \
	$(wildcard images/rubic*.png) \
	images/mruby_logo_red_cropped.png \
	images/peridotcraft_logo_1.png \
	images/Emscripten_logo_full_cropped.png \
	window.css window.html
	@echo "[Packing distribution files]"
	$(Q)mkdir -p ../dist
	$(Q)cp --parent $^ ../dist
	$(Q)rm -f ../rubic.zip
	$(Q)cd .. && zip -r rubic.zip dist
<commit_msg>Arrange distribution files for v0.1 release<commit_after>
COFFEE    := $(shell which coffee 2>/dev/null)
JSDUCKIFY := $(shell which jsduckify 2>/dev/null)
UGLIFYJS  := $(shell which uglifyjs 2>/dev/null)

Q ?= @
TARGET = app.js lib.js
RELEASE = $(TARGET:.js=.min.js)
RUNNER = node
DOCDIR = docs
SOURCES = \
	async.coffee \
	base.coffee \
	port.coffee \
		serialport.coffee \
	memhttprequest.coffee \
	board.coffee \
		peridotboard.coffee \
	editor.coffee \
		rubyeditor.coffee \
		yamleditor.coffee \
	fileutil.coffee \
	builder.coffee \
		mrubybuilder.coffee \
		mrbviewer.coffee \
	sketch.coffee \
	filesystem.coffee \
		localfilesystem.coffee \
		googledrivefilesystem.coffee \
	about.coffee \
#	marshal.coffee \
#	sandbox.coffee
#		de0board.coffee \
#		de0nanoboard.coffee \
#		wakayamarbboard.coffee \

LIB_SOURCES = \
	mruby/build/emscripten/bin/mrbc.js

.PHONY: all
all: $(TARGET)

.PHONY: run
run: all
	@echo "[Running]"
	$(Q)$(RUNNER) $(RELEASE) $(LIB)

.PHONY: release
release: $(RELEASE)

.PHONY: clean
clean:
	@echo "[Cleaning]"
	$(Q)rm -f $(TARGET) $(RELEASE)

%.min.js: %.js $(firstword $(UGLIFYJS) uglifyjs-is-missing)
	@echo "[Minimizing $<]"
	$(Q)$(UGLIFYJS) -o $@ $< || (rm -f $@; false)

%.js: %.coffee $(firstword $(COFFEE) coffee-is-missing) $(MAKEFILE_LIST)
	@echo "[Compiling CoffeeScript files]"
	$(Q)coffee -c $< > $@ || (rm -f $@; false)

app.coffee: $(SOURCES) $(MAKEFILE_LIST)
	$(Q)cat /dev/null $(filter %.coffee,$^) > $@ || (rm -f $@; false)

lib.js: $(LIB_SOURCES) $(MAKEFILE_LIST)
	@echo "[Importing external libraries]"
	$(Q)echo "var Lib;Lib=(function(){function Lib(){}" > $@.tmp
	$(Q)true $(foreach f,$(filter %.js,$^), \
		&& echo "\
		Lib.$(notdir $(basename $(f)))=function(Module){\
		Module['preInit'] = Module['preInit'] || [];\
		Module['preInit'].unshift(function(){\
		  Module['exports'] = {FS: FS, MEMFS: MEMFS};\
		});" >> $@.tmp \
		&& cat $(f) >> $@.tmp \
		&& echo "};" >> $@.tmp)
	$(Q)echo "return Lib;})();" >> $@.tmp
	$(Q)mv $@.tmp $@
#		&& echo "Module.exports={};" >> $@.tmp \
#		&& echo "Module.exports.fs=FS;" >> $@.tmp \

.PHONY: doc
doc: $(TARGET) $(firstword $(JSDUCKIFY) jsduckify-is-missing)
	@echo "[Generating document]"
	$(Q)$(JSDUCKIFY)

.PHONY: uglifyjs-is-missing
uglifyjs-is-missing:
	@echo "**** UglifyJS is required to build this project."
	@echo "**** Please visit https://github.com/mishoo/UglifyJS"
	@false

.PHONY: coffee-is-missing
coffee-is-missing:
	@echo "**** CoffeeScript is required to build this project."
	@echo "**** Please visit http://coffeescript.org/"
	@false

.PHONY: jsduckify-is-missing
jsduckify-is-missing:
	@echo "**** jsduckify is required to generate document for this project."
	@echo "**** Please visit https://github.com/lmaccherone/jsduckify"
	@false

DIST_DIR = ../dist

# Main files and mruby
DIST_FILES = manifest.json background.js window.html window.css $(TARGET)
# Embedded images
DIST_FILES += $(wildcard images/rubic_cube2x2_*.png) \
	images/mruby_logo_red_cropped.png \
	images/peridotcraft_logo_1.png \
	images/Emscripten_logo_full_cropped.png
# canarium
DIST_FILES += canarium.js
# jQuery
DIST_FILES += jquery-2.1.1.min.js
# Bootstrap (css, js and fonts)
DIST_FILES += $(addprefix bootstrap/dist/,css/bootstrap.min.css js/bootstrap.min.js)
DIST_FILES += $(addprefix bootstrap/dist/fonts/glyphicons-halflings-regular.,woff2)
# Ace (body and mode files)
DIST_FILES += $(addprefix ace-builds/src-noconflict/,ace.js mode-ruby.js mode-yaml.js)
# Bootstrap Notify
DIST_FILES += bootstrap-notify/dist/bootstrap-notify.min.js
# Bootbox.js
DIST_FILES += bootbox/bootbox.js
# js-yaml
DIST_FILES += js-yaml/dist/js-yaml.min.js
# spin.js
DIST_FILES += spin.min.js jquery.spin.js

DIST_INFO = $(DIST_DIR)/dist.txt

.PHONY: dist
dist: $(DIST_FILES)
	@echo "[Packing distribution files]"
	$(Q)test -z "$$(git status -uno --porcelain)" || \
		(echo "**** You must commit all files before distribution."; \
		 git status -uno; false)
	$(Q)mkdir -p $(DIST_DIR)
	$(Q)rm -rf $(DIST_DIR)/*
	$(Q)echo -n " " > $(DIST_INFO)
	$(Q)git log -1 --pretty=oneline >> $(DIST_INFO)
	$(Q)git submodule >> $(DIST_INFO)
	$(Q)cp --parent $^ $(DIST_DIR)
	$(Q)rm -f $(DIST_DIR)/../rubic.zip
	$(Q)cd $(DIST_DIR)/.. && zip -r rubic.zip $(notdir $(DIST_DIR))

{'fraction_non_alphanumeric': 0.1971739694062743, 'fraction_numerical': 0.00311122634171636, 'mean_word_length': 3.9140127388535033, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 44, 'https://': 4, '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': '2167414', 'n_tokens_mistral': 3338, 'n_tokens_neox': 3053, 'n_words': 614}