ArthurSonzogni / Diagon

Interactive ASCII art diagram generators. :star2:
https://arthursonzogni.com/Diagon/
MIT License
1.47k stars 56 forks source link

antlr.jar not found #37

Closed 573 closed 2 years ago

573 commented 2 years ago

I find this a wonderful project, thanks for making it.

When trying to package for NixOS I found that my build stuck at locating the antlr.jar:

Consolidate compiler generated dependencies of target antlr4_static [ 92%] Built target antlr4_static [ 92%] Generating GraphPlanarLexer.cpp, GraphPlanarParser.cpp, GraphPlanarLexer.h, GraphPlanarParser.h [ 92%] Generating FlowchartLexer.cpp, FlowchartParser.cpp, FlowchartLexer.h, FlowchartParser.h [ 92%] Generating MathLexer.cpp, MathParser.cpp, MathLexer.h, MathParser.h [ 92%] Generating SequenceLexer.cpp, SequenceParser.cpp, SequenceLexer.h, SequenceParser.h Error: Unable to access jarfile /nix/store/7g8306l1a9qxw7xswcdlbrm61v16wzi5-source/tools/antlr.jar

I'm pretty much a beginner coming to cmake or even nix, maybe you have a clue and can give a nudge here ?

This my default.nix for the build so far:

{ pkgs ? import <nixpkgs> {}, ... }:
pkgs.stdenv.mkDerivation {
  name = "Diagon";
  src = pkgs.lib.cleanSource (builtins.fetchTarball https://github.com/ArthurSonzogni/Diagon/tarball/master);
  nativeBuildInputs = with pkgs; [ cmake pkgconfig git cacert (jre_minimal.override { jdk = jdk11_headless; }) ant ];
  buildInputs = with pkgs; [ boost libuuid.dev icu ];
  propagatedBuildInputs = with pkgs; [ antlr ];
}

Also I'm getting

[100%] Built target antlr-populate -- Building without demo. To enable demo build use: -DWITH_DEMO=True -- Output libraries to /home/me/DiagonBuild/build/dist % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 162 100 162 0 0 2253 0 --:--:-- --:--:-- --:--:-- 2281 Warning: Failed to create the file antlr.jar: Permission denied 0 2040k 0 1005 0 0 3199 0 0:10:53 --:--:-- 0:10:53 3199 curl: (23) Failure writing output to destination

when running the eval cmake $cmakeFlags -Wno-dev -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON $src

ArthurSonzogni commented 2 years ago

This is about this line: https://github.com/ArthurSonzogni/Diagon/blob/master/tools/download_and_patch.sh#L8

I see this error:

Warning: Failed to create the file antlr.jar: Permission denied

Do you know why the permission to create a file is denied? Are you owning the current directory?

Inside "Diagon/tools", what is the output of:

ls -lart

?

573 commented 2 years ago

-rw-r--r-- 1 me users 1336 May 4 09:49 cmake_install.cmake -rw-r--r-- 1 me users 7837 May 4 14:50 Makefile drwxr-xr-x 7 me users 4096 May 4 15:00 build drwxr-xr-x 4 me users 4096 May 4 15:15 . drwxr-xr-x 2 me users 4096 May 4 15:15 CMakeFiles drwxr-xr-x 8 me users 4096 May 4 15:16 ..

I'll have to recheck later what the real permissions are as I download the sources while building. For now thanks for your input, I'll be back with progress.

573 commented 2 years ago

It is very roughly this, I can build using nix-build now:

# file default.nix
{ pkgs ? import <nixpkgs> {}, ... }:
pkgs.stdenv.mkDerivation {
  name = "env";
  src = pkgs.lib.cleanSource (builtins.fetchTarball https://github.com/ArthurSonzogni/Diagon/tarball/master);
  nativeBuildInputs = with pkgs; [ cmake pkgconfig git cacert (jre_minimal.override { jdk = jdk11_headless; }) ant extra-cmake-modules ];
  buildInputs = with pkgs; [ boost libuuid.dev icu ];

  # the https://github.com/ArthurSonzogni/Diagon/blob/master/tools/download_and_patch.sh should not be needed
  # bc we have antlr already in the inputs
  # Also https://github.com/ArthurSonzogni/Diagon/blob/34b68f63e45f6912e18682e797b31b43c5ac05c8/tools/CMakeLists.txt#L6
  # ..
  # https://github.com/ArthurSonzogni/Diagon/blob/34b68f63e45f6912e18682e797b31b43c5ac05c8/tools/CMakeLists.txt#L9
  # can be patched off
  # Also https://github.com/ArthurSonzogni/Diagon/blob/34b68f63e45f6912e18682e797b31b43c5ac05c8/tools/CMakeLists.txt#L36
  # can be patched replacing by
  # -jar ${pkgs.antlr.jarLocation}
  prePatch = "ls -lart tools";
  patches = [
    ./patch_cmakelists
  ];

  postPatch = ''
    substituteInPlace tools/CMakeLists.txt \
        --replace '-jar ''${DIAGON_TOOLS_DIR}/antlr.jar' '-jar ${pkgs.antlr.jarLocation}'
  '';

  propagatedBuildInputs = with pkgs; [ antlr ];
}

file ./patch_cmakelists being:

--- a/tools/CMakeLists.txt      2022-05-05 12:24:44.073703300 +0200
+++ b/tools/CMakeLists2.txt     2022-05-05 12:28:45.463703300 +0200
@@ -3,10 +3,6 @@
 # ┌─────────────────────────────────────────────────┐
 # │ ANTLR                                           │
 # └─────────────────────────────────────────────────┘
-execute_process(
-  COMMAND bash download_and_patch.sh
-  WORKING_DIRECTORY ${DIAGON_TOOLS_DIR}
-)

 # Function
 #   ANTLR(<file.g4>)