From 2dad99092c8c444aea9a29aca1633d7b9297077e Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Wed, 20 Nov 2019 16:01:31 -0500 Subject: [PATCH] Replace third_party/gif: Preflight changes Something is breaking client code in unexpected ways. Let's try this piecemeal. - skia_libgifcodec_path gn var. Default is third_party/externals/libgifcodec. Anfroid framework uses third_party/libgifcodec. - skia_use_libgifcodec gn var; defaults to !skia_use_wuffs. Allow disabling both codecs. - GN template("optional"): add public_include_dirs, similar to public_defines. - SK_USE_LIBGIFCODEC, ifdef for skia_use_libgifcodec. - SkCodec.cpp: use SK_USE_LIBGIFCODEC Original CL: https://review.skia.org/254582 Cq-Include-Trybots: luci.skia.skia.primary:Build-Debian9-Clang-x86-devrel-Android_SKQP Bug: skia:9654 Change-Id: I70561f5f945656065e4b318d5fff505961fb0b6b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255578 Reviewed-by: Hal Canary Commit-Queue: Hal Canary --- BUILD.gn | 6 +++++- gn/gn_to_bp.py | 1 + gn/skia.gni | 2 ++ src/codec/SkCodec.cpp | 4 ++-- tools/skqp/create_apk.py | 6 +++++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 4d6bfab23d..c60ec4e649 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -211,6 +211,9 @@ template("optional") { if (defined(invoker.public_configs)) { configs = invoker.public_configs } + if (defined(invoker.public_include_dirs)) { + include_dirs = invoker.public_include_dirs + } } source_set(target_name) { check_includes = false @@ -608,7 +611,8 @@ optional("gpu") { } optional("gif") { - enabled = !skia_use_wuffs + enabled = !skia_use_wuffs && skia_use_libgifcodec + public_defines = [ "SK_USE_LIBGIFCODEC" ] sources = [ "src/codec/SkGifCodec.cpp", "third_party/gif/SkGifImageReader.cpp", diff --git a/gn/gn_to_bp.py b/gn/gn_to_bp.py index 244335879a..e649b4bf93 100644 --- a/gn/gn_to_bp.py +++ b/gn/gn_to_bp.py @@ -318,6 +318,7 @@ def generate_args(target_os, enable_gpu): 'skia_use_fontconfig': 'false', 'skia_use_fixed_gamma_text': 'true', 'skia_include_multiframe_procs': 'false', + 'skia_libgifcodec_path': '"third_party/libgifcodec"', } d['target_os'] = target_os if target_os == '"android"': diff --git a/gn/skia.gni b/gn/skia.gni index 5f5fe90a41..01a5210ab2 100644 --- a/gn/skia.gni +++ b/gn/skia.gni @@ -29,6 +29,7 @@ declare_args() { skia_generate_workarounds = false skia_include_multiframe_procs = false skia_lex = false + skia_libgifcodec_path = "third_party/externals/libgifcodec" skia_pdf_subset_harfbuzz = false # TODO: set skia_pdf_subset_harfbuzz to skia_use_harfbuzz. skia_qt_path = getenv("QT_PATH") skia_skqp_global_error_tolerance = 0 @@ -93,6 +94,7 @@ declare_args() { skia_enable_nvpr = !skia_enable_flutter_defines skia_enable_spirv_validation = is_skia_dev_build && is_debug && !skia_use_dawn skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib + skia_use_libgifcodec = !skia_use_wuffs skia_use_sfntly = skia_use_icu } diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp index cc5b9bff6e..41587f8e67 100644 --- a/src/codec/SkCodec.cpp +++ b/src/codec/SkCodec.cpp @@ -26,7 +26,7 @@ #include "src/codec/SkWebpCodec.h" #ifdef SK_HAS_WUFFS_LIBRARY #include "src/codec/SkWuffsCodec.h" -#else +#elif defined(SK_USE_LIBGIFCODEC) #include "src/codec/SkGifCodec.h" #endif @@ -45,7 +45,7 @@ static std::vector* decoders() { #endif #ifdef SK_HAS_WUFFS_LIBRARY { SkWuffsCodec_IsFormat, SkWuffsCodec_MakeFromStream }, - #else + #elif defined(SK_USE_LIBGIFCODEC) { SkGifCodec::IsGif, SkGifCodec::MakeFromStream }, #endif #ifdef SK_HAS_PNG_LIBRARY diff --git a/tools/skqp/create_apk.py b/tools/skqp/create_apk.py index 2f6d94eeb2..27bff792fb 100755 --- a/tools/skqp/create_apk.py +++ b/tools/skqp/create_apk.py @@ -150,7 +150,11 @@ def create_apk_impl(opts): gn_args = opts.gn_args(arch) args = ' '.join('%s=%s' % (k, v) for k, v in gn_args.items()) check_call(['bin/gn', 'gen', build, '--args=' + args]) - check_call(['ninja', '-C', build, lib]) + try: + check_call(['ninja', '-C', build, lib]) + except subprocess.CalledProcessError: + check_call(['ninja', '-C', build, '-t', 'clean']) + check_call(['ninja', '-C', build, lib]) dst = '%s/%s' % (lib_dir, skia_to_android_arch_name_map[arch]) makedirs(dst) shutil.copy(os.path.join(build, lib), dst)