-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gersemi to format CMake files (#265)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
- Loading branch information
Showing
3 changed files
with
26 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""This task runs gersemi on CMake files.""" | ||
|
||
import subprocess | ||
import sys | ||
|
||
from wpiformat.task import Task | ||
|
||
|
||
class CMakeFormat(Task): | ||
@staticmethod | ||
def should_process_file(config_file, name): | ||
return name.endswith("CMakeLists.txt") or name.endswith(".cmake") | ||
|
||
@staticmethod | ||
def run_batch(config_file, names): | ||
try: | ||
args = [sys.executable, "-m", "gersemi", "-i"] | ||
returncode = subprocess.run(args + names).returncode | ||
except FileNotFoundError: | ||
print("Error: gersemi not found in PATH. Is it installed?", file=sys.stderr) | ||
return False | ||
return True |