Skip to content

Migrate third_party/zlib to flutter/third_party/zlib #146598

@matanlurey

Description

@matanlurey

Part of #67373.

Naively, I tried doing this migration:

Patch
diff --git a/DEPS b/DEPS
index fcf46d3053..12cd0b39b8 100644
--- a/DEPS
+++ b/DEPS
@@ -664,7 +664,7 @@ deps = {
   'src/flutter/third_party/wuffs':
    Var('skia_git') + '/external/github.com/google/wuffs-mirror-release-c.git' + '@' + '600cd96cf47788ee3a74b40a6028b035c9fd6a61',
 
-  'src/third_party/zlib':
+  'src/flutter/third_party/zlib':
    Var('chromium_git') + '/chromium/src/third_party/zlib.git' + '@' + '14dd4c4455602c9b71a1a89b5cafd1f4030d2e3f',
 
   'src/flutter/third_party/inja':
diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn
index 1d00f1dfeb..f5874b4562 100644
--- a/lib/ui/BUILD.gn
+++ b/lib/ui/BUILD.gn
@@ -183,7 +183,7 @@ source_set("ui") {
     "//flutter/skia",
     "//flutter/third_party/rapidjson",
     "//flutter/third_party/tonic",
-    "//third_party/zlib:zlib",
+    "//flutter/third_party/zlib:zlib",
   ]
 
   if (impeller_supports_rendering) {
diff --git a/lib/ui/painting/image_generator_apng.cc b/lib/ui/painting/image_generator_apng.cc
index 159d87638a..6da327b884 100644
--- a/lib/ui/painting/image_generator_apng.cc
+++ b/lib/ui/painting/image_generator_apng.cc
@@ -7,13 +7,13 @@
 #include <cstring>
 
 #include "flutter/fml/logging.h"
+#include "flutter/third_party/zlib/zlib.h"  // For crc32
 #include "third_party/skia/include/codec/SkCodec.h"
 #include "third_party/skia/include/codec/SkCodecAnimation.h"
 #include "third_party/skia/include/core/SkAlphaType.h"
 #include "third_party/skia/include/core/SkColorType.h"
 #include "third_party/skia/include/core/SkImageInfo.h"
 #include "third_party/skia/include/core/SkStream.h"
-#include "third_party/zlib/zlib.h"  // For crc32
 
 namespace flutter {

However there are various failures building the Dart runtime:

[59/574] CXX obj/flutter/third_party/dart/runtime/bin/gen_snapshot_dart_io.filter.o
FAILED: obj/flutter/third_party/dart/runtime/bin/gen_snapshot_dart_io.filter.o 
/Users/matanl/Developer/engine/src/flutter/buildtools/mac-x64/goma/gomacc ../../flutter/buildtools/mac-x64/clang/bin/clang++ -MMD -MF obj/flutter/third_party/dart/runtime/bin/gen_snapshot_dart_io.filter.o.d -DDART_IO_SECURE_SOCKET_DISABLED -DUSE_OPENSSL=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_LIBCPP_DISABLE_AVAILABILITY=1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -D_DEBUG -DNDEBUG -DSUPPORT_PERFETTO -DDART_PRECOMPILER -DTARGET_ARCH_ARM64 -DDART_TARGET_OS_MACOS -I../../flutter/third_party/dart/runtime -I../../third_party -I../.. -Igen -I../../third_party/libcxx/include -I../../third_party/libcxxabi/include -I../../flutter/build/secondary/third_party/libcxx/config -I../../flutter/third_party/dart/runtime/include -I../../flutter/third_party/zlib -fno-strict-aliasing -fstack-protector-all --target=arm64-apple-macos -arch arm64 -fcolor-diagnostics -Wall -Wextra -Wendif-labels -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-implicit-int-float-conversion -Wno-deprecated-copy -Wno-psabi -Wno-deprecated-literal-operator -Wno-unqualified-std-cast-call -Wno-non-c-typedef-for-linkage -Wno-range-loop-construct -Wunguarded-availability -Wno-deprecated-declarations -fvisibility=hidden -Wstring-conversion -Wnewline-eof -O0 -g2 -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -fno-strict-vtable-pointers -O2 -fno-omit-frame-pointer -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fvisibility=hidden -fno-exceptions -stdlib=libc++ -isysroot ../../flutter/prebuilts/SDKs/MacOSX14.2.sdk -mmacosx-version-min=10.14.0  -c ../../flutter/third_party/dart/runtime/bin/filter.cc -o obj/flutter/third_party/dart/runtime/bin/gen_snapshot_dart_io.filter.o
In file included from ../../flutter/third_party/dart/runtime/bin/filter.cc:5:
../../flutter/third_party/dart/runtime/bin/filter.h:11:10: fatal error: 'zlib/zlib.h' file not found
   11 | #include "zlib/zlib.h"
      |          ^~~~~~~~~~~~~

My guess is that either the Dart SDK needs to make this configurable, or I missed a step somewhere in my patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.e: buildmootFinal steps to remove `flutter/buildroot`.engineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions