-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a .cargo/config so intellij uses the same target dir as cmake (#…
…173)
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
Cargo.lock | ||
.cargo/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
file(WRITE CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}\n") | ||
|
||
execute_process( | ||
COMMAND /usr/bin/env "CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}" "/bin/bash" "${CMAKE_CURRENT_LIST_DIR}/scripts/setup.sh" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" | ||
RESULT_VARIABLE CARGO_RESULT | ||
OUTPUT_VARIABLE CARGO_CONFIG_OUT | ||
ERROR_VARIABLE CARGO_CONFIG_OUT) | ||
|
||
if(HAVE_RUST) | ||
add_subdirectory(ccommon_rs) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# utility script run by cmake for writing a .cargo/config that points | ||
# to the common 'target' directory under the CMAKE_BINARY_DIR. This | ||
# allows automated tools (such as the intellij rust plugin or vcode | ||
# rust integration) to share output and avoid recompiling between | ||
# the command line and the IDE. | ||
# | ||
# it is assumed that this script is run with the CWD being the | ||
# place where the .cargo dir should be created. | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
die() { echo "fatal: $*" >&2; exit 1; } | ||
|
||
if [[ -z "${CMAKE_BINARY_DIR:-}" ]]; then | ||
die "CMAKE_BINARY_DIR must be set!" | ||
fi | ||
|
||
mkdir -p .cargo | ||
|
||
cleanup() { | ||
[[ -n "${TEMPFILE:-}" ]] && rm -rf "$TEMPFILE" | ||
} | ||
trap cleanup EXIT | ||
|
||
TEMPFILE="$(mktemp '.cargo/config.XXXXXXXX')" || die "could not create tempfile" | ||
|
||
cat > "$TEMPFILE" <<EOS | ||
[build] | ||
target-dir = "${CMAKE_BINARY_DIR}/target" | ||
EOS | ||
|
||
mv "$TEMPFILE" .cargo/config |