Skip to content

[SNAP FORK][UPSTREAMED] Implement namespaced R class#66

Open
mauriciogg wants to merge 1 commit intobazelbuild:pre-alphafrom
mauriciogg:mgalindo-namespaced-r-class
Open

[SNAP FORK][UPSTREAMED] Implement namespaced R class#66
mauriciogg wants to merge 1 commit intobazelbuild:pre-alphafrom
mauriciogg:mgalindo-namespaced-r-class

Conversation

@mauriciogg
Copy link
Copy Markdown
Contributor

@mauriciogg mauriciogg commented Jan 18, 2023

The native version of the rules have this optimization (in our internal fork).

native version uptreamed: bazelbuild/bazel#11385
Enable rudimentary R class namespacing where each library only contains
references to the resources it declares instead of declarations plus all
transitive dependency references.

  • No resource merging for android_library targets
  • Smaller R.{class,txt}
  • Less desugaring + dexing

i think this addresses #10

@mauriciogg mauriciogg force-pushed the mgalindo-namespaced-r-class branch from 0d3b435 to a142f45 Compare January 18, 2023 19:08
The native version of the rules have this optimization (in our internal
fork). This is that implementationm, but in starlark.

See https://github.sc-corp.net/Snapchat/bazel/pull/126 for more details
@mauriciogg mauriciogg force-pushed the mgalindo-namespaced-r-class branch from a142f45 to 3153e3d Compare January 18, 2023 19:17
args.add("--androidJar", android_jar)
optional_inputs.append(android_jar)

_disable_warnings(args)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

disable_warnings() doesn't seem to exist on my end. Where is this function from?


optional_outputs = []
if out_class_jar:
args.add("--classJarOutput", out_class_jar)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is throwing the following error on internal tests:

Error parsing command line: Unrecognized option: --classJarOutput

Which is kind of surprising. I'll look into this a bit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You need something like this, I think:

    optional_outputs = []
    optional_args = []
    if out_class_jar:
        optional_args.add("--classJarOutput", out_class_jar)
        optional_outputs.append(out_class_jar)
    if out_r_txt:
        optional_args.add("--rTxtOut", out_r_txt)
        optional_outputs.append(out_r_txt)

    if len(optional_outputs) > 1:
        args.extend(["--"], optional_args)

@ted-xie
Copy link
Copy Markdown
Contributor

ted-xie commented Mar 21, 2023

In addition to changes above, would you mind rebasing this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants