Skip to content

Commit

Permalink
compat: Add Meson summary entry
Browse files Browse the repository at this point in the history
To make it less opaque what's actually going to be built, especially
when set to auto.

Co-authored-by: Håvard Sørbø <[email protected]>
  • Loading branch information
oleavr and hsorbo committed May 6, 2024
1 parent 117379e commit 1c902ec
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
28 changes: 22 additions & 6 deletions compat/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,17 @@ def setup(role: Role,

auto_detect = "auto" in compat
if auto_detect:
compat = {"native", "emulated"} if host_os in {"windows", "macos", "linux", "ios", "tvos", "android"} else set()
if host_os in {"windows", "macos", "linux", "ios", "tvos", "android"}:
summary = f"enabled by default for {host_os}-{host_arch}"
compat = {"native", "emulated"}
else:
summary = f"disabled by default for {host_os}-{host_arch}"
compat = set()
elif "disabled" in compat:
summary = "disabled by user"
compat = set()
else:
summary = "enabled by user"

if "native" in compat:
have_toolchain = True
Expand Down Expand Up @@ -162,8 +170,10 @@ def setup(role: Role,
except:
pass

if not auto_detect and not have_toolchain:
raise ToolchainNotFoundError(f"unable to locate toolchain for {other_triplet}")
if not have_toolchain:
if not auto_detect:
raise ToolchainNotFoundError(f"unable to locate toolchain for {other_triplet}")
summary = "disabled due to missing toolchain for {other_triplet}"

if host_os == "windows" and host_arch in {"x86_64", "x86"} and have_toolchain:
if host_arch == "x86_64":
Expand Down Expand Up @@ -294,10 +304,16 @@ def setup(role: Role,

variable_names, output_names = zip(*[(output.identifier, output.name) \
for output in itertools.chain.from_iterable(outputs.values())])
print(f"ok {','.join(variable_names)} {','.join(output_names)} {DEPFILE_FILENAME} {serialized_state}")
print("ok")
print(summary)
print(f"{','.join(variable_names)}")
print(f"{','.join(output_names)}")
print(DEPFILE_FILENAME)
print(serialized_state)
except Exception as e:
details = "\n".join(traceback.format_exception(e))
print(f"error {e}\n\n{details}")
print(f"error {e}")
print("")
traceback.print_exception(e)


class ToolchainNotFoundError(Exception):
Expand Down
15 changes: 9 additions & 6 deletions compat/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ if no_overridden_compat_bits
if setup_output.startswith('error ')
error('compat/build.py setup failed:', setup_output.substring(6))
endif
assert(setup_output.startswith('ok '))
tokens = setup_output.substring(3).split(' ')
varnames = tokens[0].split(',')
outputs = tokens[1].split(',')
depfile = tokens[2]
state = tokens[3]
lines = setup_output.split('\n')
assert(lines[0] == 'ok')
compat_summary = lines[1]
varnames = lines[2].split(',')
outputs = lines[3].split(',')
depfile = lines[4]
state = lines[5]

if host_os_family == 'darwin'
install = false
Expand Down Expand Up @@ -113,4 +114,6 @@ if no_overridden_compat_bits

i += 1
endforeach
else
compat_summary = 'not available due to externally provided helper/agent assets'
endif
7 changes: 7 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -663,3 +663,10 @@ endif
if build_tests
subdir('tests')
endif

summary(
{
'compat': compat_summary,
},
section: 'Features',
)

0 comments on commit 1c902ec

Please sign in to comment.