Skip to content

Commit

Permalink
introduce justfile for building locally
Browse files Browse the repository at this point in the history
  • Loading branch information
TheButlah committed Nov 15, 2024
1 parent 5439a4e commit 100e80f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/.idea
/.vscode
/target
/artifacts
**/artifacts
.intentionally-empty-file.o

*.swp
Expand Down
34 changes: 34 additions & 0 deletions identity-server/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Define variables
artifacts_dir := "artifacts"
target_dir := "../target"
package_name := "identity-server"
targets := ("x86_64-unknown-linux-musl"
+ "aarch64-unknown-linux-musl"
+ "x86_64-pc-windows-gnu"
+ "aarch64-apple-darwin")

default: all

# Build Rust binaries for different targets
rust-build:
cargo-zigbuild build --profile artifact -p {{package_name}} --target aarch64-apple-darwin --target x86_64-pc-windows-gnu --target aarch64-unknown-linux-musl --target x86_64-unknown-linux-musl

# Copy artifacts from cargo target dir into to the artifacts directory
artifacts: rust-build
pwd
mkdir -p {{artifacts_dir}}
cp {{target_dir}}/aarch64-apple-darwin/artifact/{{package_name}} {{artifacts_dir}}/{{package_name}}-macos-aarch64
cp {{target_dir}}/x86_64-unknown-linux-musl/artifact/{{package_name}} {{artifacts_dir}}/{{package_name}}-linux-x86_64
cp {{target_dir}}/aarch64-unknown-linux-musl/artifact/{{package_name}} {{artifacts_dir}}/{{package_name}}-linux-aarch64
cp {{target_dir}}/x86_64-pc-windows-gnu/artifact/{{package_name}}.exe {{artifacts_dir}}/{{package_name}}-windows-x86_64.exe

# Build Docker image
podman: artifacts
podman build --platform linux/arm64,linux/amd64,windows/amd64 .

# Clean artifacts
clean:
rm -rf {{artifacts_dir}}

# Run all tasks
all: rust-build artifacts podman
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.81.0" # See workspace Cargo.toml
channel = "1.82.0" # See workspace Cargo.toml
components = ["rust-src"]
profile = "default"
targets = ["x86_64-pc-windows-gnu", "x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl", "aarch64-apple-darwin"]

0 comments on commit 100e80f

Please sign in to comment.