-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
pkgs/development/compilers/dart/package-source-builders/rhttp/cargokit.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- old/cargokit/cmake/cargokit.cmake 2024-11-08 13:36:13.345889693 +0800 | ||
+++ new/cargokit/cmake/cargokit.cmake 2024-11-08 13:45:26.019632176 +0800 | ||
@@ -17,83 +17,22 @@ | ||
function(apply_cargokit target manifest_dir lib_name any_symbol_name) | ||
|
||
set(CARGOKIT_LIB_NAME "${lib_name}") | ||
- set(CARGOKIT_LIB_FULL_NAME "${CMAKE_SHARED_MODULE_PREFIX}${CARGOKIT_LIB_NAME}${CMAKE_SHARED_MODULE_SUFFIX}") | ||
- if (CMAKE_CONFIGURATION_TYPES) | ||
- set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>") | ||
- set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${CARGOKIT_LIB_FULL_NAME}") | ||
- else() | ||
- set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") | ||
- set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/${CARGOKIT_LIB_FULL_NAME}") | ||
- endif() | ||
- set(CARGOKIT_TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/cargokit_build") | ||
- | ||
- if (FLUTTER_TARGET_PLATFORM) | ||
- set(CARGOKIT_TARGET_PLATFORM "${FLUTTER_TARGET_PLATFORM}") | ||
- else() | ||
- set(CARGOKIT_TARGET_PLATFORM "windows-x64") | ||
- endif() | ||
- | ||
- set(CARGOKIT_ENV | ||
- "CARGOKIT_CMAKE=${CMAKE_COMMAND}" | ||
- "CARGOKIT_CONFIGURATION=$<CONFIG>" | ||
- "CARGOKIT_MANIFEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${manifest_dir}" | ||
- "CARGOKIT_TARGET_TEMP_DIR=${CARGOKIT_TEMP_DIR}" | ||
- "CARGOKIT_OUTPUT_DIR=${CARGOKIT_OUTPUT_DIR}" | ||
- "CARGOKIT_TARGET_PLATFORM=${CARGOKIT_TARGET_PLATFORM}" | ||
- "CARGOKIT_TOOL_TEMP_DIR=${CARGOKIT_TEMP_DIR}/tool" | ||
- "CARGOKIT_ROOT_PROJECT_DIR=${CMAKE_SOURCE_DIR}" | ||
- ) | ||
- | ||
- if (WIN32) | ||
- set(SCRIPT_EXTENSION ".cmd") | ||
- set(IMPORT_LIB_EXTENSION ".lib") | ||
- else() | ||
- set(SCRIPT_EXTENSION ".sh") | ||
- set(IMPORT_LIB_EXTENSION "") | ||
- execute_process(COMMAND chmod +x "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}") | ||
- endif() | ||
- | ||
- # Using generators in custom command is only supported in CMake 3.20+ | ||
- if (CMAKE_CONFIGURATION_TYPES AND ${CMAKE_VERSION} VERSION_LESS "3.20.0") | ||
- foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES) | ||
- add_custom_command( | ||
- OUTPUT | ||
- "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}/${CARGOKIT_LIB_FULL_NAME}" | ||
- "${CMAKE_CURRENT_BINARY_DIR}/_phony_" | ||
- COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV} | ||
- "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake | ||
- VERBATIM | ||
- ) | ||
- endforeach() | ||
- else() | ||
- add_custom_command( | ||
- OUTPUT | ||
- ${OUTPUT_LIB} | ||
- "${CMAKE_CURRENT_BINARY_DIR}/_phony_" | ||
- COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV} | ||
- "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake | ||
- VERBATIM | ||
- ) | ||
- endif() | ||
- | ||
- | ||
- set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/_phony_" PROPERTIES SYMBOLIC TRUE) | ||
|
||
if (TARGET ${target}) | ||
# If we have actual cmake target provided create target and make existing | ||
# target depend on it | ||
- add_custom_target("${target}_cargokit" DEPENDS ${OUTPUT_LIB}) | ||
+ add_custom_target("${target}_cargokit" DEPENDS OUTPUT_LIB) | ||
add_dependencies("${target}" "${target}_cargokit") | ||
- target_link_libraries("${target}" PRIVATE "${OUTPUT_LIB}${IMPORT_LIB_EXTENSION}") | ||
+ target_link_libraries("${target}" PRIVATE OUTPUT_LIB) | ||
if(WIN32) | ||
target_link_options(${target} PRIVATE "/INCLUDE:${any_symbol_name}") | ||
endif() | ||
else() | ||
# Otherwise (FFI) just use ALL to force building always | ||
- add_custom_target("${target}_cargokit" ALL DEPENDS ${OUTPUT_LIB}) | ||
+ add_custom_target("${target}_cargokit" ALL DEPENDS OUTPUT_LIB) | ||
endif() | ||
|
||
# Allow adding the output library to plugin bundled libraries | ||
- set("${target}_cargokit_lib" ${OUTPUT_LIB} PARENT_SCOPE) | ||
+ set("${target}_cargokit_lib" OUTPUT_LIB PARENT_SCOPE) | ||
|
||
endfunction() |
51 changes: 51 additions & 0 deletions
51
pkgs/development/compilers/dart/package-source-builders/rhttp/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
lib, | ||
rustPlatform, | ||
stdenv, | ||
}: | ||
|
||
{ version, src, ... }: | ||
|
||
let | ||
rustDep = rustPlatform.buildRustPackage { | ||
pname = "rhttp-rs"; | ||
inherit version src; | ||
|
||
sourceRoot = "${src.name}/rust"; | ||
|
||
cargoHash = | ||
{ | ||
_0_9_1 = "sha256-Gl3ArdSuw3/yi/JX6oloKJqerSJjTfK8HXRNei/LO+4="; | ||
} | ||
.${"_" + (lib.replaceStrings [ "." ] [ "_" ] version)} or (throw '' | ||
Unsupported version of pub 'rhttp': '${version}' | ||
Please add cargoHash here. If the cargoHash | ||
is the same with existing versions, add an alias here. | ||
''); | ||
|
||
env.RUSTFLAGS = "--cfg reqwest_unstable"; | ||
|
||
passthru.libraryPath = "lib/librhttp.so"; | ||
}; | ||
|
||
in | ||
stdenv.mkDerivation { | ||
pname = "rhttp"; | ||
inherit version src; | ||
inherit (src) passthru; | ||
|
||
patches = [ ./cargokit.patch ]; | ||
|
||
postPatch = '' | ||
substituteInPlace ./cargokit/cmake/cargokit.cmake --replace-fail "OUTPUT_LIB" "${rustDep}/${rustDep.passthru.libraryPath}" | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir $out/ | ||
cp -r ./* $out/ | ||
runHook postInstall | ||
''; | ||
} |