Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic gui version #3806

Open
wants to merge 5 commits into from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block could be run as a separate step, right? Could we have a separate function for it instead, and call it only where relevant (i.e. Flutter build, possibly MSI stuff later)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't be sure what you are referring to, because GitHub shows you highlighted only an empty line, but I guess you mean this whole new algorithm for extracting those two version components. And yes, we could definitely move it to a new function and call it only in the GUI cmake file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is what I meant. Should have been clearer. BTW, I like that you are printing the vars that are getting derived. It would be nice if you could keep that.

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
ricab marked this conversation as resolved.
Show resolved Hide resolved
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
Loading