Skip to content

Commit bb52299

Browse files
committed
build: mark target/ and pg_install/ with CACHEDIR.TAG
Backup tools such as restic recognize this. More info: https://bford.info/cachedir/ NB: cargo _should_ create the tag file in the `target/` directory but doesn't if the directory already exists, which happens frequently if rust-analyzer is launched by your IDE before you can type `cargo build`. Hence, create the file manually here. => rust-lang/cargo#14281
1 parent 4e547e6 commit bb52299

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ CARGO_CMD_PREFIX += CARGO_TERM_PROGRESS_WHEN=never CI=1
6969
# Set PQ_LIB_DIR to make sure `storage_controller` get linked with bundled libpq (through diesel)
7070
CARGO_CMD_PREFIX += PQ_LIB_DIR=$(POSTGRES_INSTALL_DIR)/v16/lib
7171

72+
CACHEDIR_TAG_CONTENTS := "Signature: 8a477f597d28d172789f06886806bc55"
73+
7274
#
7375
# Top level Makefile to build Neon and PostgreSQL
7476
#
@@ -79,15 +81,24 @@ all: neon postgres neon-pg-ext
7981
#
8082
# The 'postgres_ffi' depends on the Postgres headers.
8183
.PHONY: neon
82-
neon: postgres-headers walproposer-lib
84+
neon: postgres-headers walproposer-lib cargo-target-dir
8385
+@echo "Compiling Neon"
8486
$(CARGO_CMD_PREFIX) cargo build $(CARGO_BUILD_FLAGS)
87+
.PHONY: cargo-target-dir
88+
cargo-target-dir:
89+
# https://github.com/rust-lang/cargo/issues/14281
90+
mkdir -p target
91+
test -e target/CACHEDIR.TAG || echo "$(CACHEDIR_TAG_CONTENTS)" > target/CACHEDIR.TAG
8592

8693
### PostgreSQL parts
8794
# Some rules are duplicated for Postgres v14 and 15. We may want to refactor
8895
# to avoid the duplication in the future, but it's tolerable for now.
8996
#
9097
$(POSTGRES_INSTALL_DIR)/build/%/config.status:
98+
99+
mkdir -p $(POSTGRES_INSTALL_DIR)
100+
test -e $(POSTGRES_INSTALL_DIR)/CACHEDIR.TAG || echo "$(CACHEDIR_TAG_CONTENTS)" > $(POSTGRES_INSTALL_DIR)/CACHEDIR.TAG
101+
91102
+@echo "Configuring Postgres $* build"
92103
@test -s $(ROOT_PROJECT_DIR)/vendor/postgres-$*/configure || { \
93104
echo "\nPostgres submodule not found in $(ROOT_PROJECT_DIR)/vendor/postgres-$*/, execute "; \

0 commit comments

Comments
 (0)