Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove -cdr argument and support of Fast CDR v1 (#265)
Browse files Browse the repository at this point in the history
* Refs #19971. Remove -cdr argument

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #19971. Update submodule

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

---------

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
richiware committed Apr 8, 2024
1 parent 2e9279b commit 6381c84
Showing 14 changed files with 34 additions and 3,436 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/reusable-ubuntu-ci.yaml
Original file line number Diff line number Diff line change
@@ -122,15 +122,7 @@ jobs:
cmake --version
colcon build --event-handlers=console_direct+ --mixin rel-with-deb-info ccache --metas src/fastddsgen/.github/fastddsgen.meta
- name: Test fastddsgen with fastcdr v1
if: startsWith(inputs.fastcdr_branch, '1')
run: |
source install/local_setup.bash
cd src/fastddsgen
./gradlew test -Dcdr_version=v1 -Dblacklist_tests=external,optional
- name: Test fastddsgen with fastcdr v2
if: ${{ ! startsWith(inputs.fastcdr_branch, '1') }}
- name: Test fastddsgen
run: |
source install/local_setup.bash
cd src/fastddsgen
7 changes: 3 additions & 4 deletions .github/workflows/ubuntu-ci.yaml
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ on:
description: 'foonathan_memory_vendor branch to be used'
required: true
type: string
fastcdr_version:
description: 'Fast CDR branches to be used. Enclose the branch names like ["1.1.x", "master"], then in single quotes'
fastcdr_branch:
description: 'Fast CDR branches to be used'
required: true
type: string
fastdds_branch:
@@ -40,14 +40,13 @@ jobs:
java_version:
- 'openjdk-11-jdk'
- 'openjdk-19-jdk'
fastcdr_version: ${{ fromJson(inputs.fastcdr_version || '["master"]') }}

uses: ./.github/workflows/reusable-ubuntu-ci.yaml
with:
os_image: ${{ matrix.os_image }}
java_version: ${{ matrix.java_version }}
foonathan_memory_vendor_branch: ${{ inputs.foonathan_memory_vendor_branch || 'master' }}
fastcdr_branch: ${{ matrix.fastcdr_version }}
fastcdr_branch: ${{ inputs.fastcdr_branch || 'master' }}
fastdds_branch: ${{ inputs.fastdds_branch || github.head_ref }}
fastdds_python_branch: ${{ inputs.fastdds_python_branch || '3.0.x-devel' }}
fastddsgen_branch: ${{ inputs.fastddsgen_branch || github.ref || '4.0.x-devel' }}
12 changes: 0 additions & 12 deletions src/main/java/com/eprosima/fastcdr/idl/context/Context.java
Original file line number Diff line number Diff line change
@@ -47,17 +47,5 @@ public interface Context

public boolean isFastcdr();

public boolean isCdr_v1();

public boolean isCdr_v2();

public boolean isCdr_both();

public void isSetCdrv1Templates();

public void isUnsetCdrv1Templates();

public boolean isCdrv1TemplatesEnabled();

/*** End ***/
}
10 changes: 0 additions & 10 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg
Original file line number Diff line number Diff line change
@@ -20,13 +20,6 @@ import "FastCdrCommon.stg"
main(ctx, definitions) ::= <<
$fileHeader(ctx=ctx, file=[ctx.filename, ".h"], description=["This header file contains the declaration of the described types in the IDL file."])$

$if(ctx.cdr_both)$
#include <fastcdr/config.h>
#include "$ctx.filename$v1.h"

#if FASTCDR_VERSION_MAJOR > 1
$endif$

#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$_H_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$_H_

@@ -105,9 +98,6 @@ $definitions; separator="\n"$
#endif // _FAST_DDS_GENERATED_$ctx.headerGuardName$_H_
$"\n"$

$if(ctx.cdr_both)$
#endif // FASTCDR_VERSION_MAJOR > 1
$endif$
>>

module(ctx, parent, module, definition_list) ::= <<
921 changes: 0 additions & 921 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg

This file was deleted.

Original file line number Diff line number Diff line change
@@ -29,10 +29,6 @@ char dummy;

#include "$ctx.filename$.h"

$if(ctx.cdr_both)$
#if FASTCDR_VERSION_MAJOR > 1
$endif$

$if(ctx.generateTypeObject)$
#include "$ctx.filename$TypeObject.h"
$endif$
@@ -64,9 +60,6 @@ $if(ctx.thereIsStructOrUnion)$
#include "$ctx.filename$CdrAux.ipp"
$endif$

$if(ctx.cdr_both)$
#endif // FASTCDR_VERSION_MAJOR > 1
$endif$
>>

module(ctx, parent, module, definition_list) ::= <<
2,294 changes: 0 additions & 2,294 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg

This file was deleted.

Original file line number Diff line number Diff line change
@@ -67,9 +67,6 @@ $definitions; separator="\n"$

// Include the class interfaces
%include "$ctx.filename$.h"
$if(ctx.cdr_both)$
%include "$ctx.filename$v1.h"
$endif$

// Include the corresponding TopicDataType
%include "$ctx.filename$PubSubTypes.i"
15 changes: 0 additions & 15 deletions src/main/java/com/eprosima/fastcdr/idl/util/CdrVersion.java

This file was deleted.

115 changes: 28 additions & 87 deletions src/main/java/com/eprosima/fastdds/fastddsgen.java
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
package com.eprosima.fastdds;

import com.eprosima.fastcdr.idl.generator.TypesGenerator;
import com.eprosima.fastcdr.idl.util.CdrVersion;
import com.eprosima.fastdds.exceptions.BadArgumentException;
import com.eprosima.fastdds.idl.grammar.Context;
import com.eprosima.fastdds.solution.Project;
@@ -137,8 +136,6 @@ public enum LANGUAGE

private LANGUAGE m_languageOption = LANGUAGE.CPP; // Default language -> CPP

private CdrVersion.Select cdr_version_ = CdrVersion.Select.V2;

/*
* ----------------------------------------------------------------------------------------
*
@@ -167,33 +164,6 @@ public fastddsgen(
{
m_idlFiles.add(arg);
}
else if (arg.equals("-cdr"))
{
if (count < args.length)
{
String cdr_version_str = args[count++];
if (cdr_version_str.equals(CdrVersion.v1_str))
{
cdr_version_ = CdrVersion.Select.V1;
}
else if (cdr_version_str.equals(CdrVersion.v2_str))
{
cdr_version_ = CdrVersion.Select.V2;
}
else if (cdr_version_str.equals(CdrVersion.both_str))
{
cdr_version_ = CdrVersion.Select.BOTH;
}
else
{
throw new BadArgumentException("CDR version value " + cdr_version_str + " is not valid");
}
}
else
{
throw new BadArgumentException("No CDR version value after -cdr argument");
}
}
else if (arg.equals("-cs"))
{
m_case_sensitive = true;
@@ -564,11 +534,6 @@ public static void printHelp()
System.out.println(m_appName + " usage:");
System.out.println("\t" + m_appName + " [options] <file> [<file> ...]");
System.out.println("\twhere the options are:");
System.out.println("\t\t-cdr <version>: sets the CDR version used to generate types source code.");
System.out.println("\t\t Values:");
System.out.println("\t\t\t* " + CdrVersion.v1_str);
System.out.println("\t\t\t* " + CdrVersion.v2_str + " (default)");
System.out.println("\t\t\t* " + CdrVersion.both_str);
System.out.println("\t\t-cs: IDL grammar apply case sensitive matching.");
System.out.println("\t\t-d <path>: sets an output directory for generated files.");
System.out.print("\t\t-default_extensibility | -de <ext>: sets the default extensibility for types without");
@@ -687,7 +652,7 @@ private Project parseIDL(
TemplateManager tmanager = new TemplateManager();

Context ctx = new Context(tmanager, idlFilename, m_includePaths, m_subscribercode, m_publishercode,
m_localAppProduct, m_type_object_files, m_typesc, m_type_ros2, cdr_version_, gen_api_);
m_localAppProduct, m_type_object_files, m_typesc, m_type_ros2, gen_api_);

String relative_dir = ctx.getRelativeDir(dependant_idl_dir);
String output_dir;
@@ -724,21 +689,14 @@ private Project parseIDL(
}

// Load common types template
if(CdrVersion.Select.V1 != cdr_version_)
{
tmanager.addGroup("com/eprosima/fastcdr/idl/templates/TypesHeader.stg");
tmanager.addGroup("com/eprosima/fastcdr/idl/templates/TypesSource.stg");
}
if(CdrVersion.Select.V2 != cdr_version_)
{
tmanager.addGroup("com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg");
tmanager.addGroup("com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg");
}
tmanager.addGroup("com/eprosima/fastcdr/idl/templates/TypesHeader.stg");
tmanager.addGroup("com/eprosima/fastcdr/idl/templates/TypesSource.stg");
if (m_type_object_files)
{
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypeObjectHeader.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypeObjectSource.stg");
}

// Load Types common templates
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeader.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypesCdrAuxHeaderImpl.stg");
@@ -863,55 +821,38 @@ private Project parseIDL(

System.out.println("Generating Type definition files...");
if ((returnedValue) &&
(CdrVersion.Select.V1 == cdr_version_ || (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + ".h",
(returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + ".h",
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesHeader.stg"),
m_replace))))
m_replace)))
{
if (CdrVersion.Select.V2 == cdr_version_ || (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + (CdrVersion.Select.BOTH == cdr_version_ ? "v1" : "") + ".h",
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg"), m_replace)))
if (returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + ".cxx",
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesSource.stg"), m_replace))
{
if (CdrVersion.Select.V1 == cdr_version_ || (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + ".cxx",
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesSource.stg"), m_replace)))
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + ".h");
project.addCommonSrcFile(relative_dir + ctx.getFilename() + ".cxx");

if (m_type_object_files)
{
if (CdrVersion.Select.V2 == cdr_version_ || (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + (CdrVersion.Select.BOTH == cdr_version_ ? "v1" : "") + ".cxx",
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg"), m_replace)))
System.out.println("Generating TypeObject files...");
if (returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + "TypeObject.h",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectHeader.stg"), m_replace))
{
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + ".h");
project.addCommonSrcFile(relative_dir + ctx.getFilename() + ".cxx");
if (CdrVersion.Select.BOTH == cdr_version_)
{
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "v1.h");
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "v1.cxx");
}

if (m_type_object_files)
if (returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + "TypeObject.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectSource.stg"), m_replace))
{
System.out.println("Generating TypeObject files...");
if (returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + "TypeObject.h",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectHeader.stg"), m_replace))
{
if (returnedValue = Utils.writeFile(output_dir + ctx.getFilename() + "TypeObject.cxx",
maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectSource.stg"), m_replace))
{
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "TypeObject.h");
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "TypeObject.cxx");
}
}
project.addCommonIncludeFile(relative_dir + ctx.getFilename() + "TypeObject.h");
project.addCommonSrcFile(relative_dir + ctx.getFilename() + "TypeObject.cxx");
}
if (m_python)
{
System.out.println("Generating Swig interface files...");
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + ".i",
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg"), m_replace))
{
}
}
if (m_python)
{
System.out.println("Generating Swig interface files...");
if (returnedValue =
Utils.writeFile(output_dir + ctx.getFilename() + ".i",
maintemplates.getTemplate("com/eprosima/fastcdr/idl/templates/TypesSwigInterface.stg"), m_replace))
{

}
}
}
}
}
41 changes: 0 additions & 41 deletions src/main/java/com/eprosima/fastdds/idl/grammar/Context.java
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@

package com.eprosima.fastdds.idl.grammar;

import com.eprosima.fastcdr.idl.util.CdrVersion;
import com.eprosima.fastdds.idl.parser.typecode.AliasTypeCode;
import com.eprosima.fastdds.idl.parser.typecode.ArrayTypeCode;
import com.eprosima.fastdds.idl.parser.typecode.BitmaskTypeCode;
@@ -65,7 +64,6 @@ public Context(
boolean generate_type_object,
boolean generate_typesc,
boolean generate_type_ros2,
CdrVersion.Select cdr_version,
boolean is_generating_api
)
{
@@ -82,7 +80,6 @@ public Context(

m_type_object = generate_type_object;
m_type_ros2 = generate_type_ros2;
cdr_version_ = cdr_version;
is_generating_api_ = is_generating_api;

// Create default @Key annotation.
@@ -599,42 +596,6 @@ public String getJniFilename()
return getFilename().replace("_", "_1");
}

@Override
public boolean isCdr_v1()
{
return CdrVersion.Select.V2 != cdr_version_;
}

@Override
public boolean isCdr_v2()
{
return CdrVersion.Select.V1 != cdr_version_;
}

@Override
public boolean isCdr_both()
{
return CdrVersion.Select.BOTH == cdr_version_;
}

@Override
public void isSetCdrv1Templates()
{
cdr_v1_templates = true;
}

@Override
public void isUnsetCdrv1Templates()
{
cdr_v1_templates = false;
}

@Override
public boolean isCdrv1TemplatesEnabled()
{
return cdr_v1_templates;
}

@Override
public TypeCode getTypeCode(
String name)
@@ -665,8 +626,6 @@ public TypeCode getTypeCode(
private boolean activateFusion_ = false;
//// End Java block

private CdrVersion.Select cdr_version_ = CdrVersion.Select.V2;

private boolean cdr_v1_templates = false;

private boolean is_generating_api_ = false;
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ public long maxPlainTypeSerializedSize(
break;
case com.eprosima.idl.parser.typecode.Kind.KIND_SHORT:
case com.eprosima.idl.parser.typecode.Kind.KIND_USHORT:
case com.eprosima.idl.parser.typecode.Kind.KIND_WCHAR:
current_alignment += 2 + TypeCode.cdr_alignment(current_alignment, 2);
break;
case com.eprosima.idl.parser.typecode.Kind.KIND_BOOLEAN:
@@ -64,16 +65,6 @@ public long maxPlainTypeSerializedSize(
case com.eprosima.idl.parser.typecode.Kind.KIND_UINT8:
current_alignment += 1;
break;
case com.eprosima.idl.parser.typecode.Kind.KIND_WCHAR:
if (ctx instanceof com.eprosima.fastcdr.idl.context.Context && ((com.eprosima.fastcdr.idl.context.Context)ctx).isCdrv1TemplatesEnabled())
{
current_alignment += 4 + TypeCode.cdr_alignment(current_alignment, 4);
}
else
{
current_alignment += 2 + TypeCode.cdr_alignment(current_alignment, 2);
}
break;
}

return current_alignment - initial_alignment;
Original file line number Diff line number Diff line change
@@ -42,10 +42,7 @@ public long maxSerializedSize(
current_alignment += 4 + TypeCode.cdr_alignment(current_alignment, 4) + maxsize + 1;
break;
case Kind.KIND_WSTRING:
current_alignment += 4 + TypeCode.cdr_alignment(current_alignment, 4) + (maxsize *
(ctx instanceof com.eprosima.fastcdr.idl.context.Context && ((com.eprosima.fastcdr.idl.context.Context)ctx).isCdrv1TemplatesEnabled()
? 4 : 2
));
current_alignment += 4 + TypeCode.cdr_alignment(current_alignment, 4) + (maxsize * 2);
break;
}

@@ -59,15 +56,4 @@ public long maxPlainTypeSerializedSize(
{
throw new RuntimeGenerationException("StringTypeCode::maxPlainTypeSerializedSize(): Strings are not plain types.");
}

@Override
public String getCppTypename()
{
if (Kind.KIND_STRING == getKind() && isIsBounded() && ctx instanceof com.eprosima.fastcdr.idl.context.Context && ((com.eprosima.fastcdr.idl.context.Context)ctx).isCdrv1TemplatesEnabled())
{
return "eprosima::fastcdr::fixed_string<" + getMaxsize() + ">";
}

return super.getCppTypename();
}
}
8 changes: 0 additions & 8 deletions src/test/java/com/eprosima/fastdds/FastDDSGenTest.java
Original file line number Diff line number Diff line change
@@ -126,21 +126,13 @@ public void runTests()
blacklist_tests = java.util.Arrays.asList(blacklist_tests_str.split(",", -1));
}

String cdr_version = System.getProperty("cdr_version");
if (null == cdr_version)
{
cdr_version = "v2";
}


//Configure idl tests
TestManager tests = new TestManager(
TestLevel.RUN,
"share/fastddsgen/java/fastddsgen",
INPUT_PATH,
OUTPUT_PATH,
"CMake",
cdr_version,
list_tests,
blacklist_tests);
tests.addCMakeArguments("-DCMAKE_BUILD_TYPE=Debug");

0 comments on commit 6381c84

Please sign in to comment.