Experimental Physics and Industrial Control System
Subject: |
Re: [Merge] ~epics-core/epics-base/+git/make:rpath-origin into epics-base:7.0 |
From: |
Andrew Johnson via Core-talk <[email protected]> |
To: |
mdavidsaver <[email protected]> |
Date: |
Thu, 28 Mar 2019 21:38:39 -0000 |
Core group: See Notes below. ANJ to test on Solaris, and rewrite makeRPath into Perl.
Diff comments:
> diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE
> index b657f5b..49f82c7 100644
> --- a/configure/CONFIG_SITE
> +++ b/configure/CONFIG_SITE
> @@ -169,10 +169,17 @@ EPICS_SITE_VERSION =
> GCC_PIPE = NO
>
> # Set RPATH when linking executables and libraries.
> -# Must be either YES or NO. If you set this to NO you must also provide a
> +# Must be either YES, NO, or ORIGIN. If you set this to NO you must also provide a
> # way for Base executables to find their shared libraries when they are
> # run at build-time, e.g. set the LD_LIBRARY_PATH environment variable.
> +# ORIGIN is Linux specific.
Needs correcting
> LINKER_USE_RPATH = YES
>
> +# Only used when LINKER_USE_RPATH=ORIGIN
> +# The build time root of the relocatable tree.
> +# Linking to libraries under this root directory will be relative.
> +# Linking to libraries outside of this root will be absolute.
> +LINKER_ORIGIN_ROOT = $(INSTALL_LOCATION)
> +
> # Overrides for the settings above may appear in a CONFIG_SITE.local file
> -include $(CONFIG)/CONFIG_SITE.local
> diff --git a/modules/database/src/std/softIoc/softMain.cpp b/modules/database/src/std/softIoc/softMain.cpp
> index 8400a65..01ef19b 100644
> --- a/modules/database/src/std/softIoc/softMain.cpp
> +++ b/modules/database/src/std/softIoc/softMain.cpp
> @@ -62,23 +62,59 @@
> #include "epicsThread.h"
> #include "epicsExit.h"
> #include "epicsStdio.h"
> +#include "epicsString.h"
> #include "dbStaticLib.h"
> #include "subRecord.h"
> #include "dbAccess.h"
> #include "asDbLib.h"
> #include "iocInit.h"
> #include "iocsh.h"
> +#include "osiFileName.h"
> #include "epicsInstallDir.h"
>
> extern "C" int softIoc_registerRecordDeviceDriver(struct dbBase *pdbbase);
>
> -#define DBD_FILE EPICS_BASE "/dbd/softIoc.dbd"
> -#define EXIT_FILE EPICS_BASE "/db/softIocExit.db"
> +#define DBD_BASE "dbd/softIoc.dbd"
> +#define EXIT_BASE "db/softIocExit.db"
> +#define DBD_FILE_REL "../../" DBD_BASE
> +#define EXIT_FILE_REL "../../" EXIT_BASE
> +#define DBD_FILE EPICS_BASE "/" DBD_BASE
> +#define EXIT_FILE EPICS_BASE "/" EXIT_BASE
>
> const char *arg0;
> const char *base_dbd = DBD_FILE;
> const char *exit_db = EXIT_FILE;
>
> +static void preparePath(void)
Make it simpler (refactor, remember C++ and similar usage in softIocPVA)
> +{
> + FILE *fp;
> + char *prefix = epicsGetExecDir();
> + char *dbd, *exit;
> + if(!prefix) return;
> +
> + dbd = (char*)malloc(strlen(prefix) + strlen(DBD_FILE_REL) + 1);
> + if(dbd) {
> + dbd[0] = '\0';
> + strcat(dbd, prefix);
> + strcat(dbd, DBD_FILE_REL);
> + printf("Testing '%s'\n", dbd);
Remove printf?
> + if((fp = fopen(dbd, "rb"))!=NULL) {
> + fclose(fp);
> + base_dbd = dbd;
> + }
> + }
> +
> + exit = (char*)malloc(strlen(prefix) + strlen(EXIT_FILE_REL) + 1);
> + if(exit) {
> + exit[0] = '\0';
> + strcat(exit, prefix);
> + strcat(exit, EXIT_FILE_REL);
> + if((fp = fopen(exit, "rb"))!=NULL) {
> + fclose(fp);
> + exit_db = exit;
> + }
> + }
> +}
>
> static void exitSubroutine(subRecord *precord) {
> epicsExitLater((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE);
> diff --git a/modules/libcom/src/osi/Makefile b/modules/libcom/src/osi/Makefile
> index ecbf4c2..0352e9f 100644
> --- a/modules/libcom/src/osi/Makefile
> +++ b/modules/libcom/src/osi/Makefile
> @@ -123,6 +123,7 @@ Com_SRCS += osdMonotonic.c
> Com_SRCS += osdProcess.c
> Com_SRCS += osdNetIntf.c
> Com_SRCS += osdMessageQueue.c
> +Com_SRCS += osdgetexec.c
CamelCaseNames?
>
> Com_SRCS += devLibVME.c
> Com_SRCS += devLibVMEOSD.c
> diff --git a/modules/libcom/src/osi/os/Darwin/osdgetexec.c b/modules/libcom/src/osi/os/Darwin/osdgetexec.c
> new file mode 100644
> index 0000000..4e4961c
> --- /dev/null
> +++ b/modules/libcom/src/osi/os/Darwin/osdgetexec.c
> @@ -0,0 +1,50 @@
> +
> +#include <string.h>
> +#include <stdlib.h>
> +
> +#include <mach-o/dyld.h>
> +
> +#define epicsExportSharedSymbols
> +#include <osiFileName.h>
> +
> +char *epicsGetExecName(void)
> +{
> + uint32_t max = 64u;
> + char *ret = NULL;
> +
> + while(1) {
> + char *temp = realloc(ret, max);
> + if(!temp) {
> + /* we treat alloc failure as terminal */
> + free(ret);
> + ret = NULL;
> + break;
> + }
> + ret = temp;
> +
> + /* cf. "man 3 dyld" */
> + if(_NSGetExecutablePath(ret, &max)==0) {
> + /* max left unchanged */
> + ret[max-1] = '\0';
> + break;
> + }
> + /* max has been updated with required size */
> + }
> +
> + /* TODO: _NSGetExecutablePath() doesn't follow symlinks */
Not a TODO, just a remark.
> +
> + return ret;
> +}
> +
> +char *epicsGetExecDir(void)
> +{
> + char *ret = epicsGetExecName();
> + if(ret) {
> + char *sep = strrchr(ret, '/');
> + if(sep) {
> + /* nil the charactor after the / */
> + sep[1] = '\0';
> + }
> + }
> + return ret;
> +}
> diff --git a/modules/libcom/test/testexecname.c b/modules/libcom/test/testexecname.c
> new file mode 100644
> index 0000000..87be847
> --- /dev/null
> +++ b/modules/libcom/test/testexecname.c
> @@ -0,0 +1,24 @@
> +
> +#include <string.h>
> +
> +#include <epicsUnitTest.h>
> +#include <testMain.h>
> +
> +#include <osiFileName.h>
> +
> +MAIN(testexecname)
> +{
> + testPlan(1);
> +
> + {
> + char *buf = epicsGetExecName();
> + if(!buf) {
> + testSkip(1, "epicsGetExecName() not available for this target");
> + } else {
> + char *loc = strstr(buf, "testexecname");
> + testOk(!!loc, "Find \"testexecname\" in \"%s\"", buf);
> + }
> + }
> +
Test epicsGetExecDir()?
> + return testDone();
> +}
> diff --git a/src/tools/Makefile b/src/tools/Makefile
> index 0df1797..0d0c011 100644
> --- a/src/tools/Makefile
> +++ b/src/tools/Makefile
> @@ -39,6 +39,8 @@ PERL_SCRIPTS += tap-to-junit-xml.pl
> PERL_SCRIPTS += useManifestTool.pl
> PERL_SCRIPTS += genVersionHeader.pl
>
> +PERL_SCRIPTS += makeRPath.py
!!
Needs fixing (ANJ)
> +
> HTMLS = style.css
> HTMLS += EPICS/Getopts.html
> HTMLS += EPICS/Path.html
--
https://code.launchpad.net/~epics-core/epics-base/+git/make/+merge/359132
Your team EPICS Core Developers is requested to review the proposed merge of ~epics-core/epics-base/+git/make:rpath-origin into epics-base:7.0.
- Navigate by Date:
- Prev:
Re: [Merge] ~epics-core/epics-base/+git/Com:timeopt into epics-base:7.0 Andrew Johnson via Core-talk
- Next:
Re: [Merge] ~info-martin-konrad/epics-base:clean-up-msi into epics-base:3.15 Andrew Johnson via Core-talk
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
<2019>
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: [Merge] ~epics-core/epics-base/+git/Com:timeopt into epics-base:7.0 mdavidsaver via Core-talk
- Next:
Re: [Merge] ~epics-core/epics-base/+git/make:rpath-origin into epics-base:7.0 mdavidsaver via Core-talk
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
<2019>
2020
2021
2022
2023
2024