Skip to content

Instantly share code, notes, and snippets.

@daykin
Created March 30, 2022 16:03
Show Gist options
  • Save daykin/17096beda59efa566e79c516da662aae to your computer and use it in GitHub Desktop.
Save daykin/17096beda59efa566e79c516da662aae to your computer and use it in GitHub Desktop.
Patch allows relative path for softIoc to be overriden (current behavior by default)
Index: epics-base/configure/CONFIG_SITE
===================================================================
--- epics-base.orig/configure/CONFIG_SITE
+++ epics-base/configure/CONFIG_SITE
@@ -178,5 +178,8 @@ LINKER_USE_RPATH = YES
# All root directories are considered to be the same.
LINKER_ORIGIN_ROOT = $(INSTALL_LOCATION)
+# Compile in absolute path to softIoc.dbd as default, instead of relative
+ABSOLUTE_DBD = NO
+
# Overrides for the settings above may appear in a CONFIG_SITE.local file
-include $(CONFIG)/CONFIG_SITE.local
Index: epics-base/modules/database/src/std/softIoc/RULES
===================================================================
--- epics-base.orig/modules/database/src/std/softIoc/RULES
+++ epics-base/modules/database/src/std/softIoc/RULES
@@ -19,5 +19,5 @@ softMain$(DEP): epicsInstallDir.h
epicsInstallDir.h: $(TOP)/configure/CONFIG_SITE*
$(ECHO) "FINAL_LOCATION=$(FINAL_LOCATION)"
- $(PERL) $(STDDIR)/softIoc/makeInstallDir.pl "$(FINAL_LOCATION)" > $@
+ $(PERL) $(STDDIR)/softIoc/makeInstallDir.pl "$(FINAL_LOCATION)" "$(ABSOLUTE_DBD)" > $@
Index: epics-base/modules/database/src/std/softIoc/makeInstallDir.pl
===================================================================
--- epics-base.orig/modules/database/src/std/softIoc/makeInstallDir.pl
+++ epics-base/modules/database/src/std/softIoc/makeInstallDir.pl
@@ -10,19 +10,34 @@
use strict;
die "$0: Argument missing, INSTALL_LOCATION\n" if @ARGV == 0;
-die "$0: Too many arguments, expecting one\n" unless @ARGV == 1;
+die "$0: Too many arguments, expecting one or two\n" unless @ARGV <= 2;
my $path = shift;
+my $abs = "";
+$abs = shift unless @ARGV==0;
$path =~ s/\\/\\\\/gx;
$path =~ s/^'//;
$path =~ s/'$//;
-print "/* THIS IS A GENERATED FILE. DO NOT EDIT! */\n",
- "\n",
- "#ifndef INC_epicsInstallDir_H\n",
- "#define INC_epicsInstallDir_H\n",
- "\n",
- "#define EPICS_BASE \"$path\"\n",
- "\n",
- "#endif /* INC_epicsInstallDir_H */\n";
+if($abs eq "YES" ) {
+ print "/* THIS IS A GENERATED FILE. DO NOT EDIT! */\n",
+ "\n",
+ "#ifndef INC_epicsInstallDir_H\n",
+ "#define INC_epicsInstallDir_H\n",
+ "\n",
+ "#define EPICS_BASE \"$path\"\n",
+ "#define ABSOLUTE_DBD \"YES\"\n",
+ "\n",
+ "#endif /* INC_epicsInstallDir_H */\n";
+}
+else {
+ print "/* THIS IS A GENERATED FILE. DO NOT EDIT! */\n",
+ "\n",
+ "#ifndef INC_epicsInstallDir_H\n",
+ "#define INC_epicsInstallDir_H\n",
+ "\n",
+ "#define EPICS_BASE \"$path\"\n",
+ "\n",
+ "#endif /* INC_epicsInstallDir_H */\n";
+}
\ No newline at end of file
Index: epics-base/modules/database/src/std/softIoc/softMain.cpp
===================================================================
--- epics-base.orig/modules/database/src/std/softIoc/softMain.cpp
+++ epics-base/modules/database/src/std/softIoc/softMain.cpp
@@ -12,6 +12,7 @@
#include <iostream>
#include <string>
+#include <cstring>
#include <list>
#include <stdexcept>
@@ -38,6 +39,10 @@ extern "C" int softIoc_registerRecordDev
# error -DEPICS_BASE required
#endif
+#ifndef ABSOLUTE_DBD
+# define ABSOLUTE_DBD "NO"
+#endif
+
#define DBD_BASE "dbd" OSI_PATH_SEPARATOR "softIoc.dbd"
#define EXIT_BASE "db" OSI_PATH_SEPARATOR "softIocExit.db"
#define DBD_FILE_REL ".." OSI_PATH_SEPARATOR ".." OSI_PATH_SEPARATOR DBD_BASE
@@ -125,6 +130,8 @@ int main(int argc, char *argv[])
try {
std::string dbd_file(DBD_FILE),
exit_file(EXIT_FILE),
+ absolute_dbd(ABSOLUTE_DBD),
+ epics_base(EPICS_BASE),
macros, // scratch space for macros (may be given more than once)
xmacro;
bool interactive = true;
@@ -134,19 +141,30 @@ int main(int argc, char *argv[])
// attempt to compute relative paths
{
std::string prefix;
- char *cprefix = epicsGetExecDir();
- if(cprefix) {
- try {
- prefix = cprefix;
- free(cprefix);
- } catch(...) {
- free(cprefix);
- throw;
+ if(absolute_dbd == "YES"){
+ prefix = epics_base;
+ }
+ else{
+ char *cprefix = epicsGetExecDir();
+ if(cprefix) {
+ try {
+ prefix = cprefix;
+ free(cprefix);
+ } catch(...) {
+ free(cprefix);
+ throw;
+ }
}
}
+ if(absolute_dbd == "YES"){
+ dbd_file = prefix + OSI_PATH_SEPARATOR + DBD_BASE;
+ exit_file = prefix + OSI_PATH_SEPARATOR + EXIT_BASE;
- dbd_file = prefix + DBD_FILE_REL;
- exit_file = prefix + EXIT_FILE_REL;
+ }
+ else{
+ dbd_file = prefix + DBD_FILE_REL;
+ exit_file = prefix + EXIT_FILE_REL;
+ }
}
int opt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment