sourcetrail: fix darwin build (#112795)
This commit is contained in:
parent
be504fc82a
commit
78e3596121
|
@ -1,15 +1,28 @@
|
||||||
{ lib, stdenv, fetchFromGitHub, callPackage, writeScript, cmake, wrapQtAppsHook
|
{ lib, stdenv, fetchFromGitHub, callPackage, writeScript, fetchpatch, cmake
|
||||||
, boost, qt5, llvmPackages, gcc, jdk, pythonPackages, desktop-file-utils
|
, wrapQtAppsHook, qt5, boost, llvmPackages, gcc, jdk, maven, pythonPackages
|
||||||
, shared-mime-info, imagemagick, which, coreutils, maven, fetchpatch }:
|
, coreutils, which, desktop-file-utils, shared-mime-info, imagemagick, libicns
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
# TODO: remove when version incompatibility issue with python3Packages.jedi is
|
# TODO: remove when version incompatibility issue with python3Packages.jedi is
|
||||||
# resolved
|
# resolved
|
||||||
parso = pythonPackages.callPackage ./parso.nix {};
|
parso = pythonPackages.callPackage ./parso.nix { };
|
||||||
jedi = pythonPackages.callPackage ./jedi.nix { inherit parso; };
|
jedi = pythonPackages.callPackage ./jedi.nix { inherit parso; };
|
||||||
|
|
||||||
pythonIndexer = pythonPackages.callPackage ./python.nix { inherit jedi parso; };
|
pythonIndexer =
|
||||||
javaIndexer = callPackage ./java.nix {};
|
pythonPackages.callPackage ./python.nix { inherit jedi parso; };
|
||||||
|
javaIndexer = callPackage ./java.nix { };
|
||||||
|
|
||||||
|
appPrefixDir = if stdenv.isDarwin then
|
||||||
|
"$out/Applications/Sourcetrail.app/Contents"
|
||||||
|
else
|
||||||
|
"$out/opt/sourcetrail";
|
||||||
|
appBinDir =
|
||||||
|
if stdenv.isDarwin then "${appPrefixDir}/MacOS" else "${appPrefixDir}/bin";
|
||||||
|
appResourceDir = if stdenv.isDarwin then
|
||||||
|
"${appPrefixDir}/Resources"
|
||||||
|
else
|
||||||
|
"${appPrefixDir}/share";
|
||||||
|
|
||||||
# Upstream script:
|
# Upstream script:
|
||||||
# https://github.com/CoatiSoftware/Sourcetrail/blob/master/script/update_java_indexer.sh
|
# https://github.com/CoatiSoftware/Sourcetrail/blob/master/script/update_java_indexer.sh
|
||||||
|
@ -17,7 +30,7 @@ let
|
||||||
#!${stdenv.shell}
|
#!${stdenv.shell}
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
dst="$out/opt/sourcetrail/share/data/java/lib"
|
dst="${appResourceDir}/data/java/lib"
|
||||||
|
|
||||||
mkdir -p "$dst"
|
mkdir -p "$dst"
|
||||||
cp "${javaIndexer}/target/java-indexer-1.0.jar" "$dst/java-indexer.jar"
|
cp "${javaIndexer}/target/java-indexer-1.0.jar" "$dst/java-indexer.jar"
|
||||||
|
@ -29,12 +42,12 @@ let
|
||||||
installPythonIndexer = writeScript "download_python_indexer.sh" ''
|
installPythonIndexer = writeScript "download_python_indexer.sh" ''
|
||||||
#!${stdenv.shell}
|
#!${stdenv.shell}
|
||||||
|
|
||||||
mkdir -p $out/opt/sourcetrail/share/data
|
mkdir -p ${appResourceDir}/data
|
||||||
ln -s "${pythonIndexer}/bin" "$out/opt/sourcetrail/share/data/python"
|
ln -s "${pythonIndexer}/bin" "${appResourceDir}/data/python"
|
||||||
'';
|
'';
|
||||||
in
|
in stdenv.mkDerivation rec {
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
pname = "sourcetrail";
|
pname = "sourcetrail";
|
||||||
|
# NOTE: skip 2020.4.35 https://github.com/CoatiSoftware/Sourcetrail/pull/1136
|
||||||
version = "2020.2.43";
|
version = "2020.2.43";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
|
@ -45,7 +58,8 @@ stdenv.mkDerivation rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = let
|
patches = let
|
||||||
url = commit: "https://github.com/CoatiSoftware/Sourcetrail/commit/${commit}.patch";
|
url = commit:
|
||||||
|
"https://github.com/CoatiSoftware/Sourcetrail/commit/${commit}.patch";
|
||||||
in [
|
in [
|
||||||
./disable-updates.patch
|
./disable-updates.patch
|
||||||
./disable-failing-tests.patch # FIXME: 5 test cases failing due to sandbox
|
./disable-failing-tests.patch # FIXME: 5 test cases failing due to sandbox
|
||||||
|
@ -69,21 +83,22 @@ stdenv.mkDerivation rec {
|
||||||
desktop-file-utils
|
desktop-file-utils
|
||||||
imagemagick
|
imagemagick
|
||||||
javaIndexer # the resulting jar file is copied by our install script
|
javaIndexer # the resulting jar file is copied by our install script
|
||||||
] ++ lib.optionals doCheck testBinPath;
|
] ++ lib.optional (stdenv.isDarwin) libicns
|
||||||
buildInputs = [
|
++ lib.optionals doCheck testBinPath;
|
||||||
boost pythonIndexer shared-mime-info
|
buildInputs = [ boost pythonIndexer shared-mime-info ]
|
||||||
] ++ (with qt5; [ qtbase qtsvg ])
|
++ (with qt5; [ qtbase qtsvg ]) ++ (with llvmPackages; [ libclang llvm ]);
|
||||||
++ (with llvmPackages; [ libclang llvm ]);
|
|
||||||
binPath = [ gcc jdk.jre maven which ];
|
binPath = [ gcc jdk.jre maven which ];
|
||||||
testBinPath = binPath ++ [ coreutils ];
|
testBinPath = binPath ++ [ coreutils ];
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DBoost_USE_STATIC_LIBS=OFF"
|
"-DBoost_USE_STATIC_LIBS=OFF"
|
||||||
"-DBUILD_CXX_LANGUAGE_PACKAGE=ON"
|
"-DBUILD_CXX_LANGUAGE_PACKAGE=ON"
|
||||||
"-DCMAKE_PREFIX_PATH=${llvmPackages.clang-unwrapped}"
|
|
||||||
"-DBUILD_JAVA_LANGUAGE_PACKAGE=ON"
|
"-DBUILD_JAVA_LANGUAGE_PACKAGE=ON"
|
||||||
"-DBUILD_PYTHON_LANGUAGE_PACKAGE=ON"
|
"-DBUILD_PYTHON_LANGUAGE_PACKAGE=ON"
|
||||||
];
|
] ++ lib.optional stdenv.isLinux
|
||||||
|
"-DCMAKE_PREFIX_PATH=${llvmPackages.clang-unwrapped}"
|
||||||
|
++ lib.optional stdenv.isDarwin
|
||||||
|
"-DClang_DIR=${llvmPackages.clang-unwrapped}";
|
||||||
|
|
||||||
postPatch = let
|
postPatch = let
|
||||||
major = lib.versions.major version;
|
major = lib.versions.major version;
|
||||||
|
@ -112,6 +127,8 @@ stdenv.mkDerivation rec {
|
||||||
ln -sf ${installPythonIndexer} script/download_python_indexer.sh
|
ln -sf ${installPythonIndexer} script/download_python_indexer.sh
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# Directory layout for Linux:
|
||||||
|
#
|
||||||
# Sourcetrail doesn't use the usual cmake install() commands and instead uses
|
# Sourcetrail doesn't use the usual cmake install() commands and instead uses
|
||||||
# its own bash script for packaging. Since we're not able to reuse the script,
|
# its own bash script for packaging. Since we're not able to reuse the script,
|
||||||
# we'll have to roll our own in nixpkgs.
|
# we'll have to roll our own in nixpkgs.
|
||||||
|
@ -141,7 +158,7 @@ stdenv.mkDerivation rec {
|
||||||
#
|
#
|
||||||
# nixpkgs
|
# nixpkgs
|
||||||
# ├── bin/
|
# ├── bin/
|
||||||
# │ └── sourcetrail* (wrapper for opt/sourcetrail/bin/sourcetrail)
|
# │ └── sourcetrail@ (symlink to opt/sourcetrail/bin/sourcetrail)
|
||||||
# └── opt/sourcetrail/
|
# └── opt/sourcetrail/
|
||||||
# ├── bin/
|
# ├── bin/
|
||||||
# │ └── sourcetrail*
|
# │ └── sourcetrail*
|
||||||
|
@ -151,35 +168,76 @@ stdenv.mkDerivation rec {
|
||||||
# Upstream install script:
|
# Upstream install script:
|
||||||
# https://github.com/CoatiSoftware/Sourcetrail/blob/master/setup/Linux/createPackages.sh
|
# https://github.com/CoatiSoftware/Sourcetrail/blob/master/setup/Linux/createPackages.sh
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/opt/sourcetrail/bin
|
runHook preInstall
|
||||||
cp app/Sourcetrail $out/opt/sourcetrail/bin/sourcetrail
|
|
||||||
cp app/sourcetrail_indexer $out/opt/sourcetrail/bin/sourcetrail_indexer
|
mkdir -p ${appResourceDir}
|
||||||
|
cp -R ../bin/app/data ${appResourceDir}
|
||||||
|
cp -R ../bin/app/user/projects ${appResourceDir}/data/fallback
|
||||||
|
rm -r ${appResourceDir}/data/install ${appResourceDir}/data/*_template.xml
|
||||||
|
|
||||||
|
mkdir -p "${appBinDir}"
|
||||||
|
cp app/Sourcetrail ${appBinDir}/sourcetrail
|
||||||
|
cp app/sourcetrail_indexer ${appBinDir}/sourcetrail_indexer
|
||||||
|
wrapQtApp ${appBinDir}/sourcetrail \
|
||||||
|
--prefix PATH : ${lib.makeBinPath binPath}
|
||||||
|
|
||||||
|
mkdir -p $out/bin
|
||||||
|
'' + lib.optionalString (stdenv.isLinux) ''
|
||||||
|
ln -sf ${appBinDir}/sourcetrail $out/bin/sourcetrail
|
||||||
|
|
||||||
desktop-file-install --dir=$out/share/applications \
|
desktop-file-install --dir=$out/share/applications \
|
||||||
--set-key Exec --set-value $out/bin/sourcetrail \
|
--set-key Exec --set-value ${appBinDir}/sourcetrail \
|
||||||
../setup/Linux/data/sourcetrail.desktop
|
../setup/Linux/data/sourcetrail.desktop
|
||||||
|
|
||||||
mkdir -p $out/share/mime/packages
|
mkdir -p $out/share/mime/packages
|
||||||
cp ../setup/Linux/data/sourcetrail-mime.xml $out/share/mime/packages/
|
cp ../setup/Linux/data/sourcetrail-mime.xml $out/share/mime/packages/
|
||||||
|
|
||||||
mkdir -p $out/opt/sourcetrail/share
|
|
||||||
cp -R ../bin/app/data $out/opt/sourcetrail/share
|
|
||||||
cp -R ../bin/app/user/projects $out/opt/sourcetrail/share/data/fallback
|
|
||||||
rm $out/opt/sourcetrail/share/data/*_template.xml
|
|
||||||
rm -r $out/opt/sourcetrail/share/data/install
|
|
||||||
|
|
||||||
for size in 48 64 128 256 512; do
|
for size in 48 64 128 256 512; do
|
||||||
mkdir -p $out/share/icons/hicolor/''${size}x''${size}/apps/
|
mkdir -p $out/share/icons/hicolor/''${size}x''${size}/apps/
|
||||||
convert app/data/gui/icon/logo_1024_1024.png -resize ''${size}x''${size} \
|
convert ${appResourceDir}/data/gui/icon/logo_1024_1024.png \
|
||||||
|
-resize ''${size}x''${size} \
|
||||||
$out/share/icons/hicolor/''${size}x''${size}/apps/sourcetrail.png
|
$out/share/icons/hicolor/''${size}x''${size}/apps/sourcetrail.png
|
||||||
done
|
done
|
||||||
|
'' + lib.optionalString (stdenv.isDarwin) ''
|
||||||
|
# change case (some people *might* choose a case sensitive Nix store)
|
||||||
|
mv ${appBinDir}/sourcetrail{,.tmp}
|
||||||
|
mv ${appBinDir}/{sourcetrail.tmp,Sourcetrail}
|
||||||
|
mv ${appBinDir}/sourcetrail_indexer ${appResourceDir}/Sourcetrail_indexer
|
||||||
|
|
||||||
mkdir -p $out/bin
|
ln -sf ${appBinDir}/Sourcetrail $out/bin/sourcetrail
|
||||||
makeQtWrapper $out/opt/sourcetrail/bin/sourcetrail $out/bin/sourcetrail \
|
|
||||||
--prefix PATH : ${lib.makeBinPath binPath}
|
cp app/bundle_info.plist ${appPrefixDir}/Info.plist
|
||||||
|
|
||||||
|
mkdir -p ${appResourceDir}/icon.iconset
|
||||||
|
for size in 16 32 128 256 512; do
|
||||||
|
convert ${appResourceDir}/data/gui/icon/logo_1024_1024.png \
|
||||||
|
-resize ''${size}x''${size} \
|
||||||
|
${appResourceDir}/icon.iconset/icon_''${size}x''${size}.png
|
||||||
|
convert ${appResourceDir}/data/gui/icon/logo_1024_1024.png \
|
||||||
|
-resize $(( 2 * size ))x$(( 2 * size )) \
|
||||||
|
${appResourceDir}/icon.iconset/icon_''${size}x''${size}@2x.png
|
||||||
|
done
|
||||||
|
png2icns ${appResourceDir}/icon.icns \
|
||||||
|
${appResourceDir}/icon.iconset/icon_{16x16,32x32,128x128,256x256,512x512,512x512@2x}.png
|
||||||
|
|
||||||
|
mkdir -p ${appResourceDir}/project.iconset
|
||||||
|
for size in 16 32 64 128 256 512; do
|
||||||
|
convert ${appResourceDir}/data/gui/icon/project_256_256.png \
|
||||||
|
-resize ''${size}x''${size} \
|
||||||
|
${appResourceDir}/project.iconset/icon_''${size}x''${size}.png
|
||||||
|
convert ${appResourceDir}/data/gui/icon/project_256_256.png \
|
||||||
|
-resize $(( 2 * size ))x$(( 2 * size )) \
|
||||||
|
${appResourceDir}/project.iconset/icon_''${size}x''${size}@2x.png
|
||||||
|
done
|
||||||
|
png2icns ${appResourceDir}/project.icns \
|
||||||
|
${appResourceDir}/project.iconset/icon_{16x16,32x32,128x128,256x256,512x512,512x512@2x}.png
|
||||||
|
'' + ''
|
||||||
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
|
runHook preCheck
|
||||||
|
|
||||||
rm -rf ../bin/app/data/{python,java/lib}
|
rm -rf ../bin/app/data/{python,java/lib}
|
||||||
ln -s $out/opt/sourcetrail/share/data/python ../bin/app/data/python
|
ln -s $out/opt/sourcetrail/share/data/python ../bin/app/data/python
|
||||||
ln -s $out/opt/sourcetrail/share/data/java/lib ../bin/app/data/java/lib
|
ln -s $out/opt/sourcetrail/share/data/java/lib ../bin/app/data/java/lib
|
||||||
|
@ -194,20 +252,24 @@ stdenv.mkDerivation rec {
|
||||||
popd
|
popd
|
||||||
|
|
||||||
rm ../bin/app/data/{python,java/lib}
|
rm ../bin/app/data/{python,java/lib}
|
||||||
|
|
||||||
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# This has to be done manually in the installPhase because the actual binary
|
# This has to be done manually in the installPhase because the actual binary
|
||||||
# lives in $out/opt/sourcetrail/bin, which isn't covered by wrapQtAppsHook
|
# lives in $out/opt/sourcetrail/bin, which isn't covered by wrapQtAppsHook
|
||||||
dontWrapQtApps = true;
|
dontWrapQtApps = true;
|
||||||
|
|
||||||
# FIXME: some test cases are disabled in the patch phase
|
# FIXME: Some test cases are disabled in the patch phase.
|
||||||
doCheck = true;
|
# FIXME: Tests are disabled on some platforms because of faulty detection
|
||||||
|
# logic for libjvm.so. Should work with manual configuration.
|
||||||
|
doCheck = !stdenv.isDarwin && stdenv.isx86_64;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = "https://www.sourcetrail.com";
|
homepage = "https://www.sourcetrail.com";
|
||||||
description = "A cross-platform source explorer for C/C++ and Java";
|
description = "A cross-platform source explorer for C/C++ and Java";
|
||||||
platforms = platforms.all;
|
platforms = platforms.all;
|
||||||
license = licenses.gpl3;
|
license = licenses.gpl3Plus;
|
||||||
maintainers = with maintainers; [ midchildan ];
|
maintainers = with maintainers; [ midchildan ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,10 @@ stdenv.mkDerivation rec {
|
||||||
make -j $NIX_BUILD_CORES
|
make -j $NIX_BUILD_CORES
|
||||||
popd
|
popd
|
||||||
popd
|
popd
|
||||||
|
'' + lib.optionalString stdenv.isDarwin ''
|
||||||
|
pushd SourcetrailDB/build/bindings_python
|
||||||
|
cp _sourcetraildb.dylib _sourcetraildb.so
|
||||||
|
popd
|
||||||
'';
|
'';
|
||||||
|
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
|
@ -52,7 +56,7 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
pushd SourcetrailDB/build/bindings_python
|
pushd SourcetrailDB/build/bindings_python
|
||||||
cp sourcetraildb.py $out/libexec
|
cp sourcetraildb.py $out/libexec
|
||||||
cp _sourcetraildb* $out/libexec/_sourcetraildb.so
|
cp _sourcetraildb.so $out/libexec/_sourcetraildb.so
|
||||||
popd
|
popd
|
||||||
|
|
||||||
wrapPythonProgramsIn "$out/libexec" "$pythonPath"
|
wrapPythonProgramsIn "$out/libexec" "$pythonPath"
|
||||||
|
@ -64,7 +68,5 @@ stdenv.mkDerivation rec {
|
||||||
description = "Python indexer for Sourcetrail";
|
description = "Python indexer for Sourcetrail";
|
||||||
homepage = "https://github.com/CoatiSoftware/SourcetrailPythonIndexer";
|
homepage = "https://github.com/CoatiSoftware/SourcetrailPythonIndexer";
|
||||||
license = licenses.gpl3;
|
license = licenses.gpl3;
|
||||||
broken = stdenv.isDarwin;
|
|
||||||
# https://github.com/NixOS/nixpkgs/pull/107533#issuecomment-751063675
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -25140,10 +25140,13 @@ in
|
||||||
|
|
||||||
libspotify = callPackage ../development/libraries/libspotify (config.libspotify or {});
|
libspotify = callPackage ../development/libraries/libspotify (config.libspotify or {});
|
||||||
|
|
||||||
sourcetrail = libsForQt5.callPackage ../development/tools/sourcetrail {
|
sourcetrail = let
|
||||||
jdk = jdk8;
|
|
||||||
llvmPackages = llvmPackages_10;
|
llvmPackages = llvmPackages_10;
|
||||||
|
in libsForQt5.callPackage ../development/tools/sourcetrail {
|
||||||
|
stdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv;
|
||||||
|
jdk = jdk8;
|
||||||
pythonPackages = python3Packages;
|
pythonPackages = python3Packages;
|
||||||
|
inherit llvmPackages;
|
||||||
};
|
};
|
||||||
|
|
||||||
spotifywm = callPackage ../applications/audio/spotifywm { };
|
spotifywm = callPackage ../applications/audio/spotifywm { };
|
||||||
|
|
Loading…
Reference in a new issue