Skip to content

Commit

Permalink
add rust
Browse files Browse the repository at this point in the history
  • Loading branch information
idelvall committed Sep 7, 2023
1 parent b402f73 commit e5a6a6f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions rust/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
VERSION --arg-scope-and-set 0.7

# CARGO caches the cargo command "cargo $cargo_args"
# Arguments:
# - source_libs (required): name of the cargo packages under development
# - cargo_args (required): Cargo subcommand and its arguments
# - target_subfolder: Folder within ./target/ that build in going to generate, if any.
# - save_artifact: folder to be saved as a build artifact, if any
# - as_local: local path to save the build artifact, if any
CARGO:
COMMAND
ARG --required cargo_args
ARG --required source_libs
ARG target_subfolder
ARG save_artifact=./target/$target_subfolder
ARG as_local=""
LET cargo_home=$(echo $CARGO_HOME)
LET output_name=$(echo "$cargo_args" | head -n1 | cut -d " " -f1)
IF test $target_subfolder
CACHE ./target/$target_subfolder/
FOR source_lib IN $source_libs
RUN rm -rf ./target/$target_subfolder/.fingerprint/$source_lib-*
END
END
RUN --mount=type=cache,target=$cargo_home/registry cargo $cargo_args
IF test $save_artifact
IF [ "$as_local" != "" ]
SAVE ARTIFACT $save_artifact $output_name AS LOCAL $as_local
ELSE
SAVE ARTIFACT $save_artifact $output_name
END
END

0 comments on commit e5a6a6f

Please sign in to comment.