Skip to content

Commit

Permalink
[ci] Allow filtering out examples by Python query
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jan 14, 2024
1 parent ae9dca2 commit f90d87e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/avr/xpcc/receiver/project.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<library>
<!-- CI: enable "Windows" not in platform.platform() -->
<options>
<option name="modm:target">atmega644-20au</option>
<option name="modm:platform:core:f_cpu">14.7456M</option>
Expand Down
1 change: 1 addition & 0 deletions examples/avr/xpcc/sender/project.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<library>
<!-- CI: enable "Windows" not in platform.platform() -->
<options>
<option name="modm:target">atmega644-20au</option>
<option name="modm:platform:core:f_cpu">14.7456M</option>
Expand Down
14 changes: 13 additions & 1 deletion tools/scripts/examples_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ def run_command(where, command, all_output=False):
output += result.stderr.decode("utf-8", errors="ignore").strip(" \n")
return (result.returncode, output)

def enable(projects):
filtered_projects = []
for project in projects:
if (query := re.search(r"<!-- CI: enable (.*?) -->", project.read_text())) is not None and not eval(query[1]):
print(f"Filtering out {project}: {query[1]}")
continue
filtered_projects.append(project)
return filtered_projects


def generate(project):
path = project.parent
output = ["=" * 90, "Generating: {}".format(path)]
Expand All @@ -54,7 +64,7 @@ def build(project):
commands.append( ("scons build --cache-show --random", "SCons") )
if ":build:make" in project_cfg and not is_running_on_windows:
commands.append( ("make build", "Make") )
elif ":build:cmake" in project_cfg:
elif ":build:cmake" in project_cfg and not is_running_on_windows:
build_dir = re.search(r'name=".+?:build:build.path">(.*?)</option>', project_cfg)[1]
cmd = "cmake -E make_directory {}/cmake-build-release; ".format(build_dir)
cmd += '(cd {}/cmake-build-release && cmake -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" {}); '.format(build_dir, path.absolute())
Expand Down Expand Up @@ -107,6 +117,8 @@ def compile_examples(paths, jobs, split, part):
if split > 1:
chunk_size = math.ceil(len(projects) / args.split)
projects = projects[chunk_size*args.part:min(chunk_size*(args.part+1), len(projects))]
# Filter projects
projects = enable(projects)

# first generate all projects
with ThreadPool(jobs) as pool:
Expand Down

0 comments on commit f90d87e

Please sign in to comment.