mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-03 05:12:55 +00:00
Make it possible to configure a CMake build with the slint-compiler to be downloaded at app configure time
This commit is contained in:
parent
b428ca1297
commit
90b2058e49
3 changed files with 42 additions and 4 deletions
1
.github/workflows/upgrade_version.yaml
vendored
1
.github/workflows/upgrade_version.yaml
vendored
|
|
@ -24,6 +24,7 @@ jobs:
|
||||||
|
|
||||||
# Update the version in CmakeLists.txt
|
# Update the version in CmakeLists.txt
|
||||||
sed -i 's/ VERSION [0-9]*\.[0-9]*\.[0-9]*$/ VERSION ${{ github.event.inputs.new_version }}/' api/cpp/CMakeLists.txt
|
sed -i 's/ VERSION [0-9]*\.[0-9]*\.[0-9]*$/ VERSION ${{ github.event.inputs.new_version }}/' api/cpp/CMakeLists.txt
|
||||||
|
sed -i 's/SLINT_VERSION [0-9]*\.[0-9]*\.[0-9]*$/SLINT_VERSION ${{ github.event.inputs.new_version }}/' api/cpp/CMakeLists.txt
|
||||||
sed -i "s/(CPACK_PACKAGE_VERSION_MAJOR [0-9]*)/(CPACK_PACKAGE_VERSION_MAJOR `echo ${{ github.event.inputs.new_version }} | sed "s/\([0-9]*\)\.\([0-9]*\).\([0-9]*\)/\1/"`)/" api/cpp/CMakeLists.txt
|
sed -i "s/(CPACK_PACKAGE_VERSION_MAJOR [0-9]*)/(CPACK_PACKAGE_VERSION_MAJOR `echo ${{ github.event.inputs.new_version }} | sed "s/\([0-9]*\)\.\([0-9]*\).\([0-9]*\)/\1/"`)/" api/cpp/CMakeLists.txt
|
||||||
sed -i "s/(CPACK_PACKAGE_VERSION_MINOR [0-9]*)/(CPACK_PACKAGE_VERSION_MINOR `echo ${{ github.event.inputs.new_version }} | sed "s/\([0-9]*\)\.\([0-9]*\).\([0-9]*\)/\2/"`)/" api/cpp/CMakeLists.txt
|
sed -i "s/(CPACK_PACKAGE_VERSION_MINOR [0-9]*)/(CPACK_PACKAGE_VERSION_MINOR `echo ${{ github.event.inputs.new_version }} | sed "s/\([0-9]*\)\.\([0-9]*\).\([0-9]*\)/\2/"`)/" api/cpp/CMakeLists.txt
|
||||||
sed -i "s/(CPACK_PACKAGE_VERSION_PATCH [0-9]*)/(CPACK_PACKAGE_VERSION_PATCH `echo ${{ github.event.inputs.new_version }} | sed "s/\([0-9]*\)\.\([0-9]*\).\([0-9]*\)/\3/"`)/" api/cpp/CMakeLists.txt
|
sed -i "s/(CPACK_PACKAGE_VERSION_PATCH [0-9]*)/(CPACK_PACKAGE_VERSION_PATCH `echo ${{ github.event.inputs.new_version }} | sed "s/\([0-9]*\)\.\([0-9]*\).\([0-9]*\)/\3/"`)/" api/cpp/CMakeLists.txt
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ add_feature_info(SLINT_FEATURE_COMPILER SLINT_FEATURE_COMPILER "Enable support f
|
||||||
option(SLINT_BUILD_RUNTIME "Actually build the Slint runtime libraries (Disable that to only build the compiler)" ON)
|
option(SLINT_BUILD_RUNTIME "Actually build the Slint runtime libraries (Disable that to only build the compiler)" ON)
|
||||||
add_feature_info(SLINT_BUILD_RUNTIME SLINT_BUILD_RUNTIME "Actually build the Slint runtime libraries (Disable that to only build the compiler)")
|
add_feature_info(SLINT_BUILD_RUNTIME SLINT_BUILD_RUNTIME "Actually build the Slint runtime libraries (Disable that to only build the compiler)")
|
||||||
|
|
||||||
set(SLINT_COMPILER "" CACHE FILEPATH "Path to the slint-compiler executable. When unset, it the compiler will be build as part of the build process")
|
set(SLINT_COMPILER "" CACHE STRING "Path to the slint-compiler executable. When unset, it the compiler will be build as part of the build process. When set to 'download', the compiler will be downloaded from GitHub.")
|
||||||
set(SLINT_LIBRARY_CARGO_FLAGS "" CACHE STRING
|
set(SLINT_LIBRARY_CARGO_FLAGS "" CACHE STRING
|
||||||
"Flags to pass to cargo when building the Slint runtime library")
|
"Flags to pass to cargo when building the Slint runtime library")
|
||||||
|
|
||||||
|
|
@ -431,8 +431,12 @@ if(SLINT_BUILD_RUNTIME)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
get_property(_SLINT_STYLE GLOBAL PROPERTY SLINT_STYLE)
|
get_property(_SLINT_STYLE GLOBAL PROPERTY SLINT_STYLE)
|
||||||
get_target_property(_slint_compiler_location slint-compiler IMPORTED_LOCATION)
|
if (TARGET slint-compiler)
|
||||||
cmake_path(GET _slint_compiler_location FILENAME SLINT_COMPILER_FILE_NAME)
|
get_target_property(_slint_compiler_location slint-compiler IMPORTED_LOCATION)
|
||||||
|
cmake_path(GET _slint_compiler_location FILENAME SLINT_COMPILER_FILE_NAME)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SLINT_VERSION 1.8.0)
|
||||||
|
|
||||||
configure_package_config_file("cmake/SlintConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake" INSTALL_DESTINATION lib/cmake/Slint)
|
configure_package_config_file("cmake/SlintConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/Slint/SlintConfig.cmake" INSTALL_DESTINATION lib/cmake/Slint)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,41 @@ endif()
|
||||||
add_library(@slint_cpp_impl@ @cmake_lib_type@ IMPORTED)
|
add_library(@slint_cpp_impl@ @cmake_lib_type@ IMPORTED)
|
||||||
set_target_properties(@slint_cpp_impl@ PROPERTIES @SLINT_LIB_PROPERTIES@)
|
set_target_properties(@slint_cpp_impl@ PROPERTIES @SLINT_LIB_PROPERTIES@)
|
||||||
|
|
||||||
set(SLINT_COMPILER @SLINT_COMPILER@ CACHE FILEPATH "Path to the slint-compiler executable")
|
function(_slint_download_compiler_and_cache)
|
||||||
|
set(SLINT_GITHUB_RELEASE @SLINT_VERSION@ CACHE STRING "GitHub Release to use for Slint Binary Artifact Downloads")
|
||||||
|
|
||||||
|
if (CMAKE_HOST_WIN32)
|
||||||
|
set(compiler_exe_suffix ".exe")
|
||||||
|
set(platform_suffix "windows")
|
||||||
|
else()
|
||||||
|
set(platform_suffix "${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(prebuilt_archive_filename "slint-compiler-${platform_suffix}.tar.gz")
|
||||||
|
set(download_url "https://github.com/slint-ui/slint/releases/download/${SLINT_GITHUB_RELEASE}/${prebuilt_archive_filename}")
|
||||||
|
set(download_directory "${CMAKE_BINARY_DIR}/slint-prebuilt")
|
||||||
|
message(STATUS "Downloading pre-built Slint compiler binary from ${download_url}")
|
||||||
|
file(DOWNLOAD "${download_url}" "${download_directory}/${prebuilt_archive_filename}" STATUS download_status)
|
||||||
|
list(GET download_status 0 download_code)
|
||||||
|
if (NOT download_code EQUAL 0)
|
||||||
|
list(GET download_status 1 download_message)
|
||||||
|
message(FATAL_ERROR "Download of Slint compiler binary package failed: ${download_message}")
|
||||||
|
else()
|
||||||
|
file(ARCHIVE_EXTRACT INPUT "${download_directory}/${prebuilt_archive_filename}" DESTINATION "${download_directory}")
|
||||||
|
file(REMOVE "${download_directory}/${prebuilt_archive_filename}")
|
||||||
|
|
||||||
|
set(SLINT_COMPILER "${download_directory}/slint-compiler${compiler_exe_suffix}")
|
||||||
|
set(SLINT_COMPILER "${SLINT_COMPILER}" CACHE STRING "Path to the slint-compiler executable" FORCE)
|
||||||
|
set(SLINT_COMPILER "${SLINT_COMPILER}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
set(SLINT_COMPILER @SLINT_COMPILER@ CACHE STRING "Path to the slint-compiler executable")
|
||||||
if (SLINT_COMPILER)
|
if (SLINT_COMPILER)
|
||||||
|
if (SLINT_COMPILER STREQUAL "download")
|
||||||
|
_slint_download_compiler_and_cache(_)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(Slint::slint-compiler IMPORTED GLOBAL)
|
add_executable(Slint::slint-compiler IMPORTED GLOBAL)
|
||||||
set_target_properties(Slint::slint-compiler PROPERTIES IMPORTED_LOCATION ${SLINT_COMPILER})
|
set_target_properties(Slint::slint-compiler PROPERTIES IMPORTED_LOCATION ${SLINT_COMPILER})
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/SlintMacro.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/SlintMacro.cmake")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue