Skip to content

Commit

Permalink
build.yaml centric versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Feb 8, 2016
1 parent 469e2fd commit f008f06
Show file tree
Hide file tree
Showing 21 changed files with 188 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ E = @echo
Q = @
endif

VERSION = 0.13.0.0
VERSION = 0.13.0-dev

CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
Expand Down
12 changes: 6 additions & 6 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
'#2': It is used among other things to generate all of our project files.
'#3': Please refer to the templates directory for more information.
settings:
'#': The public version number of the library.
version:
major: 0
minor: 13
micro: 0
build: 0
'#1': The public version number of the library.
'#2': Master always has a "-dev" suffix
'#3': Use "-preN" suffixes to identify pre-release versions
'#4': Per-language overrides are possible with (eg) ruby_version security_connector_test
'#5': See the expand_version.py for all the quirks here
version: 0.13.0-dev
filegroups:
- name: census
public_headers:
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
# Break import-style to ensure we can actually find our in-repo dependencies.
import commands
import grpc_core_dependencies
import grpc_version

LICENSE = '3-clause BSD'

Expand Down Expand Up @@ -218,7 +219,7 @@ def cython_extensions(package_names, module_names, extra_sources, include_dirs,

setuptools.setup(
name='grpcio',
version='0.12.0b8',
version=grpc_version.VERSION,
license=LICENSE,
ext_modules=CYTHON_EXTENSION_MODULES,
packages=list(PACKAGES),
Expand Down
2 changes: 1 addition & 1 deletion src/core/surface/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@

#include <grpc/grpc.h>

const char *grpc_version_string(void) { return "0.13.0.0"; }
const char *grpc_version_string(void) { return "0.13.0-dev"; }
2 changes: 1 addition & 1 deletion src/csharp/Grpc.Core/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public static class VersionInfo
/// <summary>
/// Current version of gRPC C#
/// </summary>
public const string CurrentVersion = "0.13.0";
public const string CurrentVersion = "0.13.0-dev";
}
}
2 changes: 1 addition & 1 deletion src/csharp/build_packages.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@rem Builds gRPC NuGet packages

@rem Current package versions
set VERSION=0.13.0
set VERSION=0.13.0-dev
set PROTOBUF_VERSION=3.0.0-beta2

@rem Packages that depend on prerelease packages (like Google.Protobuf) need to have prerelease suffix as well.
Expand Down
32 changes: 32 additions & 0 deletions src/python/grpcio/grpc_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!!

VERSION='0.13.0.dev0'
2 changes: 1 addition & 1 deletion src/ruby/lib/grpc/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@

# GRPC contains the General RPC module.
module GRPC
VERSION = '0.13.0.0'
VERSION = '0.13.0-dev'
end
12 changes: 6 additions & 6 deletions templates/Makefile.template
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
Q = @
endif

VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
VERSION = ${settings.core_version}

CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
Expand Down Expand Up @@ -320,7 +320,7 @@
ifeq ($(SYSTEM),MINGW32)
SHARED_EXT = dll
SHARED_PREFIX =
SHARED_VERSION = -${settings.version.major}
SHARED_VERSION = -${settings.core_version.major}
else ifeq ($(SYSTEM),Darwin)
SHARED_EXT = dylib
SHARED_PREFIX = lib
Expand Down Expand Up @@ -1286,7 +1286,7 @@
ifeq ($(SYSTEM),MINGW32)
$(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
else ifneq ($(SYSTEM),Darwin)
$(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
$(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.core_version.major}
$(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
endif
% endif
Expand All @@ -1304,7 +1304,7 @@
ifeq ($(SYSTEM),MINGW32)
$(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
else ifneq ($(SYSTEM),Darwin)
$(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
$(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.core_version.major}
$(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
endif
% endif
Expand Down Expand Up @@ -1578,8 +1578,8 @@
ifeq ($(SYSTEM),Darwin)
$(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
else
$(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
$(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
$(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.core_version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
$(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) ${out_libbase}.so.${settings.core_version.major}
$(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) ${out_libbase}.so
endif
endif
Expand Down
3 changes: 1 addition & 2 deletions templates/src/core/surface/version.c.template
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@

#include <grpc/grpc.h>

const char *grpc_version_string(void) { \
return "${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}"; }
const char *grpc_version_string(void) { return "${settings.core_version}"; }
2 changes: 1 addition & 1 deletion templates/src/csharp/Grpc.Core/VersionInfo.cs.template
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
/// <summary>
/// Current version of gRPC C#
/// </summary>
public const string CurrentVersion = "${settings.version.major}.${settings.version.minor}.${settings.version.micro}";
public const string CurrentVersion = "${settings.csharp_version}";
}
}
2 changes: 1 addition & 1 deletion templates/src/csharp/build_packages.bat.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@rem Builds gRPC NuGet packages

@rem Current package versions
set VERSION=${settings.version.major}.${settings.version.minor}.${settings.version.micro}
set VERSION=${settings.csharp_version}
set PROTOBUF_VERSION=3.0.0-beta2

@rem Packages that depend on prerelease packages (like Google.Protobuf) need to have prerelease suffix as well.
Expand Down
34 changes: 34 additions & 0 deletions templates/src/python/grpcio/grpc_version.py.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%YAML 1.2
--- |
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!!

VERSION='${settings.python_version.pep440()}'
2 changes: 1 addition & 1 deletion templates/src/ruby/lib/grpc/version.rb.template
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@

# GRPC contains the General RPC module.
module GRPC
VERSION = '${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}'
VERSION = '${settings.ruby_version}'
end
2 changes: 1 addition & 1 deletion templates/tools/doxygen/Doxyfile.include
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PROJECT_NAME = "GRPC ${packagename}"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
PROJECT_NUMBER = ${settings.core_version if packagename=='Core' else settings.cpp_version}

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
3 changes: 0 additions & 3 deletions tools/buildgen/build-cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
TEST = (os.environ.get('TEST', 'false') == 'true')

_TOP_LEVEL_KEYS = ['settings', 'proto_deps', 'filegroups', 'libs', 'targets', 'vspackages']
_VERSION_KEYS = ['major', 'minor', 'micro', 'build']
_ELEM_KEYS = [
'name',
'cpu_cost',
Expand Down Expand Up @@ -83,8 +82,6 @@ def clean_elem(indict):
with open(filename) as f:
js = yaml.load(f)
js = rebuild_as_ordered_dict(js, _TOP_LEVEL_KEYS)
js['settings']['version'] = rebuild_as_ordered_dict(
js['settings']['version'], _VERSION_KEYS)
for grp in ['filegroups', 'libs', 'targets']:
if grp not in js: continue
js[grp] = sorted([clean_elem(x) for x in js[grp]],
Expand Down
94 changes: 94 additions & 0 deletions tools/buildgen/plugins/expand_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""Buildgen .proto files list plugin.
This parses the list of targets from the yaml build file, and creates
a list called "protos" that contains all of the proto file names.
"""


import re

LANGUAGES = [
'core',
'cpp',
'csharp',
'node',
'objc',
'php',
'python',
'ruby',
]

class Version:

def __init__(self, s):
if '-' in s:
s, self.tag = s.split('-')
self.major, self.minor, self.patch = [int(x) for x in s.split('.')]

def __str__(self):
"""Version string in a somewhat idiomatic style for most languages"""
s = '%d.%d.%d' % (self.major, self.minor, self.patch)
if self.tag:
s += '-%s' % self.tag
return s

def pep440(self):
"""Version string in Python PEP440 style"""
s = '%d.%d.%d' % (self.major, self.minor, self.patch)
if self.tag:
# we need to translate from grpc version tags to pep440 version
# tags; this code is likely to be a little ad-hoc
if self.tag == 'dev':
s += '.dev0'
elif len(self.tag) >= 3 and self.tag[0:3] == 'pre':
s += 'rc%d' % int(self.tag[3:])
else:
raise Exception('Don\'t know how to translate version tag "%s" to pep440' % self.tag)
return s

def mako_plugin(dictionary):
"""Expand version numbers:
- for each language, ensure there's a language_version tag in
settings (defaulting to the master version tag)
- expand version strings to major, minor, patch, and tag
"""

settings = dictionary['settings']
master_version = Version(settings['version'])
settings['version'] = master_version
for language in LANGUAGES:
version_tag = '%s_version' % language
if version_tag in settings:
settings[version_tag] = Version(settings[version_tag])
else:
settings[version_tag] = master_version
2 changes: 1 addition & 1 deletion tools/doxygen/Doxyfile.c++
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 0.13.0.0
PROJECT_NUMBER = 0.13.0-dev
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion tools/doxygen/Doxyfile.c++.internal
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.13.0.0
PROJECT_NUMBER = 0.13.0-dev

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion tools/doxygen/Doxyfile.core
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.13.0.0
PROJECT_NUMBER = 0.13.0-dev

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion tools/doxygen/Doxyfile.core.internal
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.13.0.0
PROJECT_NUMBER = 0.13.0-dev

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down

0 comments on commit f008f06

Please sign in to comment.