Skip to content

Commit

Permalink
Update makefile to build everything
Browse files Browse the repository at this point in the history
  • Loading branch information
ewpratten committed Feb 12, 2024
1 parent 6074569 commit ce81662
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ Cargo.lock
#Cargo.lock

# Built packages
/tars
/release
14 changes: 9 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ assets = [
"/usr/local/bin/protomask-clat",
"755",
],
[
"target/release/protomask-6over4",
"/usr/local/bin/protomask-6over4",
"755",
],
[
"config/protomask.json",
"/etc/protomask/protomask.json",
Expand All @@ -117,3 +112,12 @@ systemd-units = [
{ unit-name = "protomask-service", enable = false },
{ unit-name = "protomask-clat-service", enable = false },
]

[package.metadata.generate-rpm]
assets = [
{ source = "target/release/protomask", dest = "/usr/local/bin/protomask", mode = "755"},
{ source = "target/release/protomask-clat", dest = "/usr/local/bin/protomask-clat", mode = "755"},
{ source = "config/protomask.json", dest = "/etc/protomask/protomask.json", mode = "644"},
{ source = "config/protomask-clat.json", dest = "/etc/protomask/protomask-clat.json", mode = "644"},
{ source = "README.md", dest = "/usr/share/doc/protomask/README.md", mode = "644"},
]
62 changes: 57 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,71 @@
# All sources used to build the protomask binary
SRC = Cargo.toml $(shell find src/ -type f -name '*.rs')
CONFIGS = $(shell find config/ -type f -name '*.json')
DEBIAN_SCRIPTS = $(shell find debian/ -type f)

# Used to auto-version things
CRATE_VERSION = $(shell sed -n -r "s/^version = \"([0-9\.]+)\"/\1/p" Cargo.toml)

all: target/x86_64-unknown-linux-musl/release/protomask target/aarch64-unknown-linux-musl/release/protomask target/x86_64-unknown-linux-musl/debian/protomask_${CRATE_VERSION}_amd64.deb target/aarch64-unknown-linux-musl/debian/protomask_${CRATE_VERSION}_arm64.deb
.PHONY: all release clean
all: release

target/x86_64-unknown-linux-musl/release/protomask: $(SRC)
cross build --target x86_64-unknown-linux-musl --release
cross build --target x86_64-unknown-linux-musl --release --bin protomask

target/x86_64-unknown-linux-musl/release/protomask-clat: $(SRC)
cross build --target x86_64-unknown-linux-musl --release --bin protomask-clat

target/aarch64-unknown-linux-musl/release/protomask: $(SRC)
cross build --target aarch64-unknown-linux-musl --release

target/x86_64-unknown-linux-musl/debian/protomask_${CRATE_VERSION}_amd64.deb: target/x86_64-unknown-linux-musl/release/protomask
target/x86_64-unknown-linux-musl/release/protomask-clat: $(SRC)
cross build --target x86_64-unknown-linux-musl --release --bin protomask-clat

target/protomask.tar.gz: target/x86_64-unknown-linux-musl/release/protomask \
target/x86_64-unknown-linux-musl/release/protomask-clat \
target/aarch64-unknown-linux-musl/release/protomask \
target/aarch64-unknown-linux-musl/release/protomask-clat \
$(CONFIGS)
mkdir -p target/protomask_tar_temp/{bin,config}
mkdir -p target/protomask_tar_temp/bin/{x86_64,aarch64}
cp target/x86_64-unknown-linux-musl/release/protomask target/protomask_tar_temp/bin/x86_64/protomask
cp target/x86_64-unknown-linux-musl/release/protomask-clat target/protomask_tar_temp/bin/x86_64/protomask-clat
cp target/aarch64-unknown-linux-musl/release/protomask target/protomask_tar_temp/bin/aarch64/protomask
cp target/aarch64-unknown-linux-musl/release/protomask-clat target/protomask_tar_temp/bin/aarch64/protomask-clat
cp config/*.json target/protomask_tar_temp/config/
tar -czf target/protomask.tar.gz -C target/protomask_tar_temp .
rm -rf target/protomask_tar_temp

target/x86_64-unknown-linux-musl/debian/protomask_${CRATE_VERSION}_amd64.deb: target/x86_64-unknown-linux-musl/release/protomask \
target/x86_64-unknown-linux-musl/release/protomask-clat \
$(CONFIGS) \
$(DEBIAN_SCRIPTS)
cargo deb --target x86_64-unknown-linux-musl --no-build

target/aarch64-unknown-linux-musl/debian/protomask_${CRATE_VERSION}_arm64.deb: target/aarch64-unknown-linux-musl/release/protomask
cargo deb --target aarch64-unknown-linux-musl --no-build
target/aarch64-unknown-linux-musl/debian/protomask_${CRATE_VERSION}_arm64.deb: target/aarch64-unknown-linux-musl/release/protomask \
target/aarch64-unknown-linux-musl/release/protomask-clat \
$(CONFIGS) \
$(DEBIAN_SCRIPTS)
cargo deb --target aarch64-unknown-linux-musl --no-build

target/x86_64-unknown-linux-musl/generate-rpm/protomask-${CRATE_VERSION}-1.x86_64.rpm: target/x86_64-unknown-linux-musl/release/protomask \
target/x86_64-unknown-linux-musl/release/protomask-clat \
$(CONFIGS)
cargo generate-rpm --target x86_64-unknown-linux-musl

target/aarch64-unknown-linux-musl/generate-rpm/protomask-${CRATE_VERSION}-1.aarch64.rpm: target/aarch64-unknown-linux-musl/release/protomask \
target/aarch64-unknown-linux-musl/release/protomask-clat \
$(CONFIGS)
cargo generate-rpm --target aarch64-unknown-linux-musl

release: target/protomask.tar.gz \
target/x86_64-unknown-linux-musl/debian/protomask_${CRATE_VERSION}_amd64.deb \
target/aarch64-unknown-linux-musl/debian/protomask_${CRATE_VERSION}_arm64.deb \
target/x86_64-unknown-linux-musl/generate-rpm/protomask-${CRATE_VERSION}-1.x86_64.rpm \
target/aarch64-unknown-linux-musl/generate-rpm/protomask-${CRATE_VERSION}-1.aarch64.rpm
mkdir -p release
cp $^ release/

clean:
rm -rf release
cargo clean

4 comments on commit ce81662

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary sizes for x86_64-unknown-linux-musl

Channel: stable

5.9M	target/x86_64-unknown-linux-musl/release/protomask-clat
5.9M	target/x86_64-unknown-linux-musl/release/protomask
2.3M	target/x86_64-unknown-linux-musl/release/protomask-6over4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary sizes for aarch64-unknown-linux-musl

Channel: stable

6.0M	target/aarch64-unknown-linux-musl/release/protomask-clat
6.0M	target/aarch64-unknown-linux-musl/release/protomask
2.4M	target/aarch64-unknown-linux-musl/release/protomask-6over4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary sizes for aarch64-unknown-linux-musl

Channel: stable

6.0M	target/aarch64-unknown-linux-musl/release/protomask-clat
6.0M	target/aarch64-unknown-linux-musl/release/protomask
2.4M	target/aarch64-unknown-linux-musl/release/protomask-6over4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary sizes for x86_64-unknown-linux-musl

Channel: stable

5.9M	target/x86_64-unknown-linux-musl/release/protomask-clat
5.9M	target/x86_64-unknown-linux-musl/release/protomask
2.3M	target/x86_64-unknown-linux-musl/release/protomask-6over4

Please sign in to comment.