From cec29ecb158c021d36a90012c2ccf78f9de8e4fb Mon Sep 17 00:00:00 2001 From: Simon Rose Date: Mon, 12 Feb 2024 10:11:09 +0100 Subject: [PATCH] Fix issue where VSCode makefile extension can delete files The problem is that VSCode's make extension, in order to determine some information about the project, runs ``` make --dry-run --always-make ``` which despite its name will actually try to remake the configure/* files. Running `installEpics.pl` on these will delete them first, then try copy them, resulting in an error. --- configure/RULES_BUILD | 4 ++-- src/tools/installEpics.pl | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD index 869fba17e9..0553263b3c 100644 --- a/configure/RULES_BUILD +++ b/configure/RULES_BUILD @@ -532,11 +532,11 @@ endif # LOADABLE_SHRLIB_SUFFIX ifneq ($(INSTALL_CONFIGS),) $(INSTALL_CONFIG)/%: % $(ECHO) "Installing config file $@" - @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) + @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $(abspath $<) $(abspath $(@D)) $(INSTALL_CONFIG)/%: ../% $(ECHO) "Installing config file $@" - @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) + @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $(abspath $<) $(abspath $(@D)) endif $(INSTALL_INCLUDE)/%: $(COMMON_DIR)/% diff --git a/src/tools/installEpics.pl b/src/tools/installEpics.pl index 6cd06e8018..c41cc6f911 100644 --- a/src/tools/installEpics.pl +++ b/src/tools/installEpics.pl @@ -57,6 +57,9 @@ my $temp = "$install_dir/TEMP.$name.$$"; my $target = "$install_dir/$name"; + # Don't try to install the file if it already exists + next if $source eq $target; + if (-f $target) { next if -M $target < -M $source and -C $target < -C $source; # Remove old target, making sure it is deletable first