diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a2d1e5d4a..c9aa3ad0d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,6 +213,25 @@ function(determine_version OUTPUT_VARIABLE) endif() endfunction() +function(determine_version_components VERSION_STRING SEMANTIC_VERSION BUILD_NUMBER) + # stuff before + is the version and after the + is the build metadata + string(FIND "${VERSION_STRING}" "+" PLUS_POS) + string(SUBSTRING "${VERSION_STRING}" 0 ${PLUS_POS} MULTIPASS_SEMANTIC_VERSION) + if (PLUS_POS GREATER -1) + string(SUBSTRING "${VERSION_STRING}" ${PLUS_POS} -1 MULTIPASS_BUILD_STRING) + # if the build metadata starts with a g, the hexadecimal chars after that are a commit hash + # otherwise, we do not derive any build string + string(REGEX MATCH "^[+]g([a-f0-9]+)" "" "${MULTIPASS_BUILD_STRING}") + set(BUILD_NUMBER_HEX ${CMAKE_MATCH_1}) + endif() + # convert the hexadecimal commit hash to decimal. if none was extracted, this defaults to 0 + # we need it to be decimal because flutter --build-number accepts only decimal chars + math(EXPR MULTIPASS_BUILD_NUMBER "0x0${BUILD_NUMBER_HEX}") + + set(${SEMANTIC_VERSION} ${MULTIPASS_SEMANTIC_VERSION} PARENT_SCOPE) + set(${BUILD_NUMBER} ${MULTIPASS_BUILD_NUMBER} PARENT_SCOPE) +endfunction() + determine_version(MULTIPASS_VERSION) set(MULTIPASS_VERSION ${MULTIPASS_VERSION}) message(STATUS "Setting version to: ${MULTIPASS_VERSION}") diff --git a/src/client/gui/CMakeLists.txt b/src/client/gui/CMakeLists.txt index e8b146283e..37168169a6 100644 --- a/src/client/gui/CMakeLists.txt +++ b/src/client/gui/CMakeLists.txt @@ -12,6 +12,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +determine_version_components(${MULTIPASS_VERSION} MULTIPASS_SEMANTIC_VERSION MULTIPASS_BUILD_NUMBER) +message(STATUS "Setting semantic version to: ${MULTIPASS_SEMANTIC_VERSION}") +message(STATUS "Setting build number to: ${MULTIPASS_BUILD_NUMBER}") + add_library(dart_ffi SHARED ffi/dart_ffi.cpp) target_link_libraries(dart_ffi diff --git a/src/client/gui/CMakeLists.txt.linux b/src/client/gui/CMakeLists.txt.linux index 9400fd29e7..f208b1d406 100644 --- a/src/client/gui/CMakeLists.txt.linux +++ b/src/client/gui/CMakeLists.txt.linux @@ -29,7 +29,7 @@ set(MULTIPASS_GUI_EXECUTABLE_FULL_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MULTI file(GLOB_RECURSE MULTIPASS_GUI_SOURCE_FILES ${MULTIPASS_GUI_SOURCE_DIR}/lib/*.dart) -set(FLUTTER_BUILD_ARGS --release --suppress-analytics --verbose) +set(FLUTTER_BUILD_ARGS --release --suppress-analytics --verbose --build-name=${MULTIPASS_SEMANTIC_VERSION} --build-number=${MULTIPASS_BUILD_NUMBER}) add_custom_command(OUTPUT ${MULTIPASS_GUI_EXECUTABLE_FULL_PATH} DEPENDS ${MULTIPASS_GUI_SOURCE_FILES} diff --git a/src/client/gui/pubspec.yaml b/src/client/gui/pubspec.yaml index 85c8c31047..29ca48340b 100644 --- a/src/client/gui/pubspec.yaml +++ b/src/client/gui/pubspec.yaml @@ -2,8 +2,6 @@ name: multipass_gui description: A new Flutter project. publish_to: 'none' -version: 1.15.0 - environment: sdk: '>=3.0.3 <4.0.0'