@@ -131,6 +131,114 @@ 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+ from(" tester/third-party/skia/CMakeLists.txt" )
181+ eachFile { path = path.substringAfter(" /" ) }
182+ filesMatching(" **/SkRasterPipeline_opts.h" ) {
183+ filter { line ->
184+ line.replace(
185+ " #if !defined(__clang__)" ,
186+ " #if defined(SK_RASTER_PIPELINE_FORCE_SCALAR) || !defined(__clang__)" ,
187+ )
188+ }
189+ }
190+ filesMatching(" **/SkBlitter_Sprite.cpp" ) {
191+ filter { line ->
192+ line
193+ .replace(
194+ " if (gSkForceRasterPipelineBlitter) {" ,
195+ " #if !defined(SK_FORCE_RASTER_PIPELINE_BLITTER)\n if (gSkForceRasterPipelineBlitter) {" ,
196+ )
197+ .replace(
198+ " if (!blitter && !paint.getMaskFilter()) {" ,
199+ " #endif\n if (!blitter && !paint.getMaskFilter()) {" ,
200+ )
201+ }
202+ }
203+ includeEmptyDirs = false
204+ into(" $thirdParty /skia" )
205+ }
206+
207+ // GN builds these dependencies into libskia, including FreeType's color PNG glyph support.
208+ val skiaDependencies =
209+ mapOf (
210+ " freetype" to " https://github.com/freetype/freetype/archive/refs/tags/VER-2-14-2.tar.gz" ,
211+ " harfbuzz" to
212+ " https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git/+archive/8d1b000a3edc90c12267b836b4ef3f81c0e53edc.tar.gz" ,
213+ " libpng" to " https://github.com/pnggroup/libpng/archive/refs/tags/v1.6.55.tar.gz" ,
214+ " zlib" to
215+ " https://chromium.googlesource.com/chromium/src/third_party/zlib/+archive/c876c8f87101c5a75f6014b0f832499afeb65b73.tar.gz" ,
216+ )
217+ val prepareSkiaDependencies =
218+ skiaDependencies.map { (name, url) ->
219+ val archive = File (downloadsDir, " skia-$name -${url.substringAfterLast(' /' )} " )
220+ val download = downloadSkiaSource(name.replaceFirstChar { it.uppercase() }, url, archive)
221+ tasks.register<Copy >(" prepareSkia${name.replaceFirstChar { it.uppercase() }} " ) {
222+ dependsOn(download, prepareSkiaSource)
223+ from(tarTree(archive))
224+ if (name == " freetype" || name == " libpng" ) {
225+ eachFile { path = path.substringAfter(" /" ) }
226+ }
227+ if (name == " zlib" ) {
228+ filesMatching(" zutil.h" ) {
229+ filter { line ->
230+ line.replace(
231+ " defined(TARGET_OS_MAC)" ,
232+ " (defined(TARGET_OS_MAC) && !defined(__APPLE__))" ,
233+ )
234+ }
235+ }
236+ }
237+ includeEmptyDirs = false
238+ into(" $thirdParty /skia/third_party/externals/$name " )
239+ }
240+ }
241+
134242var codegenSrcDir = File (" $reactAndroidBuildDir /generated/source/codegen/jni" )
135243var codegenOutDir = File (" $buildDir /codegen" )
136244val prepareRNCodegen by
@@ -166,6 +274,9 @@ val prepareNative3pDependencies by
166274 prepareGflags,
167275 prepareNlohmannJson,
168276 prepareFolly,
277+ prepareBoringSSL,
278+ prepareSkiaSource,
279+ * prepareSkiaDependencies.toTypedArray(),
169280 " :packages:react-native:ReactAndroid:prepareBoost" ,
170281 " :packages:react-native:ReactAndroid:prepareDoubleConversion" ,
171282 " :packages:react-native:ReactAndroid:prepareFastFloat" ,
@@ -197,6 +308,7 @@ val configureFantomTester by
197308 " -DCMAKE_BUILD_TYPE=Debug" ,
198309 " -DFANTOM_CODEGEN_DIR=$buildDir /codegen" ,
199310 " -DFANTOM_THIRD_PARTY_DIR=$buildDir /third-party" ,
311+ " -DFANTOM_NINJA=$cmakePath /bin/ninja" ,
200312 " -DREACT_ANDROID_DIR=$reactAndroidDir " ,
201313 " -DREACT_COMMON_DIR=$reactNativeDir /ReactCommon" ,
202314 " -DREACT_CXX_PLATFORM_DIR=$reactNativeDir /ReactCxxPlatform" ,
@@ -215,6 +327,7 @@ val buildFantomTester by
215327 tasks.registering(CustomExecTask ::class ) {
216328 dependsOn(configureFantomTester)
217329 workingDir(testerDir)
330+ inputs.dir(testerDir)
218331 inputs.files(testerBuildOutputFileTree)
219332 commandLine(
220333 cmakeBinaryPath,
0 commit comments