Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: third_party/protobuf/update_file_lists.sh

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/protobuf/travis.sh ('k') | third_party/protobuf/util/python/BUILD » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/sh
2
3 # This script copies source file lists from src/Makefile.am to cmake files.
4
5 get_variable_value() {
6 local FILENAME=$1
7 local VARNAME=$2
8 awk "
9 BEGIN { start = 0; }
10 /^$VARNAME =/ { start = 1; }
11 { if (start) { print \$0; } }
12 /\\\\\$/ { next; }
13 { start = 0; }
14 " $FILENAME \
15 | sed "s/^$VARNAME =//" \
16 | sed "s/[ \\]//g" \
17 | grep -v "^\\$" \
18 | grep -v "^$" \
19 | LC_ALL=C sort | uniq
20 }
21
22 get_header_files() {
23 get_variable_value $@ | grep '\.h$'
24 }
25
26 get_source_files() {
27 get_variable_value $@ | grep "cc$"
28 }
29
30 get_proto_files_blacklisted() {
31 get_proto_files $@ | sed '/^google\/protobuf\/unittest_enormous_descriptor.pro to$/d'
32 }
33
34 get_proto_files() {
35 get_variable_value $@ | grep "pb.cc$" | sed "s/pb.cc/proto/"
36 }
37
38 sort_files() {
39 for FILE in $@; do
40 echo $FILE
41 done | LC_ALL=C sort | uniq
42 }
43
44 MAKEFILE=src/Makefile.am
45
46 [ -f "$MAKEFILE" ] || {
47 echo "Cannot find: $MAKEFILE"
48 exit 1
49 }
50
51 # Extract file lists from src/Makefile.am
52 GZHEADERS=$(get_variable_value $MAKEFILE GZHEADERS)
53 HEADERS=$(get_variable_value $MAKEFILE nobase_include_HEADERS)
54 PUBLIC_HEADERS=$(sort_files $GZHEADERS $HEADERS)
55 LIBPROTOBUF_LITE_SOURCES=$(get_source_files $MAKEFILE libprotobuf_lite_la_SOURCE S)
56 LIBPROTOBUF_SOURCES=$(get_source_files $MAKEFILE libprotobuf_la_SOURCES)
57 LIBPROTOC_SOURCES=$(get_source_files $MAKEFILE libprotoc_la_SOURCES)
58 LITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs)
59 PROTOS=$(get_proto_files $MAKEFILE protoc_outputs)
60 PROTOS_BLACKLISTED=$(get_proto_files_blacklisted $MAKEFILE protoc_outputs)
61 WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA)
62 COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES)
63 COMMON_LITE_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_LITE_TEST_SOURCES)
64 TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES)
65 LITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES)
66 LITE_ARENA_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_arena_test_SO URCES)
67 TEST_PLUGIN_SOURCES=$(get_source_files $MAKEFILE test_plugin_SOURCES)
68
69 ################################################################################
70 # Update cmake files.
71 ################################################################################
72
73 CMAKE_DIR=cmake
74 EXTRACT_INCLUDES_BAT=cmake/extract_includes.bat.in
75 [ -d "$CMAKE_DIR" ] || {
76 echo "Cannot find: $CMAKE_DIR"
77 exit 1
78 }
79
80 [ -f "$EXTRACT_INCLUDES_BAT" ] || {
81 echo "Cannot find: $EXTRACT_INCLUDES_BAT"
82 exit 1
83 }
84
85 set_cmake_value() {
86 local FILENAME=$1
87 local VARNAME=$2
88 local PREFIX=$3
89 shift
90 shift
91 shift
92 awk -v values="$*" -v prefix="$PREFIX" "
93 BEGIN { start = 0; }
94 /^set\\($VARNAME/ {
95 start = 1;
96 print \$0;
97 len = split(values, vlist, \" \");
98 for (i = 1; i <= len; ++i) {
99 printf(\" %s%s\\n\", prefix, vlist[i]);
100 }
101 next;
102 }
103 start && /^\\)/ {
104 start = 0;
105 }
106 !start {
107 print \$0;
108 }
109 " $FILENAME > /tmp/$$
110 cp /tmp/$$ $FILENAME
111 }
112
113
114 # Replace file lists in cmake files.
115 CMAKE_PREFIX="\${protobuf_source_dir}/src/"
116 set_cmake_value $CMAKE_DIR/libprotobuf-lite.cmake libprotobuf_lite_files $CMAKE_ PREFIX $LIBPROTOBUF_LITE_SOURCES
117 set_cmake_value $CMAKE_DIR/libprotobuf.cmake libprotobuf_files $CMAKE_PREFIX $LI BPROTOBUF_SOURCES
118 set_cmake_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $CMAKE_PREFIX $LIBPRO TOC_SOURCES
119 set_cmake_value $CMAKE_DIR/tests.cmake lite_test_protos "" $LITE_PROTOS
120 set_cmake_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS_BLACKLISTED
121 set_cmake_value $CMAKE_DIR/tests.cmake common_test_files $CMAKE_PREFIX $COMMON_T EST_SOURCES
122 set_cmake_value $CMAKE_DIR/tests.cmake common_lite_test_files $CMAKE_PREFIX $COM MON_LITE_TEST_SOURCES
123 set_cmake_value $CMAKE_DIR/tests.cmake tests_files $CMAKE_PREFIX $TEST_SOURCES
124 set_cmake_value $CMAKE_DIR/tests.cmake lite_test_files $CMAKE_PREFIX $LITE_TEST_ SOURCES
125 set_cmake_value $CMAKE_DIR/tests.cmake lite_arena_test_files $CMAKE_PREFIX $LITE _ARENA_TEST_SOURCES
126
127 # Generate extract_includes.bat
128 echo "mkdir include" > $EXTRACT_INCLUDES_BAT
129 for HEADER in $PUBLIC_HEADERS; do
130 HEADER_DIR=$(dirname $HEADER)
131 while [ ! "$HEADER_DIR" = "." ]; do
132 echo $HEADER_DIR | sed "s/\\//\\\\/g"
133 HEADER_DIR=$(dirname $HEADER_DIR)
134 done
135 done | sort | uniq | sed "s/^/mkdir include\\\\/" >> $EXTRACT_INCLUDES_BAT
136 for HEADER in $PUBLIC_HEADERS; do
137 WINPATH=$(echo $HEADER | sed 's;/;\\;g')
138 echo "copy \${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\$WINPATH include\\$WINPATH " >> $EXTRACT_INCLUDES_BAT
139 done
140
141 ################################################################################
142 # Update bazel BUILD files.
143 ################################################################################
144
145 set_bazel_value() {
146 local FILENAME=$1
147 local VARNAME=$2
148 local PREFIX=$3
149 shift
150 shift
151 shift
152 awk -v values="$*" -v prefix="$PREFIX" "
153 BEGIN { start = 0; }
154 /# AUTOGEN\\($VARNAME\\)/ {
155 start = 1;
156 print \$0;
157 # replace \$0 with indent.
158 sub(/#.*/, \"\", \$0)
159 len = split(values, vlist, \" \");
160 for (i = 1; i <= len; ++i) {
161 printf(\"%s\\\"%s%s\\\",\n\", \$0, prefix, vlist[i]);
162 }
163 next;
164 }
165 start && /\]/ {
166 start = 0
167 }
168 !start {
169 print \$0;
170 }
171 " $FILENAME > /tmp/$$
172 cp /tmp/$$ $FILENAME
173 }
174
175
176 BAZEL_BUILD=./BUILD
177 BAZEL_PREFIX="src/"
178 if [ -f "$BAZEL_BUILD" ]; then
179 set_bazel_value $BAZEL_BUILD protobuf_lite_srcs $BAZEL_PREFIX $LIBPROTOBUF_LIT E_SOURCES
180 set_bazel_value $BAZEL_BUILD protobuf_srcs $BAZEL_PREFIX $LIBPROTOBUF_SOURCES
181 set_bazel_value $BAZEL_BUILD protoc_lib_srcs $BAZEL_PREFIX $LIBPROTOC_SOURCES
182 set_bazel_value $BAZEL_BUILD lite_test_protos "" $LITE_PROTOS
183 set_bazel_value $BAZEL_BUILD well_known_protos "" $WKT_PROTOS
184 set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS
185 set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURC ES
186 set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES
187 set_bazel_value $BAZEL_BUILD test_plugin_srcs $BAZEL_PREFIX $TEST_PLUGIN_SOURC ES
188 else
189 echo "Skipped BUILD file update."
190 fi
191
OLDNEW
« no previous file with comments | « third_party/protobuf/travis.sh ('k') | third_party/protobuf/util/python/BUILD » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698