From df429cd89baa24081d71479fe75d65503f9e5090 Mon Sep 17 00:00:00 2001 From: "Eric N. Vander Weele" Date: Wed, 10 Jan 2024 13:56:44 -0500 Subject: [PATCH] Experiment with the Rust programming language for 2019 It's about time I give Rust a whirl. --- .github/workflows/puzzles.yaml | 20 +++++++++++++++++ 2019/.cargo/config.toml | 2 ++ 2019/.gitignore | 2 ++ 2019/Cargo.toml | 6 +++++ 2019/Makefile | 40 ++++++++++++++++++++++++++++++++++ 2019/src/bin/main.rs | 3 +++ 6 files changed, 73 insertions(+) create mode 100644 2019/.cargo/config.toml create mode 100644 2019/.gitignore create mode 100644 2019/Cargo.toml create mode 100644 2019/Makefile create mode 100644 2019/src/bin/main.rs diff --git a/.github/workflows/puzzles.yaml b/.github/workflows/puzzles.yaml index 9971148..ea303b0 100644 --- a/.github/workflows/puzzles.yaml +++ b/.github/workflows/puzzles.yaml @@ -11,6 +11,26 @@ on: - cron: '0 0 1 * *' jobs: + aoc-2019: + name: AoC 2019 — Rust + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./2019 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up environment + run: rustup show active-toolchain + + - name: Run + run: make + + - name: Lint + run: make lint + aoc-2021: name: AoC 2021 — Python runs-on: ubuntu-latest diff --git a/2019/.cargo/config.toml b/2019/.cargo/config.toml new file mode 100644 index 0000000..d52f0a8 --- /dev/null +++ b/2019/.cargo/config.toml @@ -0,0 +1,2 @@ +[net] +offline = true diff --git a/2019/.gitignore b/2019/.gitignore new file mode 100644 index 0000000..1e7caa9 --- /dev/null +++ b/2019/.gitignore @@ -0,0 +1,2 @@ +Cargo.lock +target/ diff --git a/2019/Cargo.toml b/2019/Cargo.toml new file mode 100644 index 0000000..7e663ce --- /dev/null +++ b/2019/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "aoc-2019" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/2019/Makefile b/2019/Makefile new file mode 100644 index 0000000..075d8bc --- /dev/null +++ b/2019/Makefile @@ -0,0 +1,40 @@ +MAKEFLAGS += --warn-undefined-variables +SHELL := bash +.SHELLFLAGS := -eu -o pipefail -c +.DEFAULT_GOAL := all +.DELETE_ON_ERROR: +.SUFFIXES: + +CARGO ?= cargo +PROFILE ?= release + +ext := .rs +srcdir := src/bin +srcs := $(wildcard $(srcdir)/puzzle_*$(ext)) +answers := $(subst puzzle,answer,$(patsubst %$(ext),%.txt, $(notdir $(srcs)))) + +include $(CURDIR)/../mk-common/common.mk + +answer_%.txt: $(srcdir)/puzzle_%$(ext) input_%.txt + $(CARGO) run --profile $(PROFILE) --bin $(basename $(notdir $<)) < $(filter-out $<, $^) | tee $@ + +.PHONY: lint +lint: lint-code lint-format + +.PHONY: lint-code +lint-code: + $(CARGO) clippy + +.PHONY: lint-format +lint-format: + $(CARGO) fmt --check + +.PHONY: format +format: + $(CARGO) clippy --fix --allow-dirty + $(CARGO) fmt + +.PHONY: distclean +distclean: clean + $(CARGO) clean + $(RM) Cargo.lock diff --git a/2019/src/bin/main.rs b/2019/src/bin/main.rs new file mode 100644 index 0000000..0672e51 --- /dev/null +++ b/2019/src/bin/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, World!"); +}