Skip to content

Commit

Permalink
Point out +INIT must be called first
Browse files Browse the repository at this point in the history
  • Loading branch information
idelvall committed Nov 14, 2023
1 parent 7dbc57f commit c884ebb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 10 additions & 9 deletions rust/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,9 @@ INIT:
ARG sweep_days=4
RUN echo "$sweep_days">/earthly/cfg/sweep_days

CHECK_INITED:
COMMAND
RUN if [ ! -f /earthly/cfg/cache_id ]; then \
echo "+INIT has not been called yet in this build environment" ; \
exit 1; \
fi;

# CARGO runs the cargo command "cargo $args".
# This UDC is thread safe. Parallel builds of targets calling this UDC should be free of race conditions.
# Notice that in order to run this UDC, +INIT must be called first.
# Arguments:
# - args: Cargo subcommand and its arguments. Required.
# - output: Regex to match the files within the target folder to be copied from the cache to the caller filesystem (image layers).
Expand Down Expand Up @@ -72,10 +66,10 @@ CARGO:
END

# RUN_WITH_CACHE runs the passed command with the CARGO caches mounted.
# Notice that in order to run this UDC, +INIT must be called first.
# Arguments:
# - command (required): Command to run, can be any expression.
#
# This implementation is not expected to change significantly. Prefer using the `CARGO` UDC if you can, so you can get future improvements transparently.
RUN_WITH_CACHE:
COMMAND
DO +CHECK_INITED
Expand Down Expand Up @@ -137,4 +131,11 @@ REMOVE_SOURCE_FINGERPRINTS:
for source_lib in \$source_libs; do
find . -maxdepth 1 -regex \"\./\$source_lib-[^-]+\" -exec bash -c 'readlink -f {}; rm -rf {}' \; ;
done
done"
done"

CHECK_INITED:
COMMAND
RUN if [ ! -f /earthly/cfg/cache_id ]; then \
echo "+INIT has not been called yet in this build environment" ; \
exit 1; \
fi;
2 changes: 2 additions & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ By default, this UDC removes the fingerprints of the packages found in the sourc

This UDC runs the cargo command `cargo $args` caching the contents of `$CARGO_HOME` and `target` for future builds of the same calling target.

Notice that in order to run this UDC, [+INIT](#init) must be called first.

### Usage

After calling `+INIT`, use it to wrap cargo commands:
Expand Down

0 comments on commit c884ebb

Please sign in to comment.