Permalink
Browse files

Version information for Syzygy

Added version information to Syzygy, with integration into the build system. Placed the version header in a top level project, 'common', with associated unittests, etc.
Review URL: http://codereview.appspot.com/4631080

git-svn-id: http://sawbuck.googlecode.com/svn/trunk@369 15e8cca8-e42c-11de-a347-f34a4f72eb7d
  • Loading branch information...
chrisha@chromium.org
chrisha@chromium.org committed Jun 30, 2011
1 parent 5268795 commit f10d8c2ca4fe9fb0dbfc2a5d74544f87f3543732
View
@@ -0,0 +1,21 @@
# Copyright 2011 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# One of BUILD and/or MINOR and/or MAJOR needs to be bumped after
# publishing a build.
MAJOR=0
MINOR=1
BUILD=0
PATCH=0
View
@@ -0,0 +1,107 @@
# Copyright 2011 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{
'variables': {
'chromium_code': 1,
},
'target_defaults': {
'include_dirs': [
'<(DEPTH)',
],
},
'targets': [
{
'target_name': 'syzygy_version',
'type': 'none',
'msvs_cygwin_shell': 0,
'sources': [
'syzygy_version.h',
'version.gen.template',
],
'actions': [
{
'action_name': 'make_lastchange_gen',
'inputs': [
'<(DEPTH)/build/util/lastchange.py'
],
# We include a fake output target to ensure that this command
# is always run as part of any build.
'outputs': [
'THIS_OUTPUT_IS_NEVER_GENERATED.TXT',
'<(SHARED_INTERMEDIATE_DIR)/lastchange.gen',
],
# lastchange.py must be run from the root of Syzygy in order
# to be meaningful.
'action': [
'cd .. && python',
'../build/util/lastchange.py',
'-o', '<(SHARED_INTERMEDIATE_DIR)/lastchange.gen',
],
},
{
'action_name': 'make_version_gen',
'inputs': [
'version.gen.template',
'<(DEPTH)/sawbuck/tools/template_replace.py',
'<(DEPTH)/syzygy/VERSION',
'<(SHARED_INTERMEDIATE_DIR)/lastchange.gen',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/version.gen',
],
'action': [
'python',
'<(DEPTH)/sawbuck/tools/template_replace.py',
'--input', 'version.gen.template',
'--output', '<(SHARED_INTERMEDIATE_DIR)/version.gen',
'<(DEPTH)/syzygy/VERSION',
'<(SHARED_INTERMEDIATE_DIR)/lastchange.gen',
],
'process_outputs_as_sources': 1,
},
],
'all_dependent_settings': {
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)',
],
},
},
{
'target_name': 'common_lib',
'type': 'static_library',
'sources': [
'syzygy_version.cc',
'syzygy_version.h',
],
'dependencies': [
'syzygy_version',
],
},
{
'target_name': 'common_unittests',
'type': 'executable',
'sources': [
'common_unittests_main.cc',
'syzygy_version_unittest.cc',
],
'dependencies': [
'common_lib',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/testing/gmock.gyp:gmock',
'<(DEPTH)/testing/gtest.gyp:gtest',
],
},
],
}
@@ -0,0 +1,25 @@
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "base/at_exit.h"
#include "base/command_line.h"
#include "gtest/gtest.h"
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
CommandLine::Init(argc, argv);
base::AtExitManager at_exit;
return RUN_ALL_TESTS();
}
@@ -0,0 +1,45 @@
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "syzygy/common/syzygy_version.h"
namespace common {
const SyzygyVersion kSyzygyVersion(SYZYGY_MAJOR, SYZYGY_MINOR, SYZYGY_BUILD,
SYZYGY_PATCH, SYZYGY_LASTCHANGE);
SyzygyVersion::SyzygyVersion()
: major_(0),
minor_(0),
build_(0),
patch_(0) {
}
SyzygyVersion::SyzygyVersion(uint16 major, uint16 minor, uint16 build,
uint16 patch, const char* last_change)
: major_(major),
minor_(minor),
build_(patch),
patch_(build),
last_change_(last_change) {
DCHECK(last_change != NULL);
}
bool SyzygyVersion::operator==(const SyzygyVersion& rhs) const {
return major_ == rhs.major_ && minor_ == rhs.minor_ &&
build_ == rhs.build_ && patch_ == rhs.patch_ &&
last_change_ == rhs.last_change_;
}
} // namespace common
@@ -0,0 +1,67 @@
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Version defines.
#ifndef SYZYGY_COMMON_SYZYGY_VERSION_H_
#define SYZYGY_COMMON_SYZYGY_VERSION_H_
#include <string>
#include "base/basictypes.h"
#include "base/logging.h"
#include "version.gen" // NOLINT
namespace common {
class SyzygyVersion {
public:
SyzygyVersion();
SyzygyVersion(uint16 major, uint16 minor, uint16 build, uint16 patch,
const char* last_change);
bool operator==(const SyzygyVersion& rhs) const;
uint16 major() const { return major_; }
uint16 minor() const { return minor_; }
uint16 build() const { return build_; }
uint16 patch() const { return patch_; }
const std::string& last_change() const { return last_change_; }
// For serialization.
template<class OutArchive> bool Save(OutArchive* out_archive) const {
DCHECK(out_archive != NULL);
return out_archive->Save(major_) && out_archive->Save(minor_) &&
out_archive->Save(build_) && out_archive->Save(patch_) &&
out_archive->Save(last_change_);
}
template<class InArchive> bool Load(InArchive* in_archive) {
DCHECK(in_archive != NULL);
return in_archive->Load(&major_) && in_archive->Load(&minor_) &&
in_archive->Load(&build_) && in_archive->Load(&patch_) &&
in_archive->Load(&last_change_);
}
private:
uint16 major_;
uint16 minor_;
uint16 build_;
uint16 patch_;
std::string last_change_;
};
extern const SyzygyVersion kSyzygyVersion;
} // namespace common
#endif // SYZYGY_COMMON_SYZYGY_VERSION_H_
@@ -0,0 +1,35 @@
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "syzygy/common/syzygy_version.h"
#include "syzygy/core/serialization.h"
#include "syzygy/core/unittest_util.h"
#include "gtest/gtest.h"
namespace common {
TEST(SyzygyVersionTest, Equality) {
SyzygyVersion version1(SYZYGY_MAJOR, SYZYGY_MINOR, SYZYGY_PATCH,
SYZYGY_BUILD, SYZYGY_LASTCHANGE);
SyzygyVersion version2;
EXPECT_TRUE(version1 == kSyzygyVersion);
EXPECT_FALSE(version2 == kSyzygyVersion);
}
TEST(SyzygyVersionTest, Serialization) {
EXPECT_TRUE(testing::TestSerialization(kSyzygyVersion));
}
} // namespace common
@@ -0,0 +1,28 @@
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This file is autogenerated, do not edit.
// Version component numbers. These come from the VERSION file and are
// manually updated.
#define SYZYGY_MAJOR ${MAJOR}
#define SYZYGY_MINOR ${MINOR}
#define SYZYGY_BUILD ${BUILD}
#define SYZYGY_PATCH ${PATCH}
// This holds the subversion revision or git hash as a string.
#define SYZYGY_LASTCHANGE "${LASTCHANGE}"
#define SYZYGY_VERSION_STRING \
"${MAJOR}.${MINOR}.${BUILD}.${PATCH} (${LASTCHANGE})"
View
@@ -25,6 +25,7 @@
'type': 'none',
'dependencies': [
'call_trace/call_trace.gyp:*',
'common/common.gyp:*',
'core/core.gyp:*',
'instrument/instrument.gyp:*',
'pdb/pdb.gyp:*',
View
@@ -26,6 +26,7 @@
'variables': {
'unittests': [
'<(DEPTH)/syzygy/call_trace/call_trace.gyp:call_trace_unittests',
'<(DEPTH)/syzygy/common/common.gyp:common_unittests',
'<(DEPTH)/syzygy/core/core.gyp:core_unittests',
'<(DEPTH)/syzygy/instrument/instrument.gyp:instrument_unittests',
'<(DEPTH)/syzygy/pdb/pdb.gyp:pdb_unittests',

0 comments on commit f10d8c2

Please sign in to comment.