Skip to content

Commit

Permalink
Refs #19388. Fix including a dependant IDL without structures
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware committed Aug 22, 2023
1 parent 0db2977 commit 8780033
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ $endif$

$definitions; separator="\n"$

$if(ctx.thereIsStructOrUnion)$
#include "$ctx.filename$CdrAux.ipp"
$endif$
>>

module(ctx, parent, module, definition_list) ::= <<
Expand Down
53 changes: 26 additions & 27 deletions src/main/java/com/eprosima/fastdds/fastddsgen.java
Original file line number Diff line number Diff line change
Expand Up @@ -842,40 +842,39 @@ private Project parseIDL(
}
}

System.out.println("Generating TopicDataTypes files...");
if (ctx.isThereIsStructOrUnion())
{
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "CdrAux.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeader.stg"), m_replace))
{
returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "CdrAux.ipp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg"), m_replace);
}
}
returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.h",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg"), m_replace);
if (ctx.existsLastStructure())
{
m_atLeastOneStructure = true;
project.setHasStruct(true);

System.out.println("Generating TopicDataTypes files...");
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + "CdrAux.hpp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeader.stg"), m_replace))
if (returnedValue &=
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSource.stg"), m_replace))
{
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + "CdrAux.ipp",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg"), m_replace))
project.addProjectIncludeFile(relative_dir + ctx.getFilename() + "CdrAux.hpp");
project.addProjectIncludeFile(relative_dir + ctx.getFilename() + "PubSubTypes.h");
project.addProjectSrcFile(relative_dir + ctx.getFilename() + "PubSubTypes.cxx");
if (m_python)
{
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.h",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeHeader.stg"), m_replace))
{
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + "PubSubTypes.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSource.stg"), m_replace))
{
project.addProjectIncludeFile(relative_dir + ctx.getFilename() + "CdrAux.hpp");
project.addProjectIncludeFile(relative_dir + ctx.getFilename() + "PubSubTypes.h");
project.addProjectSrcFile(relative_dir + ctx.getFilename() + "PubSubTypes.cxx");
if (m_python)
{
System.out.println("Generating Swig interface files...");
returnedValue = Utils.writeFile(
output_dir + ctx.getFilename() + "PubSubTypes.i",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSwigInterface.stg"), m_replace);
}
}
}
System.out.println("Generating Swig interface files...");
returnedValue &= Utils.writeFile(
output_dir + ctx.getFilename() + "PubSubTypes.i",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/DDSPubSubTypeSwigInterface.stg"), m_replace);
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/eprosima/fastdds/idl/grammar/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,20 @@ else if (content.getKind() == Kind.KIND_MAP)
typecodes.add(new SimpleEntry<String, TypeCode>(sequence.getCppTypename(), sequence));
}

public boolean isThereIsStructOrUnion()
{
for (TypeDeclaration type : m_types.values())
{
if (type.getTypeCode() instanceof StructTypeCode ||
type.getTypeCode() instanceof UnionTypeCode)
{
return true;
}
}

return false;
}

/*** Functions inherited from FastCDR Context ***/

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ message(STATUS "Configuring $project.name$...")
add_library($project.name$_lib $project.commonSrcFiles : { file | $file$}; separator=" "$)
target_link_libraries($project.name$_lib $solution.libraries : { library | $library$}; separator=" "$)

$if(!project.projectSrcFiles.empty)$
add_executable($project.name$ $project.projectSrcFiles : { file | $file$}; separator=" "$)
target_link_libraries($project.name$ $solution.libraries : { library | $library$}; separator=" "$
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$)

$endif$

$if(test)$
# $project.name$ Serialization Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ $fileHeader(ctx=ctx, file=[ctx.filename, "CdrAux.ipp"], description=["This sourc
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$CDRAUX_IPP_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$CDRAUX_IPP_

$ctx.directIncludeDependencies : {include | #include "$include$CdrAux.hpp"}; separator="\n"$
#include "$ctx.filename$CdrAux.hpp"

$if(ctx.cdr)$
Expand Down

0 comments on commit 8780033

Please sign in to comment.