-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add an action to enforce consistency in GNUmakefiles
- Loading branch information
Showing
6 changed files
with
89 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: check makefiles | ||
|
||
on: | ||
push: | ||
branches: | ||
- development | ||
- main | ||
pull_request: | ||
branches: | ||
- development | ||
|
||
jobs: | ||
check-ifdefs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v3 | ||
with: | ||
# this path is specific to Ubuntu | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Run check-ifdefs | ||
run: | | ||
python .github/workflows/check_makefiles.py | ||
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,47 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
correct_params = { | ||
"DEBUG": "FALSE", | ||
"USE_MPI": "TRUE", | ||
"COMP": "gnu", | ||
"USE_CUDA": "FALSE", | ||
"USE_HIP": "FALSE", | ||
"PRECISION": "DOUBLE", | ||
"PROFILE": "FALSE"} | ||
|
||
|
||
def find_source_files(): | ||
p = Path("./Exec") | ||
files = list(p.glob(r"**/GNUmakefile")) | ||
return files | ||
|
||
def check_makefile(makefile): | ||
|
||
with open(makefile) as mf: | ||
for _line in mf: | ||
if idx := _line.find("#") >= 0: | ||
line = _line[:idx] | ||
else: | ||
line = _line | ||
|
||
for key in correct_params: | ||
if key in line: | ||
try: | ||
_, v = line.split(":=") | ||
except ValueError: | ||
try: | ||
_, v = line.split("=") | ||
except ValueError: | ||
sys.exit(f"invalid line: {line}") | ||
|
||
if not v.strip() == correct_params[key]: | ||
sys.exit(f"invalid param {key} in {makefile}") | ||
|
||
if __name__ == "__main__": | ||
|
||
for f in find_source_files(): | ||
check_makefile(f) | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PRECISION = DOUBLE | ||
PROFILE = FALSE | ||
|
||
DEBUG = TRUE | ||
DEBUG = FALSE | ||
|
||
DIM = 3 | ||
|
||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PRECISION = DOUBLE | ||
PROFILE = FALSE | ||
|
||
DEBUG = TRUE | ||
DEBUG = FALSE | ||
|
||
DIM = 3 | ||
|
||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PRECISION = DOUBLE | ||
PROFILE = FALSE | ||
|
||
DEBUG = TRUE | ||
DEBUG = FALSE | ||
|
||
DIM = 3 | ||
|
||
|
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