vesys-bank-server/Makefile

56 lines
1.5 KiB
Makefile
Raw Permalink Normal View History

2022-03-26 10:00:13 +00:00
LINUX_X86_64_MUSL_TARGET = x86_64-unknown-linux-musl
LINUX_AARCH64_MUSL_TARGET = aarch64-unknown-linux-musl
WINDOWS_GNU_TARGET = x86_64-pc-windows-gnu
x86_64-unknown-linux-musl_strip = strip
aarch64-unknown-linux-musl_strip = aarch64-linux-musl-strip
x86_64-pc-windows-gnu_strip = strip
BINARIES = socket-server http-server
RELEASE_DIR = release
.PHONY: audit clean test linux-x86_64-musl linux-aarch64-musl windows-gnu http-client $(RELEASE_DIR) all default
TARGETS = $(LINUX_X86_64_MUSL_TARGET) $(LINUX_AARCH64_MUSL_TARGET) $(WINDOWS_GNU_TARGET)
default: all
all: linux-x86_64-musl linux-aarch64-musl windows-gnu http-client
define BUILDER
target/$(TARGET)/release/%:
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target $(TARGET) --package $$(basename $$(@F))
$($(TARGET)_strip) $$@
$(RELEASE_DIR)/$(TARGET)/%: target/$(TARGET)/release/% $(RELEASE_DIR)
mkdir -p $$(dir $$@)
cp $$< $$@
endef
$(foreach TARGET,$(TARGETS),$(eval $(BUILDER)))
define BINARY_TARGETS
linux-x86_64-musl: $(RELEASE_DIR)/$(LINUX_X86_64_MUSL_TARGET)/$(BINARY)
linux-aarch64-musl: $(RELEASE_DIR)/$(LINUX_AARCH64_MUSL_TARGET)/$(BINARY)
windows-gnu: $(RELEASE_DIR)/$(WINDOWS_GNU_TARGET)/$(BINARY).exe
endef
$(foreach BINARY,$(BINARIES),$(eval $(BINARY_TARGETS)))
http-client:
cd http-client && trunk build --release
rm -rf $(RELEASE_DIR)/$@
mkdir -p $(RELEASE_DIR)/$@
cp -r http-client/dist/* $(RELEASE_DIR)/$@
$(RELEASE_DIR):
mkdir -p $(RELEASE_DIR)
test:
cargo test
audit:
cargo audit
clean:
-rm -rf target $(RELEASE_DIR)