Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Add support for @classpath_abi macro #1780

Closed
wants to merge 6 commits into from

Conversation

raviagarwal7
Copy link
Contributor

@raviagarwal7 raviagarwal7 commented Feb 21, 2018

This is similar to @classpath macro but gives the corresponding
class-abi jar for the classpath entries.

This is useful for genrules which only depends on the dependencies abi’s.
For eg: android lint where it need not run the lint checks again if
the dependent’s abi doesn’t change.

Usage: $(@classpath_abi :<target_path>)

Copy link

@styurin styurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI build is failing.

Could you provide more context about why you need that and update the documentation?

This is similar to @classpath macro but gives the corresponding 
class-abi jar for the classpath entries.

This is useful for genrules which only depends on the dependencies abi’s.
For eg: android lint where it need not run the lint checks again if 
the dependent’s abi doesn’t change.

Usage: `$(@classpath_abi :<target_path>)`
@raviagarwal7 raviagarwal7 changed the title Add support for @abi_jar_path macro Add support for @classpath_abi macro Feb 21, 2018
@facebook-github-bot
Copy link
Contributor

@raviagarwal7 has updated the pull request.

@raviagarwal7
Copy link
Contributor Author

Added more context in the description and also added to the macros soy.
Have fixed the build errors as well.

@@ -43,18 +43,18 @@
Flavor SOURCE_ONLY_ABI_FLAVOR = InternalFlavor.of("source-only-abi");
Flavor VERIFIED_SOURCE_ABI_FLAVOR = InternalFlavor.of("verified-source-abi");

static BuildTarget getClassAbiJar(BuildTarget libraryTarget) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any changes in this file? Why do you need to move this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just moved the method to be in accordance with others, but will revert back

@@ -85,7 +85,7 @@ protected Arg expand(SourcePathResolver resolver, ClasspathMacro ignored, BuildR
// The # characters that might be present in classpaths due to flavoring would be read as
// comments. As a simple workaround, we quote the entire classpath.
private static class ClassPathWriteToFileArg extends WriteToFileArg {
public ClassPathWriteToFileArg(BuildTarget target, String prefix, Arg delegate) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file look unrelated, could you revert them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intellij was showing suggestions that this is not needed, will revert back.


ImmutableList<SourcePath> jarPaths =
getHasClasspathEntries(inputRule)
.getTransitiveClasspathDeps()
Copy link
Contributor Author

@raviagarwal7 raviagarwal7 Feb 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTransitiveClasspathDeps returns both #aar_prebuilt_jar,class-abi and #class-abi flavours. I verified that both the output jars are same, just on different paths.

//cache:com.support-compat-27.0.2.aar#aar_prebuilt_jar,class-abi
buck-out/gen/cache/com.support-27.0.2.aar#aar_prebuilt_jar,class-abi/com.support-27.0.2.aar-abi.jar

//cache:com.support-compat-27.0.2.aar#class-abi
buck-out/gen/cache/com.support-27.0.2.aar#class-abi/com.support-27.0.2.aar-abi.jar

How can I filter and keep only the #class-abi deps? Also is there a scenario where the output of the two flavours will differ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jkeljo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a filter to only include rules which have non-null sourcePathToOutput, same behaviour is in ClasspathMacro.

@facebook-github-bot
Copy link
Contributor

@raviagarwal7 has updated the pull request. View: changes

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@styurin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

raviagarwal7 added a commit to uber/okbuck that referenced this pull request Feb 22, 2018
For android lint genrule, dependencies class-abi is enough. 
classpath_abi was added in facebook/buck#1780
* @param ruleResolver BuildRuleResolver
* @return class abi jar or output jar if not found
*/
private SourcePath getJarPath(BuildRule rule, BuildRuleResolver ruleResolver) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be annotated with @Nullable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

String.format(
"%s" + File.separator + "%s",
filesystem.getRootPath(),
"buck-out/gen/cheese/cake#class-abi/cake-abi.jar"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are failing on Windows. Our CI doesn't run these tests for some reason (we're investigating), but it looks like it's failing because of the path separators.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using new File.("file-path-string")toPath() now, hopefully this would work fine on windows.

raviagarwal7 added a commit to uber/okbuck that referenced this pull request Feb 22, 2018
Running android lint on a target only needs dependent libraries class-abi,
i.e doesn’t need to rerun lint if there are no api changes in the dependent 
libraries.

Using classpath_abi returns class-abi jars of the dependencies instead of 
the class jar. (Buck pr - facebook/buck#1780)


Usage: $(@classpath_abi :<target_path>)
@facebook-github-bot
Copy link
Contributor

@raviagarwal7 has updated the pull request. View: changes, changes since last import

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@styurin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

private ProjectFilesystem filesystem;

@Before
public void createMacroExpander() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is usually called setUp. It also does more than creating macro expander.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

@Test
public void shouldIncludeARuleIfNothingIsGiven() throws Exception {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test methods usually start with test so that the method name is a verb, right now it's a statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@facebook-github-bot
Copy link
Contributor

@raviagarwal7 has updated the pull request. View: changes, changes since last import

@kageiit
Copy link
Contributor

kageiit commented Feb 28, 2018

cc @styurin the comments are addressed. Any update on this?

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@styurin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

raviagarwal7 added a commit to uber/okbuck that referenced this pull request Feb 28, 2018
Running android lint on a target only needs dependent libraries class-abi,
i.e doesn’t need to rerun lint if there are no api changes in the dependent 
libraries.

Using classpath_abi returns class-abi jars of the dependencies instead of 
the class jar. (Buck pr - facebook/buck#1780)


Usage: $(@classpath_abi :<target_path>)
raviagarwal7 added a commit to uber/okbuck that referenced this pull request Feb 28, 2018
Running android lint on a target only needs dependent libraries class-abi,
i.e doesn’t need to rerun lint if there are no api changes in the dependent
libraries.

Using classpath_abi returns class-abi jars of the dependencies instead of
the class jar. (Buck pr - facebook/buck#1780)

Usage: $(@classpath_abi :<target_path>)

To enable using classpath_abi, add the experimental extension

```
okbuck {
    experimental {
        lintWithClasspathAbi = true
    }
}
```
kageiit pushed a commit to uber/okbuck that referenced this pull request Mar 1, 2018
* Use classpath_abi macro instead of classpath in the lint genrule.

Running android lint on a target only needs dependent libraries class-abi,
i.e doesn’t need to rerun lint if there are no api changes in the dependent
libraries.

Using classpath_abi returns class-abi jars of the dependencies instead of
the class jar. (Buck pr - facebook/buck#1780)

Usage: $(@classpath_abi :<target_path>)

To enable using classpath_abi, add the experimental extension

```
okbuck {
    experimental {
        lintWithClasspathAbi = true
    }
}
```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants