@@ -131,6 +131,113 @@ val prepareNlohmannJson by
131131 into(" $thirdParty /nlohmann_json" )
132132 }
133133
134+ val boringsslVersion = " 603b54d3d338efde4b84ece7be9aa410e44b1417"
135+ val boringsslArchive = File (downloadsDir, " boringssl-$boringsslVersion .tar.gz" )
136+ val downloadBoringSSL by
137+ tasks.registering(Download ::class ) {
138+ dependsOn(createNativeDepsDirectories)
139+ src(" https://github.com/google/boringssl/archive/$boringsslVersion .tar.gz" )
140+ onlyIfModified(true )
141+ overwrite(false )
142+ retries(5 )
143+ quiet(true )
144+ dest(boringsslArchive)
145+ }
146+ val prepareBoringSSL by
147+ tasks.registering(Copy ::class ) {
148+ dependsOn(downloadBoringSSL)
149+ from(tarTree(boringsslArchive))
150+ eachFile { path = path.substringAfter(" /" ) }
151+ includeEmptyDirs = false
152+ into(" $thirdParty /boringssl" )
153+ }
154+
155+ // Match the CPU Skia revision used by the native tester in Buck.
156+ val skiaVersion = " 3f8fc145ba678f3bd47af50f8fb51bcde474ef9c"
157+
158+ fun downloadSkiaSource (name : String , url : String , destination : File ) =
159+ tasks.register<Download >(" downloadSkia${name} " ) {
160+ dependsOn(createNativeDepsDirectories)
161+ src(url)
162+ onlyIfModified(true )
163+ overwrite(false )
164+ retries(5 )
165+ quiet(true )
166+ dest(destination)
167+ }
168+
169+ val skiaArchive = File (downloadsDir, " skia-$skiaVersion .tar.gz" )
170+ val downloadSkia =
171+ downloadSkiaSource(
172+ " Core" ,
173+ " https://github.com/google/skia/archive/$skiaVersion .tar.gz" ,
174+ skiaArchive,
175+ )
176+ val prepareSkiaSource by
177+ tasks.registering(Copy ::class ) {
178+ dependsOn(downloadSkia)
179+ from(tarTree(skiaArchive))
180+ eachFile { path = path.substringAfter(" /" ) }
181+ filesMatching(" **/SkRasterPipeline_opts.h" ) {
182+ filter { line ->
183+ line.replace(
184+ " #if !defined(__clang__)" ,
185+ " #if defined(SK_RASTER_PIPELINE_FORCE_SCALAR) || !defined(__clang__)" ,
186+ )
187+ }
188+ }
189+ filesMatching(" **/SkBlitter_Sprite.cpp" ) {
190+ filter { line ->
191+ line
192+ .replace(
193+ " if (gSkForceRasterPipelineBlitter) {" ,
194+ " #if !defined(SK_FORCE_RASTER_PIPELINE_BLITTER)\n if (gSkForceRasterPipelineBlitter) {" ,
195+ )
196+ .replace(
197+ " if (!blitter && !paint.getMaskFilter()) {" ,
198+ " #endif\n if (!blitter && !paint.getMaskFilter()) {" ,
199+ )
200+ }
201+ }
202+ includeEmptyDirs = false
203+ into(" $thirdParty /skia" )
204+ }
205+
206+ // GN builds these dependencies into libskia, including FreeType's color PNG glyph support.
207+ val skiaDependencies =
208+ mapOf (
209+ " freetype" to " https://github.com/freetype/freetype/archive/refs/tags/VER-2-14-2.tar.gz" ,
210+ " harfbuzz" to
211+ " https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git/+archive/8d1b000a3edc90c12267b836b4ef3f81c0e53edc.tar.gz" ,
212+ " libpng" to " https://github.com/pnggroup/libpng/archive/refs/tags/v1.6.55.tar.gz" ,
213+ " zlib" to
214+ " https://chromium.googlesource.com/chromium/src/third_party/zlib/+archive/c876c8f87101c5a75f6014b0f832499afeb65b73.tar.gz" ,
215+ )
216+ val prepareSkiaDependencies =
217+ skiaDependencies.map { (name, url) ->
218+ val archive = File (downloadsDir, " skia-$name -${url.substringAfterLast(' /' )} " )
219+ val download = downloadSkiaSource(name.replaceFirstChar { it.uppercase() }, url, archive)
220+ tasks.register<Copy >(" prepareSkia${name.replaceFirstChar { it.uppercase() }} " ) {
221+ dependsOn(download, prepareSkiaSource)
222+ from(tarTree(archive))
223+ if (name == " freetype" || name == " libpng" ) {
224+ eachFile { path = path.substringAfter(" /" ) }
225+ }
226+ if (name == " zlib" ) {
227+ filesMatching(" zutil.h" ) {
228+ filter { line ->
229+ line.replace(
230+ " defined(TARGET_OS_MAC)" ,
231+ " (defined(TARGET_OS_MAC) && !defined(__APPLE__))" ,
232+ )
233+ }
234+ }
235+ }
236+ includeEmptyDirs = false
237+ into(" $thirdParty /skia/third_party/externals/$name " )
238+ }
239+ }
240+
134241var codegenSrcDir = File (" $reactAndroidBuildDir /generated/source/codegen/jni" )
135242var codegenOutDir = File (" $buildDir /codegen" )
136243val prepareRNCodegen by
@@ -166,6 +273,9 @@ val prepareNative3pDependencies by
166273 prepareGflags,
167274 prepareNlohmannJson,
168275 prepareFolly,
276+ prepareBoringSSL,
277+ prepareSkiaSource,
278+ * prepareSkiaDependencies.toTypedArray(),
169279 " :packages:react-native:ReactAndroid:prepareBoost" ,
170280 " :packages:react-native:ReactAndroid:prepareDoubleConversion" ,
171281 " :packages:react-native:ReactAndroid:prepareFastFloat" ,
@@ -197,6 +307,7 @@ val configureFantomTester by
197307 " -DCMAKE_BUILD_TYPE=Debug" ,
198308 " -DFANTOM_CODEGEN_DIR=$buildDir /codegen" ,
199309 " -DFANTOM_THIRD_PARTY_DIR=$buildDir /third-party" ,
310+ " -DFANTOM_NINJA=$cmakePath /bin/ninja" ,
200311 " -DREACT_ANDROID_DIR=$reactAndroidDir " ,
201312 " -DREACT_COMMON_DIR=$reactNativeDir /ReactCommon" ,
202313 " -DREACT_CXX_PLATFORM_DIR=$reactNativeDir /ReactCxxPlatform" ,
@@ -215,6 +326,7 @@ val buildFantomTester by
215326 tasks.registering(CustomExecTask ::class ) {
216327 dependsOn(configureFantomTester)
217328 workingDir(testerDir)
329+ inputs.dir(testerDir)
218330 inputs.files(testerBuildOutputFileTree)
219331 commandLine(
220332 cmakeBinaryPath,
0 commit comments