2021-08-10 14:10:10 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# Update target filters using
|
|
|
|
# make update-ci
|
|
|
|
|
2021-09-15 22:01:41 +00:00
|
|
|
import re
|
|
|
|
import os
|
2021-08-10 14:10:10 +00:00
|
|
|
import sys
|
|
|
|
import json
|
|
|
|
|
|
|
|
# these changes trigger rebuilds on all targets
|
|
|
|
common = [
|
|
|
|
"modules",
|
|
|
|
"Makefile",
|
|
|
|
"patches/**",
|
|
|
|
"targets/generic",
|
|
|
|
"targets/targets.mk",
|
|
|
|
]
|
|
|
|
|
|
|
|
# these changes are only built on x86-64
|
|
|
|
extra = [
|
|
|
|
"contrib/ci/minimal-site/**",
|
|
|
|
"package/**"
|
|
|
|
]
|
|
|
|
|
|
|
|
_filter = dict()
|
|
|
|
|
2021-09-15 22:01:41 +00:00
|
|
|
# INCLUDE_PATTERN matches:
|
|
|
|
# include '...'
|
|
|
|
# include "..."
|
|
|
|
# include("...")
|
|
|
|
# include('...')
|
|
|
|
INCLUDE_PATTERN = "^\\s*include *\\(? *[\"']([^\"']+)[\"']"
|
|
|
|
|
2021-08-10 14:10:10 +00:00
|
|
|
# construct filters map from stdin
|
|
|
|
for target in sys.stdin:
|
|
|
|
target = target.strip()
|
|
|
|
|
|
|
|
_filter[target] = [
|
|
|
|
f"targets/{target}"
|
|
|
|
] + common
|
|
|
|
|
2021-09-15 22:01:41 +00:00
|
|
|
target_file = os.path.join(os.environ['GLUON_TARGETSDIR'], target)
|
|
|
|
with open(target_file) as f:
|
|
|
|
includes = re.findall(INCLUDE_PATTERN, f.read(), re.MULTILINE)
|
|
|
|
_filter[target].extend([f"targets/{i}" for i in includes])
|
|
|
|
|
2021-08-10 14:10:10 +00:00
|
|
|
if target == "x86-64":
|
|
|
|
_filter[target].extend(extra)
|
|
|
|
|
|
|
|
# print filters to stdout in json format, because json is stdlib and yaml compatible.
|
|
|
|
print(json.dumps(_filter, indent=2))
|