Skip to content

Commit

Permalink
Compiladores: Improve packaging of scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JCapucho committed Mar 5, 2024
1 parent 8ec4570 commit 9f1a244
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 23 deletions.
17 changes: 7 additions & 10 deletions 2ano2/Compiladores/antlr4-bin/view-javadoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@

# change the following variables to point to browser and javadoc directories!

#BROWSER="/usr/bin/firefox"
BROWSER="firefox"
JDKDIR1=$(ls -fd /usr/share/doc/openjdk-*-jre-headless)
#JDKDIR1="/usr/share/doc/openjdk-8-jre-headless"
#JDKDIR2="/usr/local/share/java/docs"
JDKDIR2=""
#OTHERDIR="/usr/local/doc"
OTHERDIR="/usr/share/doc"
#OTHERDIR=""
# BROWSER="/usr/bin/firefox"
# BROWSER="firefox"
BROWSER="xdg-open"
JDKDIR1="@JDK_DOCS_DIR@"
# JDKDIR2=""
# OTHERDIR=""

if [ $# -eq 0 ]; then
echo "Usage: view-javadoc <CLASS-NAME>"
Expand Down Expand Up @@ -40,7 +37,7 @@ case ${#docs[@]} in
;;
1)
doc=${docs[0]}
"$BROWSER" $doc &
"$BROWSER" $doc >/dev/null &
;;
*)
select doc in ${docs[@]}; do
Expand Down
12 changes: 6 additions & 6 deletions 2ano2/Compiladores/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 65 additions & 7 deletions 2ano2/Compiladores/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,70 @@
inherit system;
};
in {
devShell = pkgs.mkShell {
packages = with pkgs; [
jdk17
antlr
doxygen
];
};
devShell = let
string-template = pkgs.stdenv.mkDerivation rec {
pname = "StringTemplate";
version = "4.3.4";
src = pkgs.fetchurl {
url = "https://www.stringtemplate.org/download/ST-${version}.jar";
sha256 = "sha256-+SesOExG10n4texolypTrtIeADE1CSmWFu23O/oV/zM=";
};
phases = ["installPhase"];
installPhase = ''
set -eu
mkdir -p $out/share/java
cp ${src} $out/share/java
'';
};

jdk-docs = pkgs.stdenv.mkDerivation rec {
pname = "jdk_doc-all";
version = "17.0.10";
src = pkgs.fetchzip {
url = "https://download.oracle.com/otn_software/java/jdk/${version}+11/a473b47039a34b169d45b00685dea3dd/jdk-${version}_doc-all.zip";
sha256 = "sha256-ZO1BMUhVa6c8C9ey/Ts5MROYA3P2YOkHMjbRs6kdImA=";
};
installPhase = ''
set -eu
mkdir -p $out/share/doc
cp -r . $out/share/doc
'';
};

antlr4-path = pkgs.symlinkJoin {
name = "antlr4-path";
paths = [pkgs.antlr string-template];
};

antlr4-bin = pkgs.stdenv.mkDerivation rec {
pname = "antlr4-bin";
version = "6.4";
src = ./antlr4-bin;
buildInputs = with pkgs; [bash bc];
nativeBuildInputs = [pkgs.makeWrapper pkgs.jdk17];
installPhase = ''
set -e
mkdir -p $out/bin
substituteInPlace view-javadoc \
--replace "@JDK_DOCS_DIR@" "${jdk-docs}/share/doc"
for filename in ./*; do
OUT=$out/bin/"$(basename "$filename")"
cp "$filename" "$OUT"
wrapProgram "$OUT" \
--prefix PATH : ${pkgs.lib.makeBinPath buildInputs} \
--set ANTLR4_PATH "${antlr4-path}/share/java"
done
'';
};
in
pkgs.mkShell {
packages = with pkgs; [
jdk17
doxygen
antlr4-bin
];
};
});
}
Binary file removed 2ano2/Compiladores/libs/ST-4.3.4.jar
Binary file not shown.

0 comments on commit 9f1a244

Please sign in to comment.