csci5607/assignment-1b/Makefile

54 lines
1.3 KiB
Makefile
Raw Normal View History

2023-02-06 03:52:42 +00:00
.PHONY: all clean
.PRECIOUS: $(EXAMPLES_PPM)
DOCKER := docker
ZIP := zip
PANDOC := pandoc
CONVERT := convert
2023-02-16 07:14:22 +00:00
HANDIN := ./hw1b.michael.zhang.zip
2023-02-13 05:46:54 +00:00
BINARY := ./raytracer1b
2023-02-16 07:14:22 +00:00
WRITEUP := ./writeup.pdf
SHOWCASE := ./showcase.png
2023-02-16 00:58:10 +00:00
SOURCES := Cargo.toml $(shell find -name "*.rs")
2023-02-06 03:52:42 +00:00
EXAMPLES := $(shell find examples -name "*.txt")
EXAMPLES_PPM := $(patsubst %.txt,%.ppm,$(EXAMPLES))
EXAMPLES_PNG := $(patsubst %.txt,%.png,$(EXAMPLES))
all: $(HANDIN)
$(BINARY): $(SOURCES)
2023-02-16 00:25:22 +00:00
mkdir -p target/docker
2023-02-06 03:52:42 +00:00
$(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 \
2023-02-16 00:25:22 +00:00
-e CARGO_TARGET_DIR=/usr/src/myapp/target/docker \
2023-02-06 03:52:42 +00:00
rust \
2023-02-16 00:58:10 +00:00
cargo build --profile release-handin
mv target/docker/release-handin/raytracer1b $@
2023-02-06 03:52:42 +00:00
2023-02-16 07:14:22 +00:00
$(HANDIN): $(BINARY) $(WRITEUP) Makefile Cargo.toml Cargo.lock README.md $(EXAMPLES_PNG) $(EXAMPLES_PPM) $(SHOWCASE)
2023-02-06 03:52:42 +00:00
$(ZIP) -r $@ src examples $^
2023-02-16 07:14:22 +00:00
$(SHOWCASE): examples/soft-shadow-demo.png
cp $< $@
2023-02-06 03:52:42 +00:00
examples/%.ppm: examples/%.txt $(SOURCES)
2023-02-15 08:08:21 +00:00
cargo run --release -- -o $@ $<
2023-02-06 03:52:42 +00:00
examples/%.png: examples/%.ppm
convert $< $@
writeup.pdf: writeup.md $(EXAMPLES_PNG)
$(PANDOC) -o $@ $<
clean:
2023-02-16 07:14:22 +00:00
rm -rf target/docker \
$(HANDIN) $(BINARY) $(WRITEUP) $(SHOWCASE) \
$(EXAMPLES_PPM) $(EXAMPLES_PNG)