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

Side by Side Diff: third_party/protobuf/BUILD.gn

Issue 2756543002: Statically link libprotobuf_lite on Linux component builds (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 config("protobuf_config") { 5 config("protobuf_config") {
6 include_dirs = [ "src" ] 6 include_dirs = [ "src" ]
7 defines = [ 7 defines = [
8 "GOOGLE_PROTOBUF_NO_RTTI", 8 "GOOGLE_PROTOBUF_NO_RTTI",
9 "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER", 9 "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
10 ] 10 ]
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 "/wd4244", # implicit conversion, possible loss of data 129 "/wd4244", # implicit conversion, possible loss of data
130 "/wd4267", # size_t to int truncation 130 "/wd4267", # size_t to int truncation
131 "/wd4291", # no matching operator delete for a placement new. 131 "/wd4291", # no matching operator delete for a placement new.
132 "/wd4305", # double to float truncation 132 "/wd4305", # double to float truncation
133 "/wd4355", # 'this' used in base member initializer list 133 "/wd4355", # 'this' used in base member initializer list
134 "/wd4506", # no definition for inline function (protobuf issue #240) 134 "/wd4506", # no definition for inline function (protobuf issue #240)
135 "/wd4715", # not all control paths return a value (fixed in trunk) 135 "/wd4715", # not all control paths return a value (fixed in trunk)
136 ] 136 ]
137 } 137 }
138 138
139 component("protobuf_lite") { 139 # Do not allow libprotobuf_lite to be dynamically linked on Linux. Later
140 # versions of Ubuntu like Xenial and Yakkety link in the system
141 # libprotobuf_lite by the following dependency chain: chrome -> gtk ->
142 # libmirclient -> libmirprotobuf -> libprotobuf-lite. Trying to load
143 # the system libprotobuf-lite after already having loaded the libprotobuf_lite
144 # component will result in an immediate crash. (crbug.com/700120)
145 if (is_linux && !is_chromeos) {
146 link_target_type = "static_library"
147 } else {
148 link_target_type = "component"
149 }
150
151 if (is_component_build && is_linux && !is_chromeos) {
Peter Kasting 2017/03/15 21:53:52 Nit: This deserves a comment about what it's doing
Tom (Use chromium acct) 2017/03/19 07:19:11 Done.
152 component("protobuf_globals") {
153 configs += [
154 ":protobuf_config",
155 ":protobuf_use_dlls",
156 ]
157 defines = [ "LIBPROTOBUF_EXPORTS" ]
158 sources = [
159 "src/google/protobuf/globals.cc",
160 ]
161 }
162 }
163
164 target(link_target_type, "protobuf_lite") {
140 sources = protobuf_lite_sources 165 sources = protobuf_lite_sources
141 166
142 configs -= [ "//build/config/compiler:chromium_code" ] 167 configs -= [ "//build/config/compiler:chromium_code" ]
143 configs += [ 168 configs += [
144 "//build/config/compiler:no_chromium_code", 169 "//build/config/compiler:no_chromium_code",
145 170
146 # Must be after no_chromium_code for warning flags to be ordered 171 # Must be after no_chromium_code for warning flags to be ordered
147 # correctly. 172 # correctly.
148 ":protobuf_warnings", 173 ":protobuf_warnings",
149 ] 174 ]
150 175
151 if (is_win) { 176 if (is_win) {
152 configs -= [ "//build/config/win:lean_and_mean" ] 177 configs -= [ "//build/config/win:lean_and_mean" ]
153 } 178 }
154 179
155 public_configs = [ 180 public_configs = [
156 ":protobuf_config", 181 ":protobuf_config",
157 182
158 # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. 183 # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
159 "//build/config/compiler:no_size_t_to_int_warning", 184 "//build/config/compiler:no_size_t_to_int_warning",
160 ] 185 ]
161 186
162 deps = [ 187 deps = [
163 "//build/config/sanitizers:deps", 188 "//build/config/sanitizers:deps",
164 ] 189 ]
165 190
166 cflags = protobuf_lite_cflags 191 cflags = protobuf_lite_cflags
167 192
193 if (is_component_build && is_linux && !is_chromeos) {
194 deps += [ ":protobuf_globals" ]
195 } else {
196 sources += [ "src/google/protobuf/globals.cc" ]
197 }
198
168 # Required for component builds. See http://crbug.com/172800. 199 # Required for component builds. See http://crbug.com/172800.
169 if (is_component_build) { 200 if (is_component_build && (!is_linux || is_chromeos)) {
170 public_configs += [ ":protobuf_use_dlls" ] 201 public_configs += [ ":protobuf_use_dlls" ]
171 defines = [ "LIBPROTOBUF_EXPORTS" ] 202 defines = [ "LIBPROTOBUF_EXPORTS" ]
172 } 203 }
173 } 204 }
174 205
175 # This is the full, heavy protobuf lib that's needed for c++ .protos that don't 206 # This is the full, heavy protobuf lib that's needed for c++ .protos that don't
176 # specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls 207 # specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls
177 # into that category. Do not use in Chrome code. 208 # into that category. Do not use in Chrome code.
178 static_library("protobuf_full") { 209 static_library("protobuf_full") {
179 # Prevent people from depending on this outside our file. 210 # Prevent people from depending on this outside our file.
(...skipping 28 matching lines...) Expand all
208 "src/google/protobuf/dynamic_message.h", 239 "src/google/protobuf/dynamic_message.h",
209 "src/google/protobuf/empty.pb.cc", 240 "src/google/protobuf/empty.pb.cc",
210 "src/google/protobuf/empty.pb.h", 241 "src/google/protobuf/empty.pb.h",
211 "src/google/protobuf/extension_set_heavy.cc", 242 "src/google/protobuf/extension_set_heavy.cc",
212 "src/google/protobuf/field_mask.pb.cc", 243 "src/google/protobuf/field_mask.pb.cc",
213 "src/google/protobuf/field_mask.pb.h", 244 "src/google/protobuf/field_mask.pb.h",
214 "src/google/protobuf/generated_enum_reflection.h", 245 "src/google/protobuf/generated_enum_reflection.h",
215 "src/google/protobuf/generated_enum_util.h", 246 "src/google/protobuf/generated_enum_util.h",
216 "src/google/protobuf/generated_message_reflection.cc", 247 "src/google/protobuf/generated_message_reflection.cc",
217 "src/google/protobuf/generated_message_reflection.h", 248 "src/google/protobuf/generated_message_reflection.h",
249 "src/google/protobuf/globals.cc",
218 250
219 # gzip_stream.cc pulls in zlib, but it's not actually used by protoc, just 251 # gzip_stream.cc pulls in zlib, but it's not actually used by protoc, just
220 # by test code, so instead of compiling zlib for the host, let's just 252 # by test code, so instead of compiling zlib for the host, let's just
221 # exclude this. 253 # exclude this.
222 # "src/google/protobuf/io/gzip_stream.cc", 254 # "src/google/protobuf/io/gzip_stream.cc",
223 # "src/google/protobuf/io/gzip_stream.h", 255 # "src/google/protobuf/io/gzip_stream.h",
224 256
225 "src/google/protobuf/io/printer.cc", 257 "src/google/protobuf/io/printer.cc",
226 "src/google/protobuf/io/printer.h", 258 "src/google/protobuf/io/printer.h",
227 "src/google/protobuf/io/strtod.cc", 259 "src/google/protobuf/io/strtod.cc",
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 ":copy_google_protobuf_internal", 680 ":copy_google_protobuf_internal",
649 ":copy_six", 681 ":copy_six",
650 ] 682 ]
651 683
652 # Targets that depend on this should depend on the copied data files. 684 # Targets that depend on this should depend on the copied data files.
653 data = get_target_outputs(":copy_google") 685 data = get_target_outputs(":copy_google")
654 data += get_target_outputs(":copy_six") 686 data += get_target_outputs(":copy_six")
655 data += get_target_outputs(":copy_google_protobuf") 687 data += get_target_outputs(":copy_google_protobuf")
656 data += get_target_outputs(":copy_google_protobuf_internal") 688 data += get_target_outputs(":copy_google_protobuf_internal")
657 } 689 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698