diff options
Diffstat (limited to 'pkgs/development/tools/fastddsgen/default.nix')
-rw-r--r-- | pkgs/development/tools/fastddsgen/default.nix | 96 |
1 files changed, 38 insertions, 58 deletions
diff --git a/pkgs/development/tools/fastddsgen/default.nix b/pkgs/development/tools/fastddsgen/default.nix index ec4523e270c28..8d1110334f450 100644 --- a/pkgs/development/tools/fastddsgen/default.nix +++ b/pkgs/development/tools/fastddsgen/default.nix @@ -1,8 +1,21 @@ -{ lib, stdenv, runtimeShell, writeText, fetchFromGitHub, gradle_7, openjdk17, git, perl, cmake }: +{ 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"; @@ -11,76 +24,43 @@ let hash = "sha256-oqbSIzsYUwD8bTqGKZ9he9d18EDq9mHZFoNUp0RK0qU="; }; - gradle = gradle_7; - - # fake build to pre-download deps into fixed-output derivation - deps = stdenv.mkDerivation { - pname = "${pname}-deps"; - inherit src version; - nativeBuildInputs = [ gradle openjdk17 perl ]; - - buildPhase = '' - export GRADLE_USER_HOME=$(mktemp -d); - gradle --no-daemon -x submodulesUpdate assemble - ''; - - # perl code mavenizes paths (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar) - installPhase = '' - find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \ - | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \ - | sh - ''; + nativeBuildInputs = [ + gradle + openjdk17 + makeWrapper + ]; - dontStrip = true; - - outputHashAlgo = "sha256"; - outputHashMode = "recursive"; - outputHash = "sha256-YkVRp6TXI7/5O+u0DDYiCq7DITfGJ4lT/L4hT90JOL8="; + mitmCache = gradle.fetchDeps { + inherit pname; + data = ./deps.json; }; -in -stdenv.mkDerivation { - inherit pname src version; - - nativeBuildInputs = [ gradle openjdk17 ]; - - # use our offline deps - postPatch = '' - sed -ie '1i\ - pluginManagement {\ - repositories {\ - maven { url "${deps}" }\ - }\ - }' thirdparty/idl-parser/settings.gradle - sed -ie "s#mavenCentral()#maven { url '${deps}' }#g" build.gradle - sed -ie "s#mavenCentral()#maven { url '${deps}' }#g" thirdparty/idl-parser/build.gradle - ''; - buildPhase = '' - runHook preBuild + __darwinAllowLocalNetworking = true; - export GRADLE_USER_HOME=$(mktemp -d) - - # Run gradle with daemon to make installPhase faster - gradle --offline -x submodulesUpdate assemble - - runHook postBuild - ''; + gradleFlags = [ "-x" "submodulesUpdate" ]; installPhase = '' runHook preInstall - gradle --offline -x submodulesUpdate install --install_path=$out + gradle install --install_path=$out - # Override the default start script to use absolute java path - cat <<EOF >$out/bin/fastddsgen - #!${runtimeShell} - exec ${openjdk17}/bin/java -jar "$out/share/fastddsgen/java/fastddsgen.jar" "\$@" - EOF - chmod a+x "$out/bin/fastddsgen" + # 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"; |