<commit_before># Force the use of bash for shell statements. If we don't do this, many Linux
# variants will use sh.
SHELL := /bin/bash

# Will appear as directories under build/
BUILD_TARGETS = release benchmark dev

# Can be overridden on the command line. This is the name of the tar.gz file
# produced when you run `make dist'.
DIST_NAME = $(shell echo "Doppio_`date +'%y-%m-%d'`.tar.gz")

# DEPENDENCIES
DOPPIO_DIR    := $(CURDIR)
BOOTCLASSPATH := $(DOPPIO_DIR)/vendor/classes
COFFEEC  := $(shell npm bin)/coffee
UGLIFYJS := $(shell npm bin)/uglifyjs
DOCCO    := $(shell npm bin)/docco
JAZZLIB  := $(BOOTCLASSPATH)/java/util/zip/DeflaterEngine.class
JRE      := $(BOOTCLASSPATH)/java/lang/Object.class
SED      := $(shell if command -v gsed >/dev/null; then echo "gsed"; else echo "sed"; fi;)

# JAVA
SOURCES := $(wildcard classes/test/*.java)
DISASMS := $(SOURCES:.java=.disasm)
RUNOUTS := $(SOURCES:.java=.runout)
CLASSES := $(SOURCES:.java=.class)
# note: TESTS files never get made, but we use them for make rules
TESTS   := $(SOURCES:.java=.test)

DEMO_SRCS    := $(wildcard classes/demo/*.java)
DEMO_CLASSES := $(DEMO_SRCS:.java=.class)
UTIL_SRCS    := $(wildcard classes/util/*.java)
UTIL_CLASSES := $(UTIL_SRCS:.java=.class)
# native stubs for our own implementations
LIB_SRCS     := $(wildcard classes/awt/*.java) $(wildcard classes/doppio/*.java)
LIB_CLASSES  := $(LIB_SRCS:.java=.class)

# HTML
BROWSER_TEMPLATES := $(wildcard browser/[^_]*.mustache)
BROWSER_HTML      := $(BROWSER_TEMPLATES:.mustache=.html)

# SCRIPTS
# the order here is important: must match the order of includes
# in the browser frontend html.
COMMON_BROWSER_SRCS = vendor/_.js \
	vendor/gLong.js \
	browser/util.coffee \
	browser/node.coffee \
	src/logging.coffee \
	src/exceptions.coffee \
	src/util.coffee \
	src/java_object.coffee \
	src/opcodes.coffee \
	src/attributes.coffee \
	src/ConstantPool.coffee \
	src/disassembler.coffee \
	src/ClassData.coffee \
	src/natives.coffee \
	src/methods.coffee \
	src/runtime.coffee \
	src/ClassLoader.coffee \
	src/jvm.coffee \
	src/testing.coffee \
	browser/untar.coffee
library_BROWSER_SRCS := $(COMMON_BROWSER_SRCS)
# Release uses the actual jQuery console.
release_BROWSER_SRCS := $(COMMON_BROWSER_SRCS) \
	vendor/jquery.console.js \
	browser/frontend.coffee
dev_BROWSER_SRCS := $(release_BROWSER_SRCS)
# Benchmark uses the mock jQuery console.
benchmark_BROWSER_SRCS := $(COMMON_BROWSER_SRCS) \
	browser/mockconsole.coffee \
	browser/frontend.coffee
# they don't survive uglifyjs and are already minified, so include them
# separately. also, this allows us to put them at the end of the document to
# reduce load time.
ACE_SRCS = vendor/ace/src-min/ace.js \
	vendor/ace/src-min/mode-java.js \
	vendor/ace/src-min/theme-twilight.js
CLI_SRCS := $(wildcard src/*.coffee console/*.coffee) src/natives.coffee

# Get list of native sources in alphabetical order.
NATIVE_SRCS := $(wildcard src/natives/*.coffee src/natives/classes/*.coffee)
# Get a list of all native classes, excluding inital setup and outro code
NATIVE_CLASSES := $(wildcard src/natives/classes/*.coffee)

################################################################################
# TARGETS
################################################################################
# Protect non-file-based targets from not functioning if a file with the
# target's name is present.
.PHONY: release benchmark dist dependencies java test clean docs build dev library

library: dependencies build/library/compressed.js
build/library:
		mkdir -p build/library

# Concatenate all components of natives.coffee whenever any one changes
src/natives.coffee: $(NATIVE_SRCS)
	cat src/natives/main.coffee $(NATIVE_CLASSES) src/natives/outro.coffee > src/natives.coffee

# Builds a release or benchmark version of Doppio without the documentation.
# This is a static pattern rule. '%' gets substituted for the target name.
release benchmark: %: dependencies build/% build/%/browser \
	$(patsubst %,build/\%/%,$(notdir $(BROWSER_HTML))) build/%/favicon.ico \
	build/%/compressed.js build/%/browser/mini-rt.tar build/%/ace.js \
	build/%/browser/style.css $(DEMO_CLASSES) $(UTIL_CLASSES) \
	build/%/classes build/%/vendor
	rsync browser/*.svg browser/*.png build/$*/browser/
	cd build/$*; $(COFFEEC) $(DOPPIO_DIR)/tools/gen_dir_listings.coffee > browser/listings.json

# dev: unoptimized build
dev: dependencies build/dev build/dev/browser \
	$(patsubst %.coffee,build/dev/%.js,$(filter %.coffee,$(dev_BROWSER_SRCS))) \
	build/dev/browser/style.css build/dev/index.html build/dev/favicon.ico $(DEMO_CLASSES) \
	build/dev/browser/mini-rt.tar build/dev/classes build/dev/vendor
	rsync $(filter %.js,$(dev_BROWSER_SRCS)) build/dev/vendor
	rsync browser/*.svg browser/*.png build/dev/browser/
	cd build/dev; $(COFFEEC) $(DOPPIO_DIR)/tools/gen_dir_listings.coffee > browser/listings.json

release-cli: $(CLI_SRCS:%.coffee=build/release/%.js) \
	build/release/classes build/release/vendor doppio<commit_msg>don't keep src/natives.coffee around<commit_after># Force the use of bash for shell statements. If we don't do this, many Linux
# variants will use sh.
SHELL := /bin/bash

# Will appear as directories under build/
BUILD_TARGETS = release benchmark dev

# Can be overridden on the command line. This is the name of the tar.gz file
# produced when you run `make dist'.
DIST_NAME = $(shell echo "Doppio_`date +'%y-%m-%d'`.tar.gz")

# DEPENDENCIES
DOPPIO_DIR    := $(CURDIR)
BOOTCLASSPATH := $(DOPPIO_DIR)/vendor/classes
COFFEEC  := $(shell npm bin)/coffee
UGLIFYJS := $(shell npm bin)/uglifyjs
DOCCO    := $(shell npm bin)/docco
JAZZLIB  := $(BOOTCLASSPATH)/java/util/zip/DeflaterEngine.class
JRE      := $(BOOTCLASSPATH)/java/lang/Object.class
SED      := $(shell if command -v gsed >/dev/null; then echo "gsed"; else echo "sed"; fi;)

# JAVA
SOURCES := $(wildcard classes/test/*.java)
DISASMS := $(SOURCES:.java=.disasm)
RUNOUTS := $(SOURCES:.java=.runout)
CLASSES := $(SOURCES:.java=.class)
# note: TESTS files never get made, but we use them for make rules
TESTS   := $(SOURCES:.java=.test)

DEMO_SRCS    := $(wildcard classes/demo/*.java)
DEMO_CLASSES := $(DEMO_SRCS:.java=.class)
UTIL_SRCS    := $(wildcard classes/util/*.java)
UTIL_CLASSES := $(UTIL_SRCS:.java=.class)
# native stubs for our own implementations
LIB_SRCS     := $(wildcard classes/awt/*.java) $(wildcard classes/doppio/*.java)
LIB_CLASSES  := $(LIB_SRCS:.java=.class)

# HTML
BROWSER_TEMPLATES := $(wildcard browser/[^_]*.mustache)
BROWSER_HTML      := $(BROWSER_TEMPLATES:.mustache=.html)

# SCRIPTS
# the order here is important: must match the order of includes
# in the browser frontend html.
COMMON_BROWSER_SRCS = vendor/_.js \
	vendor/gLong.js \
	browser/util.coffee \
	browser/node.coffee \
	src/logging.coffee \
	src/exceptions.coffee \
	src/util.coffee \
	src/java_object.coffee \
	src/opcodes.coffee \
	src/attributes.coffee \
	src/ConstantPool.coffee \
	src/disassembler.coffee \
	src/ClassData.coffee \
	src/natives.coffee \
	src/methods.coffee \
	src/runtime.coffee \
	src/ClassLoader.coffee \
	src/jvm.coffee \
	src/testing.coffee \
	browser/untar.coffee
library_BROWSER_SRCS := $(COMMON_BROWSER_SRCS)
# Release uses the actual jQuery console.
release_BROWSER_SRCS := $(COMMON_BROWSER_SRCS) \
	vendor/jquery.console.js \
	browser/frontend.coffee
dev_BROWSER_SRCS := $(release_BROWSER_SRCS)
# Benchmark uses the mock jQuery console.
benchmark_BROWSER_SRCS := $(COMMON_BROWSER_SRCS) \
	browser/mockconsole.coffee \
	browser/frontend.coffee
# they don't survive uglifyjs and are already minified, so include them
# separately. also, this allows us to put them at the end of the document to
# reduce load time.
ACE_SRCS = vendor/ace/src-min/ace.js \
	vendor/ace/src-min/mode-java.js \
	vendor/ace/src-min/theme-twilight.js
CLI_SRCS := $(wildcard src/*.coffee console/*.coffee) src/natives.coffee

# Get list of native sources in alphabetical order.
NATIVE_SRCS := $(wildcard src/natives/*.coffee src/natives/classes/*.coffee)
# Get a list of all native classes, excluding inital setup and outro code
NATIVE_CLASSES := $(wildcard src/natives/classes/*.coffee)

################################################################################
# TARGETS
################################################################################
# Protect non-file-based targets from not functioning if a file with the
# target's name is present.
.PHONY: release benchmark dist dependencies java test clean docs build dev library

# Don't keep this around in the src directory, because it's a generated file.
.INTERMEDIATE: src/natives.coffee

library: dependencies build/library/compressed.js
build/library:
		mkdir -p build/library

# Concatenate all components of natives.coffee whenever any one changes
src/natives.coffee: $(NATIVE_SRCS)
	cat src/natives/main.coffee $(NATIVE_CLASSES) src/natives/outro.coffee > src/natives.coffee

# Builds a release or benchmark version of Doppio without the documentation.
# This is a static pattern rule. '%' gets substituted for the target name.
release benchmark: %: dependencies build/% build/%/browser \
	$(patsubst %,build/\%/%,$(notdir $(BROWSER_HTML))) build/%/favicon.ico \
	build/%/compressed.js build/%/browser/mini-rt.tar build/%/ace.js \
	build/%/browser/style.css $(DEMO_CLASSES) $(UTIL_CLASSES) \
	build/%/classes build/%/vendor
	rsync browser/*.svg browser/*.png build/$*/browser/
	cd build/$*; $(COFFEEC) $(DOPPIO_DIR)/tools/gen_dir_listings.coffee > browser/listings.json

# dev: unoptimized build
dev: dependencies build/dev build/dev/browser \
	$(patsubst %.coffee,build/dev/%.js,$(filter %.coffee,$(dev_BROWSER_SRCS))) \
	build/dev/browser/style.css build/dev/index.html build/dev/favicon.ico $(DEMO_CLASSES) \
	build/dev/browser/mini-rt.tar build/dev/classes build/dev/vendor
	rsync $(filter %.js,$(dev_BROWSER_SRCS)) build/dev/vendor
	rsync browser/*.svg browser/*.png build/dev/browser/
	cd build/dev; $(COFFEEC) $(DOPPIO_DIR)/tools/gen_dir_listings.coffee > browser/listings.json

release-cli: $(CLI_SRCS:%.coffee=build/release/%.js) \
	build/release/classes build/release/vendor doppio
{'fraction_non_alphanumeric': 0.16161616161616163, 'fraction_numerical': 0.0, 'mean_word_length': 4.527640941434045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '992000', 'n_tokens_mistral': 3739, 'n_tokens_neox': 3464, 'n_words': 837}