Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Hofmann
RobotAPI
Commits
3a5222b2
Commit
3a5222b2
authored
1 year ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Handle ARON includes to packages with namespace
parent
e7cc26cb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Reader.cpp
+76
-11
76 additions, 11 deletions
...I/libraries/aron/codegeneration/typereader/xml/Reader.cpp
with
76 additions
and
11 deletions
source/RobotAPI/libraries/aron/codegeneration/typereader/xml/Reader.cpp
+
76
−
11
View file @
3a5222b2
...
...
@@ -42,12 +42,13 @@ namespace armarx::aron::typereader::xml
{
/// Resolve a relative package path
std
::
optional
<
fs
::
path
>
resolveRelativePackagePath
(
const
fs
::
path
&
path
,
const
std
::
vector
<
fs
::
path
>&
includePaths
)
resolveRelativePackagePath
(
const
fs
::
path
&
filepath
,
const
std
::
vector
<
fs
::
path
>&
includePaths
)
{
// new behavior: using provided include paths
for
(
const
auto
&
includePath
:
includePaths
)
{
fs
::
path
absPath
=
includePath
/
path
;
fs
::
path
absPath
=
includePath
/
file
path
;
if
(
fs
::
is_regular_file
(
absPath
))
{
// path is valid
...
...
@@ -56,20 +57,80 @@ namespace armarx::aron::typereader::xml
}
// legacy behavior: using cmake package finder paths
const
std
::
string
package
=
*
path
.
begin
();
armarx
::
CMakePackageFinder
finder
(
package
);
if
(
finder
.
packageFound
())
std
::
vector
<
std
::
string
>
packageNameCandidates
;
{
auto
it
=
filepath
.
begin
();
std
::
string
packageName
=
*
it
;
packageNameCandidates
.
push_back
(
packageName
);
++
it
;
if
(
it
!=
filepath
.
end
())
{
packageName
+=
"_"
+
it
->
string
();
packageNameCandidates
.
push_back
(
packageName
);
}
}
std
::
vector
<
armarx
::
CMakePackageFinder
>
finders
;
size_t
foundFinderIndex
=
0
;
size_t
numberOfFoundCandidates
=
0
;
for
(
const
std
::
string
&
packageName
:
packageNameCandidates
)
{
for
(
const
std
::
string
&
includePath
:
finder
.
getIncludePathList
())
armarx
::
CMakePackageFinder
&
finder
=
finders
.
emplace_back
(
packageName
);
if
(
finder
.
packageFound
())
{
fs
::
path
absPath
=
includePath
/
path
;
if
(
fs
::
is_regular_file
(
absPath
))
// TODO: In theory, we could also consider whether the requested file exists in
// the found package (see check below).
numberOfFoundCandidates
++
;
foundFinderIndex
=
finders
.
size
()
-
1
;
}
}
if
(
numberOfFoundCandidates
==
0
)
{
std
::
stringstream
msg
;
msg
<<
"No package matching the ARON include "
<<
filepath
<<
" found. Tried CMake project names:"
;
for
(
const
std
::
string
&
packageName
:
packageNameCandidates
)
{
msg
<<
" '"
<<
packageName
<<
"',"
;
}
throw
error
::
AronException
(
__PRETTY_FUNCTION__
,
msg
.
str
());
}
if
(
numberOfFoundCandidates
>
1
)
{
std
::
stringstream
msg
;
msg
<<
"The ARON include "
<<
filepath
<<
" is ambiguous: The following "
<<
numberOfFoundCandidates
<<
" CMake projects matching the include were found:"
;
ARMARX_CHECK_EQUAL
(
packageNameCandidates
.
size
(),
finders
.
size
());
for
(
size_t
i
=
0
;
i
<
packageNameCandidates
.
size
();
++
i
)
{
if
(
finders
[
i
].
packageFound
())
{
// path is valid
return
absPath
;
msg
<<
"
\n
- project '"
<<
packageNameCandidates
[
i
]
<<
"' at '"
<<
finders
[
i
].
getPackageDir
()
<<
"'"
;
}
}
return
std
::
nullopt
;
throw
error
::
AronException
(
__PRETTY_FUNCTION__
,
msg
.
str
());
}
ARMARX_CHECK_EQUAL
(
numberOfFoundCandidates
,
1
);
ARMARX_CHECK_LESS
(
foundFinderIndex
,
finders
.
size
());
CMakePackageFinder
&
finder
=
finders
.
at
(
foundFinderIndex
);
ARMARX_CHECK
(
finder
.
packageFound
());
for
(
const
std
::
string
&
includePath
:
finder
.
getIncludePathList
())
{
fs
::
path
absPath
=
includePath
/
filepath
;
if
(
fs
::
is_regular_file
(
absPath
))
{
// path is valid
return
absPath
;
}
}
return
std
::
nullopt
;
...
...
@@ -138,7 +199,9 @@ namespace armarx::aron::typereader::xml
{
auto
i
=
readCodeInclude
(
include
,
filePath
.
parent_path
(),
includePaths
);
if
(
not
i
.
empty
())
{
this
->
systemIncludes
.
push_back
(
i
);
}
}
}
...
...
@@ -149,7 +212,9 @@ namespace armarx::aron::typereader::xml
{
auto
i
=
readAronInclude
(
include
,
filePath
.
parent_path
(),
includePaths
);
if
(
not
i
.
empty
())
{
this
->
aronIncludes
.
push_back
(
i
);
}
}
}
...
...
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