<commit_before>SOURCES = $(wildcard src/*.rs)
RUSTC ?= rustc
RUSTC_FLAGS ?= -C opt-level=3 -C target-cpu=core2 -C lto -L ./lib
REGEX_VERSION ?= 0.1.30

.PHONY: all distclean clean
.SECONDARY:

all: $(patsubst src/%.rs,diff/%.diff, $(SOURCES))

clean:
	rm -fr diff

distclean: clean
	rm -fr bin out tmp lib

diff/chameneos_redux.diff: out/chameneos_redux.txt ref/chameneos_redux.txt
	mkdir -p diff
	sed -r 's/^[0-9]+/42/' $< | diff -u ref/chameneos_redux.txt - > $@

bin/regex_dna: src/regex_dna.rs lib/.regex_install

lib/.regex_install:
	mkdir -p tmp
	curl -s -L https://crates.io/api/v1/crates/regex/$(REGEX_VERSION)/download > tmp/regex-$(REGEX_VERSION).crate
	tar -C tmp/ -xzf tmp/regex-$(REGEX_VERSION).crate
	cargo build --release --manifest-path tmp/regex-$(REGEX_VERSION)/Cargo.toml
	mkdir -p lib
	cp tmp/regex-$(REGEX_VERSION)/target/release/*.rlib lib/
	@touch lib/.regex_install

bin/%: src/%.rs
	mkdir -p bin
	$(RUSTC) $(RUSTC_FLAGS) $< -o $@

out/%.txt: bin/% data/%.txt<commit_msg>generalize crate install<commit_after>SOURCES = $(wildcard src/*.rs)
RUSTC ?= rustc
RUSTC_FLAGS ?= -C opt-level=3 -C target-cpu=core2 -C lto
RUSTC_FLAGS += -L ./lib
REGEX ?= regex-0.1.30

.PHONY: all distclean clean
.SECONDARY:

all: $(patsubst src/%.rs,diff/%.diff, $(SOURCES))

clean:
	rm -fr diff

distclean: clean
	rm -fr bin out tmp lib

diff/chameneos_redux.diff: out/chameneos_redux.txt ref/chameneos_redux.txt
	mkdir -p diff
	sed -r 's/^[0-9]+/42/' $< | diff -u ref/chameneos_redux.txt - > $@

bin/regex_dna: src/regex_dna.rs lib/$(REGEX).pkg

lib/%.pkg:
	mkdir -p tmp
	curl -s -L https://crates.io/api/v1/crates/`echo '$*' | sed -r 's#-([^-]*$$)#/\1#'`/download > tmp/$*.crate
	tar -C tmp/ -xzf tmp/$*.crate
	cargo build --release --manifest-path tmp/$*/Cargo.toml
	mkdir -p lib
	cp tmp/$*/target/release/*.rlib lib/
	@touch lib/$*.pkg

bin/%: src/%.rs
	mkdir -p bin
	$(RUSTC) $(RUSTC_FLAGS) $< -o $@

out/%.txt: bin/% data/%.txt
{'fraction_non_alphanumeric': 0.19244697361614072, 'fraction_numerical': 0.01189860320744956, 'mean_word_length': 3.36568848758465, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4677324', 'n_tokens_mistral': 881, 'n_tokens_neox': 846, 'n_words': 185}