Debian Codegraph @

test/integration/targets/binary_modules/build.py

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/usr/bin/env python
2 """
3 Compile binary modules for this test for access from S3 at:
4 https://ci-files.testing.ansible.com/test/integration/roles/test_binary_modules/
5 This avoids a test dependency on go and keeps the binaries out of the git repository.
6 """
7
8 from __future__ import annotations
9
10 import os
11 import pathlib
12 import shlex
13 import subprocess
14
15
16 def main() -> None:
17 library = pathlib.Path(__file__).parent / 'library'
18
19 # NOTE: The value of `NAME` must be `ansible_architecture` for the target system, plus any required extension.
20 builds = (
21 dict(GOOS='linux', GOARCH='amd64', NAME='linux_x86_64'),
22 dict(GOOS='linux', GOARCH='arm64', NAME='linux_aarch64'),
23 dict(GOOS='windows', GOARCH='amd64', NAME='win32nt_64-bit.exe'),
24 dict(GOOS='darwin', GOARCH='amd64', NAME='darwin_x86_64'),
25 dict(GOOS='darwin', GOARCH='arm64', NAME='darwin_arm64'),
26 dict(GOOS='freebsd', GOARCH='amd64', NAME='freebsd_amd64'),
27 dict(GOOS='freebsd', GOARCH='arm64', NAME='freebsd_arm64'),
28 )
29
30 for build in builds:
31 name = build.pop('NAME')
32 cmd = ['go', 'build', '-o', f'helloworld_{name}', 'helloworld.go']
33 env = os.environ.copy()
34 env.update(build)
35
36 print(f'==> {shlex.join(f"{k}={v}" for k, v in build.items())} {shlex.join(cmd)}')
37 subprocess.run(cmd, env=env, cwd=library, check=True, text=True)
38
39
40 if __name__ == '__main__':
41 main()