@@ -131,6 +131,100 @@ 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+ includeEmptyDirs = false
190+ into(" $thirdParty /skia" )
191+ }
192+
193+ // GN builds these dependencies into libskia, including FreeType's color PNG glyph support.
194+ val skiaDependencies =
195+ mapOf (
196+ " freetype" to " https://github.com/freetype/freetype/archive/refs/tags/VER-2-14-2.tar.gz" ,
197+ " harfbuzz" to
198+ " https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git/+archive/8d1b000a3edc90c12267b836b4ef3f81c0e53edc.tar.gz" ,
199+ " libpng" to " https://github.com/pnggroup/libpng/archive/refs/tags/v1.6.55.tar.gz" ,
200+ " zlib" to
201+ " https://chromium.googlesource.com/chromium/src/third_party/zlib/+archive/c876c8f87101c5a75f6014b0f832499afeb65b73.tar.gz" ,
202+ )
203+ val prepareSkiaDependencies =
204+ skiaDependencies.map { (name, url) ->
205+ val archive = File (downloadsDir, " skia-$name -${url.substringAfterLast(' /' )} " )
206+ val download = downloadSkiaSource(name.replaceFirstChar { it.uppercase() }, url, archive)
207+ tasks.register<Copy >(" prepareSkia${name.replaceFirstChar { it.uppercase() }} " ) {
208+ dependsOn(download, prepareSkiaSource)
209+ from(tarTree(archive))
210+ if (name == " freetype" || name == " libpng" ) {
211+ eachFile { path = path.substringAfter(" /" ) }
212+ }
213+ if (name == " zlib" ) {
214+ filesMatching(" zutil.h" ) {
215+ filter { line ->
216+ line.replace(
217+ " defined(TARGET_OS_MAC)" ,
218+ " (defined(TARGET_OS_MAC) && !defined(__APPLE__))" ,
219+ )
220+ }
221+ }
222+ }
223+ includeEmptyDirs = false
224+ into(" $thirdParty /skia/third_party/externals/$name " )
225+ }
226+ }
227+
134228var codegenSrcDir = File (" $reactAndroidBuildDir /generated/source/codegen/jni" )
135229var codegenOutDir = File (" $buildDir /codegen" )
136230val prepareRNCodegen by
@@ -166,6 +260,9 @@ val prepareNative3pDependencies by
166260 prepareGflags,
167261 prepareNlohmannJson,
168262 prepareFolly,
263+ prepareBoringSSL,
264+ prepareSkiaSource,
265+ * prepareSkiaDependencies.toTypedArray(),
169266 " :packages:react-native:ReactAndroid:prepareBoost" ,
170267 " :packages:react-native:ReactAndroid:prepareDoubleConversion" ,
171268 " :packages:react-native:ReactAndroid:prepareFastFloat" ,
@@ -197,6 +294,7 @@ val configureFantomTester by
197294 " -DCMAKE_BUILD_TYPE=Debug" ,
198295 " -DFANTOM_CODEGEN_DIR=$buildDir /codegen" ,
199296 " -DFANTOM_THIRD_PARTY_DIR=$buildDir /third-party" ,
297+ " -DFANTOM_NINJA=$cmakePath /bin/ninja" ,
200298 " -DREACT_ANDROID_DIR=$reactAndroidDir " ,
201299 " -DREACT_COMMON_DIR=$reactNativeDir /ReactCommon" ,
202300 " -DREACT_CXX_PLATFORM_DIR=$reactNativeDir /ReactCxxPlatform" ,
@@ -215,6 +313,7 @@ val buildFantomTester by
215313 tasks.registering(CustomExecTask ::class ) {
216314 dependsOn(configureFantomTester)
217315 workingDir(testerDir)
316+ inputs.dir(testerDir)
218317 inputs.files(testerBuildOutputFileTree)
219318 commandLine(
220319 cmakeBinaryPath,
0 commit comments