Skip to content

Commit

Permalink
Refs #19760. Coexist fastcdr v1 and v2
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 Nov 7, 2023
1 parent 9f4a8f9 commit c77ec46
Show file tree
Hide file tree
Showing 19 changed files with 3,876 additions and 106 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
fastcdr_version: ['v1.1.x', ${{ github.event.inputs.fastcdr_branch }} ]
java_version: ['openjdk-11-jdk', 'openjdk-17-jdk', 'openjdk-18-jdk', 'openjdk-19-jdk']

steps:
Expand All @@ -57,9 +58,9 @@ jobs:
- uses: ./src/fastddsgen/.github/actions/fetch-fastddsgen-repos
with:
foonathan-memory-vendor-branch: ${{ github.event.inputs.foonathan_memory_vendor_branch || 'master' }}
fastcdr-branch: ${{ github.event.inputs.fastcdr_branch || 'master' }}
fastdds-branch: ${{ github.event.inputs.fastdds_branch || 'master' }}
fastdds-python-branch: ${{ github.event.inputs.fastdds_python_branch || 'main' }}
fastcdr-branch: ${{ matrix.fastcdr_version }}
fastdds-branch: ${{ github.event.inputs.fastdds_branch || 'future/v2.12.1' }}
fastdds-python-branch: ${{ github.event.inputs.fastdds_python_branch || 'future/v2.12.1' }}

- name: Get minimum supported version of CMake
uses: eProsima/eProsima-CI/external/get-cmake@v0
Expand All @@ -77,21 +78,29 @@ jobs:
- name: Regenerate IDL files for Fast-DDS and Fast-DDS-python
run: |
cd src/Fast-DDS/utils/scripts
./update_generated_code_from_idl.sh
cd src/Fast-DDS
./utils/scripts/update_generated_code_from_idl.sh
cd -
cd src/Fast-DDS-python/fastdds_python/test/types
./generate.sh
cd -
cd src/Fast-DDS-python/fastdds_python_examples/HelloWorldExample
fastddsgen -python -replace HelloWorld.idl
fastddsgen -cdr both -python -replace HelloWorld.idl
- name: Build workspace
run: |
cmake --version
colcon build --event-handlers=console_direct+ --mixin rel-with-deb-info ccache
- name: Test fastddsgen
- name: Test fastddsgen with fastcdr v1
if: startsWith(matrix.fastcdr_version, 'v1')
run: |
source install/local_setup.bash
cd src/fastddsgen
./gradlew test -Dcdr_version=v1 -Dblacklist_tests=external,maps,optional
- name: Test fastddsgen with fastcdr v2
if: ${{ ! startsWith(matrix.fastcdr_version, 'v1') }}
run: |
source install/local_setup.bash
cd src/fastddsgen
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/eprosima/fastcdr/idl/context/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,17 @@ 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 ***/
}
11 changes: 11 additions & 0 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ 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_

Expand Down Expand Up @@ -97,6 +104,10 @@ $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) ::= <<
Expand Down
Loading

0 comments on commit c77ec46

Please sign in to comment.