From 1c42a8b3363fde6eb919aa6e91cdc87ca3dca8cd Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Wed, 17 Jun 2015 13:31:26 -0700 Subject: Move cmake/update_file_lists.sh preparing for bazel support. Change-Id: Idecb2e3a5169f7b40d832242c9c10b0eb4325654 --- update_file_lists.sh | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100755 update_file_lists.sh (limited to 'update_file_lists.sh') diff --git a/update_file_lists.sh b/update_file_lists.sh new file mode 100755 index 00000000..7202650f --- /dev/null +++ b/update_file_lists.sh @@ -0,0 +1,119 @@ +#!/bin/sh + +# This script copies source file lists from src/Makefile.am to cmake files. + +get_variable_value() { + FILENAME=$1 + VARNAME=$2 + awk " + BEGIN { start = 0; } + /^$VARNAME =/ { start = 1; } + { if (start) { print \$0; } } + /\\\\\$/ { next; } + { start = 0; } + " $FILENAME \ + | sed "s/^$VARNAME =//" \ + | sed "s/[ \\]//g" \ + | grep -v "^\\$" \ + | grep -v "^$" \ + | LC_ALL=C sort | uniq +} + +get_source_files() { + get_variable_value $@ | grep "cc$" +} + +get_proto_files() { + get_variable_value $@ | grep "pb.cc$" | sed "s/pb.cc/proto/" +} + +set_variable_value() { + FILENAME=$1 + VARNAME=$2 + PREFIX=$3 + shift + shift + shift + awk -v values="$*" -v prefix="$PREFIX" " + BEGIN { start = 0; } + /^set\\($VARNAME/ { + start = 1; + print \$0; + len = split(values, vlist, \" \"); + for (i = 1; i <= len; ++i) { + printf(\" %s%s\\n\", prefix, vlist[i]); + } + next; + } + start && /^\\)/ { + start = 0; + } + !start { + print \$0; + } + " $FILENAME > /tmp/$$ + cp /tmp/$$ $FILENAME +} + +sort_files() { + for FILE in $@; do + echo $FILE + done | LC_ALL=C sort | uniq +} + +MAKEFILE=src/Makefile.am +CMAKE_DIR=cmake +EXTRACT_INCLUDES_BAT=cmake/extract_includes.bat.in + +[ -f "$MAKEFILE" ] || { + echo "Cannot find: $MAKEFILE" + exit 1 +} + +[ -d "$CMAKE_DIR" ] || { + echo "Cannot find: $CMAKE_DIR" + exit 1 +} + +[ -f "$EXTRACT_INCLUDES_BAT" ] || { + echo "Cannot find: $EXTRACT_INCLUDES_BAT" + exit 1 +} + +# Extract file lists from src/Makefile.am +GZHEADERS=$(get_variable_value $MAKEFILE GZHEADERS) +HEADERS=$(get_variable_value $MAKEFILE nobase_include_HEADERS) +PUBLIC_HEADERS=$(sort_files $GZHEADERS $HEADERS) +LIBPROTOBUF_LITE_SOURCES=$(get_source_files $MAKEFILE libprotobuf_lite_la_SOURCES) +LIBPROTOBUF_SOURCES=$(get_source_files $MAKEFILE libprotobuf_la_SOURCES) +LIBPROTOC_SOURCES=$(get_source_files $MAKEFILE libprotoc_la_SOURCES) +LITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs) +PROTOS=$(get_proto_files $MAKEFILE protoc_outputs) +COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES) +TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES) +LITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES) + +# Replace file lists in cmake files. +COMMON_PREFIX="\${protobuf_source_dir}/src/" +set_variable_value $CMAKE_DIR/libprotobuf-lite.cmake libprotobuf_lite_files $COMMON_PREFIX $LIBPROTOBUF_LITE_SOURCES +set_variable_value $CMAKE_DIR/libprotobuf.cmake libprotobuf_files $COMMON_PREFIX $LIBPROTOBUF_SOURCES +set_variable_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $COMMON_PREFIX $LIBPROTOC_SOURCES +set_variable_value $CMAKE_DIR/tests.cmake lite_test_protos "" $LITE_PROTOS +set_variable_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS +set_variable_value $CMAKE_DIR/tests.cmake common_test_files $COMMON_PREFIX $COMMON_TEST_SOURCES +set_variable_value $CMAKE_DIR/tests.cmake tests_files $COMMON_PREFIX $TEST_SOURCES +set_variable_value $CMAKE_DIR/tests.cmake lite_test_files $COMMON_PREFIX $LITE_TEST_SOURCES + +# Generate extract_includes.bat +echo "mkdir include" > $EXTRACT_INCLUDES_BAT +for HEADER in $PUBLIC_HEADERS; do + HEADER_DIR=$(dirname $HEADER) + while [ ! "$HEADER_DIR" = "." ]; do + echo $HEADER_DIR | sed "s/\\//\\\\/g" + HEADER_DIR=$(dirname $HEADER_DIR) + done +done | sort | uniq | sed "s/^/mkdir include\\\\/" >> $EXTRACT_INCLUDES_BAT +for HEADER in $PUBLIC_HEADERS; do + WINPATH=$(echo $HEADER | sed 's;/;\\;g') + echo "copy \${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\$WINPATH include\\$WINPATH" >> $EXTRACT_INCLUDES_BAT +done -- cgit v1.2.3 From d19604fac5652be74d3cc2a7a2bd2442a77dc44f Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Wed, 17 Jun 2015 17:37:58 -0700 Subject: Add Bazel BUILD for the project. Change-Id: I5a299d969ff96d7d2f80aadc7e8987d461d24b8f --- BUILD | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++ WORKSPACE | 0 update_file_lists.sh | 166 ++++++++++++++------- 3 files changed, 524 insertions(+), 49 deletions(-) create mode 100644 BUILD create mode 100644 WORKSPACE (limited to 'update_file_lists.sh') diff --git a/BUILD b/BUILD new file mode 100644 index 00000000..18554252 --- /dev/null +++ b/BUILD @@ -0,0 +1,407 @@ +# Bazel (http://bazel.io/) BUILD file for Protobuf. + +licenses(["notice"]) + +COPTS = [ + "-DHAVE_PTHREAD", + "-Wall", + "-Wwrite-strings", + "-Woverloaded-virtual", + "-Wno-sign-compare", + "-Wno-error=unused-function", +] + +# Bazel should provide portable link_opts for pthread. +LINK_OPTS = ["-lpthread"] + +cc_library( + name = "protobuf_lite", + srcs = [ + # AUTOGEN(protobuf_lite_srcs) + "src/google/protobuf/arena.cc", + "src/google/protobuf/arenastring.cc", + "src/google/protobuf/extension_set.cc", + "src/google/protobuf/generated_message_util.cc", + "src/google/protobuf/io/coded_stream.cc", + "src/google/protobuf/io/zero_copy_stream.cc", + "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", + "src/google/protobuf/message_lite.cc", + "src/google/protobuf/repeated_field.cc", + "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc", + "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc", + "src/google/protobuf/stubs/common.cc", + "src/google/protobuf/stubs/once.cc", + "src/google/protobuf/stubs/stringprintf.cc", + "src/google/protobuf/wire_format_lite.cc", + ], + copts = COPTS, + includes = ["src/"], + linkopts = LINK_OPTS, + visibility = ["//visibility:public"], +) + +cc_library( + name = "protobuf", + srcs = [ + # AUTOGEN(protobuf_srcs) + "src/google/protobuf/any.cc", + "src/google/protobuf/any.pb.cc", + "src/google/protobuf/api.pb.cc", + "src/google/protobuf/compiler/importer.cc", + "src/google/protobuf/compiler/parser.cc", + "src/google/protobuf/descriptor.cc", + "src/google/protobuf/descriptor.pb.cc", + "src/google/protobuf/descriptor_database.cc", + "src/google/protobuf/duration.pb.cc", + "src/google/protobuf/dynamic_message.cc", + "src/google/protobuf/empty.pb.cc", + "src/google/protobuf/extension_set_heavy.cc", + "src/google/protobuf/field_mask.pb.cc", + "src/google/protobuf/generated_message_reflection.cc", + "src/google/protobuf/io/gzip_stream.cc", + "src/google/protobuf/io/printer.cc", + "src/google/protobuf/io/strtod.cc", + "src/google/protobuf/io/tokenizer.cc", + "src/google/protobuf/io/zero_copy_stream_impl.cc", + "src/google/protobuf/map_field.cc", + "src/google/protobuf/message.cc", + "src/google/protobuf/reflection_ops.cc", + "src/google/protobuf/service.cc", + "src/google/protobuf/source_context.pb.cc", + "src/google/protobuf/struct.pb.cc", + "src/google/protobuf/stubs/structurally_valid.cc", + "src/google/protobuf/stubs/strutil.cc", + "src/google/protobuf/stubs/substitute.cc", + "src/google/protobuf/text_format.cc", + "src/google/protobuf/timestamp.pb.cc", + "src/google/protobuf/type.pb.cc", + "src/google/protobuf/unknown_field_set.cc", + "src/google/protobuf/wire_format.cc", + "src/google/protobuf/wrappers.pb.cc", + ], + copts = COPTS, + includes = ["src/"], + linkopts = LINK_OPTS, + visibility = ["//visibility:public"], + deps = [":protobuf_lite"], +) + +cc_library( + name = "protoc_lib", + srcs = [ + # AUTOGEN(protoc_lib_srcs) + "src/google/protobuf/compiler/code_generator.cc", + "src/google/protobuf/compiler/command_line_interface.cc", + "src/google/protobuf/compiler/cpp/cpp_enum.cc", + "src/google/protobuf/compiler/cpp/cpp_enum_field.cc", + "src/google/protobuf/compiler/cpp/cpp_extension.cc", + "src/google/protobuf/compiler/cpp/cpp_field.cc", + "src/google/protobuf/compiler/cpp/cpp_file.cc", + "src/google/protobuf/compiler/cpp/cpp_generator.cc", + "src/google/protobuf/compiler/cpp/cpp_helpers.cc", + "src/google/protobuf/compiler/cpp/cpp_map_field.cc", + "src/google/protobuf/compiler/cpp/cpp_message.cc", + "src/google/protobuf/compiler/cpp/cpp_message_field.cc", + "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc", + "src/google/protobuf/compiler/cpp/cpp_service.cc", + "src/google/protobuf/compiler/cpp/cpp_string_field.cc", + "src/google/protobuf/compiler/csharp/csharp_enum.cc", + "src/google/protobuf/compiler/csharp/csharp_enum_field.cc", + "src/google/protobuf/compiler/csharp/csharp_extension.cc", + "src/google/protobuf/compiler/csharp/csharp_field_base.cc", + "src/google/protobuf/compiler/csharp/csharp_generator.cc", + "src/google/protobuf/compiler/csharp/csharp_helpers.cc", + "src/google/protobuf/compiler/csharp/csharp_message.cc", + "src/google/protobuf/compiler/csharp/csharp_message_field.cc", + "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc", + "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc", + "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc", + "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc", + "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc", + "src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc", + "src/google/protobuf/compiler/csharp/csharp_writer.cc", + "src/google/protobuf/compiler/java/java_context.cc", + "src/google/protobuf/compiler/java/java_doc_comment.cc", + "src/google/protobuf/compiler/java/java_enum.cc", + "src/google/protobuf/compiler/java/java_enum_field.cc", + "src/google/protobuf/compiler/java/java_enum_field_lite.cc", + "src/google/protobuf/compiler/java/java_extension.cc", + "src/google/protobuf/compiler/java/java_field.cc", + "src/google/protobuf/compiler/java/java_file.cc", + "src/google/protobuf/compiler/java/java_generator.cc", + "src/google/protobuf/compiler/java/java_generator_factory.cc", + "src/google/protobuf/compiler/java/java_helpers.cc", + "src/google/protobuf/compiler/java/java_lazy_message_field.cc", + "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc", + "src/google/protobuf/compiler/java/java_map_field.cc", + "src/google/protobuf/compiler/java/java_map_field_lite.cc", + "src/google/protobuf/compiler/java/java_message.cc", + "src/google/protobuf/compiler/java/java_message_builder.cc", + "src/google/protobuf/compiler/java/java_message_builder_lite.cc", + "src/google/protobuf/compiler/java/java_message_field.cc", + "src/google/protobuf/compiler/java/java_message_field_lite.cc", + "src/google/protobuf/compiler/java/java_message_lite.cc", + "src/google/protobuf/compiler/java/java_name_resolver.cc", + "src/google/protobuf/compiler/java/java_primitive_field.cc", + "src/google/protobuf/compiler/java/java_primitive_field_lite.cc", + "src/google/protobuf/compiler/java/java_service.cc", + "src/google/protobuf/compiler/java/java_shared_code_generator.cc", + "src/google/protobuf/compiler/java/java_string_field.cc", + "src/google/protobuf/compiler/java/java_string_field_lite.cc", + "src/google/protobuf/compiler/javanano/javanano_enum.cc", + "src/google/protobuf/compiler/javanano/javanano_enum_field.cc", + "src/google/protobuf/compiler/javanano/javanano_extension.cc", + "src/google/protobuf/compiler/javanano/javanano_field.cc", + "src/google/protobuf/compiler/javanano/javanano_file.cc", + "src/google/protobuf/compiler/javanano/javanano_generator.cc", + "src/google/protobuf/compiler/javanano/javanano_helpers.cc", + "src/google/protobuf/compiler/javanano/javanano_map_field.cc", + "src/google/protobuf/compiler/javanano/javanano_message.cc", + "src/google/protobuf/compiler/javanano/javanano_message_field.cc", + "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc", + "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", + "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", + "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", + "src/google/protobuf/compiler/objectivec/objectivec_field.cc", + "src/google/protobuf/compiler/objectivec/objectivec_file.cc", + "src/google/protobuf/compiler/objectivec/objectivec_generator.cc", + "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc", + "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc", + "src/google/protobuf/compiler/objectivec/objectivec_message.cc", + "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc", + "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc", + "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", + "src/google/protobuf/compiler/plugin.cc", + "src/google/protobuf/compiler/plugin.pb.cc", + "src/google/protobuf/compiler/python/python_generator.cc", + "src/google/protobuf/compiler/ruby/ruby_generator.cc", + "src/google/protobuf/compiler/subprocess.cc", + "src/google/protobuf/compiler/zip_writer.cc", + ], + copts = COPTS, + includes = ["src/"], + linkopts = LINK_OPTS, + visibility = ["//visibility:public"], + deps = [":protobuf"], +) + +cc_binary( + name = "protoc", + srcs = ["src/google/protobuf/compiler/main.cc"], + includes = ["src/"], + linkopts = LINK_OPTS, + visibility = ["//visibility:public"], + deps = [":protoc_lib"], +) + +WELL_KNOWN_PROTOS = [ + # AUTOGEN(well_known_protos) + "google/protobuf/any.proto", + "google/protobuf/api.proto", + "google/protobuf/compiler/plugin.proto", + "google/protobuf/descriptor.proto", + "google/protobuf/duration.proto", + "google/protobuf/empty.proto", + "google/protobuf/field_mask.proto", + "google/protobuf/source_context.proto", + "google/protobuf/struct.proto", + "google/protobuf/timestamp.proto", + "google/protobuf/type.proto", + "google/protobuf/wrappers.proto", +] + +################################################################################ +# Tests +################################################################################ + +LITE_TEST_PROTOS = [ + # AUTOGEN(lite_test_protos) + "google/protobuf/map_lite_unittest.proto", + "google/protobuf/unittest_import_lite.proto", + "google/protobuf/unittest_import_public_lite.proto", + "google/protobuf/unittest_lite.proto", +] + +LITE_TEST_PROTOS_OUTS = [ + # AUTOGEN(lite_test_protos_outs) + "src/google/protobuf/map_lite_unittest.pb.cc", + "src/google/protobuf/map_lite_unittest.pb.h", + "src/google/protobuf/unittest_import_lite.pb.cc", + "src/google/protobuf/unittest_import_lite.pb.h", + "src/google/protobuf/unittest_import_public_lite.pb.cc", + "src/google/protobuf/unittest_import_public_lite.pb.h", + "src/google/protobuf/unittest_lite.pb.cc", + "src/google/protobuf/unittest_lite.pb.h", +] + +TEST_PROTOS = [ + # AUTOGEN(test_protos) + "google/protobuf/any_test.proto", + "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto", + "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto", + "google/protobuf/map_proto2_unittest.proto", + "google/protobuf/map_unittest.proto", + "google/protobuf/unittest.proto", + "google/protobuf/unittest_arena.proto", + "google/protobuf/unittest_custom_options.proto", + "google/protobuf/unittest_drop_unknown_fields.proto", + "google/protobuf/unittest_embed_optimize_for.proto", + "google/protobuf/unittest_empty.proto", + "google/protobuf/unittest_enormous_descriptor.proto", + "google/protobuf/unittest_import.proto", + "google/protobuf/unittest_import_public.proto", + "google/protobuf/unittest_lite_imports_nonlite.proto", + "google/protobuf/unittest_mset.proto", + "google/protobuf/unittest_no_arena.proto", + "google/protobuf/unittest_no_arena_import.proto", + "google/protobuf/unittest_no_field_presence.proto", + "google/protobuf/unittest_no_generic_services.proto", + "google/protobuf/unittest_optimize_for.proto", + "google/protobuf/unittest_preserve_unknown_enum.proto", + "google/protobuf/unittest_preserve_unknown_enum2.proto", + "google/protobuf/unittest_proto3_arena.proto", + "google/protobuf/unittest_well_known_types.proto", +] + +TEST_PROTOS_OUTS = [ + # AUTOGEN(test_protos_outs) + "src/google/protobuf/any_test.pb.cc", + "src/google/protobuf/any_test.pb.h", + "src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc", + "src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h", + "src/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc", + "src/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.h", + "src/google/protobuf/map_proto2_unittest.pb.cc", + "src/google/protobuf/map_proto2_unittest.pb.h", + "src/google/protobuf/map_unittest.pb.cc", + "src/google/protobuf/map_unittest.pb.h", + "src/google/protobuf/unittest.pb.cc", + "src/google/protobuf/unittest.pb.h", + "src/google/protobuf/unittest_arena.pb.cc", + "src/google/protobuf/unittest_arena.pb.h", + "src/google/protobuf/unittest_custom_options.pb.cc", + "src/google/protobuf/unittest_custom_options.pb.h", + "src/google/protobuf/unittest_drop_unknown_fields.pb.cc", + "src/google/protobuf/unittest_drop_unknown_fields.pb.h", + "src/google/protobuf/unittest_embed_optimize_for.pb.cc", + "src/google/protobuf/unittest_embed_optimize_for.pb.h", + "src/google/protobuf/unittest_empty.pb.cc", + "src/google/protobuf/unittest_empty.pb.h", + "src/google/protobuf/unittest_enormous_descriptor.pb.cc", + "src/google/protobuf/unittest_enormous_descriptor.pb.h", + "src/google/protobuf/unittest_import.pb.cc", + "src/google/protobuf/unittest_import.pb.h", + "src/google/protobuf/unittest_import_public.pb.cc", + "src/google/protobuf/unittest_import_public.pb.h", + "src/google/protobuf/unittest_lite_imports_nonlite.pb.cc", + "src/google/protobuf/unittest_lite_imports_nonlite.pb.h", + "src/google/protobuf/unittest_mset.pb.cc", + "src/google/protobuf/unittest_mset.pb.h", + "src/google/protobuf/unittest_no_arena.pb.cc", + "src/google/protobuf/unittest_no_arena.pb.h", + "src/google/protobuf/unittest_no_arena_import.pb.cc", + "src/google/protobuf/unittest_no_arena_import.pb.h", + "src/google/protobuf/unittest_no_field_presence.pb.cc", + "src/google/protobuf/unittest_no_field_presence.pb.h", + "src/google/protobuf/unittest_no_generic_services.pb.cc", + "src/google/protobuf/unittest_no_generic_services.pb.h", + "src/google/protobuf/unittest_optimize_for.pb.cc", + "src/google/protobuf/unittest_optimize_for.pb.h", + "src/google/protobuf/unittest_preserve_unknown_enum.pb.cc", + "src/google/protobuf/unittest_preserve_unknown_enum.pb.h", + "src/google/protobuf/unittest_preserve_unknown_enum2.pb.cc", + "src/google/protobuf/unittest_preserve_unknown_enum2.pb.h", + "src/google/protobuf/unittest_proto3_arena.pb.cc", + "src/google/protobuf/unittest_proto3_arena.pb.h", + "src/google/protobuf/unittest_well_known_types.pb.cc", + "src/google/protobuf/unittest_well_known_types.pb.h", +] + +PROTOS = LITE_TEST_PROTOS + TEST_PROTOS + +INPUTS = PROTOS + WELL_KNOWN_PROTOS + +OUTPUTS = LITE_TEST_PROTOS_OUTS + TEST_PROTOS_OUTS + +genrule( + name = "gen_test_protos", + srcs = ["src/" + x for x in INPUTS], + outs = OUTPUTS, + cmd = + "$(location :protoc) --cpp_out=$(@D)/src" + + "".join([" -I" + x + "=$(location src/" + x + ")" for x in INPUTS]) + + "".join([" $(location src/" + x + ")" for x in PROTOS]), + tools = [":protoc"], +) + +COMMON_TEST_SRCS = [ + # AUTOGEN(common_test_srcs) + "src/google/protobuf/arena_test_util.cc", + "src/google/protobuf/map_test_util.cc", + "src/google/protobuf/test_util.cc", + "src/google/protobuf/testing/file.cc", + "src/google/protobuf/testing/googletest.cc", +] + +# TODO(liujisi): Add gtest dependency and enable tests. +# cc_test( +# name = "protobuf_test", +# srcs = OUTPUTS + COMMON_TEST_SRCS + [ +# # AUTOGEN(test_srcs) +# "src/google/protobuf/any_test.cc", +# "src/google/protobuf/arena_unittest.cc", +# "src/google/protobuf/arenastring_unittest.cc", +# "src/google/protobuf/compiler/command_line_interface_unittest.cc", +# "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc", +# "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc", +# "src/google/protobuf/compiler/cpp/cpp_unittest.cc", +# "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc", +# "src/google/protobuf/compiler/importer_unittest.cc", +# "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc", +# "src/google/protobuf/compiler/java/java_plugin_unittest.cc", +# "src/google/protobuf/compiler/mock_code_generator.cc", +# "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc", +# "src/google/protobuf/compiler/parser_unittest.cc", +# "src/google/protobuf/compiler/python/python_plugin_unittest.cc", +# "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc", +# "src/google/protobuf/descriptor_database_unittest.cc", +# "src/google/protobuf/descriptor_unittest.cc", +# "src/google/protobuf/drop_unknown_fields_test.cc", +# "src/google/protobuf/dynamic_message_unittest.cc", +# "src/google/protobuf/extension_set_unittest.cc", +# "src/google/protobuf/generated_message_reflection_unittest.cc", +# "src/google/protobuf/io/coded_stream_unittest.cc", +# "src/google/protobuf/io/printer_unittest.cc", +# "src/google/protobuf/io/tokenizer_unittest.cc", +# "src/google/protobuf/io/zero_copy_stream_unittest.cc", +# "src/google/protobuf/map_field_test.cc", +# "src/google/protobuf/map_test.cc", +# "src/google/protobuf/message_unittest.cc", +# "src/google/protobuf/no_field_presence_test.cc", +# "src/google/protobuf/preserve_unknown_enum_test.cc", +# "src/google/protobuf/proto3_arena_unittest.cc", +# "src/google/protobuf/reflection_ops_unittest.cc", +# "src/google/protobuf/repeated_field_reflection_unittest.cc", +# "src/google/protobuf/repeated_field_unittest.cc", +# "src/google/protobuf/stubs/common_unittest.cc", +# "src/google/protobuf/stubs/once_unittest.cc", +# "src/google/protobuf/stubs/stringprintf_unittest.cc", +# "src/google/protobuf/stubs/structurally_valid_unittest.cc", +# "src/google/protobuf/stubs/strutil_unittest.cc", +# "src/google/protobuf/stubs/template_util_unittest.cc", +# "src/google/protobuf/stubs/type_traits_unittest.cc", +# "src/google/protobuf/text_format_unittest.cc", +# "src/google/protobuf/unknown_field_set_unittest.cc", +# "src/google/protobuf/well_known_types_unittest.cc", +# "src/google/protobuf/wire_format_unittest.cc", +# ], +# copts = COPTS, +# includes = [ +# "src/", +# ], +# linkopts = LINK_OPTS, +# deps = [ +# ":protobuf", +# ":protoc_lib", +# ], +# ) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 00000000..e69de29b diff --git a/update_file_lists.sh b/update_file_lists.sh index 7202650f..767b2202 100755 --- a/update_file_lists.sh +++ b/update_file_lists.sh @@ -3,8 +3,8 @@ # This script copies source file lists from src/Makefile.am to cmake files. get_variable_value() { - FILENAME=$1 - VARNAME=$2 + local FILENAME=$1 + local VARNAME=$2 awk " BEGIN { start = 0; } /^$VARNAME =/ { start = 1; } @@ -19,6 +19,10 @@ get_variable_value() { | LC_ALL=C sort | uniq } +get_header_files() { + get_variable_value $@ | grep '\.h$' +} + get_source_files() { get_variable_value $@ | grep "cc$" } @@ -27,32 +31,8 @@ get_proto_files() { get_variable_value $@ | grep "pb.cc$" | sed "s/pb.cc/proto/" } -set_variable_value() { - FILENAME=$1 - VARNAME=$2 - PREFIX=$3 - shift - shift - shift - awk -v values="$*" -v prefix="$PREFIX" " - BEGIN { start = 0; } - /^set\\($VARNAME/ { - start = 1; - print \$0; - len = split(values, vlist, \" \"); - for (i = 1; i <= len; ++i) { - printf(\" %s%s\\n\", prefix, vlist[i]); - } - next; - } - start && /^\\)/ { - start = 0; - } - !start { - print \$0; - } - " $FILENAME > /tmp/$$ - cp /tmp/$$ $FILENAME +get_proto_outs() { + get_variable_value $@ | grep '\.pb\.' } sort_files() { @@ -62,24 +42,12 @@ sort_files() { } MAKEFILE=src/Makefile.am -CMAKE_DIR=cmake -EXTRACT_INCLUDES_BAT=cmake/extract_includes.bat.in [ -f "$MAKEFILE" ] || { echo "Cannot find: $MAKEFILE" exit 1 } -[ -d "$CMAKE_DIR" ] || { - echo "Cannot find: $CMAKE_DIR" - exit 1 -} - -[ -f "$EXTRACT_INCLUDES_BAT" ] || { - echo "Cannot find: $EXTRACT_INCLUDES_BAT" - exit 1 -} - # Extract file lists from src/Makefile.am GZHEADERS=$(get_variable_value $MAKEFILE GZHEADERS) HEADERS=$(get_variable_value $MAKEFILE nobase_include_HEADERS) @@ -88,21 +56,69 @@ LIBPROTOBUF_LITE_SOURCES=$(get_source_files $MAKEFILE libprotobuf_lite_la_SOURCE LIBPROTOBUF_SOURCES=$(get_source_files $MAKEFILE libprotobuf_la_SOURCES) LIBPROTOC_SOURCES=$(get_source_files $MAKEFILE libprotoc_la_SOURCES) LITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs) +LITE_PROTOS_OUTS=$(get_proto_outs $MAKEFILE protoc_lite_outputs) PROTOS=$(get_proto_files $MAKEFILE protoc_outputs) +PROTOS_OUTS=$(get_proto_outs $MAKEFILE protoc_outputs) +WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA) COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES) TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES) LITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES) +################################################################################ +# Update cmake files. +################################################################################ + +CMAKE_DIR=cmake +EXTRACT_INCLUDES_BAT=cmake/extract_includes.bat.in +[ -d "$CMAKE_DIR" ] || { + echo "Cannot find: $CMAKE_DIR" + exit 1 +} + +[ -f "$EXTRACT_INCLUDES_BAT" ] || { + echo "Cannot find: $EXTRACT_INCLUDES_BAT" + exit 1 +} + +set_cmake_value() { + local FILENAME=$1 + local VARNAME=$2 + local PREFIX=$3 + shift + shift + shift + awk -v values="$*" -v prefix="$PREFIX" " + BEGIN { start = 0; } + /^set\\($VARNAME/ { + start = 1; + print \$0; + len = split(values, vlist, \" \"); + for (i = 1; i <= len; ++i) { + printf(\" %s%s\\n\", prefix, vlist[i]); + } + next; + } + start && /^\\)/ { + start = 0; + } + !start { + print \$0; + } + " $FILENAME > /tmp/$$ + cp /tmp/$$ $FILENAME +} + + # Replace file lists in cmake files. -COMMON_PREFIX="\${protobuf_source_dir}/src/" -set_variable_value $CMAKE_DIR/libprotobuf-lite.cmake libprotobuf_lite_files $COMMON_PREFIX $LIBPROTOBUF_LITE_SOURCES -set_variable_value $CMAKE_DIR/libprotobuf.cmake libprotobuf_files $COMMON_PREFIX $LIBPROTOBUF_SOURCES -set_variable_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $COMMON_PREFIX $LIBPROTOC_SOURCES -set_variable_value $CMAKE_DIR/tests.cmake lite_test_protos "" $LITE_PROTOS -set_variable_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS -set_variable_value $CMAKE_DIR/tests.cmake common_test_files $COMMON_PREFIX $COMMON_TEST_SOURCES -set_variable_value $CMAKE_DIR/tests.cmake tests_files $COMMON_PREFIX $TEST_SOURCES -set_variable_value $CMAKE_DIR/tests.cmake lite_test_files $COMMON_PREFIX $LITE_TEST_SOURCES +CMAKE_PREFIX="\${protobuf_source_dir}/src/" +set_cmake_value $CMAKE_DIR/libprotobuf-lite.cmake libprotobuf_lite_files $CMAKE_PREFIX $LIBPROTOBUF_LITE_SOURCES +set_cmake_value $CMAKE_DIR/libprotobuf.cmake libprotobuf_files $CMAKE_PREFIX $LIBPROTOBUF_SOURCES +set_cmake_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $CMAKE_PREFIX $LIBPROTOC_SOURCES +set_cmake_value $CMAKE_DIR/tests.cmake lite_test_protos "" $LITE_PROTOS +set_cmake_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS +set_cmake_value $CMAKE_DIR/tests.cmake common_test_files $CMAKE_PREFIX $COMMON_TEST_SOURCES +set_cmake_value $CMAKE_DIR/tests.cmake tests_files $CMAKE_PREFIX $TEST_SOURCES +set_cmake_value $CMAKE_DIR/tests.cmake lite_test_files $CMAKE_PREFIX $LITE_TEST_SOURCES # Generate extract_includes.bat echo "mkdir include" > $EXTRACT_INCLUDES_BAT @@ -117,3 +133,55 @@ for HEADER in $PUBLIC_HEADERS; do WINPATH=$(echo $HEADER | sed 's;/;\\;g') echo "copy \${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\$WINPATH include\\$WINPATH" >> $EXTRACT_INCLUDES_BAT done + +################################################################################ +# Update bazel BUILD files. +################################################################################ + +BAZEL_BUILD=./BUILD +[ -f "$BAZEL_BUILD" ] || { + echo "Cannot find: $BAZEL_BUILD" + exit 1 +} +set_bazel_value() { + local FILENAME=$1 + local VARNAME=$2 + local PREFIX=$3 + shift + shift + shift + awk -v values="$*" -v prefix="$PREFIX" " + BEGIN { start = 0; } + /# AUTOGEN\\($VARNAME\\)/ { + start = 1; + print \$0; + # replace \$0 with indent. + sub(/#.*/, \"\", \$0) + len = split(values, vlist, \" \"); + for (i = 1; i <= len; ++i) { + printf(\"%s\\\"%s%s\\\",\n\", \$0, prefix, vlist[i]); + } + next; + } + start && /\]/ { + start = 0 + } + !start { + print \$0; + } + " $FILENAME > /tmp/$$ + cp /tmp/$$ $FILENAME +} + + +BAZEL_PREFIX="src/" +set_bazel_value $BAZEL_BUILD protobuf_lite_srcs $BAZEL_PREFIX $LIBPROTOBUF_LITE_SOURCES +set_bazel_value $BAZEL_BUILD protobuf_srcs $BAZEL_PREFIX $LIBPROTOBUF_SOURCES +set_bazel_value $BAZEL_BUILD protoc_lib_srcs $BAZEL_PREFIX $LIBPROTOC_SOURCES +set_bazel_value $BAZEL_BUILD lite_test_protos "" $LITE_PROTOS +set_bazel_value $BAZEL_BUILD lite_test_protos_outs $BAZEL_PREFIX $LITE_PROTOS_OUTS +set_bazel_value $BAZEL_BUILD well_known_protos "" $WKT_PROTOS +set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS +set_bazel_value $BAZEL_BUILD test_protos_outs $BAZEL_PREFIX $PROTOS_OUTS +set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES +set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES -- cgit v1.2.3 From 94062398dc25906a7d9179a9f038fec4cb0d9878 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 18 Jun 2015 14:04:53 -0700 Subject: Remove OUTS constants in BUILD Induce those from the input proto file names instead to reduce the lenght of the BUILD file. Change-Id: I1dda57dedac547f4bd0cc3a7d08fb611d72acd13 --- BUILD | 89 ++-------------------------------------------------- update_file_lists.sh | 8 ----- 2 files changed, 2 insertions(+), 95 deletions(-) (limited to 'update_file_lists.sh') diff --git a/BUILD b/BUILD index c4929367..e897617d 100644 --- a/BUILD +++ b/BUILD @@ -244,18 +244,6 @@ LITE_TEST_PROTOS = [ "google/protobuf/unittest_lite.proto", ] -LITE_TEST_PROTOS_OUTS = [ - # AUTOGEN(lite_test_protos_outs) - "src/google/protobuf/map_lite_unittest.pb.cc", - "src/google/protobuf/map_lite_unittest.pb.h", - "src/google/protobuf/unittest_import_lite.pb.cc", - "src/google/protobuf/unittest_import_lite.pb.h", - "src/google/protobuf/unittest_import_public_lite.pb.cc", - "src/google/protobuf/unittest_import_public_lite.pb.h", - "src/google/protobuf/unittest_lite.pb.cc", - "src/google/protobuf/unittest_lite.pb.h", -] - TEST_PROTOS = [ # AUTOGEN(test_protos) "google/protobuf/any_test.proto", @@ -294,88 +282,15 @@ TEST_PROTOS = [ "google/protobuf/util/json_format_proto3.proto", ] -TEST_PROTOS_OUTS = [ - # AUTOGEN(test_protos_outs) - "src/google/protobuf/any_test.pb.cc", - "src/google/protobuf/any_test.pb.h", - "src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc", - "src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h", - "src/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc", - "src/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.h", - "src/google/protobuf/map_proto2_unittest.pb.cc", - "src/google/protobuf/map_proto2_unittest.pb.h", - "src/google/protobuf/map_unittest.pb.cc", - "src/google/protobuf/map_unittest.pb.h", - "src/google/protobuf/unittest.pb.cc", - "src/google/protobuf/unittest.pb.h", - "src/google/protobuf/unittest_arena.pb.cc", - "src/google/protobuf/unittest_arena.pb.h", - "src/google/protobuf/unittest_custom_options.pb.cc", - "src/google/protobuf/unittest_custom_options.pb.h", - "src/google/protobuf/unittest_drop_unknown_fields.pb.cc", - "src/google/protobuf/unittest_drop_unknown_fields.pb.h", - "src/google/protobuf/unittest_embed_optimize_for.pb.cc", - "src/google/protobuf/unittest_embed_optimize_for.pb.h", - "src/google/protobuf/unittest_empty.pb.cc", - "src/google/protobuf/unittest_empty.pb.h", - "src/google/protobuf/unittest_enormous_descriptor.pb.cc", - "src/google/protobuf/unittest_enormous_descriptor.pb.h", - "src/google/protobuf/unittest_import.pb.cc", - "src/google/protobuf/unittest_import.pb.h", - "src/google/protobuf/unittest_import_public.pb.cc", - "src/google/protobuf/unittest_import_public.pb.h", - "src/google/protobuf/unittest_lite_imports_nonlite.pb.cc", - "src/google/protobuf/unittest_lite_imports_nonlite.pb.h", - "src/google/protobuf/unittest_mset.pb.cc", - "src/google/protobuf/unittest_mset.pb.h", - "src/google/protobuf/unittest_no_arena.pb.cc", - "src/google/protobuf/unittest_no_arena.pb.h", - "src/google/protobuf/unittest_no_arena_import.pb.cc", - "src/google/protobuf/unittest_no_arena_import.pb.h", - "src/google/protobuf/unittest_no_field_presence.pb.cc", - "src/google/protobuf/unittest_no_field_presence.pb.h", - "src/google/protobuf/unittest_no_generic_services.pb.cc", - "src/google/protobuf/unittest_no_generic_services.pb.h", - "src/google/protobuf/unittest_optimize_for.pb.cc", - "src/google/protobuf/unittest_optimize_for.pb.h", - "src/google/protobuf/unittest_preserve_unknown_enum.pb.cc", - "src/google/protobuf/unittest_preserve_unknown_enum.pb.h", - "src/google/protobuf/unittest_preserve_unknown_enum2.pb.cc", - "src/google/protobuf/unittest_preserve_unknown_enum2.pb.h", - "src/google/protobuf/unittest_proto3_arena.pb.cc", - "src/google/protobuf/unittest_proto3_arena.pb.h", - "src/google/protobuf/unittest_well_known_types.pb.cc", - "src/google/protobuf/unittest_well_known_types.pb.h", - "src/google/protobuf/util/internal/testdata/anys.pb.cc", - "src/google/protobuf/util/internal/testdata/anys.pb.h", - "src/google/protobuf/util/internal/testdata/books.pb.cc", - "src/google/protobuf/util/internal/testdata/books.pb.h", - "src/google/protobuf/util/internal/testdata/default_value.pb.cc", - "src/google/protobuf/util/internal/testdata/default_value.pb.h", - "src/google/protobuf/util/internal/testdata/default_value_test.pb.cc", - "src/google/protobuf/util/internal/testdata/default_value_test.pb.h", - "src/google/protobuf/util/internal/testdata/field_mask.pb.cc", - "src/google/protobuf/util/internal/testdata/field_mask.pb.h", - "src/google/protobuf/util/internal/testdata/maps.pb.cc", - "src/google/protobuf/util/internal/testdata/maps.pb.h", - "src/google/protobuf/util/internal/testdata/struct.pb.cc", - "src/google/protobuf/util/internal/testdata/struct.pb.h", - "src/google/protobuf/util/internal/testdata/timestamp_duration.pb.cc", - "src/google/protobuf/util/internal/testdata/timestamp_duration.pb.h", - "src/google/protobuf/util/json_format_proto3.pb.cc", - "src/google/protobuf/util/json_format_proto3.pb.h", -] - PROTOS = LITE_TEST_PROTOS + TEST_PROTOS INPUTS = PROTOS + WELL_KNOWN_PROTOS -OUTPUTS = LITE_TEST_PROTOS_OUTS + TEST_PROTOS_OUTS - genrule( name = "gen_test_protos", srcs = ["src/" + x for x in INPUTS], - outs = OUTPUTS, + outs = ["src/" + x[:-5] + "pb.h" for x in PROTOS] + + ["src/" + x[:-5] + "pb.cc" for x in PROTOS], cmd = "$(location :protoc) --cpp_out=$(@D)/src" + "".join([" -I" + x + "=$(location src/" + x + ")" for x in INPUTS]) + diff --git a/update_file_lists.sh b/update_file_lists.sh index 767b2202..aa0d15ae 100755 --- a/update_file_lists.sh +++ b/update_file_lists.sh @@ -31,10 +31,6 @@ get_proto_files() { get_variable_value $@ | grep "pb.cc$" | sed "s/pb.cc/proto/" } -get_proto_outs() { - get_variable_value $@ | grep '\.pb\.' -} - sort_files() { for FILE in $@; do echo $FILE @@ -56,9 +52,7 @@ LIBPROTOBUF_LITE_SOURCES=$(get_source_files $MAKEFILE libprotobuf_lite_la_SOURCE LIBPROTOBUF_SOURCES=$(get_source_files $MAKEFILE libprotobuf_la_SOURCES) LIBPROTOC_SOURCES=$(get_source_files $MAKEFILE libprotoc_la_SOURCES) LITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs) -LITE_PROTOS_OUTS=$(get_proto_outs $MAKEFILE protoc_lite_outputs) PROTOS=$(get_proto_files $MAKEFILE protoc_outputs) -PROTOS_OUTS=$(get_proto_outs $MAKEFILE protoc_outputs) WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA) COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES) TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES) @@ -179,9 +173,7 @@ set_bazel_value $BAZEL_BUILD protobuf_lite_srcs $BAZEL_PREFIX $LIBPROTOBUF_LITE_ set_bazel_value $BAZEL_BUILD protobuf_srcs $BAZEL_PREFIX $LIBPROTOBUF_SOURCES set_bazel_value $BAZEL_BUILD protoc_lib_srcs $BAZEL_PREFIX $LIBPROTOC_SOURCES set_bazel_value $BAZEL_BUILD lite_test_protos "" $LITE_PROTOS -set_bazel_value $BAZEL_BUILD lite_test_protos_outs $BAZEL_PREFIX $LITE_PROTOS_OUTS set_bazel_value $BAZEL_BUILD well_known_protos "" $WKT_PROTOS set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS -set_bazel_value $BAZEL_BUILD test_protos_outs $BAZEL_PREFIX $PROTOS_OUTS set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES -- cgit v1.2.3 From 7a0c431c8f2e5071c54f7f0fa37834138d9648de Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 18 Jun 2015 16:45:27 -0700 Subject: Enable tests for bazel build. Change-Id: I63ed5fb58a45e098f2fd1fa457a219148de030bd --- BUILD | 175 ++++++++++++++++++++++++++++----------------------- WORKSPACE | 16 +++++ gmock.BUILD | 23 +++++++ update_file_lists.sh | 3 + 4 files changed, 140 insertions(+), 77 deletions(-) create mode 100644 gmock.BUILD (limited to 'update_file_lists.sh') diff --git a/BUILD b/BUILD index e897617d..f5077060 100644 --- a/BUILD +++ b/BUILD @@ -286,11 +286,13 @@ PROTOS = LITE_TEST_PROTOS + TEST_PROTOS INPUTS = PROTOS + WELL_KNOWN_PROTOS +OUTPUTS = ["src/" + x[:-5] + "pb.h" for x in PROTOS] + \ + ["src/" + x[:-5] + "pb.cc" for x in PROTOS] + genrule( name = "gen_test_protos", srcs = ["src/" + x for x in INPUTS], - outs = ["src/" + x[:-5] + "pb.h" for x in PROTOS] + - ["src/" + x[:-5] + "pb.cc" for x in PROTOS], + outs = OUTPUTS, cmd = "$(location :protoc) --cpp_out=$(@D)/src" + "".join([" -I" + x + "=$(location src/" + x + ")" for x in INPUTS]) + @@ -307,78 +309,97 @@ COMMON_TEST_SRCS = [ "src/google/protobuf/testing/googletest.cc", ] -# TODO(liujisi): Add gtest dependency and enable tests. -# cc_test( -# name = "protobuf_test", -# srcs = OUTPUTS + COMMON_TEST_SRCS + [ -# "src/google/protobuf/any_test.cc", -# "src/google/protobuf/arena_unittest.cc", -# "src/google/protobuf/arenastring_unittest.cc", -# "src/google/protobuf/compiler/command_line_interface_unittest.cc", -# "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc", -# "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc", -# "src/google/protobuf/compiler/cpp/cpp_unittest.cc", -# "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc", -# "src/google/protobuf/compiler/importer_unittest.cc", -# "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc", -# "src/google/protobuf/compiler/java/java_plugin_unittest.cc", -# "src/google/protobuf/compiler/mock_code_generator.cc", -# "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc", -# "src/google/protobuf/compiler/parser_unittest.cc", -# "src/google/protobuf/compiler/python/python_plugin_unittest.cc", -# "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc", -# "src/google/protobuf/descriptor_database_unittest.cc", -# "src/google/protobuf/descriptor_unittest.cc", -# "src/google/protobuf/drop_unknown_fields_test.cc", -# "src/google/protobuf/dynamic_message_unittest.cc", -# "src/google/protobuf/extension_set_unittest.cc", -# "src/google/protobuf/generated_message_reflection_unittest.cc", -# "src/google/protobuf/io/coded_stream_unittest.cc", -# "src/google/protobuf/io/printer_unittest.cc", -# "src/google/protobuf/io/tokenizer_unittest.cc", -# "src/google/protobuf/io/zero_copy_stream_unittest.cc", -# "src/google/protobuf/map_field_test.cc", -# "src/google/protobuf/map_test.cc", -# "src/google/protobuf/message_unittest.cc", -# "src/google/protobuf/no_field_presence_test.cc", -# "src/google/protobuf/preserve_unknown_enum_test.cc", -# "src/google/protobuf/proto3_arena_unittest.cc", -# "src/google/protobuf/reflection_ops_unittest.cc", -# "src/google/protobuf/repeated_field_reflection_unittest.cc", -# "src/google/protobuf/repeated_field_unittest.cc", -# "src/google/protobuf/stubs/bytestream_unittest.cc", -# "src/google/protobuf/stubs/common_unittest.cc", -# "src/google/protobuf/stubs/once_unittest.cc", -# "src/google/protobuf/stubs/status_test.cc", -# "src/google/protobuf/stubs/statusor_test.cc", -# "src/google/protobuf/stubs/stringpiece_unittest.cc", -# "src/google/protobuf/stubs/stringprintf_unittest.cc", -# "src/google/protobuf/stubs/structurally_valid_unittest.cc", -# "src/google/protobuf/stubs/strutil_unittest.cc", -# "src/google/protobuf/stubs/template_util_unittest.cc", -# "src/google/protobuf/stubs/time_test.cc", -# "src/google/protobuf/stubs/type_traits_unittest.cc", -# "src/google/protobuf/text_format_unittest.cc", -# "src/google/protobuf/unknown_field_set_unittest.cc", -# "src/google/protobuf/util/field_comparator_test.cc", -# "src/google/protobuf/util/internal/default_value_objectwriter_test.cc", -# "src/google/protobuf/util/internal/json_objectwriter_test.cc", -# "src/google/protobuf/util/internal/json_stream_parser_test.cc", -# "src/google/protobuf/util/internal/protostream_objectsource_test.cc", -# "src/google/protobuf/util/internal/protostream_objectwriter_test.cc", -# "src/google/protobuf/util/internal/type_info_test_helper.cc", -# "src/google/protobuf/util/json_util_test.cc", -# "src/google/protobuf/util/type_resolver_util_test.cc", -# "src/google/protobuf/well_known_types_unittest.cc", -# "src/google/protobuf/wire_format_unittest.cc", -# ], -# copts = COPTS, -# includes = [ -# "src/", -# ], -# linkopts = LINK_OPTS, -# deps = [ -# ":protobuf", -# ":protoc_lib", -# ], -# ) +cc_binary( + name = "test_plugin", + srcs = [ + # AUTOGEN(test_plugin_srcs) + "src/google/protobuf/compiler/mock_code_generator.cc", + "src/google/protobuf/compiler/test_plugin.cc", + "src/google/protobuf/testing/file.cc", + ], + deps = [ + ":protobuf", + ":protoc_lib", + "//external:gtest", + ], +) + +cc_test( + name = "protobuf_test", + srcs = OUTPUTS + COMMON_TEST_SRCS + [ + # AUTOGEN(test_srcs) + "src/google/protobuf/any_test.cc", + "src/google/protobuf/arena_unittest.cc", + "src/google/protobuf/arenastring_unittest.cc", + "src/google/protobuf/compiler/command_line_interface_unittest.cc", + "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc", + "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc", + "src/google/protobuf/compiler/cpp/cpp_unittest.cc", + "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc", + "src/google/protobuf/compiler/importer_unittest.cc", + "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc", + "src/google/protobuf/compiler/java/java_plugin_unittest.cc", + "src/google/protobuf/compiler/mock_code_generator.cc", + "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc", + "src/google/protobuf/compiler/parser_unittest.cc", + "src/google/protobuf/compiler/python/python_plugin_unittest.cc", + "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc", + "src/google/protobuf/descriptor_database_unittest.cc", + "src/google/protobuf/descriptor_unittest.cc", + "src/google/protobuf/drop_unknown_fields_test.cc", + "src/google/protobuf/dynamic_message_unittest.cc", + "src/google/protobuf/extension_set_unittest.cc", + "src/google/protobuf/generated_message_reflection_unittest.cc", + "src/google/protobuf/io/coded_stream_unittest.cc", + "src/google/protobuf/io/printer_unittest.cc", + "src/google/protobuf/io/tokenizer_unittest.cc", + "src/google/protobuf/io/zero_copy_stream_unittest.cc", + "src/google/protobuf/map_field_test.cc", + "src/google/protobuf/map_test.cc", + "src/google/protobuf/message_unittest.cc", + "src/google/protobuf/no_field_presence_test.cc", + "src/google/protobuf/preserve_unknown_enum_test.cc", + "src/google/protobuf/proto3_arena_unittest.cc", + "src/google/protobuf/reflection_ops_unittest.cc", + "src/google/protobuf/repeated_field_reflection_unittest.cc", + "src/google/protobuf/repeated_field_unittest.cc", + "src/google/protobuf/stubs/bytestream_unittest.cc", + "src/google/protobuf/stubs/common_unittest.cc", + "src/google/protobuf/stubs/once_unittest.cc", + "src/google/protobuf/stubs/status_test.cc", + "src/google/protobuf/stubs/statusor_test.cc", + "src/google/protobuf/stubs/stringpiece_unittest.cc", + "src/google/protobuf/stubs/stringprintf_unittest.cc", + "src/google/protobuf/stubs/structurally_valid_unittest.cc", + "src/google/protobuf/stubs/strutil_unittest.cc", + "src/google/protobuf/stubs/template_util_unittest.cc", + "src/google/protobuf/stubs/time_test.cc", + "src/google/protobuf/stubs/type_traits_unittest.cc", + "src/google/protobuf/text_format_unittest.cc", + "src/google/protobuf/unknown_field_set_unittest.cc", + "src/google/protobuf/util/field_comparator_test.cc", + "src/google/protobuf/util/internal/default_value_objectwriter_test.cc", + "src/google/protobuf/util/internal/json_objectwriter_test.cc", + "src/google/protobuf/util/internal/json_stream_parser_test.cc", + "src/google/protobuf/util/internal/protostream_objectsource_test.cc", + "src/google/protobuf/util/internal/protostream_objectwriter_test.cc", + "src/google/protobuf/util/internal/type_info_test_helper.cc", + "src/google/protobuf/util/json_util_test.cc", + "src/google/protobuf/util/type_resolver_util_test.cc", + "src/google/protobuf/well_known_types_unittest.cc", + "src/google/protobuf/wire_format_unittest.cc", + ], + copts = COPTS, + data = [ + ":test_plugin", + ], + includes = [ + "src/", + ], + linkopts = LINK_OPTS, + deps = [ + ":protobuf", + ":protoc_lib", + "//external:gtest_main", + ], +) diff --git a/WORKSPACE b/WORKSPACE index e69de29b..f72f239a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -0,0 +1,16 @@ +new_http_archive( + name = "gmock_archive", + url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip", + sha256 = "26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b", + build_file = "gmock.BUILD", +) + +bind( + name = "gtest", + actual = "@gmock_archive//:gtest", +) + +bind( + name = "gtest_main", + actual = "@gmock_archive//:gtest_main", +) diff --git a/gmock.BUILD b/gmock.BUILD new file mode 100644 index 00000000..66cddea9 --- /dev/null +++ b/gmock.BUILD @@ -0,0 +1,23 @@ +cc_library( + name = "gtest", + srcs = [ + "gmock-1.7.0/gtest/src/gtest-all.cc", + "gmock-1.7.0/src/gmock-all.cc", + ], + includes = [ + "gmock-1.7.0", + "gmock-1.7.0/gtest", + "gmock-1.7.0/gtest/include", + "gmock-1.7.0/include", + ], + linkopts = ["-pthread"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "gtest_main", + srcs = ["gmock-1.7.0/src/gmock_main.cc"], + linkopts = ["-pthread"], + visibility = ["//visibility:public"], + deps = [":gtest"], +) diff --git a/update_file_lists.sh b/update_file_lists.sh index aa0d15ae..34443456 100755 --- a/update_file_lists.sh +++ b/update_file_lists.sh @@ -57,6 +57,7 @@ WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA) COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES) TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES) LITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES) +TEST_PLUGIN_SOURCES=$(get_source_files $MAKEFILE test_plugin_SOURCES) ################################################################################ # Update cmake files. @@ -177,3 +178,5 @@ set_bazel_value $BAZEL_BUILD well_known_protos "" $WKT_PROTOS set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES +set_bazel_value $BAZEL_BUILD test_plugin_srcs $BAZEL_PREFIX $TEST_PLUGIN_SOURCES + -- cgit v1.2.3