-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support uses-permission merging in manifest merger
Adding support for conditionally merging `uses-permissions`. #10628 #5411 Closes #13445. RELNOTES: Enable merging permissions during Android manifest merging with the --merge_android_manifest_permissions flag. PiperOrigin-RevId: 439613035
- Loading branch information
1 parent
2fdac7e
commit 9119815
Showing
9 changed files
with
318 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/com/google/devtools/build/lib/rules/android/BazelAndroidConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2022 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.rules.android; | ||
|
||
import com.google.devtools.build.lib.analysis.config.BuildOptions; | ||
import com.google.devtools.build.lib.analysis.config.Fragment; | ||
import com.google.devtools.build.lib.analysis.config.FragmentOptions; | ||
import com.google.devtools.build.lib.analysis.config.RequiresOptions; | ||
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; | ||
import com.google.devtools.common.options.Option; | ||
import com.google.devtools.common.options.OptionDocumentationCategory; | ||
import com.google.devtools.common.options.OptionEffectTag; | ||
import com.google.errorprone.annotations.CheckReturnValue; | ||
|
||
/** Configuration fragment for Android rules that is specific to Bazel. */ | ||
@Immutable | ||
@RequiresOptions(options = {BazelAndroidConfiguration.Options.class}) | ||
@CheckReturnValue | ||
public class BazelAndroidConfiguration extends Fragment { | ||
|
||
@Override | ||
public boolean isImmutable() { | ||
return true; // immutable and Starlark-hashable | ||
} | ||
|
||
/** Android configuration options that are specific to Bazel. */ | ||
public static class Options extends FragmentOptions { | ||
|
||
@Option( | ||
name = "merge_android_manifest_permissions", | ||
defaultValue = "false", | ||
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, | ||
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, | ||
help = | ||
"If enabled, the manifest merger will merge uses-permission and " | ||
+ "uses-permission-sdk-23 attributes.") | ||
public boolean mergeAndroidManifestPermissions; | ||
} | ||
|
||
private final boolean mergeAndroidManifestPermissions; | ||
|
||
public BazelAndroidConfiguration(BuildOptions buildOptions) { | ||
Options options = buildOptions.get(BazelAndroidConfiguration.Options.class); | ||
this.mergeAndroidManifestPermissions = options.mergeAndroidManifestPermissions; | ||
} | ||
|
||
public boolean getMergeAndroidManifestPermissions() { | ||
return this.mergeAndroidManifestPermissions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.