csci5607/assignment-1d/Makefile

54 lines
1.2 KiB
Makefile
Raw Normal View History

2023-03-20 21:10:01 +00:00
.PHONY: all clean
.PRECIOUS: $(EXAMPLES_PPM)
2023-03-25 10:05:53 +00:00
DEBUG :=
2023-04-03 07:01:51 +00:00
CARGO_FLAGS := --release
2023-03-20 21:10:01 +00:00
RAYTRACER_FLAGS :=
DOCKER := docker
ZIP := zip
PANDOC := pandoc
CONVERT := convert
2023-04-03 07:01:51 +00:00
ifeq ($(DEBUG),1)
RAYTRACER_FLAGS += -vvvv
else
endif
2023-03-20 21:10:01 +00:00
HANDIN := ./hw1d.michael.zhang.zip
BINARY := ./raytracer1d
SOURCES := Cargo.toml $(shell find -name "*.rs")
EXAMPLES := $(shell find examples -name "*.txt")
EXAMPLES_PPM := $(patsubst %.txt,%.ppm,$(EXAMPLES))
EXAMPLES_PNG := $(patsubst %.txt,%.png,$(EXAMPLES))
all: $(HANDIN)
$(BINARY): $(SOURCES)
mkdir -p target/docker
$(DOCKER) run \
--rm \
-v "$(shell pwd)":/usr/src/myapp \
-v cargo-registry:/usr/local/cargo \
--user "$(shell id -u)":"$(shell id -g)" \
-w /usr/src/myapp \
-e CARGO_TARGET_DIR=/usr/src/myapp/target/docker \
rust \
2023-04-05 07:08:54 +00:00
cargo build --profile release-handin --features release-handin
2023-03-20 21:10:01 +00:00
mv target/docker/release-handin/raytracer1d $@
$(HANDIN): $(BINARY) Makefile Cargo.toml Cargo.lock README.md $(EXAMPLES_PNG) $(EXAMPLES_PPM)
$(ZIP) -r $@ src examples $^
examples/%.ppm: examples/%.txt $(SOURCES)
2023-04-03 07:01:51 +00:00
cargo run $(CARGO_FLAGS) -- -o $@ $(RAYTRACER_FLAGS) $<
2023-03-20 21:10:01 +00:00
examples/%.png: examples/%.ppm
convert $< $@
clean:
rm -rf target/docker \
$(HANDIN) $(BINARY) \
$(EXAMPLES_PPM) $(EXAMPLES_PNG)