Content-Length: 373960 | pFad | http://github.com/facebook/react-native/pull/49438/commits/2a7ce7ba698f26c2a6dafd96802d7f1200df4b31

85 Gradle Configuration Cache - Round 2 by cortinico · Pull Request #49438 · facebook/react-native · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Configuration Cache - Round 2 #49438

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[skip ci] Gradle Configuration Cache - Round 2
Summary:
This is the second part of a series of diff needed to enable G. Configuration Cache:
https://docs.gradle.org/current/userguide/configuration_cache.html
as it will make our CI faster (and will be the default in the future Gradle version).

Here I'm making the exec tasks CC friendly.

The problem is that previously we were using explicit streams which are not CC friendly
for stderr/stdout. The solution is to create a custom task and handle files as input
properties.

Changelog:
[Internal] [Changed] -

Differential Revision: D69662246
  • Loading branch information
cortinico authored and facebook-github-bot committed Feb 14, 2025
commit 2a7ce7ba698f26c2a6dafd96802d7f1200df4b31
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.tasks.internal

import java.io.File
import java.io.FileOutputStream
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Exec
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile

/**
* A Task that will just expose an Exec-like task and that offers properties to configure the
* standard output and error.
*/
abstract class CustomExecTask : Exec() {

@get:OutputFile @get:Optional abstract val standardOutputFile: RegularFileProperty

@get:OutputFile @get:Optional abstract val errorOutputFile: RegularFileProperty

@get:Input @get:Optional abstract val onlyIfProvidedPathDoesNotExists: Property<String>

override fun exec() {
if (onlyIfProvidedPathDoesNotExists.isPresent &&
File(onlyIfProvidedPathDoesNotExists.get()).exists()) {
return
}
if (standardOutputFile.isPresent) {
standardOutput = FileOutputStream(standardOutputFile.get().asFile)
}
if (errorOutputFile.isPresent) {
errorOutput = FileOutputStream(errorOutputFile.get().asFile)
}
super.exec()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.tasks.internal

import com.facebook.react.tests.createTestTask
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder

class CustomExecTaskTest {

@get:Rule val tempFolder = TemporaryFolder()

@Test
fun customExec_inputProperties_areSetCorrectly() {
val outFile = tempFolder.newFile("stdout")
val errFile = tempFolder.newFile("stderr")
val task =
createTestTask<CustomExecTask> { task ->
task.errorOutputFile.set(errFile)
task.standardOutputFile.set(outFile)
}

assertThat(task.errorOutputFile.get().asFile).isEqualTo(errFile)
assertThat(task.standardOutputFile.get().asFile).isEqualTo(outFile)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.react.tasks.internal.*
import de.undercouch.gradle.tasks.download.Download
import java.io.FileOutputStream
import org.apache.tools.ant.taskdefs.condition.Os

plugins {
Expand Down Expand Up @@ -131,7 +131,7 @@ val installCMake by
}

val configureBuildForHermes by
tasks.registering(Exec::class) {
tasks.registering(CustomExecTask::class) {
dependsOn(installCMake)
workingDir(hermesDir)
inputs.dir(hermesDir)
Expand All @@ -149,11 +149,11 @@ val configureBuildForHermes by
hermesBuildDir.toString(),
"-DJSI_DIR=" + jsiDir.absolutePath,
))
standardOutput = FileOutputStream("$buildDir/configure-hermesc.log")
standardOutputFile.set(project.file("$buildDir/configure-hermesc.log"))
}

val buildHermesC by
tasks.registering(Exec::class) {
tasks.registering(CustomExecTask::class) {
dependsOn(configureBuildForHermes)
workingDir(hermesDir)
inputs.files(hermesBuildOutputFileTree)
Expand All @@ -167,8 +167,8 @@ val buildHermesC by
"-j",
ndkBuildJobs,
)
standardOutput = FileOutputStream("$buildDir/build-hermesc.log")
errorOutput = FileOutputStream("$buildDir/build-hermesc.error.log")
standardOutputFile.set(project.file("$buildDir/build-hermesc.log"))
errorOutputFile.set(project.file("$buildDir/build-hermesc.error.log"))
}

val prepareHeadersForPrefab by
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/facebook/react-native/pull/49438/commits/2a7ce7ba698f26c2a6dafd96802d7f1200df4b31

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy