<commit_before>OUT ?= out

# Set path to prebuilts used in the build.
UNNAME_S := $(shell uname -s | tr '[:upper:]' '[:lower:]')
PREBUILTS := $(PWD)/prebuilts/$(UNNAME_S)-x64
GN ?= $(PREBUILTS)/gn/gn
NINJA ?= $(PREBUILTS)/ninja/ninja
export PATH := $(PREBUILTS)/clang/bin:$(PATH)

# Configure the build arguments.
GCC ?= false
ARCH ?= aarch64
PLATFORM ?= qemu

.PHONY: all
all: $(OUT)/build.ninja
	@$(NINJA) -C $(OUT)

$(OUT)/build.ninja: $(OUT)/args.gn
	@$(GN) --export-compile-commands gen $(OUT)

# Configure the build by loading the configuration arguments for the
# architecture and platform.
$(OUT)/args.gn: build/arch/$(ARCH)/$(PLATFORM).args
	@echo Copying config for $(ARCH) on $(PLATFORM)
	@mkdir -p $(OUT)
	@echo "arch = \"$(ARCH)\"" >> $@
	@echo "use_gcc = $(GCC)" >> $@
	@echo >> $@
	@cat $< >> $@

.PHONY: clean
clean:
	@$(NINJA) -C $(OUT) -t clean

.PHONY: clobber
clobber:
	rm -rf $(OUT)

# see .clang-format.
.PHONY: format
format:
	@echo "Formatting..."
	@find src/ -name *.c -o -name *.h | xargs clang-format -style file -i
	@find inc/ -name *.c -o -name *.h | xargs clang-format -style file -i
	@find test/ -name *.c -o -name *.h | xargs clang-format -style file -i
	@find . -name *.gn -o -name *.gni -exec $(GN) format {} \;

# see .clang-tidy.
.PHONY: tidy
tidy: $(OUT)/build.ninja
	@$(NINJA) -C $(OUT)
	@echo "Tidying..."<commit_msg>Remove out/args.gn when cleaning.<commit_after>OUT ?= out

# Set path to prebuilts used in the build.
UNNAME_S := $(shell uname -s | tr '[:upper:]' '[:lower:]')
PREBUILTS := $(PWD)/prebuilts/$(UNNAME_S)-x64
GN ?= $(PREBUILTS)/gn/gn
NINJA ?= $(PREBUILTS)/ninja/ninja
export PATH := $(PREBUILTS)/clang/bin:$(PATH)

# Configure the build arguments.
GCC ?= false
ARCH ?= aarch64
PLATFORM ?= qemu

.PHONY: all
all: $(OUT)/build.ninja
	@$(NINJA) -C $(OUT)

$(OUT)/build.ninja: $(OUT)/args.gn
	@$(GN) --export-compile-commands gen $(OUT)

# Configure the build by loading the configuration arguments for the
# architecture and platform.
$(OUT)/args.gn: build/arch/$(ARCH)/$(PLATFORM).args
	@echo Copying config for $(ARCH) on $(PLATFORM)
	@mkdir -p $(OUT)
	@echo "arch = \"$(ARCH)\"" >> $@
	@echo "use_gcc = $(GCC)" >> $@
	@echo >> $@
	@cat $< >> $@

.PHONY: clean
clean:
	@$(NINJA) -C $(OUT) -t clean
	rm -f $(OUT)/args.gn

.PHONY: clobber
clobber:
	rm -rf $(OUT)

# see .clang-format.
.PHONY: format
format:
	@echo "Formatting..."
	@find src/ -name *.c -o -name *.h | xargs clang-format -style file -i
	@find inc/ -name *.c -o -name *.h | xargs clang-format -style file -i
	@find test/ -name *.c -o -name *.h | xargs clang-format -style file -i
	@find . -name *.gn -o -name *.gni -exec $(GN) format {} \;

# see .clang-tidy.
.PHONY: tidy
tidy: $(OUT)/build.ninja
	@$(NINJA) -C $(OUT)
	@echo "Tidying..."
{'fraction_non_alphanumeric': 0.21459694989106753, 'fraction_numerical': 0.002904865649963689, 'mean_word_length': 3.373015873015873, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1603862', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1134, 'n_words': 323}