Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
e3-require
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Lindh Olsson
e3-require
Commits
87140744
Commit
87140744
authored
9 years ago
by
Dirk Zimoch
Browse files
Options
Downloads
Patches
Plain Diff
optimized EPICS_DB_INCLUDE_PATH setting
parent
b0f278af
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
require.c
+51
-18
51 additions, 18 deletions
require.c
with
51 additions
and
18 deletions
require.c
+
51
−
18
View file @
87140744
...
...
@@ -476,9 +476,6 @@ int require(const char* module, const char* version, const char* args)
registerExternalModules
();
}
if
(
getenv
(
"EPICS_DB_INCLUDE_PATH"
)
==
NULL
)
putenv
(
"EPICS_DB_INCLUDE_PATH=."
);
if
(
getenv
(
"T_A"
)
==
NULL
)
putenvprintf
(
"T_A=%s"
,
targetArch
);
...
...
@@ -1007,7 +1004,9 @@ loadlib:
/* load dbd file */
if
(
TRY_NONEMPTY_FILE
(
releasediroffs
,
"dbd"
DIRSEP
"%s%s.dbd"
,
module
,
versionstr
)
||
TRY_NONEMPTY_FILE
(
releasediroffs
,
"%s%s.dbd"
,
module
,
versionstr
))
TRY_NONEMPTY_FILE
(
releasediroffs
,
"%s%s.dbd"
,
module
,
versionstr
)
||
TRY_NONEMPTY_FILE
(
releasediroffs
,
".."
DIRSEP
"dbd"
DIRSEP
"%s%s.dbd"
,
module
,
versionstr
)
||
TRY_NONEMPTY_FILE
(
releasediroffs
,
".."
DIRSEP
"%s%s.dbd"
,
module
,
versionstr
))
{
printf
(
"Loading dbd file %s
\n
"
,
filename
);
if
(
dbLoadDatabase
(
filename
,
NULL
,
NULL
)
!=
0
)
...
...
@@ -1062,14 +1061,31 @@ loadlib:
if
(
requireDebug
)
printf
(
"require: looking for template directory
\n
"
);
/* filename = "<dirname>/[dirlen]<module>/<version>/R<epicsRelease>/[releasediroffs]..." */
if
(
TRY_FILE
(
releasediroffs
,
TEMPLATEDIR
))
if
(
TRY_FILE
(
releasediroffs
,
TEMPLATEDIR
)
||
TRY_FILE
(
releasediroffs
,
".."
DIRSEP
TEMPLATEDIR
))
{
char
*
old_path
;
char
*
p
;
char
*
q
;
size_t
len
;
#ifndef vxWorks
char
*
absdir
;
absdir
=
realpath
(
filename
,
NULL
);
/* so we can change directory later safely */
#else
/* vxWorks has no realpath() -- at least make directory absolute */
char
absdir
[
MAX_FILENAME_LENGTH
];
if
(
filename
[
0
]
!=
DIRSEP
[
0
])
{
getcwd
(
absdir
,
MAX_FILENAME_LENGTH
);
len
=
strlen
(
absdir
);
if
(
len
&&
absdir
[
len
-
1
]
!=
DIRSEP
[
0
])
absdir
[
len
++
]
=
DIRSEP
[
0
];
strcpy
(
absdir
+
len
,
filename
);
}
#endif
len
=
strlen
(
absdir
);
if
(
requireDebug
)
printf
(
"require: found template directory %s
\n
"
,
filename
);
printf
(
"require: found template directory %s
\n
"
,
absdir
);
/* set up db search path environment variables
<module>_TEMPLATES template path of <module>
...
...
@@ -1077,21 +1093,38 @@ loadlib:
EPICS_DB_INCLUDE_PATH template path of all loaded modules (appended)
*/
putenvprintf
(
"%s_TEMPLATES=%s"
,
module
,
filename
);
putenvprintf
(
"TEMPLATES=%s"
,
filename
);
putenvprintf
(
"%s_TEMPLATES=%s"
,
module
,
absdir
);
putenvprintf
(
"TEMPLATES=%s"
,
absdir
);
/* add directory to front of EPICS_DB_INCLUDE_PATH */
old_path
=
getenv
(
"EPICS_DB_INCLUDE_PATH"
);
if
(
loaded
)
/* Library was already loaded thus filename is already in path. Remove it. */
if
(
old_path
==
NULL
)
putenvprintf
(
"EPICS_DB_INCLUDE_PATH=%s"
,
absdir
);
else
{
p
=
strstr
(
old_path
,
filename
);
if
(
p
)
{
/* remove leading or trailing ':' */
q
=
p
+
releasediroffs
+
sizeof
(
TEMPLATEDIR
)
-
1
;
if
(
*
q
==
':'
)
q
++
;
else
if
(
p
!=
old_path
&&
*
(
p
-
1
)
==
':'
)
p
--
;
strcpy
(
p
,
q
);
/* If directory is already in path, move it to front. */
p
=
old_path
;
while
((
p
=
strstr
(
p
,
absdir
))
!=
NULL
)
{
/* /ioc/modules/sysmon/1.1.2/R3.14.12/db:/ioc/modules/mrfioc2/zimoch/R3.14.12/db */
if
(
p
==
old_path
)
break
;
/* already at front, nothing to do */
if
(
*
(
p
-
1
)
==
PATHSEP
[
0
]
&&
(
p
[
len
]
==
0
||
p
[
len
]
==
PATHSEP
[
0
]))
/* found pre:absdir or pre:absdir:post */
{
memmove
(
old_path
+
len
+
1
,
old_path
,
p
-
old_path
-
1
);
/* ....:[pre](:post) */
strcpy
(
old_path
,
absdir
);
old_path
[
len
]
=
PATHSEP
[
0
];
if
(
requireDebug
)
printf
(
"require: modified EPICS_DB_INCLUDE_PATH=%s
\n
"
,
old_path
);
break
;
}
p
+=
len
;
}
if
(
p
==
NULL
)
/* add new directory to the front */
putenvprintf
(
"EPICS_DB_INCLUDE_PATH=%s:%s"
,
absdir
,
old_path
);
}
putenvprintf
(
"EPICS_DB_INCLUDE_PATH=%s:%s"
,
filename
,
old_path
);
#ifndef vxWorks
free
(
absdir
);
#endif
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment