
fastddsgen internally calls 'cpp' (the C preprocessor) to resolve
include directives, include guards, etc. See
541129f6e7/src/main/java/com/eprosima/fastdds/fastddsgen.java (L1423)
Make 'cpp' available from the fastddsgen wrapper script. Use the
unwrapped 'cpp', because the wrapped one passes additional parameters,
which make the produced output incompatible with fastddsgen (string out
of bounds exception).
Fixes the error when using IDL files with includes:
```
Processing the file build/foo.idl...
ERROR: Cannot generate the files
begin -3, end 1, length 1
java.lang.StringIndexOutOfBoundsException: begin -3, end 1, length 1
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
at java.base/java.lang.String.substring(String.java:2705)
at com.eprosima.idl.context.Context.processPreprocessorLine(Context.java:955)
at com.eprosima.idl.parser.grammar.IDLLexer.PREPROC_DIRECTIVE_action(IDLLexer.java:223)
at com.eprosima.idl.parser.grammar.IDLLexer.action(IDLLexer.java:215)
at org.antlr.v4.runtime.atn.LexerCustomAction.execute(LexerCustomAction.java:97)
at org.antlr.v4.runtime.atn.LexerActionExecutor.execute(LexerActionExecutor.java:168)
at org.antlr.v4.runtime.atn.LexerATNSimulator.accept(LexerATNSimulator.java:366)
at org.antlr.v4.runtime.atn.LexerATNSimulator.failOrAccept(LexerATNSimulator.java:299)
at org.antlr.v4.runtime.atn.LexerATNSimulator.execATN(LexerATNSimulator.java:230)
at org.antlr.v4.runtime.atn.LexerATNSimulator.match(LexerATNSimulator.java:114)
at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:141)
at org.antlr.v4.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:169)
at org.antlr.v4.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:152)
at org.antlr.v4.runtime.BufferedTokenStream.setup(BufferedTokenStream.java:254)
at org.antlr.v4.runtime.BufferedTokenStream.lazyInit(BufferedTokenStream.java:249)
at org.antlr.v4.runtime.CommonTokenStream.LT(CommonTokenStream.java:92)
at org.antlr.v4.runtime.Parser.enterRule(Parser.java:628)
at com.eprosima.idl.parser.grammar.IDLParser.specification(IDLParser.java:304)
at com.eprosima.fastdds.fastddsgen.parseIDL(fastddsgen.java:809)
at com.eprosima.fastdds.fastddsgen.process(fastddsgen.java:640)
at com.eprosima.fastdds.fastddsgen.execute(fastddsgen.java:458)
at com.eprosima.fastdds.fastddsgen.main(fastddsgen.java:1581)
```
81 lines
2.0 KiB
Nix
81 lines
2.0 KiB
Nix
{ lib
|
|
, stdenv
|
|
, makeWrapper
|
|
, fetchFromGitHub
|
|
, gradle_7
|
|
, openjdk17
|
|
}:
|
|
|
|
let
|
|
pname = "fastddsgen";
|
|
version = "3.3.0";
|
|
|
|
gradle = gradle_7;
|
|
|
|
in
|
|
stdenv.mkDerivation {
|
|
inherit pname version;
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "eProsima";
|
|
repo = "Fast-DDS-Gen";
|
|
rev = "v${version}";
|
|
fetchSubmodules = true;
|
|
hash = "sha256-oqbSIzsYUwD8bTqGKZ9he9d18EDq9mHZFoNUp0RK0qU=";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
gradle
|
|
openjdk17
|
|
makeWrapper
|
|
];
|
|
|
|
mitmCache = gradle.fetchDeps {
|
|
inherit pname;
|
|
data = ./deps.json;
|
|
};
|
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
gradleFlags = [ "-x" "submodulesUpdate" ];
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
gradle install --install_path=$out
|
|
|
|
# Override the default start script to use absolute java path.
|
|
# Make the unwrapped "cpp" available in the path, since the wrapped "cpp"
|
|
# passes additional flags and produces output incompatible with fastddsgen.
|
|
makeWrapper ${openjdk17}/bin/java $out/bin/fastddsgen \
|
|
--add-flags "-jar $out/share/fastddsgen/java/fastddsgen.jar" \
|
|
--prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc ]}
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
postGradleUpdate = ''
|
|
cd thirdparty/idl-parser
|
|
# fix "Task 'submodulesUpdate' not found"
|
|
gradleFlags=
|
|
gradle nixDownloadDeps
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Fast-DDS IDL code generator tool";
|
|
mainProgram = "fastddsgen";
|
|
homepage = "https://github.com/eProsima/Fast-DDS-Gen";
|
|
license = licenses.asl20;
|
|
longDescription = ''
|
|
eProsima Fast DDS-Gen is a Java application that generates
|
|
eProsima Fast DDS C++ or Python source code using the data types
|
|
defined in an IDL (Interface Definition Language) file. This
|
|
generated source code can be used in any Fast DDS application in
|
|
order to define the data type of a topic, which will later be
|
|
used to publish or subscribe.
|
|
'';
|
|
maintainers = with maintainers; [ wentasah ];
|
|
platforms = openjdk17.meta.platforms;
|
|
};
|
|
}
|