mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 22:30:47 +00:00
55 lines
876 B
Bash
Executable File
55 lines
876 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
name=day-"$1"
|
|
|
|
if [ -d day-"$name" ]; then
|
|
echo "program $name already exists"
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$name"/testdata
|
|
touch "$name"/makefile
|
|
|
|
cat <<EOT >> "$name"/makefile
|
|
program = $name
|
|
|
|
GO = go
|
|
SRC_DIR := src
|
|
BIN_DIR := bin
|
|
|
|
EXE := \$(BIN_DIR)/\$(program)
|
|
|
|
.DEFAULT_GOAL := build
|
|
|
|
.PHONY: fmt vet build clean
|
|
fmt:
|
|
\$(GO) fmt ./...
|
|
|
|
vet: fmt
|
|
\$(GO) vet ./...
|
|
|
|
build: vet | \$(BIN_DIR)
|
|
\$(GO) build -o \$(EXE) ./\$(SRC_DIR)
|
|
|
|
\$(BIN_DIR):
|
|
@mkdir -p \$@
|
|
|
|
clean:
|
|
@rm -rv \$(BIN_DIR)
|
|
EOT
|
|
|
|
cat <<EOT >> "$name"/solution.go
|
|
/********************************************************************************
|
|
Advent of Code 2024 - $name
|
|
********************************************************************************/
|
|
|
|
package main
|
|
|
|
func main() {
|
|
|
|
}
|
|
EOT
|
|
|
|
cd "$name" || exit
|
|
|
|
go mod init github.com/onyx-and-iris/aoc2024/"$name" |