mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-11 07:23:40 +00:00
91 lines
3.9 KiB
Diff
91 lines
3.9 KiB
Diff
--- old/rust_builder/cargokit/cmake/cargokit.cmake 2024-11-08 13:36:13.345889693 +0000
|
|
+++ new/rust_builder/cargokit/cmake/cargokit.cmake 2024-11-08 13:45:26.019632176 +0000
|
|
@@ -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()
|