Skip to content

Commit

Permalink
Merge pull request #3806 from canonical/automatic-gui-version
Browse files Browse the repository at this point in the history
Automatic gui version
  • Loading branch information
sharder996 authored Dec 18, 2024
2 parents 7074116 + 8c24637 commit 25a6647
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
4 changes: 4 additions & 0 deletions src/client/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

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
Expand Down
2 changes: 1 addition & 1 deletion src/client/gui/CMakeLists.txt.linux
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 0 additions & 2 deletions src/client/gui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 25a6647

Please sign in to comment.