Skip to content

Simplify version string generation and handling - #1083

Merged
gmaurel merged 2 commits into
uncrustify:masterfrom
CDanU:fix-version
Apr 9, 2017
Merged

gmaurel merged 2 commits into
uncrustify:masterfrom
CDanU:fix-version

Conversation

@CDanU

@CDanU CDanU commented Mar 31, 2017 •

Copy link
Copy Markdown
Collaborator

Depends upon: #1102


CMake calls make_version.py which now can generate the following version
string formats:

Case Output
last commit has a tag Uncrustify-0.64
last commit is preceding a tagged commit Uncrustify-0.64-518-0dda18c9
last N commits are pulled and no tags are available in the repository Uncrustify-0dda18c
E: make_version.py error Uncrustify-0.64_f

If the repository is in a dirty state a -dirty suffix is attached

Uncrustify-0.64-dirty

If CMAKE_BUILD_TYPE is set to Debug a _d suffix is attached to Uncrustify:

Uncrustify_d-0.64

Note that the _d suffix is handled while CMake is running, Visual Studio builds will always have this generated prefix, even if the build type is changed in the .sln file.

Also fixes these Windows problems when executing make_version.py:

  • os.EX_* is cannot be imported
  • return error codes with sys.exit()

NOTE: If this is merged all new tags must adhere the current syntax, adding differently formatted tags will break the regex and therefore the build. E: will use the fallback version string.


ref: #1069, #1081, #1074, #776

@CDanU
CDanU force-pushed the fix-version branch 7 times, most recently from 6a1a4a6 to 17a07c1 Compare April 1, 2017 16:12
CMake calls make_version.py which now can generate the following version
string formats:

Uncrustify-0.64              - when last commit has a tag
Uncrustify-0.64-518-0dda18c9 - when last commit is preceding a tagged commit
Uncrustify-0dda18c           - when N commits are pulled and no tags are
                               available in the repository

If the repository is in a dirty state a '-dirty' suffix is attached
    Uncrustify-0.64-dirty

If CMAKE_BUILD_TYPE is set to Debug a '_d' suffix is attached to
Uncrustify:
    Uncrustify_d-0.64

Note that the '_d' suffix is handled while CMake is running, Visual Studio
builds will always have this generated prefix, even if the build type is
changed in the .sln file.

Also fixes these windows problems when executing make_version.py:
- os.EX_* is cannot be imported
- return error codes with sys.exit()
@CDanU CDanU closed this Apr 2, 2017
@CDanU

CDanU commented Apr 2, 2017 •

Copy link
Copy Markdown
Collaborator Author

@andrewhit posted:

... Previously I downloaded uncrustify zip file directly so there is no .git ...

What do you guys think about this?
Personally I'd obviously would like to have as few dependencies as possible, but seeing that we already need CMake and Python to build Uncrustify I don't think that Git would increase the burden. My impression is that there is no one out there who is working with source code without having the possibility to get access to Git.

Making the build depending on the Git history is highly unusual though. I didn't consider this previously.
I think the solution to this would be to (re)introduce a fallback string into the CMakeLists.txt file.
Something like:

if( NOT CMAKE_BUILD_TYPE )
  set( CMAKE_BUILD_TYPE Release )
endif()
set( FALLBACK_VERSION "Uncrustify-0.64_f" )

....

message(STATUS )
if (make_version_error)
    message(WARNING "${make_version_error}: ${make_version_output}, scripts/make_version.py doesn't work properly")
    set( CURRENT_VERSION ${FALLBACK_VERSION} )
else()
    string(STRIP ${make_version_output} CURRENT_VERSION)
endif()

That would mean that we would have to manually bump the version of that version string for every release, and that there still would be the possibility to get logs with not enough version info ("Uncrustify-0.64_f"). Both of those points defeat the main purpose of this PR.

The only benefits that would remain are the introduced processing of the version string, if the git history is available, and it would fix the current make_version.py which, in the current state, does not work on Windows.

@CDanU CDanU reopened this Apr 6, 2017
@CDanU
CDanU force-pushed the fix-version branch 3 times, most recently from 37f6139 to cebd65d Compare April 8, 2017 15:24
@gmaurel
gmaurel merged commit ed81671 into uncrustify:master Apr 9, 2017
@CDanU
CDanU deleted the fix-version branch April 28, 2017 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants