Skip to content

Commit

Permalink
Stop using absl flags in proguard_whitelister.
Browse files Browse the repository at this point in the history
bazelbuild#16882

PiperOrigin-RevId: 493696178
Change-Id: I61dbfb6f35fd5be77aa97f579d69b26bf8b01f89
  • Loading branch information
aiuto authored and copybara-github committed Dec 7, 2022
1 parent 9376eb9 commit 7f5dd0a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
3 changes: 0 additions & 3 deletions tools/jdk/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,6 @@ py_binary(
srcs = [
"proguard_whitelister.py",
],
deps = [
"//third_party/py/abseil",
],
)

py_test(
Expand Down
34 changes: 23 additions & 11 deletions tools/jdk/proguard_whitelister.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@
binary through a library dependency.
"""

import argparse
import re
from typing import Sequence

# Do not edit this line. Copybara replaces it with PY2 migration helper.
from absl import app
from absl import flags

flags.DEFINE_string('path', None, 'Path to the proguard config to validate')
flags.DEFINE_string('output', None, 'Where to put the validated config')

FLAGS = flags.FLAGS
PROGUARD_COMMENTS_PATTERN = '#.*(\n|$)'


Expand Down Expand Up @@ -83,10 +76,29 @@ def _ValidateArg(self, arg: str) -> bool:
return False


def main(unused_argv: Sequence[str]):
validator = ProguardConfigValidator(FLAGS.path, FLAGS.output)
def ParseCommandLine() -> Sequence[str]:
"""Parses the command line and returns a flags block."""
parser = argparse.ArgumentParser(
description="""Checks for proguard configuration rules that cannot be combined across libs.
The only valid proguard arguments for a library are -keep, -assumenosideeffects,
-assumevalues and -dontnote and -dontwarn when they are provided with arguments.
Limiting libraries to using these flags prevents drastic, sweeping effects
(such as obfuscation being disabled) from being inadvertently applied to a
binary through a library dependency.""")
parser.add_argument('--path', required=True,
help='Path to the proguard config to validate')
parser.add_argument('--output', required=True,
help='Where to put the validated config')
flags = parser.parse_args()
return flags


def main():
flags = ParseCommandLine()
validator = ProguardConfigValidator(flags.path, flags.output)
validator.ValidateAndWriteOutput()


if __name__ == '__main__':
app.run(main)
main()

0 comments on commit 7f5dd0a

Please sign in to comment.