Merge pull request #316573 from jcaesar/pr-7

glm: 0.9.9.8 -> 1.0.1, opensplat: 1.1.2 -> 1.1.3, fix frogatto's engine's build
This commit is contained in:
Sebastián Mancilla 2024-06-11 00:02:11 -04:00 committed by GitHub
commit 591c2d057d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 46 additions and 67 deletions

View File

@ -43,6 +43,7 @@ stdenv.mkDerivation {
cmakeFlags = [ cmakeFlags = [
(lib.cmakeBool "USE_SYSTEM_OPENXR" true) (lib.cmakeBool "USE_SYSTEM_OPENXR" true)
(lib.cmakeBool "USE_SYSTEM_GLM" true) (lib.cmakeBool "USE_SYSTEM_GLM" true)
(lib.cmakeFeature "CMAKE_CXX_FLAGS" "-DGLM_ENABLE_EXPERIMENTAL")
# debug logging macros cause format-security warnings # debug logging macros cause format-security warnings
(lib.cmakeFeature "CMAKE_CXX_FLAGS" "-Wno-error=format-security") (lib.cmakeFeature "CMAKE_CXX_FLAGS" "-Wno-error=format-security")
]; ];

View File

@ -4,13 +4,13 @@
cmake, cmake,
ninja, ninja,
fetchFromGitHub, fetchFromGitHub,
fetchpatch,
python3, python3,
opencv, opencv,
nlohmann_json, nlohmann_json,
nanoflann, nanoflann,
glm, glm,
cxxopts, cxxopts,
nix-update-script,
config, config,
# Upstream has rocm/hip support, too. anyone? # Upstream has rocm/hip support, too. anyone?
cudaSupport ? config.cudaSupport, cudaSupport ? config.cudaSupport,
@ -18,7 +18,7 @@
autoAddDriverRunpath, autoAddDriverRunpath,
}: }:
let let
version = "1.1.2"; version = "1.1.3";
torch = python3.pkgs.torch.override { inherit cudaSupport; }; torch = python3.pkgs.torch.override { inherit cudaSupport; };
# Using a normal stdenv with cuda torch gives # Using a normal stdenv with cuda torch gives
# ld: /nix/store/k1l7y96gv0nc685cg7i3g43i4icmddzk-python3.11-torch-2.2.1-lib/lib/libc10.so: undefined reference to `std::ios_base_library_init()@GLIBCXX_3.4.32' # ld: /nix/store/k1l7y96gv0nc685cg7i3g43i4icmddzk-python3.11-torch-2.2.1-lib/lib/libc10.so: undefined reference to `std::ios_base_library_init()@GLIBCXX_3.4.32'
@ -32,27 +32,9 @@ stdenv'.mkDerivation {
owner = "pierotofy"; owner = "pierotofy";
repo = "OpenSplat"; repo = "OpenSplat";
rev = "refs/tags/v${version}"; rev = "refs/tags/v${version}";
hash = "sha256-3tk62b5fSf6wzuc5TwkdfAKgUMrw3ZxetCJa2RVMS/s="; hash = "sha256-2NcKb2SWU/vNsnd2KhdU85J60fJPuc44ZxIle/1UT6g=";
}; };
patches = [
(fetchpatch {
name = "install-executables.patch";
url = "https://github.com/pierotofy/OpenSplat/commit/b4c4176819b508978583b7ebf66306171807a8e6.patch";
hash = "sha256-BUgPMcO3lt3ZEzv24u36k3aTEIoloOhxrCGi1KQ5Epk=";
})
];
postPatch = ''
# the two vendored gsplats are so heavily modified they may be considered a fork
find vendor ! -name 'gsplat*' -maxdepth 1 -mindepth 1 -exec rm -rf {} +
mkdir vendor/{nanoflann,glm}
ln -s ${glm}/include/glm vendor/glm/glm
ln -s ${nanoflann}/include/nanoflann.hpp vendor/nanoflann/nanoflann.hpp
ln -s ${nlohmann_json}/include/nlohmann vendor/json
ln -s ${cxxopts}/include/cxxopts.hpp vendor/cxxopts.hpp
'';
nativeBuildInputs = [ nativeBuildInputs = [
cmake cmake
ninja ninja
@ -63,6 +45,9 @@ stdenv'.mkDerivation {
buildInputs = [ buildInputs = [
nlohmann_json nlohmann_json
nanoflann
glm
cxxopts
torch.cxxdev torch.cxxdev
torch torch
opencv opencv
@ -74,15 +59,23 @@ stdenv'.mkDerivation {
cmakeFlags = [ cmakeFlags = [
(lib.cmakeBool "CMAKE_SKIP_RPATH" true) (lib.cmakeBool "CMAKE_SKIP_RPATH" true)
(lib.cmakeFeature "FETCHCONTENT_TRY_FIND_PACKAGE_MODE" "ALWAYS")
] ++ lib.optionals cudaSupport [ ] ++ lib.optionals cudaSupport [
(lib.cmakeFeature "GPU_RUNTIME" "CUDA") (lib.cmakeFeature "GPU_RUNTIME" "CUDA")
(lib.cmakeFeature "CUDA_TOOLKIT_ROOT_DIR" "${cudaPackages.cudatoolkit}/") (lib.cmakeFeature "CUDA_TOOLKIT_ROOT_DIR" "${cudaPackages.cudatoolkit}/")
]; ];
passthru.updateScript = nix-update-script { };
meta = { meta = {
description = "Production-grade 3D gaussian splatting"; description = "Production-grade 3D gaussian splatting";
homepage = "https://github.com/pierotofy/OpenSplat/"; homepage = "https://github.com/pierotofy/OpenSplat/";
license = lib.licenses.mit; license = [
# main
lib.licenses.agpl3Only
# vendored+modified gsplat
lib.licenses.asl20
];
maintainers = [ lib.maintainers.jcaesar ]; maintainers = [ lib.maintainers.jcaesar ];
platforms = lib.platforms.linux ++ lib.optionals (!cudaSupport) lib.platforms.darwin; platforms = lib.platforms.linux ++ lib.optionals (!cudaSupport) lib.platforms.darwin;
}; };

View File

@ -1,61 +1,40 @@
{ lib { lib
, stdenv , stdenv
, fetchFromGitHub , fetchFromGitHub
, fetchpatch
, cmake , cmake
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "0.9.9.8"; version = "1.0.1";
pname = "glm"; pname = "glm";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "g-truc"; owner = "g-truc";
repo = pname; repo = pname;
rev = version; rev = version;
sha256 = "sha256-F//+3L5Ozrw6s7t4LrcUmO7sN30ZSESdrPAYX57zgr8="; sha256 = "sha256-GnGyzNRpzuguc3yYbEFtYLvG+KiCtRAktiN+NvbOICE=";
}; };
# (https://github.com/g-truc/glm/pull/986 wasn't enough, and -Werror is used)
# (https://github.com/g-truc/glm/pull/1055 neither)
patches = [
(fetchpatch {
name = "glm-0.9.9.8-clang.patch";
url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/media-libs/glm/files/glm-0.9.9.8-clang.patch?id=79476d4b145a4a6b0cbc0e73a6cefb5d584bf8fa";
hash = "sha256-D8O+qofnGUEaH5nQGdNddwHyr5FhPQa/lOup4z4SFgY=";
})
];
outputs = [ "out" "doc" ]; outputs = [ "out" "doc" ];
nativeBuildInputs = [ cmake ]; nativeBuildInputs = [ cmake ];
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102823 env.NIX_CFLAGS_COMPILE =
env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "11") "-fno-ipa-modref"; # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102823
if (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "11") then "-fno-ipa-modref"
# Fix compilation errors on darwin
else if (stdenv.cc.isClang) then "-Wno-error"
else "";
cmakeFlags = [ cmakeFlags = [
"-DBUILD_SHARED_LIBS=OFF" (lib.cmakeBool "BUILD_SHARED_LIBS" false)
"-DBUILD_STATIC_LIBS=OFF" (lib.cmakeBool "BUILD_STATIC_LIBS" false)
"-DGLM_TEST_ENABLE=${if doCheck then "ON" else "OFF"}" (lib.cmakeBool "GLM_TEST_ENABLE" doCheck)
]; ];
doCheck = true; doCheck = true;
installPhase = '' postInstall = ''
runHook preInstall
# Install header-only library
mkdir -p $out/include
cp -rv ../glm $out/include
rm $out/include/glm/CMakeLists.txt
rm $out/include/glm/detail/*.cpp
# Install CMake files
mkdir -p $out/lib
cp -rv ../cmake $out/lib
substituteInPlace $out/lib/cmake/glm/glmConfig.cmake \
--replace 'GLM_INCLUDE_DIRS ''${_IMPORT_PREFIX}' "GLM_INCLUDE_DIRS $out/include"
# Install pkg-config file # Install pkg-config file
mkdir -p $out/lib/pkgconfig mkdir -p $out/lib/pkgconfig
substituteAll ${./glm.pc.in} $out/lib/pkgconfig/glm.pc substituteAll ${./glm.pc.in} $out/lib/pkgconfig/glm.pc
@ -64,8 +43,6 @@ stdenv.mkDerivation rec {
mkdir -p $doc/share/doc/glm mkdir -p $doc/share/doc/glm
cp -rv ../doc/api $doc/share/doc/glm/html cp -rv ../doc/api $doc/share/doc/glm/html
cp -v ../doc/manual.pdf $doc/share/doc/glm cp -v ../doc/manual.pdf $doc/share/doc/glm
runHook postInstall
''; '';
meta = with lib; { meta = with lib; {

View File

@ -33,7 +33,8 @@ let
buildInputs = [ sfml libX11 glm SDL2 ]; buildInputs = [ sfml libX11 glm SDL2 ];
cmakeFlags = [ cmakeFlags = [
"-DFETCHCONTENT_SOURCE_DIR_BASIS=${basis-universal}" (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_BASIS" "${basis-universal}")
(lib.cmakeFeature "CMAKE_CXX_FLAGS" "-DGLM_ENABLE_EXPERIMENTAL")
]; ];
meta = with lib; { meta = with lib; {
@ -63,15 +64,16 @@ stdenv.mkDerivation {
buildInputs = [ serious-proton sfml glew libX11 python3 glm SDL2 ninja ]; buildInputs = [ serious-proton sfml glew libX11 python3 glm SDL2 ninja ];
cmakeFlags = [ cmakeFlags = [
"-DSERIOUS_PROTON_DIR=${serious-proton.src}" (lib.cmakeFeature "SERIOUS_PROTON_DIR" "${serious-proton.src}")
"-DCPACK_PACKAGE_VERSION=${version.emptyepsilon}" (lib.cmakeFeature "CPACK_PACKAGE_VERSION" "${version.emptyepsilon}")
"-DCPACK_PACKAGE_VERSION_MAJOR=${major}" (lib.cmakeFeature "CPACK_PACKAGE_VERSION_MAJOR" "${major}")
"-DCPACK_PACKAGE_VERSION_MINOR=${minor}" (lib.cmakeFeature "CPACK_PACKAGE_VERSION_MINOR" "${minor}")
"-DCPACK_PACKAGE_VERSION_PATCH=${patch.emptyepsilon}" (lib.cmakeFeature "CPACK_PACKAGE_VERSION_PATCH" "${patch.emptyepsilon}")
"-DFETCHCONTENT_SOURCE_DIR_BASIS=${basis-universal}" (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_BASIS" "${basis-universal}")
"-DFETCHCONTENT_SOURCE_DIR_MESHOPTIMIZER=${meshoptimizer.src}" (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_MESHOPTIMIZER" "${meshoptimizer.src}")
"-DCMAKE_AR=${stdenv.cc.cc}/bin/gcc-ar" (lib.cmakeFeature "CMAKE_AR" "${stdenv.cc.cc}/bin/gcc-ar")
"-DCMAKE_RANLIB=${stdenv.cc.cc}/bin/gcc-ranlib" (lib.cmakeFeature "CMAKE_RANLIB" "${stdenv.cc.cc}/bin/gcc-ranlib")
(lib.cmakeFeature "CMAKE_CXX_FLAGS" "-DGLM_ENABLE_EXPERIMENTAL")
"-G Ninja" "-G Ninja"
]; ];

View File

@ -33,6 +33,8 @@ stdenv.mkDerivation {
glm glm
]; ];
env.CXXFLAGS = "-DGLM_ENABLE_EXPERIMENTAL -Wno-error=deprecated-declarations";
enableParallelBuilding = true; enableParallelBuilding = true;
installPhase = '' installPhase = ''

View File

@ -22,6 +22,10 @@ mkDerivation rec {
openal libmodplug libvorbis openal libmodplug libvorbis
qtbase glm ]; qtbase glm ];
cmakeFlags = [
(lib.cmakeFeature "CMAKE_CXX_FLAGS" "-DGLM_ENABLE_EXPERIMENTAL")
];
preFixup = '' preFixup = ''
mkdir $lib/ mkdir $lib/
mv $out/lib $lib mv $out/lib $lib