Skip to content

Commit

Permalink
Add ASI project vcxproj CI check
Browse files Browse the repository at this point in the history
  • Loading branch information
pongo1231 committed Oct 21, 2023
1 parent beb946a commit 50bbb6b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/asi-vcxproj-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ChaosMod.vcxproj Check

on: push

jobs:
tests:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4

- name: Run scripts/asi_vcxproj_check.py
run: python scripts/asi_vcxproj_check.py ChaosMod/ ChaosMod.vcxproj
38 changes: 38 additions & 0 deletions scripts/asi_vcxproj_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import sys

BLACKLISTED_SUBDIRS = ( "x64" ".cache" "build" )

if len(sys.argv) < 3:
print("Need source directory and file as parameter!")
exit(1)

SOURCE_DIR = sys.argv[1]
PROJECT_FILE = sys.argv[2]

source_files = []
project_files = []
is_successful = True

for subdir, dirs, files in os.walk(SOURCE_DIR, topdown = True):
subdir = "" if subdir == SOURCE_DIR else (subdir[len(SOURCE_DIR):].replace("/", "\\") + "\\")

for file in files:
if file.endswith(".cpp") or file.endswith(".h"):
source_files.append(f"{subdir}{file}")

dirs[:] = [dir for dir in dirs if not dir in BLACKLISTED_SUBDIRS]

with open(SOURCE_DIR + PROJECT_FILE, "r") as _in:
for line in _in:
if "<ClCompile " in line or "<ClInclude " in line:
file = line.split("Include=\"")[1].split("\"")[0]
if not file.startswith(".."):
project_files.append(file)

for file in source_files:
if file not in project_files:
is_successful = False
print(f"File {file} missing in {PROJECT_FILE}!")

exit(0 if is_successful else 1)

0 comments on commit 50bbb6b

Please sign in to comment.