23
23
abseil = _CR_PREFIX + "chromium/src/third_party/abseil-cpp" ,
24
24
fast_float = _CR_PREFIX + "external/github.com/fastfloat/fast_float" ,
25
25
catapult = _CR_PREFIX + "catapult" , # android
26
- icu = _CR_PREFIX + "chromium/deps/icu" , # cibuildwheel
26
+ icu = _CR_PREFIX + "chromium/deps/icu" , # for cibuildwheel
27
27
gtest = _CR_PREFIX + "external/github.com/google/googletest" ,
28
28
test_fonts = _CR_PREFIX + "chromium/src/third_party/test_fonts" ,
29
29
)
@@ -156,7 +156,7 @@ def autopatch_dir(dir, globexpr, pattern, repl, is_regex, exp_count=None):
156
156
autopatch (file , pattern , repl , is_regex , exp_count )
157
157
158
158
159
- def get_sources (deps_info , short_ver , with_tests , compiler , clang_path , single_lib , reset ):
159
+ def get_sources (deps_info , short_ver , with_tests , compiler , clang_path , single_lib , reset , vendor_deps ):
160
160
161
161
assert not IGNORE_FULLVER
162
162
full_ver , pdfium_rev , chromium_rev = handle_sbuild_vers (short_ver )
@@ -227,7 +227,7 @@ def get_sources(deps_info, short_ver, with_tests, compiler, clang_path, single_l
227
227
_fetch_dep (deps_info , "fast_float" , PDFIUM_3RDPARTY / "fast_float" / "src" )
228
228
if IS_ANDROID :
229
229
_fetch_dep (deps_info , "catapult" , PDFIUM_3RDPARTY / "catapult" )
230
- if IS_CIBUILDWHEEL :
230
+ if "icu" in vendor_deps :
231
231
_fetch_dep (deps_info , "icu" , PDFIUM_3RDPARTY / "icu" )
232
232
if with_tests :
233
233
_fetch_dep (deps_info , "gtest" , PDFIUM_3RDPARTY / "googletest" / "src" )
@@ -236,13 +236,12 @@ def get_sources(deps_info, short_ver, with_tests, compiler, clang_path, single_l
236
236
return full_ver
237
237
238
238
239
- def prepare (config_dict , build_dir ):
239
+ def prepare (config_dict , build_dir , vendor_deps ):
240
240
# Create an empty gclient config
241
241
(PDFIUM_DIR / "build" / "config" / "gclient_args.gni" ).touch (exist_ok = True )
242
- if not IS_CIBUILDWHEEL :
242
+ if "icu" not in vendor_deps :
243
243
# Unbundle ICU
244
244
# alternatively, we could call build/linux/unbundle/replace_gn_files.py --system-libraries icu
245
- # Don't do this with cibuildwheel, the libicu pulled in via auditwheel is quite big.
246
245
(PDFIUM_3RDPARTY / "icu" ).mkdir (exist_ok = True )
247
246
shutil .copyfile (
248
247
PDFIUM_DIR / "build" / "linux" / "unbundle" / "icu.gn" ,
@@ -306,7 +305,13 @@ def setup_compiler(config, compiler, clang_path):
306
305
assert False , f"Unhandled compiler { compiler } "
307
306
308
307
309
- def main (build_ver = None , with_tests = False , n_jobs = None , compiler = None , clang_path = None , single_lib = False , reset = False ):
308
+ def main (build_ver = None , with_tests = False , n_jobs = None , compiler = None , clang_path = None , single_lib = False , reset = False , vendor_deps = None ):
309
+
310
+ if vendor_deps is None :
311
+ vendor_deps = set ()
312
+ # Vendor ICU in cibuildwheel by default, the libicudata pulled in from the system is quite big. This reduces wheel size by about 10 MB.
313
+ if IS_CIBUILDWHEEL :
314
+ vendor_deps .add ("icu" )
310
315
311
316
if build_ver is None :
312
317
build_ver = SBUILD_NATIVE_PIN
@@ -329,7 +334,7 @@ def main(build_ver=None, with_tests=False, n_jobs=None, compiler=None, clang_pat
329
334
deps_fields = ["build" , "abseil" , "fast_float" ]
330
335
if IS_ANDROID :
331
336
deps_fields .append ("catapult" )
332
- if IS_CIBUILDWHEEL :
337
+ if "icu" in vendor_deps :
333
338
deps_fields .append ("icu" )
334
339
if with_tests :
335
340
deps_fields += ("gtest" , "test_fonts" )
@@ -338,10 +343,10 @@ def main(build_ver=None, with_tests=False, n_jobs=None, compiler=None, clang_pat
338
343
339
344
mkdir (SOURCES_DIR )
340
345
full_ver = get_sources (
341
- deps_info , build_ver , with_tests , compiler , clang_path , single_lib , reset
346
+ deps_info , build_ver , with_tests , compiler , clang_path , single_lib , reset , vendor_deps
342
347
)
343
348
setup_compiler (config , compiler , clang_path )
344
- prepare (config , build_dir )
349
+ prepare (config , build_dir , vendor_deps )
345
350
build (with_tests , build_dir , n_jobs )
346
351
if with_tests :
347
352
test (build_dir )
@@ -392,9 +397,18 @@ def parse_args(argv):
392
397
action = "store_true" ,
393
398
help = "Whether to create a single DLL that bundles the dependency libraries. Otherwise, separate DLLs will be used. Note, the corresponding patch will only be applied if pdfium is downloaded anew or reset, else the existing state is used." ,
394
399
)
400
+ parser .add_argument (
401
+ "--vendor" ,
402
+ dest = "vendor_deps" ,
403
+ nargs = "*" ,
404
+ action = "extend" ,
405
+ help = "Dependencies to vendor. Note, this only supports libraries where there is a specific reason to vendor despite the native build. Currently this means 'icu' only ('libc++' may be added in the future). For an exhaustive vendored build, use build_toolchained.py. Pass --vendor without arguments to drop default vendorings, if any."
406
+ )
395
407
args = parser .parse_args (argv )
396
408
if args .compiler :
397
409
args .compiler = Compiler [args .compiler ]
410
+ if args .vendor_deps :
411
+ args .vendor_deps = set (args .vendor_deps )
398
412
return args
399
413
400
414
0 commit comments