From c26ff71d44a43243288176732489899a1296eb8a Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Fri, 5 Aug 2016 17:41:38 -0400 Subject: [PATCH 01/19] vcs: Added a vcs module, with Git and Subversion support. This provides a mechanism to interact with VCS-controlled projects. It currently supports Git and Subversion. The main interesting feature here is a rule to generate a version string. There are other rules for querying a directory for its properties that may also prove generally useful. There are also rules to 'fetch' from a repository into a directory and 'checkout' a symbolic reference from a directory. These could be used to forcibly get a specific revision of a package from a repository. It could also be used to create a proper source package management system within Boost.Build. There are two examples to show how this module might be used. The documentation build has not been tested. However, a reStructuredText document that should be identical to the BoostBook file is included in the doc directory for reference. There are no tests, but there are two examples that do quite a bit of work to test the module, but do not verify the results. This has been tested on Linux, OS X, and Windows. The 'type' rule fails on Windows due to `path.exists' rule failing. This needs to be investigated. This does not implement these functions in Python. It should be straightforward to do so. --- doc/src/vcs.rst | 217 +++++++++++++++ doc/src/vcs.xml | 238 ++++++++++++++++ .../vcs-generate-version-string/.gitignore | 1 + .../vcs-generate-version-string/README.rst | 16 ++ .../vcs-generate-version-string/jamroot.jam | 25 ++ example/vcs-generate-version-string/main.cpp | 12 + example/vcs/.gitignore | 2 + example/vcs/README.rst | 27 ++ example/vcs/jamroot.jam | 22 ++ example/vcs/vcs-helper.jam | 40 +++ src/tools/vcs-git.jam | 216 +++++++++++++++ src/tools/vcs-svn.jam | 262 ++++++++++++++++++ src/tools/vcs.jam | 253 +++++++++++++++++ 13 files changed, 1331 insertions(+) create mode 100644 doc/src/vcs.rst create mode 100644 doc/src/vcs.xml create mode 100644 example/vcs-generate-version-string/.gitignore create mode 100644 example/vcs-generate-version-string/README.rst create mode 100644 example/vcs-generate-version-string/jamroot.jam create mode 100644 example/vcs-generate-version-string/main.cpp create mode 100644 example/vcs/.gitignore create mode 100644 example/vcs/README.rst create mode 100644 example/vcs/jamroot.jam create mode 100644 example/vcs/vcs-helper.jam create mode 100644 src/tools/vcs-git.jam create mode 100644 src/tools/vcs-svn.jam create mode 100644 src/tools/vcs.jam diff --git a/doc/src/vcs.rst b/doc/src/vcs.rst new file mode 100644 index 0000000000..ddf73c776d --- /dev/null +++ b/doc/src/vcs.rst @@ -0,0 +1,217 @@ +Boost.Build ``vcs`` Module +========================== + +.. contents:: + +Overview +-------- + +The Boost.Build ``vcs`` module exposes a limited subset of version +control system functionality to Boost.Build projects for a set of +supported version control system back ends. Currently, Boost.Build +``vcs`` supports Subversion and Git. Other systems should be +straightforward to implement. + +Usage +----- + +An example Boost.Build project illustrating the vcs interface is shown +below. + +:: + + import vcs ; + + import assert ; + + # print the type of version control system and the generated + # version string for this project + echo [ vcs.type . ] + echo [ vcs.generate-version-string . ] ; + + # fetch and checkout the 1.0 reference of a project kept in the Git + # version control system + vcs.get git : https://example.com/git/path/to/project/root : /path/to/desired/root ; + vcs.checkout : /path/to/desired/root : 1.0 ; + + # verify that the URL and reference matches the desired + assert.equal [ vcs.root-url /path/to/desired/root ] : https://example.com/git/path/to/desired/root ; + assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root : 1.0 ] ; + +Also, see the `example <../../example/vcs>`_ for an exhaustive example. + +Design +------ + +The Boost.Build ``vcs`` module depends on separate backends to +implement the interface. The backend file should be named +``vcs-BACKEND.jam`` where BACKEND is the name of the backend and +should contain implementations for each of the functions defined +below. + +Currently, there are two supported backends: + +- Git +- Subversion + +Note that the only rule that requires that that the type of version +control system is specified is the ``fetch`` rule. The rest detect +the version control system from querying the given directory. + +Reference +--------- + +``type ( directory )`` + + Returns the type of version control system for the indicated + directory, or the empty string if none was detected. + +``generate-version-string ( directory )`` + + Returns a string uniquely describing the state of the repository at + the given directory. + + - When on a tag, all version control systems will return the tag + name + + - Otherwise + + - Git: ---g + + - Subversion: ---s + + The ``generate-version-string`` rule can be used to generate a version + string for a program dynamically. The example below shows how to use + this to create a ``version_string.cpp`` file containing the version + string. The ``print`` module provides a mechanism to ensure that the + generated file is only modified when the version string actually + changes. + + Also, see the `example <../../example/vcs-generate-version-string>`_ for + an complete example. + + :: + + # A Jamroot to run a program that prints a generated version string. + + import testing ; + + import vcs ; + import print ; + + path-constant working-directory-root : ../.. ; + + # run it to see the output + run versioned : : : : versioned-run ; + + # note that version_string.cpp is generated below + exe versioned : main.cpp version_string.cpp ; + + # generate the version_string.cpp file + make version_string.cpp : : @generate-file ; + rule generate-file ( target : sources * : properties * ) + { + local v = [ vcs.generate-version-string $(working-directory-root) ] ; + + print.output $(target) ; + print.text "const char * version_string = \"$(v)\";" : true ; + print.text "" ; + } + + .. code:: cpp + + // A program to print the version string. + + #include + + extern const char * version_string; + + int + main () + { + std::cout << "generated version is '" << version_string << "'\n"; + + return 0; + } + +``fetch ( vcs : root-url : directory )`` + + Fetches from the URL to the root of the vcs project to the + indicated directory using vcs. + +``checkout ( directory : symbolic-ref )`` + + Checks out the indicated symbolic reference from the repository + located at the indicated directory. + +``root-url ( directory )`` + + Returns the URL to the root of the vcs project located at the + indicated directory. + +``ref ( directory : symbolic-ref ? )`` + + Returns a unique identifier representing the current state of the + vcs project located at directory. If the symbolic reference is + given, the rule returns the reference of that symbolic reference, + not the current state of the project. + +Backends Reference +------------------ + +``generate-version-string ( directory )`` + + Returns the version string as defined for the backend. Note that + each backend is required to return the exact tag name if the + directory is on a tag. Otherwise, the format is free-form, but it + is recommended that it be as close to the Git format for ``git + describe`` as possible for maximum information. + +``fetch ( root-url : directory )`` + + Fetches the from the URL to the root of the vcs project to the + indicated directory using the backend. + +``checkout ( directory : symbolic-ref )`` + + Checks out the indicated symbolic reference from the repository + located at the indicated directory. + +``root-url ( directory )`` + + Returns the URL to the root of the vcs project located at the + indicated directory. + +``ref ( directory : symbolic-ref ? )`` + + Returns a unique identifier representing the current state of the + vcs project located at directory. If the symbolic reference is + given, the rule returns the reference of that symbolic reference, + not the current state of the project. + +``is-repository ( directory )`` + + Returns true if the directory is controlled by the backend version + control system. This can be as complex or as simple as required. + +``executable-exists ( )`` + + Returns true if the executable required to support the backend + exists on the system. + +Implementation +-------------- + +Hopefully, knowing the implementation will not be required to use this +module, but they are included here for reference. + +``vcs`` Interface +~~~~~~~~~~~~~~~~~ + +- `vcs <../../src/tools/vcs.jam>`_ + +Backends +~~~~~~~~ + +- `vcs-git <../../src/tools/vcs-git.jam>`_ +- `vcs-svn <../../src/tools/vcs-svn.jam>`_ diff --git a/doc/src/vcs.xml b/doc/src/vcs.xml new file mode 100644 index 0000000000..327332b6b1 --- /dev/null +++ b/doc/src/vcs.xml @@ -0,0 +1,238 @@ + + + +
+ + vcs + + vcs + module + + +
+ Overview + + The Boost.Build vcs module exposes a limited subset + of version control system functionality to Boost.Build projects + for a set of supported version control system back ends. + Currently, Boost.Build vcs supports Subversion and + Git. Other systems should be straightforward to implement. + +
+ +
+ Overview + + The Boost.Build vcs module depends on separate + backends to implement the interface. The backend file should be + named vcs-BACKEND.jam where BACKEND is the name of + the backend and should contain implementations for each of the + functions defined below. + +
+ +
+ Usage + + An example Boost.Build project illustrating the vcs interface is shown + below. + + + + + jamroot.jam + +import vcs ; + +import assert ; + +# print the type of version control system and the generated +# version string for this project +echo [ vcs.type . ] +echo [ vcs.generate-version-string . ] ; + +# fetch and checkout the 1.0 reference of a project kept in the Git +# version control system +vcs.get git : https://example.com/git/path/to/project/root : /path/to/desired/root ; +vcs.checkout : /path/to/desired/root : 1.0 ; + +# verify that the URL and reference matches the desired +assert.equal [ vcs.root-url /path/to/desired/root ] : https://example.com/git/path/to/desired/root ; +assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root : 1.0 ] ; + + + + + + Also, see example/vcs in the source repository for + an exhaustive example. + + +
+ +
+ Design + + Note that the only rule that requires that that the type of + version control system is specified is the fetch + rule. The rest detect the version control system from querying + the given directory. + + + + Currently, there are two supported backends: + + + Git + Subversion + + +
+ + + + + + type + vcs + + rule type ( directory ) + + Returns the type of version control system for the indicated + directory, or the empty string if none was detected. + + + + + + generate-version-string + vcs + + rule generate-version-string ( directory ) + + Returns a string uniquely describing the state of the + repository at the given directory. + + + + + When on a tag, all version control systems will return + the tag name. + + + + + + Otherwise: + + + + Git: <nearest-tag-name>-<branch-name>-<commits-since-nearest-tag>-g<commit-id> + + + + + Subversion: -<URL>--s<REV> + + + + + + + + + + The generate-version-string rule can be used to + generate a version string for a program dynamically. The + example below shows how to use this to create a + version_string.cpp file containing the version + string. The print module provides a mechanism to + ensure that the generated file is only modified when the + version string actually changes. + + + + Also, see the example + example/vcs-generate-version-string in the source + repository for an complete example. + + + + + jamroot.jam + + + + + + + + + + main.cpp + + + + + + + + + + fetch + vcs + + rule fetch ( vcs : root-url : directory ) + + Fetches the from the URL to the root of the vcs project to the + indicated directory using vcs. + + + + + + checkout + vcs + + rule checkout ( directory : symbolic-ref ) + + Checks out the indicated symbolic reference from the + repository located at the indicated directory. + + + + + + root-url + vcs + + rule root-url ( directory ) + + Returns the URL to the root of the vcs project located at the + indicated directory. + + + + + + ref + vcs + + rule ref ( directory : symbolic-ref ? ) + + Returns a unique identifier representing the current state of + the vcs project located at directory. If the symbolic + reference is given, the rule returns the reference of that + symbolic reference, not the current state of the project. + + + + + +
diff --git a/example/vcs-generate-version-string/.gitignore b/example/vcs-generate-version-string/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/example/vcs-generate-version-string/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/example/vcs-generate-version-string/README.rst b/example/vcs-generate-version-string/README.rst new file mode 100644 index 0000000000..fad935a1c7 --- /dev/null +++ b/example/vcs-generate-version-string/README.rst @@ -0,0 +1,16 @@ +Generate a Version String from VCS +================================== + +This example shows how to generate a version string directly from the +VCS system used to check out Boost.Build using the ``vcs`` module. + +This Boost.Build project generates a program to print out the version +string of the current working directory. It should be run with +``--verbose-test`` so the result is easy to see. + +.. code:: + + b2 --verbose-test + +Note that the ``version_string.cpp`` file can be found in the ``bin`` +directory tree. diff --git a/example/vcs-generate-version-string/jamroot.jam b/example/vcs-generate-version-string/jamroot.jam new file mode 100644 index 0000000000..c42e5e537b --- /dev/null +++ b/example/vcs-generate-version-string/jamroot.jam @@ -0,0 +1,25 @@ +# A Jamroot to run a program that prints a generated version string. + +import testing ; + +import vcs ; +import print ; + +path-constant working-directory-root : ../.. ; + +# run it to see the output +run versioned : : : : versioned-run ; + +# note that version_string.cpp is generated below +exe versioned : main.cpp version_string.cpp ; + +# generate the version_string.cpp file +make version_string.cpp : : @generate-file ; +rule generate-file ( target : sources * : properties * ) +{ + local v = [ vcs.generate-version-string $(working-directory-root) ] ; + + print.output $(target) ; + print.text "const char * version_string = \"$(v)\";" : true ; + print.text "" ; +} diff --git a/example/vcs-generate-version-string/main.cpp b/example/vcs-generate-version-string/main.cpp new file mode 100644 index 0000000000..05431f8915 --- /dev/null +++ b/example/vcs-generate-version-string/main.cpp @@ -0,0 +1,12 @@ +// A program to print the version string. +#include + +extern const char * version_string; + +int +main () +{ + std::cout << "generated version is '" << version_string << "'\n"; + + return 0; +} diff --git a/example/vcs/.gitignore b/example/vcs/.gitignore new file mode 100644 index 0000000000..e14fcd1b13 --- /dev/null +++ b/example/vcs/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/repositories/ diff --git a/example/vcs/README.rst b/example/vcs/README.rst new file mode 100644 index 0000000000..84f5da733c --- /dev/null +++ b/example/vcs/README.rst @@ -0,0 +1,27 @@ +Boost.Build vcs Module Demonstration +==================================== + +This Boost.Build project provides a demonstration of the functionality +available from the ``vcs`` module. + +It first prints the properties of the VCS system used to maintain this +repository, then fetches and checks out the Boost.Build source code +form GitHub using both Git and Subversion and prints the properties of +each of those repositories. + +This will create the following directory tree by checking out the +Boost.Build source code at the indicated versions. + +:: + + repositories + repositories/git + repositories/gitboost-build-boost-1.55.0 + repositories/gitboost-build-master + repositories/gitboost-build-origin-master + repositories/gitboost-build-refs-heads-master + repositories/gitboost-build-refs-tags-boost-1.55.0 + repositories/gitboost-build-tags-boost-1.55.0 + repositories/svn + repositories/svn/boost-build-boost-tags-1.55.0 + repositories/svn/boost-build-trunk diff --git a/example/vcs/jamroot.jam b/example/vcs/jamroot.jam new file mode 100644 index 0000000000..b5077f4550 --- /dev/null +++ b/example/vcs/jamroot.jam @@ -0,0 +1,22 @@ +import vcs ; + +import vcs-helper ; + +path-constant working-directory-root : ../.. ; + +# print information from vcs about this repository +echo "the version control system used for $(working-directory-root) is:" ; +echo " type:" [ vcs.type $(working-directory-root) ] ; +echo " encoded revision:" [ vcs.generate-version-string $(working-directory-root) ] ; +echo " root URL:" [ vcs.root-url $(working-directory-root) ] ; +echo " symbolic reference:" [ vcs.ref $(working-directory-root) ] ; + +# fetch and checkout the Boost.Build source directory +vcs-helper.execute git : https://github.com/boostorg/build : master : boost-build-master ; +vcs-helper.execute git : https://github.com/boostorg/build : refs/heads/master : boost-build-refs-heads-master ; +vcs-helper.execute git : https://github.com/boostorg/build : origin/master : boost-build-origin-master ; +vcs-helper.execute git : https://github.com/boostorg/build : boost-1.55.0 : boost-build-boost-1.55.0 ; +vcs-helper.execute git : https://github.com/boostorg/build : tags/boost-1.55.0 : boost-build-tags-boost-1.55.0 ; +vcs-helper.execute git : https://github.com/boostorg/build : refs/tags/boost-1.55.0 : boost-build-refs-tags-boost-1.55.0 ; +vcs-helper.execute svn : https://github.com/boostorg/build : trunk : boost-build-trunk ; +vcs-helper.execute svn : https://github.com/boostorg/build : tags/boost-1.55.0 : boost-build-boost-tags-1.55.0 ; diff --git a/example/vcs/vcs-helper.jam b/example/vcs/vcs-helper.jam new file mode 100644 index 0000000000..0c490afe17 --- /dev/null +++ b/example/vcs/vcs-helper.jam @@ -0,0 +1,40 @@ +import path ; +import errors ; + +import vcs ; + +# fetch, checkout, and analyze a vcs repository +rule execute ( vcs : root-url : symbolic-ref : path ) +{ + echo "------------------------------------------------------------------------------" ; + + # a place to put the test repositories + local tmp = repositories/$(vcs) ; + + local desired-url = $(root-url) ; + local desired-symbolic-ref = $(symbolic-ref) ; + local desired-dir = $(tmp)/$(path) ; + + if ! [ path.exists $(desired-dir) ] + { + vcs.fetch $(vcs) : $(desired-url) : $(desired-dir) ; + } + else + { + echo "info: path '$(desired-dir)' exists, skipping fetch" ; + } + vcs.checkout $(desired-dir) : $(desired-symbolic-ref) ; + + local actual-vcs = [ vcs.type $(desired-dir) ] ; + local actual-root-url = [ vcs.root-url $(desired-dir) ] ; + local actual-head-ref = [ vcs.ref $(desired-dir) ] ; + local actual-symbolic-ref = [ vcs.ref $(desired-dir) : $(desired-symbolic-ref) ] ; + local actual-version-string = [ vcs.generate-version-string $(desired-dir) ] ; + + echo "info: analyzing $(desired-dir):" ; + echo " type: $(actual-vcs)" ; + echo " root URL: $(actual-root-url)" ; + echo " head reference: $(actual-head-ref)" ; + echo " symbolic reference: $(actual-symbolic-ref)" ; + echo " generated version string: $(actual-version-string)" ; +} diff --git a/src/tools/vcs-git.jam b/src/tools/vcs-git.jam new file mode 100644 index 0000000000..f9d7947ed5 --- /dev/null +++ b/src/tools/vcs-git.jam @@ -0,0 +1,216 @@ +# Copyright 2016 +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# Version Control System - Git +# +# @todo detect if git is available +# @todo detect if the current repository is a git repository + +import path ; +import errors ; +import assert ; + +# Returns a version string representing the version of the Git +# repository. +# +# If on a tag: +# +# +# +# If not on a tag: +# +# ---g +# +# If the repository is dirty, "-dirty" will be appended. +# +rule generate-version-string +( + directory # A directory resulting from a fetch or checkout. +) +{ + local v = "" ; + + if ! [ executable-exists ] + { + errors.user-error "vcs-git: Git executable is not installed" ; + } + + if ! [ is-repository $(directory) ] + { + errors.user-error "vcs-git: $(directory) is not a Git repository." ; + } + + v = [ SHELL "(cd $(directory) && git describe --tags --exact-match --dirty)" ] ; + v = [ SPLIT_BY_CHARACTERS $(v) : "\n" ] ; + + if $(v) != "" + { + local m = [ MATCH "^(.+)$" : $(v) ] ; + if $(m) + { + v = $(m[1]) ; + } + } + else + { + local v0 = [ SHELL "(cd $(directory) && git describe --tags --long --dirty)" ] ; + v0 = [ SPLIT_BY_CHARACTERS $(v0) : "\n" ] ; + local m0 = [ MATCH "^(.+)-([0-9]+)-g([0-9a-fA-F]+)(-dirty)?$" : $(v0) ] ; + if ! $(m0) + { + m0 = "" "" ; + } + + local v1 = [ SHELL "(cd $(directory) && git describe --all --long --dirty)" ] ; + v1 = [ SPLIT_BY_CHARACTERS $(v1) : "\n" ] ; + local m1 = [ MATCH "^(heads|remotes/.+)/(.+)-([0-9]+)-g([0-9a-fA-F]+)(-dirty)?$" : $(v1) ] ; + assert.variable-not-empty m1 ; + + v = "$(m0[1])-$(m0[2])-$(m1[2])-g$(m1[4])" ; + if $(m1[5]) + { + v = "$(v)-dirty" ; + } + } + + return $(v) ; +} + +# Fetches from the given url to the given directory. +# +# git clone --recurse-submodules $(root-url) $(directory) +# +rule fetch +( + root-url : # The root URL of the repository from which to fetch. + directory # A directory resulting from a fetch or checkout. +) +{ + # @todo check results + local r = [ SHELL "git clone --quiet $(root-url) $(directory)" ] ; + + # @todo should work, but doesn't + # assert.true path.exists $(directory) ; +} + +# Checks out the indicated symbolic reference for the Git +# repository at directory. +# +# A symbolic reference for Git is a URI based off the 'refs/' base or +# anything else that looks like a reference or a commit. +# +# refs/heads/master +# refs/tags/1.1.1 +# refs/heads/devel-fixes +# +rule checkout +( + directory : # A directory resulting from a Git fetch or checkout. + symbolic-ref ? # An optional Git-specific symbolic reference. +) +{ + symbolic-ref = [ normalize-symbolic-ref $(symbolic-ref) ] ; + + # check errors, etc. + local r = [ SHELL "(cd $(directory) && git checkout --quiet $(symbolic-ref))" ] ; + local s = [ SHELL "(cd $(directory) && git submodule --quiet update --init --recursive)" ] ; +} + +# Returns the root URL of the Git repository at the given directory. +# +rule root-url +( + directory # A directory resulting from a fetch or checkout. +) +{ + local u = ; + + local output = [ SHELL "(cd $(directory) && git remote -v)" ] ; + local lines = [ SPLIT_BY_CHARACTERS $(output) : "\n" ] ; + for local line in $(lines) + { + local m = [ MATCH "^origin[ ]+(.+) .fetch." : $(line) ] ; + if $(m) + { + assert.equal $(u) : ; + + u = $(m[0]) ; + } + } + + assert.variable-not-empty u ; + + return $(u) ; +} + +# Returns the reference for the symbolic reference requested or HEAD +# if it is empty for the git repository at directory. +# +# For a Git repository, a reference is the SHA-1. +# +# deed12131a3334df4322 +# +rule ref +( + directory : # A directory resulting from a fetch or checkout. + symbolic-ref ? # An optional Git-specific symbolic reference. +) +{ + if ! $(symbolic-ref) + { + symbolic-ref = HEAD ; + } + symbolic-ref = [ normalize-symbolic-ref $(symbolic-ref) ] ; + + return [ SHELL "(cd $(directory) && git log -n 1 --pretty=format:\"%H\" $(symbolic-ref))" ] ; +} + +# Returns true if the given directory is a Git repository. +# +rule is-repository +( + directory # A directory resulting from a fetch or checkout. +) +{ + # @todo is there a better way? + return [ path.exists "$(directory)/.git" ] ; +} + +# Return true if the Git executable exists. +# +rule executable-exists ( ) +{ + # @todo always say true for now + return 1 == 1 ; +} + +# Returns a normalized symbolic reference. +# +# refs/heads/* -> origin/* +# +# refs/tags/* -> * +# +local rule normalize-symbolic-ref +( + symbolic-ref # A Git-specific symbolic reference. +) +{ + local m0 = [ MATCH "^(refs/)?tags/(.+)$" : $(symbolic-ref) ] ; + if $(m0) + { + symbolic-ref = $(m0[2]) ; + } + else + { + local m1 = [ MATCH "^(refs/)?heads/(.+)$" : $(symbolic-ref) ] ; + if $(m1) + { + symbolic-ref = origin/$(m1[2]) ; + } + } + + return $(symbolic-ref) ; +} diff --git a/src/tools/vcs-svn.jam b/src/tools/vcs-svn.jam new file mode 100644 index 0000000000..60efce2ad9 --- /dev/null +++ b/src/tools/vcs-svn.jam @@ -0,0 +1,262 @@ +# Copyright 2016 +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# Version Control System - Subversion +# +# @todo detect if svn is available +# @todo detect if the current repository is a Subversion repository + +import path ; +import errors ; +import assert ; + +# Generates a version string from the Subversion repository assuming a +# standard repository layout. +# +# If on a tag: +# +# +# +# If not on a tag: +# +# @todo work to match the Git format, missing nearest tag and commits +# since nearest tag +# +# ---s +# +# If the repository is dirty, "-dirty" will be appended. +# +rule generate-version-string +( + directory # A directory resulting from a fetch or checkout. +) +{ + local v = "" ; + + if ! [ executable-exists ] + { + errors.user-error "vcs-svn: Subversion executable is not installed" ; + } + + if ! [ is-repository $(directory) ] + { + errors.user-error "vcs-svn: $(directory) is not a Subversion repository." ; + } + + local tag = "" ; + local branch = "" ; + local commits = "0" ; + local revision = "" ; + + local url = "" ; + local exact_match = "" ; + + local lines = [ SHELL "svn info $(directory)" ] ; + + lines = [ SPLIT_BY_CHARACTERS $(lines) : "\n" ] ; + + for local line in $(lines) + { + local urlm = [ MATCH "^URL: (.+)\n$" : $(line) ] ; + if $(urlm) + { + url = $(urlm[1]) ; + } + local revisionm = [ MATCH "^Revision: ([0-9]+)\n$" : $(line) ] ; + if $(revisionm) + { + revision = $(revisionm[1]) ; + } + } + + if $(url) != "" + { + tagm = [ MATCH "^.*/tags/(.+)$" : $(url) ] ; + if $(tagm) + { + exact_match = "exact_match" ; + + tag = $(tagm[1]) ; + } + + branchm = [ MATCH "^.*/branches/(.+)$" : $(url) ] ; + if $(branchm) + { + branch = $(branchm[1]) ; + } + else + { + trunkm = [ MATCH "^.*/(trunk)$" : $(url) ] ; + if $(trunkm) + { + branch = $(trunkm[1]) ; + } + } + } + + # create the version string + if $(exact_match) = "exact_match" + { + v = $(tag) ; + } + else + { + v = $(tag)-$(branch)-$(commits)-s$(revision) ; + } + + # check if the working copy is dirty + if [ SHELL "cd $(directory) && svn diff" ] != "" + { + v = "$(v)-dirty" ; + } + + return $(v) ; +} + +# Fetches from the given url to the given directory. +# +# svn checkout $(root-url)/trunk $(directory) +# +rule fetch +( + root-url : # The root URL of the repository from which to fetch. + directory # A directory resulting from a fetch or checkout. +) +{ + # @todo check results + + # @todo there may not be a trunk, what to do? + local r = [ SHELL "svn checkout $(root-url)/trunk $(directory)" ] ; + + # @todo should work, but doesn't + # assert.true path.exists $(directory) ; +} + +# Checks out the indicated symbolic reference for the Subversion +# repository at directory. +# +# A symbolic reference for Subversion is a URI based off the root URL. +# +# trunk +# tags/1.1.1 +# branches/devel-fixes +# +rule checkout +( + directory : # A directory resulting from a Subversion fetch or checkout. + symbolic-ref ? # An optional Subversion-specific symbolic reference. +) +{ + # check errors, etc. + local ru = [ root-url $(directory) ] ; + + local r = [ SHELL "( cd $(directory) && svn switch $(ru)/$(symbolic-ref) )" ] ; +} + +# Returns the root URL of the Subversion repository at the given +# directory. +# +rule root-url +( + directory # A directory resulting from a fetch or checkout. +) +{ + local u = ; + + local output = [ SHELL "( cd $(directory) && svn info )" ] ; + local lines = [ SPLIT_BY_CHARACTERS $(output) : "\n" ] ; + for local line in $(lines) + { + m = [ MATCH "^Repository Root: (.+)" : $(line) ] ; + if $(m) + { + assert.equal $(u) : ; + + u = $(m[0]) ; + } + } + + assert.variable-not-empty u ; + + return $(u) ; +} + +# Returns the reference for the symbol reference if it is not empty or +# HEAD for the Subversion repository at directory. +# +# For a Subversion repository, a reference is the URL fragment beyond +# the root and the last changed revision. +# +# tags/1.1.1@12345 +# +rule ref +( + directory : # A directory resulting from a fetch or checkout. + symbolic-ref ? # An optional Subversion-specific symbolic reference. +) +{ + local ru = [ root-url $(directory) ] ; + + local lines = ; + if ! $(symbolic-ref) + { + lines = [ SHELL "( cd $(directory) && svn info )" ] ; + } + else + { + lines = [ SHELL "svn info $(ru)/$(symbolic-ref)" ] ; + } + + assert.variable-not-empty lines ; + + local r = ; + local sr = ; + + for local line in $(lines) + { + line = [ SPLIT_BY_CHARACTERS $(line) : "\n" ] ; + + m0 = [ MATCH "^Last Changed Rev: (.+)" : $(line) ] ; + if $(m0) + { + assert.equal $(r) : ; + + r = $(m0[0]) ; + } + + m1 = [ MATCH "^URL: $(ru)/(.+)" : $(line) ] ; + if $(m1) + { + assert.equal $(sr) : ; + + sr = $(m1[0]) ; + } + } + + assert.variable-not-empty r ; + assert.variable-not-empty sr ; + + return $(sr)@$(r) ; +} + +# Returns true if the given directory is a Subversion repository. +# +rule is-repository +( + directory # A directory resulting from a fetch or checkout. +) +{ + # @todo is there a better way? + return [ path.exists "$(directory)/.svn" ] ; +} + +# Return true if the Subversion executable exists. +# +rule executable-exists ( ) +{ + # @todo always say true for now + return 1 == 1 ; +} diff --git a/src/tools/vcs.jam b/src/tools/vcs.jam new file mode 100644 index 0000000000..8415323aee --- /dev/null +++ b/src/tools/vcs.jam @@ -0,0 +1,253 @@ +# Copyright 2016 +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# Version Control System module +# +# Overview +# +# The Boost.Build ``vcs`` module exposes a limited subset of version +# control system functionality to Boost.Build projects for a set of +# supported version control system back ends. Currently, Boost.Build +# ``vcs`` supports Subversion and Git. Other systems should be +# straightforward to implement. +# +# Usage +# +# An example Boost.Build project illustrating the vcs interface is shown +# below. +# +# :: +# +# import vcs ; +# +# import assert ; +# +# # print the type of version control system and the generated +# # version string for this project +# echo [ vcs.type . ] +# echo [ vcs.generate-version-string . ] ; +# +# # fetch and checkout the 1.0 reference of a project kept in the Git +# # version control system +# vcs.get git : https://example.com/git/path/to/project/root : /path/to/desired/root ; +# vcs.checkout : /path/to/desired/root : 1.0 ; +# +# # verify that the URL and reference matches the desired +# assert.equal [ vcs.root-url /path/to/desired/root ] : https://example.com/git/path/to/desired/root ; +# assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root : 1.0 ] ; +# +# Also, see the `example <../../example/vcs>`_ for an exhaustive example. + +import path ; +import errors ; +import assert ; + +debugging-enable = ; + +# The list of version control systems supported by this module. +# +supported-vcs = git svn ; + +for vcs in $(supported-vcs) +{ + import vcs-$(vcs) ; +} + +# Returns the type of version control system for the indicated +# directory, or the empty string if none was detected. +# +rule type +( + directory # A directory resulting from a fetch or checkout. +) +{ + t = ; + for vcs in $(supported-vcs) + { + if ! $(t) && [ vcs-$(vcs).is-repository $(directory) ] + { + t = $(vcs) ; + } + } + + if ! $(t) + { + errors.error "unknown vcs system at $(directory)" ; + } + + return $(t) ; +} + +# Returns a string uniquely describing the state of the repository at +# the given directory. +# +# - When on a tag, all version control systems will return the tag +# name +# +# - Otherwise +# +# - Git: ---g +# +# - Subversion: ---s +# +# The ``generate-version-string`` rule can be used to generate a version +# string for a program dynamically. The example below shows how to use +# this to create a ``version_string.cpp`` file containing the version +# string. The ``print`` module provides a mechanism to ensure that the +# generated file is only modified when the version string actually +# changes. +# +# Also, see the `example <../../example/vcs-generate-version-string>`_ for +# an complete example. +# +# :: +# +# # A Jamroot to run a program that prints a generated version string. +# +# import testing ; +# +# import vcs ; +# import print ; +# +# path-constant working-directory-root : ../.. ; +# +# # run it to see the output +# run versioned : : : : versioned-run ; +# +# # note that version_string.cpp is generated below +# exe versioned : main.cpp version_string.cpp ; +# +# # generate the version_string.cpp file +# make version_string.cpp : : @generate-file ; +# rule generate-file ( target : sources * : properties * ) +# { +# local v = [ vcs.generate-version-string $(working-directory-root) ] ; +# +# print.output $(target) ; +# print.text "const char * version_string = \"$(v)\";" : true ; +# print.text "" ; +# } +# +# :: +# +# // A program to print the version string. +# +# #include +# +# extern const char * version_string; +# +# int +# main () +# { +# std::cout << "generated version is '" << version_string << "'\n"; +# +# return 0; +# } +# +rule generate-version-string +( + directory # A directory resulting from a fetch or checkout. +) +{ + # @todo need to fix this + # if ! [ path.exists $(directory) ] + # { + # errors.user-error "$(directory) does not exist." ; + # } + + vcs = [ type $(directory) ] ; + assert.in $(vcs) : $(supported-vcs) ; + + return [ vcs-$(vcs).generate-version-string $(directory) ] ; +} + +# Fetches from the URL to the root of the vcs project to the +# indicated directory using vcs. +# +rule fetch +( + vcs : # The VCS system to use to fetch the root URL. + root-url : # The root URL of the repository from which to fetch. + directory # The directory into which to fetch the root URL. +) +{ + assert.in $(vcs) : $(supported-vcs) ; + + if [ path.exists $(directory) ] + { + assert.true type $(directory) : $(vcs) ; + + local current-url = [ vcs-$(vcs).root-url $(directory) ] ; + + if $(current-url) != $(root-url) + { + errors.error "vcs:$(vcs): $(directory) is at $(current-url) not $(root-url)" ; + } + } + else + { + if $(debugging-enable) + { + echo "vcs: fetching $(root-url) to $(directory)" ; + } + + local r1 = [ vcs-$(vcs).fetch $(root-url) : $(directory) ] ; + } +} + +# Checks out the indicated symbolic reference from the repository +# located at the indicated directory. +# +rule checkout +( + directory # A directory resulting from a fetch or checkout. + symbolic-ref # The VCS-specific symbolic reference to check out. +) +{ + local vcs = [ type $(directory) ] ; + + assert.in $(vcs) : $(supported-vcs) ; + + if $(debugging-enable) + { + echo "vcs: checking out $(symbolic-ref) at $(directory)" ; + } + + local r = [ vcs-$(vcs).checkout $(directory) : $(symbolic-ref) ] ; +} + +# Returns the URL to the root of the vcs project located at the +# indicated directory. +# +rule root-url +( + directory # A directory resulting from a fetch or checkout. +) +{ + local vcs = [ type $(directory) ] ; + + assert.in $(vcs) : $(supported-vcs) ; + + return [ vcs-$(vcs).root-url $(directory) ] ; +} + +# Returns a unique identifier representing the current state of the +# vcs project located at directory. If the symbolic reference is +# given, the rule returns the reference of that symbolic reference, +# not the current state of the project. +# +rule ref +( + directory : # A directory resulting from a fetch or checkout. + symbolic-ref ? # An optional VCS-specific symbolic reference. +) +{ + local vcs = [ type $(directory) ] ; + + assert.in $(vcs) : $(supported-vcs) ; + + return [ vcs-$(vcs).ref $(directory) : $(symbolic-ref) ] ; +} From 32cbd6bf1ea31563c2a5f661cc5155c1b166a4ba Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sat, 1 Apr 2017 13:08:09 -0400 Subject: [PATCH 02/19] vcs: Fixes to vcs BoostBook. The BoostBook for the vcs module was missing several sections and had a few glaring mistakes. --- doc/src/vcs.xml | 445 +++++++++++++++++++++++++++++++----------------- 1 file changed, 287 insertions(+), 158 deletions(-) diff --git a/doc/src/vcs.xml b/doc/src/vcs.xml index 327332b6b1..0109ea5904 100644 --- a/doc/src/vcs.xml +++ b/doc/src/vcs.xml @@ -22,17 +22,6 @@ -
- Overview - - The Boost.Build vcs module depends on separate - backends to implement the interface. The backend file should be - named vcs-BACKEND.jam where BACKEND is the name of - the backend and should contain implementations for each of the - functions defined below. - -
-
Usage @@ -66,8 +55,7 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root - Also, see example/vcs in the source repository for - an exhaustive example. + Also, see the example example/vcs for an exhaustive example.
@@ -75,10 +63,11 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root
Design - Note that the only rule that requires that that the type of - version control system is specified is the fetch - rule. The rest detect the version control system from querying - the given directory. + The Boost.Build vcs module depends on separate backends to + implement the interface. The backend file should be named + vcs-BACKEND.jam where BACKEND is the name of the backend and + should contain implementations for each of the functions defined + below. @@ -89,150 +78,290 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root Subversion + + + Note that the only rule that requires that that the type of version + control system is specified is the fetch rule. The rest detect + the version control system from querying the given directory. +
- - - - - type - vcs - - rule type ( directory ) - - Returns the type of version control system for the indicated - directory, or the empty string if none was detected. - - - - - - generate-version-string - vcs - - rule generate-version-string ( directory ) - - Returns a string uniquely describing the state of the - repository at the given directory. - - - - - When on a tag, all version control systems will return - the tag name. - - - - - - Otherwise: - - - - Git: <nearest-tag-name>-<branch-name>-<commits-since-nearest-tag>-g<commit-id> - - - - - Subversion: -<URL>--s<REV> - - - - - - - - - - The generate-version-string rule can be used to - generate a version string for a program dynamically. The - example below shows how to use this to create a - version_string.cpp file containing the version - string. The print module provides a mechanism to - ensure that the generated file is only modified when the - version string actually changes. - - - - Also, see the example - example/vcs-generate-version-string in the source - repository for an complete example. - - - - - jamroot.jam - - - - - - - - - - main.cpp - - - +
+ Reference + + + + + + type + vcs + + rule type ( directory ) + + Returns the type of version control system for the indicated + directory, or the empty string if none was detected. + + + + + + generate-version-string + vcs + + rule generate-version-string ( directory ) + + Returns a string uniquely describing the state of the repository at + the given directory. + + + + + When on a tag, all version control systems will return the tag + name. + + + + + + Otherwise: + + + + Git: <nearest-tag-name>-<branch-name>-<commits-since-nearest-tag>-g<commit-id> + + + + + Subversion: -<URL>--s<REV> + + + + + + + + + + The generate-version-string rule can be used to generate a version + string for a program dynamically. The example below shows how to use + this to create a version_string.cpp file containing the version + string. The print module provides a mechanism to ensure that the + generated file is only modified when the version string actually + changes. + + + + Also, see the example example/vcs-generate-version-string for + an complete example. + + + + + jamroot.jam + + + + + + + + + + main.cpp + + + + + + + + + + + + fetch + vcs + + rule fetch ( vcs : root-url : directory ) + + Fetches the from the URL to the root of the vcs project to the + indicated directory using vcs. + + + + + + checkout + vcs + + rule checkout ( directory : symbolic-ref ) + + Checks out the indicated symbolic reference from the repository + located at the indicated directory. + + + + + + root-url + vcs + + rule root-url ( directory ) + + Returns the URL to the root of the vcs project located at the + indicated directory. + + + + + + ref + vcs + + rule ref ( directory : symbolic-ref ? ) + + Returns a unique identifier representing the current state of the + vcs project located at directory. If the symbolic reference is + given, the rule returns the reference of that symbolic reference, + not the current state of the project. + + + + + +
+ +
+ Backends Reference + + + + + + generate-version-string + vcs + + rule generate-version-string ( directory ) + + Returns the version string as defined for the backend. Note that + each backend is required to return the exact tag name if the + directory is on a tag. Otherwise, the format is free-form, but it + is recommended that it be as close to the Git format for git + describe as possible for maximum information. + + + + + + fetch + vcs + + rule fetch ( root-url : directory ) + + Fetches the from the URL to the root of the vcs project to the + indicated directory using the backend. + + + + + + checkout + vcs + + rule checkout ( directory : symbolic-ref ) + + Checks out the indicated symbolic reference from the repository + located at the indicated directory. + + + + + + root-url + vcs + + rule root-url ( directory ) + + Returns the URL to the root of the vcs project located at the + indicated directory. + + + + + + ref + vcs + + rule ref ( directory : symbolic-ref ? ) + + Returns a unique identifier representing the current state of the + vcs project located at directory. If the symbolic reference is + given, the rule returns the reference of that symbolic reference, + not the current state of the project. + + + + + + is-repository + vcs + + rule is-repository ( directory ) + + Returns true if the directory is controlled by the backend version + control system. This can be as complex or as simple as required. + + + + + + executable-exists + vcs + + rule executable-exists ( ) + + Returns true if the executable required to support the backend + exists on the system. + + + + + +
+ +
+ Implementation + + Hopefully, knowing the implementation will not be required to use this + module, but a link to the implementation and links to the backends are + included here for reference. - - - - - fetch - vcs - - rule fetch ( vcs : root-url : directory ) - - Fetches the from the URL to the root of the vcs project to the - indicated directory using vcs. - - - - - - checkout - vcs - - rule checkout ( directory : symbolic-ref ) - - Checks out the indicated symbolic reference from the - repository located at the indicated directory. - - - - - - root-url - vcs - - rule root-url ( directory ) - - Returns the URL to the root of the vcs project located at the - indicated directory. - - - - - - ref - vcs - - rule ref ( directory : symbolic-ref ? ) - - Returns a unique identifier representing the current state of - the vcs project located at directory. If the symbolic - reference is given, the rule returns the reference of that - symbolic reference, not the current state of the project. - - - - +
+ <code>vcs</code> Interface + + + src/tools/vcs.jam + + +
+ +
+ Backends + + + + src/tools/vcs-git.jam + + + src/tools/vcs-svn.jam + + +
+
From 84161fb48b4ec9eb8b855e4a9d7aa80876c415e8 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sat, 1 Apr 2017 14:46:59 -0400 Subject: [PATCH 03/19] vcs: Use ".. code::" instead of "::" where possible. This is clearer than using the literal section in these cases. --- doc/src/vcs.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/vcs.rst b/doc/src/vcs.rst index ddf73c776d..86a7305731 100644 --- a/doc/src/vcs.rst +++ b/doc/src/vcs.rst @@ -18,7 +18,7 @@ Usage An example Boost.Build project illustrating the vcs interface is shown below. -:: +.. code:: import vcs ; @@ -90,7 +90,7 @@ Reference Also, see the `example <../../example/vcs-generate-version-string>`_ for an complete example. - :: + .. code:: # A Jamroot to run a program that prints a generated version string. @@ -118,7 +118,7 @@ Reference print.text "" ; } - .. code:: cpp + .. code:: // A program to print the version string. From 4b3906f181e4553b8b51a4d471aafdb52b50cbba Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sat, 1 Apr 2017 14:48:07 -0400 Subject: [PATCH 04/19] vcs: Use ".. include::" to include code listings. While this is not as portable as including the code directly, this matches the BoostBook documentation approach and makes ensuring that the reStructredText documentation is identical to the DocBook documentation. --- doc/src/vcs.rst | 46 ++++------------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/doc/src/vcs.rst b/doc/src/vcs.rst index 86a7305731..bda66492fc 100644 --- a/doc/src/vcs.rst +++ b/doc/src/vcs.rst @@ -90,49 +90,11 @@ Reference Also, see the `example <../../example/vcs-generate-version-string>`_ for an complete example. - .. code:: + .. include:: ../../example/vcs-generate-version-string/jamroot.jam + :code: - # A Jamroot to run a program that prints a generated version string. - - import testing ; - - import vcs ; - import print ; - - path-constant working-directory-root : ../.. ; - - # run it to see the output - run versioned : : : : versioned-run ; - - # note that version_string.cpp is generated below - exe versioned : main.cpp version_string.cpp ; - - # generate the version_string.cpp file - make version_string.cpp : : @generate-file ; - rule generate-file ( target : sources * : properties * ) - { - local v = [ vcs.generate-version-string $(working-directory-root) ] ; - - print.output $(target) ; - print.text "const char * version_string = \"$(v)\";" : true ; - print.text "" ; - } - - .. code:: - - // A program to print the version string. - - #include - - extern const char * version_string; - - int - main () - { - std::cout << "generated version is '" << version_string << "'\n"; - - return 0; - } + .. include:: ../../example/vcs-generate-version-string/main.cpp + :code: ``fetch ( vcs : root-url : directory )`` From 5b310ce39b4e3c9c15e8491f23c9fb0b5bc630f2 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sat, 1 Apr 2017 14:30:59 -0400 Subject: [PATCH 05/19] vcs: Moved design section after the reference sections. --- doc/src/vcs.rst | 36 +++++++++++++++++----------------- doc/src/vcs.xml | 51 ++++++++++++++++++++++++------------------------- 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/doc/src/vcs.rst b/doc/src/vcs.rst index bda66492fc..3d63475337 100644 --- a/doc/src/vcs.rst +++ b/doc/src/vcs.rst @@ -40,24 +40,6 @@ below. Also, see the `example <../../example/vcs>`_ for an exhaustive example. -Design ------- - -The Boost.Build ``vcs`` module depends on separate backends to -implement the interface. The backend file should be named -``vcs-BACKEND.jam`` where BACKEND is the name of the backend and -should contain implementations for each of the functions defined -below. - -Currently, there are two supported backends: - -- Git -- Subversion - -Note that the only rule that requires that that the type of version -control system is specified is the ``fetch`` rule. The rest detect -the version control system from querying the given directory. - Reference --------- @@ -161,6 +143,24 @@ Backends Reference Returns true if the executable required to support the backend exists on the system. +Design +------ + +The Boost.Build ``vcs`` module depends on separate backends to +implement the interface. The backend file should be named +``vcs-BACKEND.jam`` where BACKEND is the name of the backend and +should contain implementations for each of the functions defined +below. + +Currently, there are two supported backends: + +- Git +- Subversion + +Note that the only rule that requires that that the type of version +control system is specified is the ``fetch`` rule. The rest detect +the version control system from querying the given directory. + Implementation -------------- diff --git a/doc/src/vcs.xml b/doc/src/vcs.xml index 0109ea5904..ec0712d02b 100644 --- a/doc/src/vcs.xml +++ b/doc/src/vcs.xml @@ -60,32 +60,6 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root -
- Design - - The Boost.Build vcs module depends on separate backends to - implement the interface. The backend file should be named - vcs-BACKEND.jam where BACKEND is the name of the backend and - should contain implementations for each of the functions defined - below. - - - - Currently, there are two supported backends: - - - Git - Subversion - - - - - Note that the only rule that requires that that the type of version - control system is specified is the fetch rule. The rest detect - the version control system from querying the given directory. - -
-
Reference @@ -330,7 +304,32 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root +
+
+ Design + + The Boost.Build vcs module depends on separate backends to + implement the interface. The backend file should be named + vcs-BACKEND.jam where BACKEND is the name of the backend and + should contain implementations for each of the functions defined + below. + + + + Currently, there are two supported backends: + + + Git + Subversion + + + + + Note that the only rule that requires that that the type of version + control system is specified is the fetch rule. The rest detect + the version control system from querying the given directory. +
From 98d623d819e115685453b3acb249cb7bac59d160 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sat, 1 Apr 2017 14:32:02 -0400 Subject: [PATCH 06/19] vcs: Move usage out of the reference section. This change makes it easier to see the rules provided by the vcs module. --- doc/src/vcs.rst | 29 ++++++++++---------- doc/src/vcs.xml | 73 +++++++++++++++++++++++++------------------------ 2 files changed, 52 insertions(+), 50 deletions(-) diff --git a/doc/src/vcs.rst b/doc/src/vcs.rst index 3d63475337..4fd235290a 100644 --- a/doc/src/vcs.rst +++ b/doc/src/vcs.rst @@ -40,6 +40,20 @@ below. Also, see the `example <../../example/vcs>`_ for an exhaustive example. +The example below shows how to use this to create a +``version_string.cpp`` file containing the version string. The +``print`` module provides a mechanism to ensure that the generated +file is only modified when the version string actually changes. + +.. include:: ../../example/vcs-generate-version-string/jamroot.jam + :code: + +.. include:: ../../example/vcs-generate-version-string/main.cpp + :code: + +Also, see the `example <../../example/vcs-generate-version-string>`_ for +an complete example. + Reference --------- @@ -63,20 +77,7 @@ Reference - Subversion: ---s The ``generate-version-string`` rule can be used to generate a version - string for a program dynamically. The example below shows how to use - this to create a ``version_string.cpp`` file containing the version - string. The ``print`` module provides a mechanism to ensure that the - generated file is only modified when the version string actually - changes. - - Also, see the `example <../../example/vcs-generate-version-string>`_ for - an complete example. - - .. include:: ../../example/vcs-generate-version-string/jamroot.jam - :code: - - .. include:: ../../example/vcs-generate-version-string/main.cpp - :code: + string for a program dynamically. ``fetch ( vcs : root-url : directory )`` diff --git a/doc/src/vcs.xml b/doc/src/vcs.xml index ec0712d02b..469aece764 100644 --- a/doc/src/vcs.xml +++ b/doc/src/vcs.xml @@ -58,6 +58,41 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root Also, see the example example/vcs for an exhaustive example. + + The example below shows how to use this to create a + version_string.cpp file containing the version string. The + print module provides a mechanism to ensure that the generated + file is only modified when the version string actually changes. + + + + + jamroot.jam + + + + + + + + + + main.cpp + + + + + + + + + Also, see the example example/vcs-generate-version-string for + an complete example. +
@@ -116,43 +151,9 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root - The generate-version-string rule can be used to generate a version - string for a program dynamically. The example below shows how to use - this to create a version_string.cpp file containing the version - string. The print module provides a mechanism to ensure that the - generated file is only modified when the version string actually - changes. - - - - Also, see the example example/vcs-generate-version-string for - an complete example. + The generate-version-string rule can be used to + generate a version string for a program dynamically. - - - - jamroot.jam - - - - - - - - - - main.cpp - - - - - - - From d10082f53d6fb07cb29cf73e39247b03137ad58d Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sat, 1 Apr 2017 14:38:18 -0400 Subject: [PATCH 07/19] vcs: Minor cleanup to some code sections. --- doc/src/vcs.rst | 6 +++--- doc/src/vcs.xml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/vcs.rst b/doc/src/vcs.rst index 4fd235290a..016d219fb2 100644 --- a/doc/src/vcs.rst +++ b/doc/src/vcs.rst @@ -72,9 +72,9 @@ Reference - Otherwise - - Git: ---g + - Git: ``---g`` - - Subversion: ---s + - Subversion: ``---s`` The ``generate-version-string`` rule can be used to generate a version string for a program dynamically. @@ -149,7 +149,7 @@ Design The Boost.Build ``vcs`` module depends on separate backends to implement the interface. The backend file should be named -``vcs-BACKEND.jam`` where BACKEND is the name of the backend and +``vcs-BACKEND.jam`` where ``BACKEND`` is the name of the backend and should contain implementations for each of the functions defined below. diff --git a/doc/src/vcs.xml b/doc/src/vcs.xml index 469aece764..4655a6e00a 100644 --- a/doc/src/vcs.xml +++ b/doc/src/vcs.xml @@ -136,12 +136,12 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root - Git: <nearest-tag-name>-<branch-name>-<commits-since-nearest-tag>-g<commit-id> + Git: <nearest-tag-name>-<branch-name>-<commits-since-nearest-tag>-g<commit-id> - Subversion: -<URL>--s<REV> + Subversion: -<URL>--s<REV> @@ -312,7 +312,7 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root The Boost.Build vcs module depends on separate backends to implement the interface. The backend file should be named - vcs-BACKEND.jam where BACKEND is the name of the backend and + vcs-BACKEND.jam where BACKEND is the name of the backend and should contain implementations for each of the functions defined below. From 15773f9f3a2a1d6f16e149ac3a9d3f756ace0f2f Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sat, 1 Apr 2017 14:39:24 -0400 Subject: [PATCH 08/19] vcs: Improve readability of the documentation. --- doc/src/vcs.rst | 28 +++++++++++++++------------- doc/src/vcs.xml | 25 ++++++++++++------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/doc/src/vcs.rst b/doc/src/vcs.rst index 016d219fb2..38e44ab542 100644 --- a/doc/src/vcs.rst +++ b/doc/src/vcs.rst @@ -15,8 +15,7 @@ straightforward to implement. Usage ----- -An example Boost.Build project illustrating the vcs interface is shown -below. +The following example illustrates the use of the ``vcs`` module. .. code:: @@ -38,11 +37,16 @@ below. assert.equal [ vcs.root-url /path/to/desired/root ] : https://example.com/git/path/to/desired/root ; assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root : 1.0 ] ; -Also, see the `example <../../example/vcs>`_ for an exhaustive example. +The `example/vcs <../../example/vcs>`_ directory in the source +repository contains a working example of the ``vcs`` module. -The example below shows how to use this to create a -``version_string.cpp`` file containing the version string. The -``print`` module provides a mechanism to ensure that the generated +The `example/vcs-generate-version-string +<../../example/vcs-generate-version-string>`_ directory in the source +repository contains the complete source code to generate a version +string using the ``vcs`` module. The listings below illustrate the +use of ``vcs.generate-version-string`` to create a +``version_string.cpp`` file containing the version string. Note that +the ``print`` module provides a mechanism to ensure that the generated file is only modified when the version string actually changes. .. include:: ../../example/vcs-generate-version-string/jamroot.jam @@ -51,9 +55,6 @@ file is only modified when the version string actually changes. .. include:: ../../example/vcs-generate-version-string/main.cpp :code: -Also, see the `example <../../example/vcs-generate-version-string>`_ for -an complete example. - Reference --------- @@ -158,15 +159,16 @@ Currently, there are two supported backends: - Git - Subversion -Note that the only rule that requires that that the type of version -control system is specified is the ``fetch`` rule. The rest detect -the version control system from querying the given directory. +Note that the only rule that requires the type of version control +system to be specified is the ``fetch`` rule. The rest of the rules +detect the version control system from querying the given directory. Implementation -------------- Hopefully, knowing the implementation will not be required to use this -module, but they are included here for reference. +module, but a link to the implementation and links to the backends are +included here for reference. ``vcs`` Interface ~~~~~~~~~~~~~~~~~ diff --git a/doc/src/vcs.xml b/doc/src/vcs.xml index 4655a6e00a..d7a0943a30 100644 --- a/doc/src/vcs.xml +++ b/doc/src/vcs.xml @@ -25,8 +25,7 @@
Usage - An example Boost.Build project illustrating the vcs interface is shown - below. + The following example illustrates the use of the vcs module. @@ -55,13 +54,18 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root - Also, see the example example/vcs for an exhaustive example. + The example/vcs directory in the source + repository contains a working example of the vcs module. - The example below shows how to use this to create a - version_string.cpp file containing the version string. The - print module provides a mechanism to ensure that the generated + The + example/vcs-generate-version-string directory in the source + repository contains the complete source code to generate a version + string using the vcs module. The listings below illustrate the + use of vcs.generate-version-string to create a + version_string.cpp file containing the version string. Note that + the print module provides a mechanism to ensure that the generated file is only modified when the version string actually changes. @@ -88,11 +92,6 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root - - - Also, see the example example/vcs-generate-version-string for - an complete example. -
@@ -151,8 +150,8 @@ assert.equal [ vcs.ref /path/to/desired/root ] : [ vcs.ref /path/to/desired/root - The generate-version-string rule can be used to - generate a version string for a program dynamically. + The generate-version-string rule can be used to generate a version + string for a program dynamically. From 8e57bacab7defb516e2d0bad4dae91f2a18362a6 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 12:28:37 -0400 Subject: [PATCH 09/19] vcs: Backends do not currently support VMS. Some of the syntax in the SHELL commands is not compatible with VMS. --- src/tools/vcs-git.jam | 8 ++++++++ src/tools/vcs-svn.jam | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/tools/vcs-git.jam b/src/tools/vcs-git.jam index f9d7947ed5..e12b19a946 100644 --- a/src/tools/vcs-git.jam +++ b/src/tools/vcs-git.jam @@ -9,10 +9,18 @@ # @todo detect if git is available # @todo detect if the current repository is a git repository +import os ; import path ; import errors ; import assert ; +# @todo SHELL commands below need to be abstracted to support all +# systems. +if [ os.name ] = VMS +{ + errors.error "VMS is not supported at this time." ; +} + # Returns a version string representing the version of the Git # repository. # diff --git a/src/tools/vcs-svn.jam b/src/tools/vcs-svn.jam index 60efce2ad9..d94a53947a 100644 --- a/src/tools/vcs-svn.jam +++ b/src/tools/vcs-svn.jam @@ -9,10 +9,18 @@ # @todo detect if svn is available # @todo detect if the current repository is a Subversion repository +import os ; import path ; import errors ; import assert ; +# @todo SHELL commands below need to be abstracted to support all +# systems. +if [ os.name ] = VMS +{ + errors.error "VMS is not supported at this time." ; +} + # Generates a version string from the Subversion repository assuming a # standard repository layout. # From 843c6393bfb33bfc1fa2b9bced398f5670c31495 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 12:35:57 -0400 Subject: [PATCH 10/19] vcs: Fixed a bug that caused checkout to fail. --- src/tools/vcs.jam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/vcs.jam b/src/tools/vcs.jam index 8415323aee..78f26e2f09 100644 --- a/src/tools/vcs.jam +++ b/src/tools/vcs.jam @@ -203,7 +203,7 @@ rule fetch # rule checkout ( - directory # A directory resulting from a fetch or checkout. + directory : # A directory resulting from a fetch or checkout. symbolic-ref # The VCS-specific symbolic reference to check out. ) { From fe71d09c1da35d568bf4b033cf12897831ea97cd Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 14:06:20 -0400 Subject: [PATCH 11/19] vcs: Added test for the basic features. This adds a test to test the functionality of all vcs functionality. * type * fetch * checkout, * ref * generate-version-string. This tests all backends. * Git * Subversion --- test/test_all.py | 1 + test/vcs.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/vcs.py diff --git a/test/test_all.py b/test/test_all.py index 07e428159d..5dc07e188d 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -305,6 +305,7 @@ def reorder_tests(tests, first_test): "unused", "use_requirements", "using", + "vcs", "wrapper", "wrong_project", ] diff --git a/test/vcs.py b/test/vcs.py new file mode 100644 index 0000000000..c2a1323025 --- /dev/null +++ b/test/vcs.py @@ -0,0 +1,45 @@ +#!/usr/bin/python + +import os + +import BoostBuild + +t = BoostBuild.Tester(use_test_config=False) + +t.write("jamroot.jam", """ +import vcs ; + +vcs.fetch git : https://github.com/boostorg/build.git : wd-git ; + +vcs.checkout wd-git : 2016.03 ; + +echo "type:" [ vcs.type wd-git ] ; +echo "root-url:" [ vcs.root-url wd-git ] ; +echo "head-ref:" [ vcs.ref wd-git ] ; +echo "symbolic-ref:" [ vcs.ref wd-git : 2016.03 ] ; +echo "generate-version-string:" [ vcs.generate-version-string wd-git ] ; + +vcs.fetch svn : https://github.com/boostorg/build.git : wd-svn ; + +vcs.checkout wd-svn : tags/2016.03 ; + +echo "type:" [ vcs.type wd-svn ] ; +echo "root-url:" [ vcs.root-url wd-svn ] ; +echo "head-ref:" [ vcs.ref wd-svn ] ; +echo "symbolic-ref:" [ vcs.ref wd-svn : tags/2016.03 ] ; +echo "generate-version-string:" [ vcs.generate-version-string wd-svn ] ; +""") + +t.run_build_system() + +t.expect_output_lines("type: git") +t.expect_output_lines("root-url: https://github.com/boostorg/build.git") +t.expect_output_lines("head-ref: e83838da44f46bbe1f9e07c61dd8d96d13be55df") +t.expect_output_lines("symbolic-ref: e83838da44f46bbe1f9e07c61dd8d96d13be55df") +t.expect_output_lines("generate-version-string: 2016.03") + +t.expect_output_lines("type: svn") +t.expect_output_lines("root-url: https://github.com/boostorg/build.git") +t.expect_output_lines("head-ref: tags/2016.03@12703") +t.expect_output_lines("symbolic-ref: tags/2016.03@12703") +t.expect_output_lines("generate-version-string: 2016.03") From 4d278c5b0e1272bcda01b088537e5f7957e55a95 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 14:09:53 -0400 Subject: [PATCH 12/19] vcs: Fixed the GitHub URL in the vcs example. This change fixes the GitHub URL for the Boost.Build project. The previous URL was correct except that it ceased to work for Subversion checkouts some time ago. --- example/vcs/jamroot.jam | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/example/vcs/jamroot.jam b/example/vcs/jamroot.jam index b5077f4550..dc2e1131d8 100644 --- a/example/vcs/jamroot.jam +++ b/example/vcs/jamroot.jam @@ -12,11 +12,11 @@ echo " root URL:" [ vcs.root-url $(working-directory-root) ] ; echo " symbolic reference:" [ vcs.ref $(working-directory-root) ] ; # fetch and checkout the Boost.Build source directory -vcs-helper.execute git : https://github.com/boostorg/build : master : boost-build-master ; -vcs-helper.execute git : https://github.com/boostorg/build : refs/heads/master : boost-build-refs-heads-master ; -vcs-helper.execute git : https://github.com/boostorg/build : origin/master : boost-build-origin-master ; -vcs-helper.execute git : https://github.com/boostorg/build : boost-1.55.0 : boost-build-boost-1.55.0 ; -vcs-helper.execute git : https://github.com/boostorg/build : tags/boost-1.55.0 : boost-build-tags-boost-1.55.0 ; -vcs-helper.execute git : https://github.com/boostorg/build : refs/tags/boost-1.55.0 : boost-build-refs-tags-boost-1.55.0 ; -vcs-helper.execute svn : https://github.com/boostorg/build : trunk : boost-build-trunk ; -vcs-helper.execute svn : https://github.com/boostorg/build : tags/boost-1.55.0 : boost-build-boost-tags-1.55.0 ; +vcs-helper.execute git : https://github.com/boostorg/build.git : master : boost-build-master ; +vcs-helper.execute git : https://github.com/boostorg/build.git : refs/heads/master : boost-build-refs-heads-master ; +vcs-helper.execute git : https://github.com/boostorg/build.git : origin/master : boost-build-origin-master ; +vcs-helper.execute git : https://github.com/boostorg/build.git : boost-1.55.0 : boost-build-boost-1.55.0 ; +vcs-helper.execute git : https://github.com/boostorg/build.git : tags/boost-1.55.0 : boost-build-tags-boost-1.55.0 ; +vcs-helper.execute git : https://github.com/boostorg/build.git : refs/tags/boost-1.55.0 : boost-build-refs-tags-boost-1.55.0 ; +vcs-helper.execute svn : https://github.com/boostorg/build.git : trunk : boost-build-trunk ; +vcs-helper.execute svn : https://github.com/boostorg/build.git : tags/boost-1.55.0 : boost-build-boost-tags-1.55.0 ; From d19c8a3fe7171544c74ced15a4f8be9b42ad0c45 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 14:11:40 -0400 Subject: [PATCH 13/19] vcs: Remove the vcs examples dependency on Boost.Build checkout. This change removes the assumption that the working copy has been checked out via a supported vcs. Using the actual location of the example/vcs directory in the example was not very useful and made running the example from the test harness impossible. --- example/vcs-generate-version-string/jamroot.jam | 5 +++-- example/vcs/jamroot.jam | 9 --------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/example/vcs-generate-version-string/jamroot.jam b/example/vcs-generate-version-string/jamroot.jam index c42e5e537b..6ac185496d 100644 --- a/example/vcs-generate-version-string/jamroot.jam +++ b/example/vcs-generate-version-string/jamroot.jam @@ -5,7 +5,8 @@ import testing ; import vcs ; import print ; -path-constant working-directory-root : ../.. ; +vcs.fetch git : https://github.com/boostorg/build.git : wd-git ; +vcs.checkout wd-git : 2016.03 ; # run it to see the output run versioned : : : : versioned-run ; @@ -17,7 +18,7 @@ exe versioned : main.cpp version_string.cpp ; make version_string.cpp : : @generate-file ; rule generate-file ( target : sources * : properties * ) { - local v = [ vcs.generate-version-string $(working-directory-root) ] ; + local v = [ vcs.generate-version-string wd-git ] ; print.output $(target) ; print.text "const char * version_string = \"$(v)\";" : true ; diff --git a/example/vcs/jamroot.jam b/example/vcs/jamroot.jam index dc2e1131d8..d46a30e119 100644 --- a/example/vcs/jamroot.jam +++ b/example/vcs/jamroot.jam @@ -2,15 +2,6 @@ import vcs ; import vcs-helper ; -path-constant working-directory-root : ../.. ; - -# print information from vcs about this repository -echo "the version control system used for $(working-directory-root) is:" ; -echo " type:" [ vcs.type $(working-directory-root) ] ; -echo " encoded revision:" [ vcs.generate-version-string $(working-directory-root) ] ; -echo " root URL:" [ vcs.root-url $(working-directory-root) ] ; -echo " symbolic reference:" [ vcs.ref $(working-directory-root) ] ; - # fetch and checkout the Boost.Build source directory vcs-helper.execute git : https://github.com/boostorg/build.git : master : boost-build-master ; vcs-helper.execute git : https://github.com/boostorg/build.git : refs/heads/master : boost-build-refs-heads-master ; From 644fc937661f1534bc71fa78efe2407d6ea0f08a Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 14:46:26 -0400 Subject: [PATCH 14/19] vcs: Do not print info in vcs example. This change minimizes any confusion caused by unnecessary warnings. --- example/vcs/vcs-helper.jam | 5 ----- 1 file changed, 5 deletions(-) diff --git a/example/vcs/vcs-helper.jam b/example/vcs/vcs-helper.jam index 0c490afe17..ab0dbd59bc 100644 --- a/example/vcs/vcs-helper.jam +++ b/example/vcs/vcs-helper.jam @@ -1,5 +1,4 @@ import path ; -import errors ; import vcs ; @@ -19,10 +18,6 @@ rule execute ( vcs : root-url : symbolic-ref : path ) { vcs.fetch $(vcs) : $(desired-url) : $(desired-dir) ; } - else - { - echo "info: path '$(desired-dir)' exists, skipping fetch" ; - } vcs.checkout $(desired-dir) : $(desired-symbolic-ref) ; local actual-vcs = [ vcs.type $(desired-dir) ] ; From 7f2f08967418cb3fcaf34f5060a0adcad0a436de Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 14:47:25 -0400 Subject: [PATCH 15/19] vcs: Skip fetch if working directory already exists in example. --- example/vcs-generate-version-string/jamroot.jam | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/example/vcs-generate-version-string/jamroot.jam b/example/vcs-generate-version-string/jamroot.jam index 6ac185496d..5079419fc3 100644 --- a/example/vcs-generate-version-string/jamroot.jam +++ b/example/vcs-generate-version-string/jamroot.jam @@ -3,9 +3,13 @@ import testing ; import vcs ; +import path ; import print ; -vcs.fetch git : https://github.com/boostorg/build.git : wd-git ; +if ! [ path.exists wd-git ] +{ + vcs.fetch git : https://github.com/boostorg/build.git : wd-git ; +} vcs.checkout wd-git : 2016.03 ; # run it to see the output From ac4bd68b37a90dd2ac33e74f8e8fb70616dacb6f Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 14:48:40 -0400 Subject: [PATCH 16/19] vcs: Simplified output in example generating a version string. --- example/vcs-generate-version-string/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/vcs-generate-version-string/main.cpp b/example/vcs-generate-version-string/main.cpp index 05431f8915..bad43498c5 100644 --- a/example/vcs-generate-version-string/main.cpp +++ b/example/vcs-generate-version-string/main.cpp @@ -6,7 +6,7 @@ extern const char * version_string; int main () { - std::cout << "generated version is '" << version_string << "'\n"; + std::cout << version_string << "\n"; return 0; } From 96f83c831f9305e21e238927e3c70dd7975241e9 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 14:59:59 -0400 Subject: [PATCH 17/19] vcs: Run example generating a versions string during test. --- test/example_vcs_generate_version_string.py | 15 +++++++++++++++ test/test_all.py | 1 + 2 files changed, 16 insertions(+) create mode 100644 test/example_vcs_generate_version_string.py diff --git a/test/example_vcs_generate_version_string.py b/test/example_vcs_generate_version_string.py new file mode 100644 index 0000000000..e42bca58cc --- /dev/null +++ b/test/example_vcs_generate_version_string.py @@ -0,0 +1,15 @@ +#!/usr/bin/python + +# Test the 'vcs-generate-version-string' example. + +import BoostBuild + +t = BoostBuild.Tester(use_test_config=False) + +t.set_tree("../example/vcs-generate-version-string") + +t.run_build_system() + +#t.expect_output_lines("2016.03") + +t.cleanup() diff --git a/test/test_all.py b/test/test_all.py index 5dc07e188d..dec7f0f6d2 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -226,6 +226,7 @@ def reorder_tests(tests, first_test): "duplicate", "example_libraries", "example_make", + "example_vcs_generate_version_string", "exit_status", "expansion", "explicit", From 15f29afa0dcd8b68e73b24b10fb979aa4a18e3cc Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 13:58:38 -0400 Subject: [PATCH 18/19] vcs: Run complete vcs example during test. --- test/example_vcs.py | 15 +++++++++++++++ test/test_all.py | 1 + 2 files changed, 16 insertions(+) create mode 100644 test/example_vcs.py diff --git a/test/example_vcs.py b/test/example_vcs.py new file mode 100644 index 0000000000..c33fd56838 --- /dev/null +++ b/test/example_vcs.py @@ -0,0 +1,15 @@ +#!/usr/bin/python + +# Test the 'vcs' example. + +import BoostBuild + +t = BoostBuild.Tester(use_test_config=False) + +t.set_tree("../example/vcs") + +t.run_build_system() + +#t.expect_output_lines("----------") + +t.cleanup() diff --git a/test/test_all.py b/test/test_all.py index dec7f0f6d2..14bb71cc95 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -226,6 +226,7 @@ def reorder_tests(tests, first_test): "duplicate", "example_libraries", "example_make", + "example_vcs", "example_vcs_generate_version_string", "exit_status", "expansion", From bc6a976bd4665f4ed6714697faac595d284ba7d8 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Sun, 2 Apr 2017 12:30:44 -0400 Subject: [PATCH 19/19] vcs: Ensure vcs-git protects user from git stderr. This change ensures that stderr is not printed when an exact match, as expected, is not found. The stderr from git was confusing to users. --- src/tools/vcs-git.jam | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tools/vcs-git.jam b/src/tools/vcs-git.jam index e12b19a946..5812510c12 100644 --- a/src/tools/vcs-git.jam +++ b/src/tools/vcs-git.jam @@ -51,7 +51,14 @@ rule generate-version-string errors.user-error "vcs-git: $(directory) is not a Git repository." ; } - v = [ SHELL "(cd $(directory) && git describe --tags --exact-match --dirty)" ] ; + if [ os.name ] = NT + { + v = [ SHELL "(cd $(directory) && git describe --tags --exact-match --dirty) 2> NUL" ] ; + } + else + { + v = [ SHELL "(cd $(directory) && git describe --tags --exact-match --dirty) 2> /dev/null" ] ; + } v = [ SPLIT_BY_CHARACTERS $(v) : "\n" ] ; if $(v) != ""