Skip to content

Commit

Permalink
Adjust for const qualification of all data related inputs in DataWr…
Browse files Browse the repository at this point in the history
…iter APIs (#357)

* Refs #21183: Adjust for const changes in DataWriter APIs

Signed-off-by: eduponz <[email protected]>

* Refs #21183: Generate Discovery-Server types in CI

Signed-off-by: eduponz <[email protected]>

---------

Signed-off-by: eduponz <[email protected]>
  • Loading branch information
EduPonz authored Jun 21, 2024
1 parent 549ef80 commit a9572b9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 78 deletions.
6 changes: 6 additions & 0 deletions .github/actions/fetch-fastddsgen-repos/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 'fetch-fastddsgen-repos'
description: 'Fetch Fast DDS dependencies'

inputs:
foonathan-memory-vendor-branch:
description: 'foonathan_memory_vendor branch to be used'
Expand All @@ -13,6 +14,10 @@ inputs:
fastdds-python-branch:
description: 'Fast-DDS-Python branch to be used'
required: true
discovery-server-branch:
description: 'Discovery Server branch to be used'
required: true

runs:
using: "composite"
steps:
Expand All @@ -24,5 +29,6 @@ runs:
git clone https://github.com/eProsima/Fast-CDR.git --branch ${{ inputs.fastcdr-branch }}
git clone https://github.com/eProsima/Fast-DDS.git --branch ${{ inputs.fastdds-branch }}
git clone https://github.com/eProsima/Fast-DDS-python.git --branch ${{ inputs.fastdds-python-branch }}
git clone https://github.com/eProsima/Discovery-Server.git --branch ${{ inputs.discovery-server-branch }}
cd ..
shell: bash
88 changes: 44 additions & 44 deletions .github/workflows/reusable-ubuntu-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,10 @@ on:
description: 'The Java version to be used'
required: true
type: string
foonathan_memory_vendor_branch:
description: 'foonathan_memory_vendor branch to be used'
required: true
type: string
fastcdr_branch:
description: 'Fast CDR branch to be used'
required: true
type: string
fastdds_branch:
description: 'Fast DDS branch to be used'
required: true
type: string
fastdds_python_branch:
description: 'Fast DDS Python branch to be used'
required: true
type: string
fastddsgen_branch:
description: 'Fast DDS Gen branch to be used'
required: true
type: string
fastdds_fallback_branch:
description: 'Fast DDS fallback branch in case `fastdds_branch` does not exist (e.g. master or 3.0.x-devel)'
required: false
type: string

defaults:
run:
Expand Down Expand Up @@ -76,40 +56,56 @@ jobs:
- name: Install python packages
uses: eProsima/eProsima-CI/multiplatform/install_colcon@v0

- name: Determine the Fast DDS branch to be used
run: |
FASTDDS_REPO=https://github.com/eProsima/Fast-DDS.git
# Attempt to use PR's source branch
TEMP_BRANCH=${{ inputs.fastdds_branch }}
RESPONSE_CODE=$(git ls-remote --heads $FASTDDS_REPO $TEMP_BRANCH | wc -l)
if [[ ${RESPONSE_CODE} == "0" ]]
then
echo "PR source branch '$TEMP_BRANCH' branch DOES NOT exist using default branch '${{ inputs.fastdds_fallback_branch }}'"
# Attempt to use PR's fallback branch
TEMP_BRANCH=${{ inputs.fastdds_fallback_branch }}
RESPONSE_CODE=$(git ls-remote --heads $FASTDDS_REPO $TEMP_BRANCH | wc -l)
if [[ ${RESPONSE_CODE} == "0" ]]
then
echo "PR fallback branch '$TEMP_BRANCH' branch DOES NOT exist"
exit 1
fi
fi
echo "FASTDDS_BRANCH=$TEMP_BRANCH" >> $GITHUB_ENV
- name: Get Foonathan Memory Vendor branch
id: get_foonathan_memory_vendor_branch
uses: eProsima/eProsima-CI/ubuntu/get_related_branch_from_repo@v0
with:
remote_repository: eProsima/foonathan_memory_vendor
fallback_branch: master

- name: Get Fast CDR branch
id: get_fastcdr_branch
uses: eProsima/eProsima-CI/ubuntu/get_related_branch_from_repo@v0
with:
remote_repository: eProsima/Fast-CDR
fallback_branch: master

- name: Get Fast DDS branch
id: get_fastdds_branch
uses: eProsima/eProsima-CI/ubuntu/get_related_branch_from_repo@v0
with:
remote_repository: eProsima/Fast-DDS
fallback_branch: master

- name: Get Fast DDS Python branch
id: get_fastdds_python_branch
uses: eProsima/eProsima-CI/ubuntu/get_related_branch_from_repo@v0
with:
remote_repository: eProsima/Fast-DDS-python
fallback_branch: main

- name: Get Discovery Server branch
id: get_discovery_server_branch
uses: eProsima/eProsima-CI/ubuntu/get_related_branch_from_repo@v0
with:
remote_repository: eProsima/Discovery-Server
fallback_branch: master

- uses: ./src/fastddsgen/.github/actions/fetch-fastddsgen-repos
with:
foonathan-memory-vendor-branch: ${{ inputs.foonathan_memory_vendor_branch }}
fastcdr-branch: ${{ inputs.fastcdr_branch }}
fastdds-branch: ${{ env.FASTDDS_BRANCH }}
fastdds-python-branch: ${{ inputs.fastdds_python_branch }}
foonathan-memory-vendor-branch: ${{ steps.get_foonathan_memory_vendor_branch.outputs.deduced_branch }}
fastcdr-branch: ${{ steps.get_fastcdr_branch.outputs.deduced_branch }}
fastdds-branch: ${{ steps.get_fastdds_branch.outputs.deduced_branch }}
fastdds-python-branch: ${{ steps.get_fastdds_python_branch.outputs.deduced_branch }}
discovery-server-branch: ${{ steps.get_discovery_server_branch.outputs.deduced_branch }}

- name: Build fastddsgen
run: |
cd src/fastddsgen
./gradlew assemble
echo "$(pwd)/scripts" >> ${{ github.path }}
- name: Regenerate IDL files for Fast-DDS and Fast-DDS-python
- name: Regenerate IDL files for Fast DDS, Fast DDS Python, and Discovery Server
run: |
cd src/Fast-DDS
./utils/scripts/update_generated_code_from_idl.sh
Expand All @@ -119,6 +115,10 @@ jobs:
./utils/scripts/update_generated_code_from_idl.sh
cd -
cd src/Discovery-Server
./utils/scripts/update_generated_code_from_idl.sh
cd -
- name: Build workspace
run: |
cmake --version
Expand Down
21 changes: 0 additions & 21 deletions .github/workflows/ubuntu-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@ name: Fast DDS Gen Ubuntu CI
on:
workflow_dispatch:
inputs:
foonathan_memory_vendor_branch:
description: 'foonathan_memory_vendor branch to be used'
required: true
type: string
fastcdr_branch:
description: 'Fast CDR branches to be used'
required: true
type: string
fastdds_branch:
description: 'Fast-DDS branch to be used'
required: true
type: string
fastdds_python_branch:
description: 'Fast-DDS-Python branch to be used'
required: true
type: string
fastddsgen_branch:
description: 'Fast-DDS-Gen branch to be used'
required: true
Expand All @@ -45,9 +29,4 @@ jobs:
with:
os_image: ${{ matrix.os_image }}
java_version: ${{ matrix.java_version }}
foonathan_memory_vendor_branch: ${{ inputs.foonathan_memory_vendor_branch || 'master' }}
fastcdr_branch: ${{ inputs.fastcdr_branch || 'master' }}
fastdds_branch: ${{ inputs.fastdds_branch || github.head_ref }}
fastdds_python_branch: ${{ inputs.fastdds_python_branch || 'main' }}
fastddsgen_branch: ${{ inputs.fastddsgen_branch || github.ref || 'master' }}
fastdds_fallback_branch: ${{ 'master' }}
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ public:
eProsima_user_DllExport ~$struct.name$PubSubType() override;

eProsima_user_DllExport bool serialize(
void* data,
const void* const data,
eprosima::fastdds::rtps::SerializedPayload_t* payload) override
{
return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION);
}

eProsima_user_DllExport bool serialize(
void* data,
const void* const data,
eprosima::fastdds::rtps::SerializedPayload_t* payload,
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;

Expand All @@ -128,17 +128,17 @@ public:
void* data) override;

eProsima_user_DllExport std::function<uint32_t()> getSerializedSizeProvider(
void* data) override
const void* const data) override
{
return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION);
}

eProsima_user_DllExport std::function<uint32_t()> getSerializedSizeProvider(
void* data,
const void* const data,
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;

eProsima_user_DllExport bool getKey(
void* data,
const void* const data,
eprosima::fastdds::rtps::InstanceHandle_t* ihandle,
bool force_md5 = false) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ $struct.name$PubSubType::~$struct.name$PubSubType()
}

bool $struct.name$PubSubType::serialize(
void* data,
const void* const data,
SerializedPayload_t* payload,
DataRepresentationId_t data_representation)
{
$struct.name$* p_type = static_cast<$struct.name$*>(data);
const $struct.name$* p_type = static_cast<const $struct.name$*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->max_size);
Expand Down Expand Up @@ -153,7 +153,7 @@ bool $struct.name$PubSubType::deserialize(
}

std::function<uint32_t()> $struct.name$PubSubType::getSerializedSizeProvider(
void* data,
const void* const data,
DataRepresentationId_t data_representation)
{
return [data, data_representation]() -> uint32_t
Expand All @@ -170,7 +170,7 @@ std::function<uint32_t()> $struct.name$PubSubType::getSerializedSizeProvider(
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
size_t current_alignment {0};
return static_cast<uint32_t>(calculator.calculate_serialized_size(
*static_cast<$struct.name$*>(data), current_alignment)) +
*static_cast<const $struct.name$*>(data), current_alignment)) +
4u /*encapsulation*/;
}
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
Expand All @@ -193,7 +193,7 @@ void $struct.name$PubSubType::deleteData(
}

bool $struct.name$PubSubType::getKey(
void* data,
const void* const data,
InstanceHandle_t* handle,
bool force_md5)
{
Expand All @@ -202,7 +202,7 @@ bool $struct.name$PubSubType::getKey(
return false;
}

$struct.name$* p_type = static_cast<$struct.name$*>(data);
const $struct.name$* p_type = static_cast<const $struct.name$*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(m_keyBuffer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class $struct.name$PubSubJNI : public TopicDataType, public SubscriberListener
Domain::removeSubscriber(subscriber_);
}

bool serialize(void *data, SerializedPayload_t *payload)
bool serialize(const void* const data, SerializedPayload_t *payload)
{
$struct.scopedname$ *p_type = ($struct.scopedname$*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*) payload->data, payload->max_size);
Expand Down Expand Up @@ -220,7 +220,7 @@ class $struct.name$PubSubJNI : public TopicDataType, public SubscriberListener
delete(($struct.scopedname$*)data);
}

bool getKey(void *data, InstanceHandle_t* handle, bool force_md5)
bool getKey(const void* const data, InstanceHandle_t* handle, bool force_md5)
{
if(!m_isGetKeyDefined)
return false;
Expand Down

0 comments on commit a9572b9

Please sign in to comment.