Skip to content

Commit

Permalink
stop running restyle on java zap-generated files (#26951)
Browse files Browse the repository at this point in the history
* Skip restyling java generated files

* Run zap_regen_all

* Fix restyle path to include a glob

---------

Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Aug 1, 2023
1 parent 058ada5 commit f4cb377
Show file tree
Hide file tree
Showing 7 changed files with 65,572 additions and 72,026 deletions.
1 change: 1 addition & 0 deletions .restyled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ exclude:
- "src/darwin/Framework/CHIP/zap-generated/*" # already clang-formatted by our zap tooling
- "zzz_generated/**/*" # already clang-formatted by our zap tooling
- "src/controller/java/generated/java/**/*" # not formatted: generated files
- "src/controller/java/zap-generated/**/*" # not formatted: generated files


changed_paths:
Expand Down
28 changes: 0 additions & 28 deletions scripts/tools/zap/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,33 +254,6 @@ def runClangPrettifier(templates_file, output_dir):
print('clang-format error:', err)


def runJavaPrettifier(templates_file, output_dir):
try:
jsonData = json.loads(Path(templates_file).read_text())
outputs = [(os.path.join(output_dir, template['output']))
for template in jsonData['templates']]
javaOutputs = list(
filter(lambda filepath: os.path.splitext(filepath)[1] == ".java", outputs))

if len(javaOutputs) > 0:
# Keep this version in sync with what restyler uses (https://github.com/project-chip/connectedhomeip/blob/master/.restyled.yaml).
google_java_format_version = "1.6"
google_java_format_url = 'https://github.com/google/google-java-format/releases/download/google-java-format-' + \
google_java_format_version + '/'
google_java_format_jar = 'google-java-format-' + \
google_java_format_version + '-all-deps.jar'
jar_url = google_java_format_url + google_java_format_jar

home = str(Path.home())
path, http_message = urllib.request.urlretrieve(
jar_url, home + '/' + google_java_format_jar)
args = ['java', '-jar', path, '--replace']
args.extend(javaOutputs)
subprocess.check_call(args)
except Exception as err:
print('google-java-format error:', err)


class LockFileSerializer:
def __init__(self, path):
self.lock_file_path = path
Expand Down Expand Up @@ -329,7 +302,6 @@ def main():
if cmdLineArgs.prettify_output:
prettifiers = [
runClangPrettifier,
runJavaPrettifier,
]

for prettifier in prettifiers:
Expand Down
Loading

0 comments on commit f4cb377

Please sign in to comment.