ja2-stracciatella: remove helper derivation by using cargoSetupHook

authored by TomaSajt and committed by Alyssa Ross 882709be fd7329e1

+48 -101
+17
pkgs/by-name/ja/ja2-stracciatella/dont-use-vendored-sdl2.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index e4e5547af..a3017d197 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -428,12 +425,6 @@ if (MINGW) 6 + install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/install-dlls-mingw.cmake") 7 + endif() 8 + 9 + -if(APPLE) 10 + - file(GLOB APPLE_DIST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/assets/distr-files-mac/*.txt") 11 + - install(FILES ${APPLE_DIST_FILES} DESTINATION .) 12 + - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/lib-SDL2-2.0.8-macos/SDL2.framework DESTINATION .) 13 + -endif() 14 + - 15 + ## Uninstall 16 + 17 + add_custom_templated_target("uninstall")
+31 -28
pkgs/by-name/ja/ja2-stracciatella/package.nix
··· 6 6 cmake, 7 7 python3, 8 8 rustPlatform, 9 + cargo, 10 + rustc, 9 11 SDL2, 10 12 fltk, 11 13 rapidjson, 12 14 gtest, 13 15 }: 16 + 14 17 let 18 + stringTheoryUrl = "https://github.com/zrax/string_theory/archive/3.1.tar.gz"; 19 + stringTheory = fetchurl { 20 + url = stringTheoryUrl; 21 + sha256 = "1flq26kkvx2m1yd38ldcq2k046yqw07jahms8a6614m924bmbv41"; 22 + }; 23 + in 24 + stdenv.mkDerivation rec { 25 + pname = "ja2-stracciatella"; 15 26 version = "0.17.0"; 27 + 16 28 src = fetchFromGitHub { 17 29 owner = "ja2-stracciatella"; 18 30 repo = "ja2-stracciatella"; 19 31 rev = "v${version}"; 20 32 sha256 = "0m6rvgkba29jy3yq5hs1sn26mwrjl6mamqnv4plrid5fqaivhn6j"; 21 33 }; 22 - libstracciatella = rustPlatform.buildRustPackage { 23 - pname = "libstracciatella"; 24 - inherit version; 25 - src = "${src}/rust"; 26 - cargoHash = "sha256-asUt+wUpwwDvSyuNZds6yMC4Ef4D8woMYWamzcJJiy4="; 27 34 28 - preBuild = '' 29 - mkdir -p $out/include/stracciatella 30 - export HEADER_LOCATION=$out/include/stracciatella/stracciatella.h 31 - ''; 32 - }; 33 - stringTheoryUrl = "https://github.com/zrax/string_theory/archive/3.1.tar.gz"; 34 - stringTheory = fetchurl { 35 - url = stringTheoryUrl; 36 - sha256 = "1flq26kkvx2m1yd38ldcq2k046yqw07jahms8a6614m924bmbv41"; 37 - }; 38 - in 39 - stdenv.mkDerivation { 40 - pname = "ja2-stracciatella"; 41 - inherit src version; 35 + patches = [ 36 + # Note: this patch is only relevant for darwin 37 + ./dont-use-vendored-sdl2.patch 38 + ]; 42 39 43 40 nativeBuildInputs = [ 44 41 cmake 45 42 python3 43 + rustPlatform.cargoSetupHook 44 + cargo 45 + rustc 46 46 ]; 47 + 47 48 buildInputs = [ 48 49 SDL2 49 50 fltk ··· 51 52 gtest 52 53 ]; 53 54 54 - patches = [ 55 - ./remove-rust-buildstep.patch 56 - ]; 55 + cargoRoot = "rust"; 56 + 57 + cargoDeps = rustPlatform.fetchCargoTarball { 58 + inherit 59 + pname 60 + version 61 + src 62 + cargoRoot 63 + ; 64 + hash = "sha256-zkctR16QIjCTiDmrhFqPPOThbPwsm0T0nlnCekkXNN8="; 65 + }; 57 66 58 67 preConfigure = '' 59 - # Use rust library built with nix 60 - substituteInPlace CMakeLists.txt \ 61 - --replace lib/libstracciatella_c_api.a ${libstracciatella}/lib/libstracciatella_c_api.a \ 62 - --replace include/stracciatella ${libstracciatella}/include/stracciatella \ 63 - --replace bin/ja2-resource-pack ${libstracciatella}/bin/ja2-resource-pack 64 - 65 68 # Patch dependencies that are usually loaded by url 66 69 substituteInPlace dependencies/lib-string_theory/builder/CMakeLists.txt.in \ 67 70 --replace ${stringTheoryUrl} file://${stringTheory}
-73
pkgs/by-name/ja/ja2-stracciatella/remove-rust-buildstep.patch
··· 1 - diff --git a/CMakeLists.txt b/CMakeLists.txt 2 - index e4e5547af..a3017d197 100644 3 - --- a/CMakeLists.txt 4 - +++ b/CMakeLists.txt 5 - @@ -175,13 +175,12 @@ if(BUILD_LAUNCHER) 6 - endif() 7 - message(STATUS "Fltk Libraries: ${FLTK_LIBRARIES}") 8 - 9 - -set(JA2_INCLUDES "") 10 - +set(JA2_INCLUDES "include/stracciatella") 11 - set(JA2_SOURCES "") 12 - add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/externalized") 13 - add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/game") 14 - add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/sgp") 15 - add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/dependencies/lib-smacker") 16 - -add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/dependencies/lib-stracciatella") 17 - add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/dependencies/lib-string_theory") 18 - 19 - if(BUILD_LAUNCHER) 20 - @@ -239,14 +238,12 @@ string(LENGTH "${CMAKE_SOURCE_DIR}/src/" SOURCE_PATH_SIZE) 21 - add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}") 22 - 23 - add_executable(${JA2_BINARY} ${JA2_SOURCES}) 24 - -target_link_libraries(${JA2_BINARY} ${SDL2_LIBRARY} ${GTEST_LIBRARIES} smacker ${STRACCIATELLA_LIBRARIES} string_theory-internal) 25 - -add_dependencies(${JA2_BINARY} stracciatella) 26 - +target_link_libraries(${JA2_BINARY} ${SDL2_LIBRARY} ${GTEST_LIBRARIES} smacker lib/libstracciatella_c_api.a dl pthread string_theory-internal) 27 - set_property(SOURCE ${CMAKE_SOURCE_DIR}/src/game/GameVersion.cc APPEND PROPERTY COMPILE_DEFINITIONS "GAME_VERSION=v${ja2-stracciatella_VERSION}") 28 - 29 - if(BUILD_LAUNCHER) 30 - add_executable(${LAUNCHER_BINARY} ${LAUNCHER_SOURCES}) 31 - - target_link_libraries(${LAUNCHER_BINARY} ${FLTK_LIBRARIES} ${STRACCIATELLA_LIBRARIES} string_theory-internal) 32 - - add_dependencies(${LAUNCHER_BINARY} stracciatella) 33 - + target_link_libraries(${LAUNCHER_BINARY} ${FLTK_LIBRARIES} lib/libstracciatella_c_api.a dl pthread string_theory-internal) 34 - endif() 35 - 36 - macro(copy_assets_dir_to_ja2_binary_after_build DIR) 37 - @@ -375,12 +372,12 @@ set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}_${CPACK_PACKAGE_VERSION}_${PACKAGE_ 38 - 39 - include(CPack) 40 - 41 - -if (UNIX AND NOT MINGW AND NOT APPLE) 42 - +if (UNIX) 43 - install(TARGETS ${JA2_BINARY} RUNTIME DESTINATION bin) 44 - if(BUILD_LAUNCHER) 45 - install(TARGETS ${LAUNCHER_BINARY} RUNTIME DESTINATION bin) 46 - endif() 47 - - install(PROGRAMS "${CMAKE_BINARY_DIR}/lib-stracciatella/bin/ja2-resource-pack${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin) 48 - + install(PROGRAMS "bin/ja2-resource-pack" DESTINATION bin) 49 - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets/externalized assets/mods assets/unittests DESTINATION share/ja2) 50 - if(WITH_EDITOR_SLF) 51 - install(FILES "${EDITORSLF_FILE}" DESTINATION share/ja2) 52 - @@ -400,7 +397,7 @@ else() 53 - if(BUILD_LAUNCHER) 54 - install(TARGETS ${LAUNCHER_BINARY} RUNTIME DESTINATION .) 55 - endif() 56 - - install(PROGRAMS "${CMAKE_BINARY_DIR}/lib-stracciatella/bin/ja2-resource-pack${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION .) 57 - + install(PROGRAMS "bin/ja2-resource-pack" DESTINATION .) 58 - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets/externalized assets/mods assets/unittests DESTINATION .) 59 - if(WITH_EDITOR_SLF) 60 - install(FILES "${EDITORSLF_FILE}" DESTINATION .) 61 - @@ -428,12 +425,6 @@ if (MINGW) 62 - install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/install-dlls-mingw.cmake") 63 - endif() 64 - 65 - -if(APPLE) 66 - - file(GLOB APPLE_DIST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/assets/distr-files-mac/*.txt") 67 - - install(FILES ${APPLE_DIST_FILES} DESTINATION .) 68 - - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/lib-SDL2-2.0.8-macos/SDL2.framework DESTINATION .) 69 - -endif() 70 - - 71 - ## Uninstall 72 - 73 - add_custom_templated_target("uninstall")