Skip to content

Commit

Permalink
compat: Ensure submodules are checked out
Browse files Browse the repository at this point in the history
In the case when we're a subproject, our parent project doesn't have
releng, and we don't have releng checked out.
  • Loading branch information
oleavr committed Apr 11, 2024
1 parent e3ac0b1 commit 1eba812
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions compat/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def main(argv):

args = parser.parse_args()
if "func" in args:
args.func(args)
try:
args.func(args)
except subprocess.CalledProcessError as e:
print(e, file=sys.stderr)
print("Output:\n\t| " + "\n\t| ".join(e.output.strip().split("\n")), file=sys.stderr)
sys.exit(1)
else:
parser.print_usage(file=sys.stderr)
sys.exit(1)
Expand Down Expand Up @@ -81,7 +86,9 @@ def setup(role: Role,
components: set[str]):
outputs: Mapping[str, Sequence[Output]] = {}

configure_import_path(query_releng_parentdir(role))
releng_parentdir = query_releng_parentdir(role)
ensure_submodules_checked_out(releng_parentdir)
configure_import_path(releng_parentdir)

if "auto" in compat:
compat = {"native", "emulated"} if host_os in {"windows", "macos", "ios", "tvos", "android"} else set()
Expand Down Expand Up @@ -413,6 +420,16 @@ def query_releng_parentdir(role: Role) -> Path:
return REPO_ROOT


def ensure_submodules_checked_out(releng_parentdir: Path):
if not (releng_parentdir / "releng" / "meson" / "meson.py").exists():
subprocess.run(["git", "submodule", "update", "--init", "--recursive", "--depth", "1", "releng"],
cwd=releng_parentdir,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
encoding="utf-8",
check=True)


def configure_import_path(releng_parentdir: Path):
sys.path.insert(0, str(releng_parentdir / "releng" / "meson"))
sys.path.insert(0, str(releng_parentdir))
Expand Down

0 comments on commit 1eba812

Please sign in to comment.