Skip to content

Commit

Permalink
Add script for checking sorted order of entrypoints
Browse files Browse the repository at this point in the history
The ordering isn't load-bearing.
  • Loading branch information
ctz committed Apr 4, 2024
1 parent f7bc699 commit f0f2381
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/libssl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ jobs:
run: ./admin/format --all -- --check
- name: Check C formatting
run: make format-check
- name: Check ordering of build.rs entrypoints
run: ./admin/sort-entrypoints.py

clippy:
name: Clippy
Expand Down
28 changes: 28 additions & 0 deletions rustls-libssl/admin/sort-entrypoints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3

from os import path
import difflib

entries = []
in_entries = False

location = path.join(path.dirname(__file__), '../build.rs')

for line in open(location):
if in_entries:
if '];' in line:
in_entries = False
continue

entries.append(line)

if 'const ENTRYPOINTS:' in line:
in_entries = True

assert len(entries) != 0
sorted_entries = list(sorted(entries, key=lambda s: s.lower()))

if entries != sorted_entries:
print('!!! ENTRYPOINTS is not sorted')
print(''.join(difflib.context_diff(entries, sorted_entries, fromfile='build.rs', tofile='build.rs')))
exit(1)

0 comments on commit f0f2381

Please sign in to comment.