Merge pull request #2381 from Yannic:fix_bazel
PiperOrigin-RevId: 264186624
This commit is contained in:
commit
30e58a89a4
18
BUILD.bazel
18
BUILD.bazel
|
@ -30,6 +30,8 @@
|
||||||
#
|
#
|
||||||
# Bazel Build for Google C++ Testing Framework(Google Test)
|
# Bazel Build for Google C++ Testing Framework(Google Test)
|
||||||
|
|
||||||
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||||
|
|
||||||
package(default_visibility = ["//visibility:public"])
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
licenses(["notice"])
|
licenses(["notice"])
|
||||||
|
@ -81,6 +83,10 @@ cc_library(
|
||||||
":has_absl": ["GTEST_HAS_ABSL=1"],
|
":has_absl": ["GTEST_HAS_ABSL=1"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
|
features = select({
|
||||||
|
":windows": ["windows_export_all_symbols"],
|
||||||
|
"//conditions:default": [],
|
||||||
|
}),
|
||||||
includes = [
|
includes = [
|
||||||
"googlemock",
|
"googlemock",
|
||||||
"googlemock/include",
|
"googlemock/include",
|
||||||
|
@ -102,20 +108,16 @@ cc_library(
|
||||||
],
|
],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
features = select({
|
|
||||||
":windows": ["windows_export_all_symbols"],
|
|
||||||
"//conditions:default": [],
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "gtest_main",
|
name = "gtest_main",
|
||||||
srcs = ["googlemock/src/gmock_main.cc"],
|
srcs = ["googlemock/src/gmock_main.cc"],
|
||||||
deps = [":gtest"],
|
|
||||||
features = select({
|
features = select({
|
||||||
":windows": ["windows_export_all_symbols"],
|
":windows": ["windows_export_all_symbols"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})
|
}),
|
||||||
|
deps = [":gtest"],
|
||||||
)
|
)
|
||||||
|
|
||||||
# The following rules build samples of how to use gTest.
|
# The following rules build samples of how to use gTest.
|
||||||
|
@ -136,7 +138,7 @@ cc_library(
|
||||||
features = select({
|
features = select({
|
||||||
":windows": ["windows_export_all_symbols"],
|
":windows": ["windows_export_all_symbols"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_test(
|
cc_test(
|
||||||
|
@ -155,11 +157,11 @@ cc_test(
|
||||||
"googletest/samples/sample7_unittest.cc",
|
"googletest/samples/sample7_unittest.cc",
|
||||||
"googletest/samples/sample8_unittest.cc",
|
"googletest/samples/sample8_unittest.cc",
|
||||||
],
|
],
|
||||||
|
linkstatic = 0,
|
||||||
deps = [
|
deps = [
|
||||||
"gtest_sample_lib",
|
"gtest_sample_lib",
|
||||||
":gtest_main",
|
":gtest_main",
|
||||||
],
|
],
|
||||||
linkstatic = 0,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_test(
|
cc_test(
|
||||||
|
|
13
WORKSPACE
13
WORKSPACE
|
@ -9,3 +9,16 @@ http_archive(
|
||||||
strip_prefix = "abseil-cpp-d9aa92d7fb324314f9df487ac23d32a25650b742",
|
strip_prefix = "abseil-cpp-d9aa92d7fb324314f9df487ac23d32a25650b742",
|
||||||
sha256 = "caf4c323eb6211397df96dd5ff96e46c7e5dd77c74d3daed2181f87868159eca",
|
sha256 = "caf4c323eb6211397df96dd5ff96e46c7e5dd77c74d3daed2181f87868159eca",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
http_archive(
|
||||||
|
name = "rules_cc",
|
||||||
|
strip_prefix = "rules_cc-master",
|
||||||
|
urls = ["https://github.com/bazelbuild/rules_cc/archive/master.zip"],
|
||||||
|
)
|
||||||
|
|
||||||
|
http_archive(
|
||||||
|
name = "rules_python",
|
||||||
|
strip_prefix = "rules_python-master",
|
||||||
|
urls = ["https://github.com/bazelbuild/rules_python/archive/master.zip"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ install:
|
||||||
|
|
||||||
# install Bazel
|
# install Bazel
|
||||||
if ($env:build_system -eq "bazel") {
|
if ($env:build_system -eq "bazel") {
|
||||||
appveyor DownloadFile https://github.com/bazelbuild/bazel/releases/download/0.21.0/bazel-0.21.0-windows-x86_64.exe -FileName bazel.exe
|
appveyor DownloadFile https://github.com/bazelbuild/bazel/releases/download/0.28.1/bazel-0.28.1-windows-x86_64.exe -FileName bazel.exe
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($env:build_system -eq "cmake") {
|
if ($env:build_system -eq "cmake") {
|
||||||
|
|
|
@ -1,303 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# These variables are automatically filled in by the configure script.
|
|
||||||
name="@PACKAGE_TARNAME@"
|
|
||||||
version="@PACKAGE_VERSION@"
|
|
||||||
|
|
||||||
show_usage()
|
|
||||||
{
|
|
||||||
echo "Usage: gmock-config [OPTIONS...]"
|
|
||||||
}
|
|
||||||
|
|
||||||
show_help()
|
|
||||||
{
|
|
||||||
show_usage
|
|
||||||
cat <<\EOF
|
|
||||||
|
|
||||||
The `gmock-config' script provides access to the necessary compile and linking
|
|
||||||
flags to connect with Google C++ Mocking Framework, both in a build prior to
|
|
||||||
installation, and on the system proper after installation. The installation
|
|
||||||
overrides may be issued in combination with any other queries, but will only
|
|
||||||
affect installation queries if called on a built but not installed gmock. The
|
|
||||||
installation queries may not be issued with any other types of queries, and
|
|
||||||
only one installation query may be made at a time. The version queries and
|
|
||||||
compiler flag queries may be combined as desired but not mixed. Different
|
|
||||||
version queries are always combined with logical "and" semantics, and only the
|
|
||||||
last of any particular query is used while all previous ones ignored. All
|
|
||||||
versions must be specified as a sequence of numbers separated by periods.
|
|
||||||
Compiler flag queries output the union of the sets of flags when combined.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
gmock-config --min-version=1.0 || echo "Insufficient Google Mock version."
|
|
||||||
|
|
||||||
g++ $(gmock-config --cppflags --cxxflags) -o foo.o -c foo.cpp
|
|
||||||
g++ $(gmock-config --ldflags --libs) -o foo foo.o
|
|
||||||
|
|
||||||
# When using a built but not installed Google Mock:
|
|
||||||
g++ $(../../my_gmock_build/scripts/gmock-config ...) ...
|
|
||||||
|
|
||||||
# When using an installed Google Mock, but with installation overrides:
|
|
||||||
export GMOCK_PREFIX="/opt"
|
|
||||||
g++ $(gmock-config --libdir="/opt/lib64" ...) ...
|
|
||||||
|
|
||||||
Help:
|
|
||||||
--usage brief usage information
|
|
||||||
--help display this help message
|
|
||||||
|
|
||||||
Installation Overrides:
|
|
||||||
--prefix=<dir> overrides the installation prefix
|
|
||||||
--exec-prefix=<dir> overrides the executable installation prefix
|
|
||||||
--libdir=<dir> overrides the library installation prefix
|
|
||||||
--includedir=<dir> overrides the header file installation prefix
|
|
||||||
|
|
||||||
Installation Queries:
|
|
||||||
--prefix installation prefix
|
|
||||||
--exec-prefix executable installation prefix
|
|
||||||
--libdir library installation directory
|
|
||||||
--includedir header file installation directory
|
|
||||||
--version the version of the Google Mock installation
|
|
||||||
|
|
||||||
Version Queries:
|
|
||||||
--min-version=VERSION return 0 if the version is at least VERSION
|
|
||||||
--exact-version=VERSION return 0 if the version is exactly VERSION
|
|
||||||
--max-version=VERSION return 0 if the version is at most VERSION
|
|
||||||
|
|
||||||
Compilation Flag Queries:
|
|
||||||
--cppflags compile flags specific to the C-like preprocessors
|
|
||||||
--cxxflags compile flags appropriate for C++ programs
|
|
||||||
--ldflags linker flags
|
|
||||||
--libs libraries for linking
|
|
||||||
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function bounds our version with a min and a max. It uses some clever
|
|
||||||
# POSIX-compliant variable expansion to portably do all the work in the shell
|
|
||||||
# and avoid any dependency on a particular "sed" or "awk" implementation.
|
|
||||||
# Notable is that it will only ever compare the first 3 components of versions.
|
|
||||||
# Further components will be cleanly stripped off. All versions must be
|
|
||||||
# unadorned, so "v1.0" will *not* work. The minimum version must be in $1, and
|
|
||||||
# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should
|
|
||||||
# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than
|
|
||||||
# continuing to maintain our own shell version.
|
|
||||||
check_versions()
|
|
||||||
{
|
|
||||||
major_version=${version%%.*}
|
|
||||||
minor_version="0"
|
|
||||||
point_version="0"
|
|
||||||
if test "${version#*.}" != "${version}"; then
|
|
||||||
minor_version=${version#*.}
|
|
||||||
minor_version=${minor_version%%.*}
|
|
||||||
fi
|
|
||||||
if test "${version#*.*.}" != "${version}"; then
|
|
||||||
point_version=${version#*.*.}
|
|
||||||
point_version=${point_version%%.*}
|
|
||||||
fi
|
|
||||||
|
|
||||||
min_version="$1"
|
|
||||||
min_major_version=${min_version%%.*}
|
|
||||||
min_minor_version="0"
|
|
||||||
min_point_version="0"
|
|
||||||
if test "${min_version#*.}" != "${min_version}"; then
|
|
||||||
min_minor_version=${min_version#*.}
|
|
||||||
min_minor_version=${min_minor_version%%.*}
|
|
||||||
fi
|
|
||||||
if test "${min_version#*.*.}" != "${min_version}"; then
|
|
||||||
min_point_version=${min_version#*.*.}
|
|
||||||
min_point_version=${min_point_version%%.*}
|
|
||||||
fi
|
|
||||||
|
|
||||||
max_version="$2"
|
|
||||||
max_major_version=${max_version%%.*}
|
|
||||||
max_minor_version="0"
|
|
||||||
max_point_version="0"
|
|
||||||
if test "${max_version#*.}" != "${max_version}"; then
|
|
||||||
max_minor_version=${max_version#*.}
|
|
||||||
max_minor_version=${max_minor_version%%.*}
|
|
||||||
fi
|
|
||||||
if test "${max_version#*.*.}" != "${max_version}"; then
|
|
||||||
max_point_version=${max_version#*.*.}
|
|
||||||
max_point_version=${max_point_version%%.*}
|
|
||||||
fi
|
|
||||||
|
|
||||||
test $(($major_version)) -lt $(($min_major_version)) && exit 1
|
|
||||||
if test $(($major_version)) -eq $(($min_major_version)); then
|
|
||||||
test $(($minor_version)) -lt $(($min_minor_version)) && exit 1
|
|
||||||
if test $(($minor_version)) -eq $(($min_minor_version)); then
|
|
||||||
test $(($point_version)) -lt $(($min_point_version)) && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
test $(($major_version)) -gt $(($max_major_version)) && exit 1
|
|
||||||
if test $(($major_version)) -eq $(($max_major_version)); then
|
|
||||||
test $(($minor_version)) -gt $(($max_minor_version)) && exit 1
|
|
||||||
if test $(($minor_version)) -eq $(($max_minor_version)); then
|
|
||||||
test $(($point_version)) -gt $(($max_point_version)) && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Show the usage line when no arguments are specified.
|
|
||||||
if test $# -eq 0; then
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
while test $# -gt 0; do
|
|
||||||
case $1 in
|
|
||||||
--usage) show_usage; exit 0;;
|
|
||||||
--help) show_help; exit 0;;
|
|
||||||
|
|
||||||
# Installation overrides
|
|
||||||
--prefix=*) GMOCK_PREFIX=${1#--prefix=};;
|
|
||||||
--exec-prefix=*) GMOCK_EXEC_PREFIX=${1#--exec-prefix=};;
|
|
||||||
--libdir=*) GMOCK_LIBDIR=${1#--libdir=};;
|
|
||||||
--includedir=*) GMOCK_INCLUDEDIR=${1#--includedir=};;
|
|
||||||
|
|
||||||
# Installation queries
|
|
||||||
--prefix|--exec-prefix|--libdir|--includedir|--version)
|
|
||||||
if test -n "${do_query}"; then
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
do_query=${1#--}
|
|
||||||
;;
|
|
||||||
|
|
||||||
# Version checking
|
|
||||||
--min-version=*)
|
|
||||||
do_check_versions=yes
|
|
||||||
min_version=${1#--min-version=}
|
|
||||||
;;
|
|
||||||
--max-version=*)
|
|
||||||
do_check_versions=yes
|
|
||||||
max_version=${1#--max-version=}
|
|
||||||
;;
|
|
||||||
--exact-version=*)
|
|
||||||
do_check_versions=yes
|
|
||||||
exact_version=${1#--exact-version=}
|
|
||||||
;;
|
|
||||||
|
|
||||||
# Compiler flag output
|
|
||||||
--cppflags) echo_cppflags=yes;;
|
|
||||||
--cxxflags) echo_cxxflags=yes;;
|
|
||||||
--ldflags) echo_ldflags=yes;;
|
|
||||||
--libs) echo_libs=yes;;
|
|
||||||
|
|
||||||
# Everything else is an error
|
|
||||||
*) show_usage; exit 1;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
# These have defaults filled in by the configure script but can also be
|
|
||||||
# overridden by environment variables or command line parameters.
|
|
||||||
prefix="${GMOCK_PREFIX:-@prefix@}"
|
|
||||||
exec_prefix="${GMOCK_EXEC_PREFIX:-@exec_prefix@}"
|
|
||||||
libdir="${GMOCK_LIBDIR:-@libdir@}"
|
|
||||||
includedir="${GMOCK_INCLUDEDIR:-@includedir@}"
|
|
||||||
|
|
||||||
# We try and detect if our binary is not located at its installed location. If
|
|
||||||
# it's not, we provide variables pointing to the source and build tree rather
|
|
||||||
# than to the install tree. We also locate Google Test using the configured
|
|
||||||
# gtest-config script rather than searching the PATH and our bindir for one.
|
|
||||||
# This allows building against a just-built gmock rather than an installed
|
|
||||||
# gmock.
|
|
||||||
bindir="@bindir@"
|
|
||||||
this_relative_bindir=`dirname $0`
|
|
||||||
this_bindir=`cd ${this_relative_bindir}; pwd -P`
|
|
||||||
if test "${this_bindir}" = "${this_bindir%${bindir}}"; then
|
|
||||||
# The path to the script doesn't end in the bindir sequence from Autoconf,
|
|
||||||
# assume that we are in a build tree.
|
|
||||||
build_dir=`dirname ${this_bindir}`
|
|
||||||
src_dir=`cd ${this_bindir}/@top_srcdir@; pwd -P`
|
|
||||||
|
|
||||||
# TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we
|
|
||||||
# should work to remove it, and/or remove libtool altogether, replacing it
|
|
||||||
# with direct references to the library and a link path.
|
|
||||||
gmock_libs="${build_dir}/lib/libgmock.la"
|
|
||||||
gmock_ldflags=""
|
|
||||||
|
|
||||||
# We provide hooks to include from either the source or build dir, where the
|
|
||||||
# build dir is always preferred. This will potentially allow us to write
|
|
||||||
# build rules for generated headers and have them automatically be preferred
|
|
||||||
# over provided versions.
|
|
||||||
gmock_cppflags="-I${build_dir}/include -I${src_dir}/include"
|
|
||||||
gmock_cxxflags=""
|
|
||||||
|
|
||||||
# Directly invoke the gtest-config script used during the build process.
|
|
||||||
gtest_config="@GTEST_CONFIG@"
|
|
||||||
else
|
|
||||||
# We're using an installed gmock, although it may be staged under some
|
|
||||||
# prefix. Assume (as our own libraries do) that we can resolve the prefix,
|
|
||||||
# and are present in the dynamic link paths.
|
|
||||||
gmock_ldflags="-L${libdir}"
|
|
||||||
gmock_libs="-l${name}"
|
|
||||||
gmock_cppflags="-I${includedir}"
|
|
||||||
gmock_cxxflags=""
|
|
||||||
|
|
||||||
# We also prefer any gtest-config script installed in our prefix. Lacking
|
|
||||||
# one, we look in the PATH for one.
|
|
||||||
gtest_config="${bindir}/gtest-config"
|
|
||||||
if test ! -x "${gtest_config}"; then
|
|
||||||
gtest_config=`which gtest-config`
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Ensure that we have located a Google Test to link against.
|
|
||||||
if ! test -x "${gtest_config}"; then
|
|
||||||
echo "Unable to locate Google Test, check your Google Mock configuration" \
|
|
||||||
"and installation" >&2
|
|
||||||
exit 1
|
|
||||||
elif ! "${gtest_config}" "--exact-version=@GTEST_VERSION@"; then
|
|
||||||
echo "The Google Test found is not the same version as Google Mock was " \
|
|
||||||
"built against" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add the necessary Google Test bits into the various flag variables
|
|
||||||
gmock_cppflags="${gmock_cppflags} `${gtest_config} --cppflags`"
|
|
||||||
gmock_cxxflags="${gmock_cxxflags} `${gtest_config} --cxxflags`"
|
|
||||||
gmock_ldflags="${gmock_ldflags} `${gtest_config} --ldflags`"
|
|
||||||
gmock_libs="${gmock_libs} `${gtest_config} --libs`"
|
|
||||||
|
|
||||||
# Do an installation query if requested.
|
|
||||||
if test -n "$do_query"; then
|
|
||||||
case $do_query in
|
|
||||||
prefix) echo $prefix; exit 0;;
|
|
||||||
exec-prefix) echo $exec_prefix; exit 0;;
|
|
||||||
libdir) echo $libdir; exit 0;;
|
|
||||||
includedir) echo $includedir; exit 0;;
|
|
||||||
version) echo $version; exit 0;;
|
|
||||||
*) show_usage; exit 1;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Do a version check if requested.
|
|
||||||
if test "$do_check_versions" = "yes"; then
|
|
||||||
# Make sure we didn't receive a bad combination of parameters.
|
|
||||||
test "$echo_cppflags" = "yes" && show_usage && exit 1
|
|
||||||
test "$echo_cxxflags" = "yes" && show_usage && exit 1
|
|
||||||
test "$echo_ldflags" = "yes" && show_usage && exit 1
|
|
||||||
test "$echo_libs" = "yes" && show_usage && exit 1
|
|
||||||
|
|
||||||
if test "$exact_version" != ""; then
|
|
||||||
check_versions $exact_version $exact_version
|
|
||||||
# unreachable
|
|
||||||
else
|
|
||||||
check_versions ${min_version:-0.0.0} ${max_version:-9999.9999.9999}
|
|
||||||
# unreachable
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Do the output in the correct order so that these can be used in-line of
|
|
||||||
# a compiler invocation.
|
|
||||||
output=""
|
|
||||||
test "$echo_cppflags" = "yes" && output="$output $gmock_cppflags"
|
|
||||||
test "$echo_cxxflags" = "yes" && output="$output $gmock_cxxflags"
|
|
||||||
test "$echo_ldflags" = "yes" && output="$output $gmock_ldflags"
|
|
||||||
test "$echo_libs" = "yes" && output="$output $gmock_libs"
|
|
||||||
echo $output
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -32,6 +32,9 @@
|
||||||
#
|
#
|
||||||
# Bazel Build for Google C++ Testing Framework(Google Test)-googlemock
|
# Bazel Build for Google C++ Testing Framework(Google Test)-googlemock
|
||||||
|
|
||||||
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
|
||||||
|
load("@rules_python//python:defs.bzl", "py_library", "py_test")
|
||||||
|
|
||||||
licenses(["notice"])
|
licenses(["notice"])
|
||||||
|
|
||||||
# Tests for GMock itself
|
# Tests for GMock itself
|
||||||
|
|
|
@ -172,6 +172,7 @@ def FuseGTestH(gtest_root, output_dir):
|
||||||
output_file.write(line)
|
output_file.write(line)
|
||||||
|
|
||||||
ProcessFile(GTEST_H_SEED)
|
ProcessFile(GTEST_H_SEED)
|
||||||
|
ProcessFile(GTEST_SPI_H_SEED)
|
||||||
output_file.close()
|
output_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,20 +194,15 @@ def FuseGTestAllCcToFile(gtest_root, output_file):
|
||||||
for line in open(os.path.join(gtest_root, gtest_source_file), 'r'):
|
for line in open(os.path.join(gtest_root, gtest_source_file), 'r'):
|
||||||
m = INCLUDE_GTEST_FILE_REGEX.match(line)
|
m = INCLUDE_GTEST_FILE_REGEX.match(line)
|
||||||
if m:
|
if m:
|
||||||
if 'include/' + m.group(1) == GTEST_SPI_H_SEED:
|
# It's '#include "gtest/foo.h"'.
|
||||||
# It's '#include "gtest/gtest-spi.h"'. This file is not
|
# We treat it as '#include "gtest/gtest.h"', as all other
|
||||||
# #included by "gtest/gtest.h", so we need to process it.
|
# gtest headers are being fused into gtest.h and cannot be
|
||||||
ProcessFile(GTEST_SPI_H_SEED)
|
# #included directly.
|
||||||
else:
|
|
||||||
# It's '#include "gtest/foo.h"' where foo is not gtest-spi.
|
|
||||||
# We treat it as '#include "gtest/gtest.h"', as all other
|
|
||||||
# gtest headers are being fused into gtest.h and cannot be
|
|
||||||
# #included directly.
|
|
||||||
|
|
||||||
# There is no need to #include "gtest/gtest.h" more than once.
|
# There is no need to #include "gtest/gtest.h" more than once.
|
||||||
if not GTEST_H_SEED in processed_files:
|
if not GTEST_H_SEED in processed_files:
|
||||||
processed_files.add(GTEST_H_SEED)
|
processed_files.add(GTEST_H_SEED)
|
||||||
output_file.write('#include "%s"\n' % (GTEST_H_OUTPUT,))
|
output_file.write('#include "%s"\n' % (GTEST_H_OUTPUT,))
|
||||||
else:
|
else:
|
||||||
m = INCLUDE_SRC_FILE_REGEX.match(line)
|
m = INCLUDE_SRC_FILE_REGEX.match(line)
|
||||||
if m:
|
if m:
|
||||||
|
|
|
@ -1,158 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
#
|
|
||||||
# Copyright 2013 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.
|
|
||||||
|
|
||||||
"""Script for branching Google Test/Mock wiki pages for a new version.
|
|
||||||
|
|
||||||
SYNOPSIS
|
|
||||||
release_docs.py NEW_RELEASE_VERSION
|
|
||||||
|
|
||||||
Google Test and Google Mock's external user documentation is in
|
|
||||||
interlinked wiki files. When we release a new version of
|
|
||||||
Google Test or Google Mock, we need to branch the wiki files
|
|
||||||
such that users of a specific version of Google Test/Mock can
|
|
||||||
look up documenation relevant for that version. This script
|
|
||||||
automates that process by:
|
|
||||||
|
|
||||||
- branching the current wiki pages (which document the
|
|
||||||
behavior of the SVN trunk head) to pages for the specified
|
|
||||||
version (e.g. branching FAQ.wiki to V2_6_FAQ.wiki when
|
|
||||||
NEW_RELEASE_VERSION is 2.6);
|
|
||||||
- updating the links in the branched files to point to the branched
|
|
||||||
version (e.g. a link in V2_6_FAQ.wiki that pointed to
|
|
||||||
Primer.wiki#Anchor will now point to V2_6_Primer.wiki#Anchor).
|
|
||||||
|
|
||||||
NOTE: NEW_RELEASE_VERSION must be a NEW version number for
|
|
||||||
which the wiki pages don't yet exist; otherwise you'll get SVN
|
|
||||||
errors like "svn: Path 'V1_7_PumpManual.wiki' is not a
|
|
||||||
directory" when running the script.
|
|
||||||
|
|
||||||
EXAMPLE
|
|
||||||
$ cd PATH/TO/GTEST_SVN_WORKSPACE/trunk
|
|
||||||
$ scripts/release_docs.py 2.6 # create wiki pages for v2.6
|
|
||||||
$ svn status # verify the file list
|
|
||||||
$ svn diff # verify the file contents
|
|
||||||
$ svn commit -m "release wiki pages for v2.6"
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import common
|
|
||||||
|
|
||||||
|
|
||||||
# Wiki pages that shouldn't be branched for every gtest/gmock release.
|
|
||||||
GTEST_UNVERSIONED_WIKIS = ['DevGuide.wiki']
|
|
||||||
GMOCK_UNVERSIONED_WIKIS = [
|
|
||||||
'DesignDoc.wiki',
|
|
||||||
'DevGuide.wiki',
|
|
||||||
'KnownIssues.wiki'
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def DropWikiSuffix(wiki_filename):
|
|
||||||
"""Removes the .wiki suffix (if any) from the given filename."""
|
|
||||||
|
|
||||||
return (wiki_filename[:-len('.wiki')] if wiki_filename.endswith('.wiki')
|
|
||||||
else wiki_filename)
|
|
||||||
|
|
||||||
|
|
||||||
class WikiBrancher(object):
|
|
||||||
"""Branches ..."""
|
|
||||||
|
|
||||||
def __init__(self, dot_version):
|
|
||||||
self.project, svn_root_path = common.GetSvnInfo()
|
|
||||||
if self.project not in ('googletest', 'googlemock'):
|
|
||||||
sys.exit('This script must be run in a gtest or gmock SVN workspace.')
|
|
||||||
self.wiki_dir = svn_root_path + '/wiki'
|
|
||||||
# Turn '2.6' to 'V2_6_'.
|
|
||||||
self.version_prefix = 'V' + dot_version.replace('.', '_') + '_'
|
|
||||||
self.files_to_branch = self.GetFilesToBranch()
|
|
||||||
page_names = [DropWikiSuffix(f) for f in self.files_to_branch]
|
|
||||||
# A link to Foo.wiki is in one of the following forms:
|
|
||||||
# [Foo words]
|
|
||||||
# [Foo#Anchor words]
|
|
||||||
# [http://code.google.com/.../wiki/Foo words]
|
|
||||||
# [http://code.google.com/.../wiki/Foo#Anchor words]
|
|
||||||
# We want to replace 'Foo' with 'V2_6_Foo' in the above cases.
|
|
||||||
self.search_for_re = re.compile(
|
|
||||||
# This regex matches either
|
|
||||||
# [Foo
|
|
||||||
# or
|
|
||||||
# /wiki/Foo
|
|
||||||
# followed by a space or a #, where Foo is the name of an
|
|
||||||
# unversioned wiki page.
|
|
||||||
r'(\[|/wiki/)(%s)([ #])' % '|'.join(page_names))
|
|
||||||
self.replace_with = r'\1%s\2\3' % (self.version_prefix,)
|
|
||||||
|
|
||||||
def GetFilesToBranch(self):
|
|
||||||
"""Returns a list of .wiki file names that need to be branched."""
|
|
||||||
|
|
||||||
unversioned_wikis = (GTEST_UNVERSIONED_WIKIS if self.project == 'googletest'
|
|
||||||
else GMOCK_UNVERSIONED_WIKIS)
|
|
||||||
return [f for f in os.listdir(self.wiki_dir)
|
|
||||||
if (f.endswith('.wiki') and
|
|
||||||
not re.match(r'^V\d', f) and # Excluded versioned .wiki files.
|
|
||||||
f not in unversioned_wikis)]
|
|
||||||
|
|
||||||
def BranchFiles(self):
|
|
||||||
"""Branches the .wiki files needed to be branched."""
|
|
||||||
|
|
||||||
print 'Branching %d .wiki files:' % (len(self.files_to_branch),)
|
|
||||||
os.chdir(self.wiki_dir)
|
|
||||||
for f in self.files_to_branch:
|
|
||||||
command = 'svn cp %s %s%s' % (f, self.version_prefix, f)
|
|
||||||
print command
|
|
||||||
os.system(command)
|
|
||||||
|
|
||||||
def UpdateLinksInBranchedFiles(self):
|
|
||||||
|
|
||||||
for f in self.files_to_branch:
|
|
||||||
source_file = os.path.join(self.wiki_dir, f)
|
|
||||||
versioned_file = os.path.join(self.wiki_dir, self.version_prefix + f)
|
|
||||||
print 'Updating links in %s.' % (versioned_file,)
|
|
||||||
text = file(source_file, 'r').read()
|
|
||||||
new_text = self.search_for_re.sub(self.replace_with, text)
|
|
||||||
file(versioned_file, 'w').write(new_text)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
if len(sys.argv) != 2:
|
|
||||||
sys.exit(__doc__)
|
|
||||||
|
|
||||||
brancher = WikiBrancher(sys.argv[1])
|
|
||||||
brancher.BranchFiles()
|
|
||||||
brancher.UpdateLinksInBranchedFiles()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -32,6 +32,9 @@
|
||||||
#
|
#
|
||||||
# Bazel BUILD for The Google C++ Testing Framework (Google Test)
|
# Bazel BUILD for The Google C++ Testing Framework (Google Test)
|
||||||
|
|
||||||
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
|
||||||
|
load("@rules_python//python:defs.bzl", "py_library", "py_test")
|
||||||
|
|
||||||
licenses(["notice"])
|
licenses(["notice"])
|
||||||
|
|
||||||
#on windows exclude gtest-tuple.h
|
#on windows exclude gtest-tuple.h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user