[go: up one dir, main page]

tree: 75ea81bbea97507ca734a0b4a208f205fb1c8e40 [path history] [tgz]
  1. chromium-module/
  2. chromium-tests/
  3. patches/
  4. .gitignore
  5. 3pp.pb
  6. install.sh
  7. LICENSE
  8. local-test.sh
  9. OWNERS
  10. README.chromium
  11. README.md
3pp/copybara/README.md

Copybara+

This package is a patched version of opensource Copybara. The patches add support for Chromium specific functionality so that we can compile Copybara with this baked in.

What's added

To make this as straightforward and easy to fix as possible, there is a few different components.

patches/

This directory contains .patch files which make changes to files which exist in the upstream GitHub repo. There is one patch file for each upstream file we modify. These are kept as simple as possible, mostly limited to patching BUILD files so bazel includes the new chromium modules and tests when building.

Patched files:

	modified:   java/com/google/copybara/BUILD
	modified:   java/com/google/copybara/ModuleSupplier.java
	modified:   javatests/com/google/copybara/BUILD

Extracting patches

Run the local-test.sh script first, to generate the directories that the recipe expects to exist.

When extracting patches, you should make sure you're in the copybara source checkout directory created when running local-test.sh. Otherwise, the patch paths may be incorrect.

Try to extract one patch per changed file to limit the density of patch files. Everything more complex should be added directly to chromium-module or chromium-tests which are copied directly into Copybara by the install.sh to make upgrades as painless as possible.

git diff javatests/com/google/copybara/BUILD > ../patches/javatests-com-google-copybara-BUILD.patch

chromium-module

This is where the new functionality we've added exists. During the install.sh run, the contents of this directory is copied into java/com/google/copybara/chromium.

chromium-tests

The test files for the new chromium-module. The contents of this directory are copied into javatests/com/google/copybara/chromium by install.sh. The tests are also run during install to verify that everything is loaded correctly after patching. While verify.sh does exist as a 3PP step, it would run on the compiled version after build, which isn't useful here.

Fixing or testing this locally

  1. Make sure you have bazel installed for both building and testing.
  2. Run local-test.sh. This will download the open source version of Copybara at the revision specified in the 3pp.pb file and patch it with Chromium changes.
  3. If it builds successfully, the resulting binary will exist at local-build/copybara/copybara_deploy.jar. Any failures should cause the install script to immediately exit with an error.
  4. Format Java files with google-java-format -r chromium-module/* chromium-tests/*

Using the Chromium functionality

Once the patched version of Copybara is built, you can use the new helpers:

core.workflow(
    name = "My Cool Dependency",
    origin = git.origin(
        url = "https://example.com/some/upstream_project.git",
        ref = "main",
    ),
    destination = git.destination(
        url = "https://example.com/your/chromium_repo.git",
        fetch = "main",
    ),
    transformations = [
        # This is where we use the custom Chromium transformations.
        # It will update 'Version' and 'Revision' with the provided values.
        # Since 'Update Mechanism' is not explicitly provided in metadata,
        # it will update with the default value of 'Autoroll'.
        chromium.update_readme(
            metadata = {
                "Version": "1.2.3",
                "Revision": "abcdef1234567890abcdef1234567890abcdef12",
            },
        ),
        # Other transformations
        core.move("", "third_party/{0}/src".format(DEPENDENCY_NAME)),
    ],
)