Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Versioning library #7468

Merged
merged 30 commits into from
Jun 20, 2019
Merged

Versioning library #7468

merged 30 commits into from
Jun 20, 2019

Conversation

johndebord
Copy link
Contributor

@johndebord johndebord commented Jun 5, 2019

Change Description

In reference to Issue #7396 and previous Pull Request #7414, this PR alters the format of printing the cleos version in a more intuitive way by the addition of a new library in repository EOSIO/eosversion. This library is extensible enough to be included into other programs as well. Also, a new cleos sub-command has been added as well; cleos version full.


Under The Hood:
We can see that when running make, the build system updates the version metadata if need be.

~/eos/build $ make
.
.
.
[ 83%] Built target eosio_chain
[ 84%] Built target eosio_testing
[ 84%] Updating version metadata... <---
[ 84%] Built target evaluate_every_build <---
[ 85%] Built target version <---
[ 86%] Built target chain_plugin
[ 87%] Built target http_client_plugin
.
.
.

This notable behavior can be found in file /eos/libraries/version/CMakeLists.txt.

.
.
.
# Create a custom target to update the version metadata upon every build.
find_package(Git)
if(EXISTS ${CMAKE_SOURCE_DIR}/.git AND ${GIT_FOUND})
   add_custom_target(
      evaluate_every_build ALL
      COMMAND ${CMAKE_COMMAND} -DGIT_EXEC=${GIT_EXECUTABLE}
                               -DCUR_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}
                               -DCUR_SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}
                               -DSRC_DIR=${CMAKE_SOURCE_DIR}
                               -DV_MAJOR=${VERSION_MAJOR}
                               -DV_MINOR=${VERSION_MINOR}
                               -DV_PATCH=${VERSION_PATCH}
                               -DV_SUFFIX=${VERSION_SUFFIX}
                               -P ${CMAKE_SOURCE_DIR}/CMakeModules/VersionUtils.cmake
      COMMENT "Updating version metadata..." VERBATIM )
else()
   # Modify and substitute the `.cpp.in` file for a `.cpp` in the build directory.
   configure_file(
      ${CMAKE_CURRENT_SOURCE_DIR}/src/version_impl.cpp.in
      ${CMAKE_CURRENT_BINARY_DIR}/src/version_impl.cpp
      @ONLY )
endif()
.
.
.

Examples:

~/eos/build/bin $ ./cleos version client
1.9.0-develop
~/eos/build/bin $ ./cleos version full
v1.9.0-develop-cccfb5cd4a1d98b8b4392c2969713bd13b9eee8b

Walk-through:

~/eos/build/bin $ git describe --tags --dirty; ./nodeos --version; ./cleos version full
v1.8.0-rc1-590-gcccfb5cd4
v1.8.0-rc1-590-gcccfb5cd4
v1.9.0-develop-cccfb5cd4a1d98b8b4392c2969713bd13b9eee8b
~/eos/build/bin $ echo "//yo" >> ../../programs/cleos/main.cpp 
~/eos/build/bin $ git describe --tags --dirty; ./nodeos --version; ./cleos version full
v1.8.0-rc1-590-gcccfb5cd4-dirty
v1.8.0-rc1-590-gcccfb5cd4
v1.9.0-develop-cccfb5cd4a1d98b8b4392c2969713bd13b9eee8b
~/eos/build $ make -j20
.
.
.
[100%] Built target nodeos
[100%] Linking CXX executable cleos
[100%] Built target cleos
~/eos/build/bin $ git describe --tags --dirty; ./nodeos --version; ./cleos version full
v1.8.0-rc1-590-gcccfb5cd4-dirty
v1.8.0-rc1-590-gcccfb5cd4-dirty
v1.9.0-develop-cccfb5cd4a1d98b8b4392c2969713bd13b9eee8b-dirty
~/eos/build/bin $ git status
On branch version-library
Your branch is up to date with 'origin/version-library'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   ../../programs/cleos/main.cpp

no changes added to commit (use "git add" and/or "git commit -a")
~/eos/build/bin $ git add ../../programs/cleos/main.cpp; git commit -m "Test"
[version-library 2e89339aa] Test
 1 file changed, 1 insertion(+)
~/eos/build/bin $ git describe --tags --dirty; ./nodeos --version; ./cleos version full
v1.8.0-rc1-591-g2e89339aa
v1.8.0-rc1-590-gcccfb5cd4-dirty
v1.9.0-develop-cccfb5cd4a1d98b8b4392c2969713bd13b9eee8b-dirty
~/eos/build $ make -j20
.
.
.
[100%] Built target nodeos
[100%] Linking CXX executable cleos
[100%] Built target cleos
~/eos/build/bin $ git describe --tags --dirty; ./nodeos --version; ./cleos version full
v1.8.0-rc1-591-g2e89339aa
v1.8.0-rc1-591-g2e89339aa
v1.9.0-develop-2e89339aad51f26ac41de43984aa2189767845d1

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

New cleos version sub-command: cleos version full.

Documentation Additions

  • Documentation Additions

@johndebord johndebord marked this pull request as ready for review June 6, 2019 20:40
libraries/version/CMakeLists.txt Outdated Show resolved Hide resolved
@NorseGaud
Copy link
Contributor

Make sure to merge in develop to this branch or CICD will continue to fail

Copy link
Contributor

@spoonincode spoonincode left a comment

Choose a reason for hiding this comment

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

Something is not right with the dependency graph.

$ git status
HEAD detached at origin/version-library
nothing to commit, working tree clean

$ ninja
$ programs/cleos/cleos version full
v1.9.0-develop-bc02b709dc6006f492b80b8f7da86e14ae8aea22

$ echo "//hello" >> programs/eosio-blocklog/main.cpp
$ git status
HEAD detached at origin/version-library
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   programs/eosio-blocklog/main.cpp

$ ninja
$ programs/cleos/cleos version full
v1.9.0-develop-bc02b709dc6006f492b80b8f7da86e14ae8aea22
$ ninja
$ programs/cleos/cleos version full
v1.9.0-develop-bc02b709dc6006f492b80b8f7da86e14ae8aea22-dirty

Take a close look at how appbase does it -- it doesn't have this problem of needing to build twice to pick up a change.

@johndebord
Copy link
Contributor Author

@spoonincode Very interesting. This seems to be a caveat associated with ninja. I'll look into it.


~/eos $ mkdir ninja; mkdir make; pushd ./; cd ninja; cmake -GNinja ..; popd; pushd ./; cd make; cmake ..; popd;
.
.
.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/john.debord/eos/ninja
.
.
.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/john.debord/eos/make	
~/eos $ pushd ./; cd ninja; ninja; popd; pushd ./; cd make; make -j20; popd;
.
.
.
[437/601] Building CXX object libraries/chain/CMakeFiles/eosio_chain.dir/resource_limits.cpp.o
[438/601] Building CXX object libraries/chain/CMakeFiles/eosio_chain.dir/thread_utils.cpp.o
[439/601] Updating version metadata... <---
[441/601] Building CXX object libraries/wabt/CMakeFiles/wabt.dir/src/token.cc.o
[442/601] Building CXX object libraries/wabt/CMakeFiles/wabt.dir/src/opcode.cc.o
.
.
.
[  6%] Building CXX object libraries/wabt/CMakeFiles/wabt.dir/src/prebuilt/wast-lexer-gen.cc.o
[  5%] Linking C static library libbuiltins.a
/Library/Developer/CommandLineTools/usr/bin/ranlib: Updating version metadata... <---
[  5%] Built target appbase_version
[  6%] Building CXX object libraries/wabt/CMakeFiles/wabt.dir/src/lexer-source.cc.o
.
.
.
~/eos $ ./ninja/bin/cleos version full; ./make/bin/cleos version full;
v1.9.0-develop-680b6bb50c2b41af59cec25a49afd9b2cb98de10
v1.9.0-develop-680b6bb50c2b41af59cec25a49afd9b2cb98de10
~/eos $ echo "//yo" >> programs/cleos/main.cpp;
~/eos $ git status
On branch version-library
Your branch is ahead of 'origin/version-library' by 2 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   programs/cleos/main.cpp
~/eos $ pushd ./; cd ninja; ninja; popd; pushd ./; cd make; make -j20; popd;
.
.
.
~/eos $ ./ninja/bin/cleos version full; ./make/bin/cleos version full;
v1.9.0-develop-98f88862f3ba286ee3780dbb89175b5436432537
v1.9.0-develop-98f88862f3ba286ee3780dbb89175b5436432537-dirty
~/eos $ pushd ./; cd ninja; ninja; popd; pushd ./; cd make; make -j20; popd;
.
.
.
~/eos $ ./ninja/bin/cleos version full; ./make/bin/cleos version full;
v1.9.0-develop-98f88862f3ba286ee3780dbb89175b5436432537-dirty
v1.9.0-develop-98f88862f3ba286ee3780dbb89175b5436432537-dirty

@johndebord
Copy link
Contributor Author

johndebord commented Jun 18, 2019

@spoonincode Fixed. Turns out that ninja aggressively starts building before version_impl.cpp even has a chance to get generated (therefore ninja never sees that version_impl.cpp has been touched).

This is why the version library would only get built on the second iteration of using ninja; because on the second iteration, ninja only then sees that version_impl.cpp has been touched.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants