Closed AndreaFinazzi closed 1 year ago
@AndreaFinazzi
Hi, I encountered the same problem and after multiple attempts, I found that the idl file present in src/main/java/com/pro sima/fastdds/idl/templates
can be accepted by this command-line parameter.
For example, although the -example
option was not used when generating code, the -extrastg
option can be used to specify the code corresponding to the DDSPublisherHeader.stg
template.
Example:
The generated code using the command fastddsgen perception. idl -d out replace
is as follows
Out/
|--Perception.cxx
|--Perception. h
|--PerceptionPubSubTypes.cxx
`--PerceptionPubSubTypes. h
Using - extrastgfastddsgen Perception.idl -d out -replace -extrastg DDSPublisherHeader.stg publisherHeader.h
Out/
|--Perception.cxx
|--Perception. h
|--PerceptionPubSubTypes.cxx
|--PerceptionPubSubTypes. h
`--PublisherHeader. h
Opening the file reveals that publisherHeader.h
has been generated.
The content generated by this file should have been generated when -example
was specified, but it can now also be generated through -extrastg
My solution is as follows:
RUN git clone -b v2.5.1 https://github.com/eProsima/Fast-DDS-Gen.git \
&& sed -i 's/private\:/protected\:/' Fast-DDS-Gen/src/main/java/com/eprosima/fastdds/idl/templates/DDSPublisherHeader.stg \
&& sed -i 's/bool init/virtual bool init/' Fast-DDS-Gen/src/main/java/com/eprosima/fastdds/idl/templates/DDSPublisherHeader.stg \
&& sed -i 's/void run/virtual void run/' Fast-DDS-Gen/src/main/java/com/eprosima/fastdds/idl/templates/DDSPublisherHeader.stg \
&& sed -i 's/private\:/protected\:/' Fast-DDS-Gen/src/main/java/com/eprosima/fastdds/idl/templates/DDSSubscriberHeader.stg \
&& sed -i 's/bool init/virtual bool init/' Fast-DDS-Gen/src/main/java/com/eprosima/fastdds/idl/templates/DDSSubscriberHeader.stg \
&& sed -i 's/void run/virtual void run/' Fast-DDS-Gen/src/main/java/com/eprosima/fastdds/idl/templates/DDSSubscriberHeader.stg \
&& cd Fast-DDS-Gen && ./gradlew assemble && ./gradlew install \
&& rm -rf /opt/packages/Fast-DDS-Gen
This achieves the goal of customizing the template.
@AndreaFinazzi
Fast DDS-Gen v3.0.0 modified this feature to load the templates directly from the filesystem. Could you check if it works now as expected?
First of all thanks for this great project and for open-sourcing it!
I'm trying to generate a custom header out of my IDL definitions using the
-extrastg
argument, but I can't get it to work. Couldn't find any example either.This is how I use the tool:
I tried different combinations (even adding the custom template to the source template folder), but I always get:
Could you point me to a working example, please? Any help would be much appreciated, thanks!