Skip to content

Commit

Permalink
Experiment with the Rust programming language for 2019
Browse files Browse the repository at this point in the history
It's about time I give Rust a whirl.
  • Loading branch information
ericvw committed Jan 10, 2024
1 parent e13c62c commit 4e2b46d
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/puzzles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions 2019/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[net]
offline = true
2 changes: 2 additions & 0 deletions 2019/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cargo.lock
target/
6 changes: 6 additions & 0 deletions 2019/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "aoc-2019"
version = "0.1.0"
edition = "2021"

[dependencies]
46 changes: 46 additions & 0 deletions 2019/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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

targetdir := target/$(PROFILE)

answer_%.txt: $(targetdir)/puzzle_% input_%.txt
./$< < $(filter-out $<, $^) | tee $@

.NOTINTERMEDIATE: $(targetdir)/puzzle_%
$(targetdir)/puzzle_%: $(srcdir)/puzzle_%$(ext)
$(CARGO) build --profile $(PROFILE) --bin $(notdir $@)

.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
3 changes: 3 additions & 0 deletions 2019/src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, World!");
}

0 comments on commit 4e2b46d

Please sign in to comment.