shrinkwraptool 2026.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. shrinkwraptool-2026.9.0/PKG-INFO +57 -0
  2. shrinkwraptool-2026.9.0/README.md +30 -0
  3. shrinkwraptool-2026.9.0/license.rst +41 -0
  4. shrinkwraptool-2026.9.0/pyproject.toml +65 -0
  5. shrinkwraptool-2026.9.0/setup.cfg +4 -0
  6. shrinkwraptool-2026.9.0/src/shrinkwrap/__init__.py +1 -0
  7. shrinkwraptool-2026.9.0/src/shrinkwrap/__main__.py +4 -0
  8. shrinkwraptool-2026.9.0/src/shrinkwrap/commands/__init__.py +0 -0
  9. shrinkwraptool-2026.9.0/src/shrinkwrap/commands/build.py +118 -0
  10. shrinkwraptool-2026.9.0/src/shrinkwrap/commands/buildall.py +214 -0
  11. shrinkwraptool-2026.9.0/src/shrinkwrap/commands/clean.py +201 -0
  12. shrinkwraptool-2026.9.0/src/shrinkwrap/commands/inspect.py +272 -0
  13. shrinkwraptool-2026.9.0/src/shrinkwrap/commands/process.py +129 -0
  14. shrinkwraptool-2026.9.0/src/shrinkwrap/commands/run.py +374 -0
  15. shrinkwraptool-2026.9.0/src/shrinkwrap/config/FVP_Base_RevC-2xAEMvA-base.yaml +98 -0
  16. shrinkwraptool-2026.9.0/src/shrinkwrap/config/FVP_Base_RevC-2xAEMvA-rme.yaml +44 -0
  17. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.0.yaml +22 -0
  18. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.1.yaml +26 -0
  19. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.2.yaml +28 -0
  20. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.3.yaml +25 -0
  21. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.4.yaml +26 -0
  22. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.5.yaml +29 -0
  23. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.6.yaml +28 -0
  24. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.7.yaml +24 -0
  25. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.8.yaml +31 -0
  26. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v8.9.yaml +32 -0
  27. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v9.0.yaml +29 -0
  28. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v9.1.yaml +25 -0
  29. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v9.2.yaml +29 -0
  30. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v9.3.yaml +23 -0
  31. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v9.4.yaml +21 -0
  32. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v9.5.yaml +20 -0
  33. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v9.6.yaml +22 -0
  34. shrinkwraptool-2026.9.0/src/shrinkwrap/config/arch/v9.7.yaml +31 -0
  35. shrinkwraptool-2026.9.0/src/shrinkwrap/config/bootwrapper.yaml +76 -0
  36. shrinkwraptool-2026.9.0/src/shrinkwrap/config/buildroot.config +16 -0
  37. shrinkwraptool-2026.9.0/src/shrinkwrap/config/buildroot.yaml +54 -0
  38. shrinkwraptool-2026.9.0/src/shrinkwrap/config/cca-3world.yaml +220 -0
  39. shrinkwraptool-2026.9.0/src/shrinkwrap/config/cca-4world.yaml +62 -0
  40. shrinkwraptool-2026.9.0/src/shrinkwrap/config/cca-edk2.yaml +58 -0
  41. shrinkwraptool-2026.9.0/src/shrinkwrap/config/debug/armdbg.yaml +16 -0
  42. shrinkwraptool-2026.9.0/src/shrinkwrap/config/debug/rmm.yaml +12 -0
  43. shrinkwraptool-2026.9.0/src/shrinkwrap/config/debug/tfa.yaml +12 -0
  44. shrinkwraptool-2026.9.0/src/shrinkwrap/config/debug/tftf.yaml +13 -0
  45. shrinkwraptool-2026.9.0/src/shrinkwrap/config/dt-base.yaml +115 -0
  46. shrinkwraptool-2026.9.0/src/shrinkwrap/config/edk2-base.yaml +83 -0
  47. shrinkwraptool-2026.9.0/src/shrinkwrap/config/ffa-hafnium-optee.yaml +45 -0
  48. shrinkwraptool-2026.9.0/src/shrinkwrap/config/ffa-optee.yaml +30 -0
  49. shrinkwraptool-2026.9.0/src/shrinkwrap/config/ffa-tftf.yaml +26 -0
  50. shrinkwraptool-2026.9.0/src/shrinkwrap/config/hafnium-base.yaml +59 -0
  51. shrinkwraptool-2026.9.0/src/shrinkwrap/config/kvm-unit-tests.yaml +32 -0
  52. shrinkwraptool-2026.9.0/src/shrinkwrap/config/kvmtool-base.yaml +33 -0
  53. shrinkwraptool-2026.9.0/src/shrinkwrap/config/linux-base.yaml +80 -0
  54. shrinkwraptool-2026.9.0/src/shrinkwrap/config/ns-edk2-base.yaml +83 -0
  55. shrinkwraptool-2026.9.0/src/shrinkwrap/config/ns-edk2-optee.yaml +41 -0
  56. shrinkwraptool-2026.9.0/src/shrinkwrap/config/ns-edk2.yaml +49 -0
  57. shrinkwraptool-2026.9.0/src/shrinkwrap/config/ns-preload.yaml +98 -0
  58. shrinkwraptool-2026.9.0/src/shrinkwrap/config/optee-base.yaml +37 -0
  59. shrinkwraptool-2026.9.0/src/shrinkwrap/config/rfa-base.yaml +48 -0
  60. shrinkwraptool-2026.9.0/src/shrinkwrap/config/rfa.yaml +57 -0
  61. shrinkwraptool-2026.9.0/src/shrinkwrap/config/rmm-base.yaml +53 -0
  62. shrinkwraptool-2026.9.0/src/shrinkwrap/config/rust.yaml +31 -0
  63. shrinkwraptool-2026.9.0/src/shrinkwrap/config/tfa-base.yaml +72 -0
  64. shrinkwraptool-2026.9.0/src/shrinkwrap/config/tfa-rme.yaml +37 -0
  65. shrinkwraptool-2026.9.0/src/shrinkwrap/config/tftf-base.yaml +61 -0
  66. shrinkwraptool-2026.9.0/src/shrinkwrap/shrinkwrap_main.py +161 -0
  67. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/__init__.py +0 -0
  68. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/clivars.py +16 -0
  69. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/config.py +1358 -0
  70. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/graph.py +257 -0
  71. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/label.py +155 -0
  72. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/logger.py +162 -0
  73. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/process.py +224 -0
  74. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/runtime.py +195 -0
  75. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/ssh_agent.py +100 -0
  76. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/tty.py +63 -0
  77. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/vars.py +15 -0
  78. shrinkwraptool-2026.9.0/src/shrinkwrap/utils/workspace.py +63 -0
  79. shrinkwraptool-2026.9.0/src/shrinkwraptool.egg-info/PKG-INFO +57 -0
  80. shrinkwraptool-2026.9.0/src/shrinkwraptool.egg-info/SOURCES.txt +86 -0
  81. shrinkwraptool-2026.9.0/src/shrinkwraptool.egg-info/dependency_links.txt +1 -0
  82. shrinkwraptool-2026.9.0/src/shrinkwraptool.egg-info/entry_points.txt +2 -0
  83. shrinkwraptool-2026.9.0/src/shrinkwraptool.egg-info/requires.txt +19 -0
  84. shrinkwraptool-2026.9.0/src/shrinkwraptool.egg-info/top_level.txt +1 -0
  85. shrinkwraptool-2026.9.0/test/test.py +567 -0
  86. shrinkwraptool-2026.9.0/test/test_commands.py +232 -0
  87. shrinkwraptool-2026.9.0/test/test_commands_blackbox.py +178 -0
  88. shrinkwraptool-2026.9.0/test/test_config.py +91 -0
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.4
2
+ Name: shrinkwraptool
3
+ Version: 2026.9.0
4
+ Summary: Shrinkwrap is a tool to simplify the process of building and running firmware on Arm Fixed Virtual Platforms (FVP).
5
+ Author-email: Ryan Roberts <ryan.roberts@arm.com>, Saul Romero D <saul.romerodominguez@arm.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://gitlab.arm.com/tooling/shrinkwrap
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.9.0
11
+ Description-Content-Type: text/markdown
12
+ License-File: license.rst
13
+ Requires-Dist: PyYAML>=6.0.3
14
+ Requires-Dist: tuxmake>=1.34.0
15
+ Requires-Dist: termcolor<3.0,>=2.4.0; python_version < "3.10"
16
+ Requires-Dist: termcolor>=3.2.0; python_version >= "3.10"
17
+ Provides-Extra: dev
18
+ Requires-Dist: build; extra == "dev"
19
+ Requires-Dist: twine; extra == "dev"
20
+ Requires-Dist: pytest; extra == "dev"
21
+ Requires-Dist: ruff==0.15.21; extra == "dev"
22
+ Provides-Extra: docs
23
+ Requires-Dist: Sphinx<10,>=8.2; extra == "docs"
24
+ Requires-Dist: sphinx-rtd-theme<4,>=3.1.0; extra == "docs"
25
+ Requires-Dist: sphinx-copybutton>=0.5.2; extra == "docs"
26
+ Dynamic: license-file
27
+
28
+ # Shrinkwrap
29
+
30
+ Shrinkwrap is a tool to simplify the process of building and running firmware on
31
+ Arm Fixed Virtual Platforms (FVP). Users simply invoke the tool to build the
32
+ required config, then pass their own kernel and rootfs to the tool to boot the
33
+ full system on FVP.
34
+
35
+ - Documentation is available at: [ReadTheDocs](https://shrinkwrap.docs.arm.com)
36
+ - Source Code is available at: [GitLab](https://gitlab.arm.com/tooling/shrinkwrap)
37
+ - Shrinkwrap Container Images are available at: [DockerHub](https://hub.docker.com/u/shrinkwraptool)
38
+
39
+ The documentation (linked above) contains a
40
+ [QuickStart](https://shrinkwrap.docs.arm.com/en/latest/userguide/quickstart.html)
41
+ section, which details how to install and use the tool. However, if you are in a
42
+ hurry, here are the minimal steps:
43
+
44
+ > **NOTE:** This assumes you have Python >=3.9.0 and docker installed. If this
45
+ > is not the case, please refer to the documentation.
46
+
47
+ ```
48
+ sudo apt-get install git netcat-openbsd python3 python3-pip telnet
49
+ python3 -m venv .venv
50
+ source .venv/bin/activate
51
+ pip install --upgrade pip
52
+ pip install shrinkwraptool
53
+ ```
54
+
55
+ ```
56
+ shrinkwrap --help
57
+ ```
@@ -0,0 +1,30 @@
1
+ # Shrinkwrap
2
+
3
+ Shrinkwrap is a tool to simplify the process of building and running firmware on
4
+ Arm Fixed Virtual Platforms (FVP). Users simply invoke the tool to build the
5
+ required config, then pass their own kernel and rootfs to the tool to boot the
6
+ full system on FVP.
7
+
8
+ - Documentation is available at: [ReadTheDocs](https://shrinkwrap.docs.arm.com)
9
+ - Source Code is available at: [GitLab](https://gitlab.arm.com/tooling/shrinkwrap)
10
+ - Shrinkwrap Container Images are available at: [DockerHub](https://hub.docker.com/u/shrinkwraptool)
11
+
12
+ The documentation (linked above) contains a
13
+ [QuickStart](https://shrinkwrap.docs.arm.com/en/latest/userguide/quickstart.html)
14
+ section, which details how to install and use the tool. However, if you are in a
15
+ hurry, here are the minimal steps:
16
+
17
+ > **NOTE:** This assumes you have Python >=3.9.0 and docker installed. If this
18
+ > is not the case, please refer to the documentation.
19
+
20
+ ```
21
+ sudo apt-get install git netcat-openbsd python3 python3-pip telnet
22
+ python3 -m venv .venv
23
+ source .venv/bin/activate
24
+ pip install --upgrade pip
25
+ pip install shrinkwraptool
26
+ ```
27
+
28
+ ```
29
+ shrinkwrap --help
30
+ ```
@@ -0,0 +1,41 @@
1
+ #######
2
+ License
3
+ #######
4
+
5
+ The software is provided under the MIT license (below).
6
+
7
+ .. code-block:: none
8
+
9
+ Copyright (c) 2022 Arm Limited
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to
13
+ deal in the Software without restriction, including without limitation the
14
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15
+ sell copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice (including the next
19
+ paragraph) shall be included in all copies or substantial portions of the
20
+ Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28
+ IN THE SOFTWARE.
29
+
30
+ ****************
31
+ SPDX Identifiers
32
+ ****************
33
+
34
+ Individual files contain the following tag instead of the full license text.
35
+
36
+ .. code-block:: none
37
+
38
+ SPDX-License-Identifier: MIT
39
+
40
+ This enables machine processing of license information based on the SPDX
41
+ License Identifiers that are here available: http://spdx.org/licenses/
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "shrinkwraptool"
7
+ dynamic = ["version"]
8
+ authors = [
9
+ { name="Ryan Roberts", email="ryan.roberts@arm.com" },
10
+ { name="Saul Romero D", email="saul.romerodominguez@arm.com" }
11
+ ]
12
+
13
+ description = "Shrinkwrap is a tool to simplify the process of building and running firmware on Arm Fixed Virtual Platforms (FVP)."
14
+ readme = "README.md"
15
+ requires-python = ">=3.9.0"
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Operating System :: OS Independent",
19
+ ]
20
+ license = "MIT"
21
+ license-files = ["license*"]
22
+
23
+ dependencies = [
24
+ "PyYAML>=6.0.3",
25
+ "tuxmake>=1.34.0",
26
+ # termcolor 3.x requires Python >= 3.10
27
+ "termcolor>=2.4.0,<3.0; python_version < '3.10'",
28
+ "termcolor>=3.2.0; python_version >= '3.10'",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ dev = [
33
+ "build",
34
+ "twine",
35
+ "pytest",
36
+ "ruff==0.15.21",
37
+ ]
38
+
39
+ docs = [
40
+ "Sphinx>=8.2,<10",
41
+ "sphinx-rtd-theme>=3.1.0,<4",
42
+ "sphinx-copybutton>=0.5.2",
43
+ ]
44
+
45
+ [project.urls]
46
+ Homepage = "https://gitlab.arm.com/tooling/shrinkwrap"
47
+
48
+ [project.scripts]
49
+ shrinkwrap = "shrinkwrap.shrinkwrap_main:cli"
50
+
51
+ [tool.setuptools]
52
+ package-dir = {"" = "src"}
53
+ include-package-data = true
54
+
55
+ [tool.setuptools.package-data]
56
+ shrinkwrap = [
57
+ "config/**/*.yaml",
58
+ "config/**/*.config",
59
+ ]
60
+
61
+ [tool.setuptools.dynamic]
62
+ version = { attr = "shrinkwrap.__version__" }
63
+
64
+ [tool.setuptools.packages.find]
65
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "2026.9.0"
@@ -0,0 +1,4 @@
1
+ from .shrinkwrap_main import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,118 @@
1
+ # Copyright (c) 2022, Arm Limited.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ import os
5
+ import shrinkwrap.commands.buildall as buildall
6
+ import shrinkwrap.utils.vars as vars
7
+
8
+
9
+ cmd_name = os.path.splitext(os.path.basename(__file__))[0]
10
+
11
+
12
+ def add_parser(parser, formatter):
13
+ """
14
+ Part of the command interface expected by shrinkwrap.py. Adds the
15
+ subcommand to the parser, along with all options and documentation.
16
+ Returns the subcommand name.
17
+ """
18
+ cmdp = parser.add_parser(
19
+ cmd_name,
20
+ formatter_class=formatter,
21
+ help="""Builds a specified config and packages it ready
22
+ to run.""",
23
+ epilog="""Custom config store(s) can be defined at at
24
+ <SHRINKWRAP_CONFIG> as a colon-separated list of
25
+ directories. Building is done at <SHRINKWRAP_BUILD> and
26
+ output is saved to <SHRINKWRAP_PACKAGE>. The package
27
+ includes all FW binaries, a manifest and a build.sh script
28
+ containing all the commands that were executed per config.
29
+ Any pre-existing config package directory is first deleted.
30
+ Shrinkwrap will always search its default config store even
31
+ if <SHRINKWRAP_CONFIG> is not defined. <SHRINKWRAP_BUILD>
32
+ and <SHRINKWRAP_PACKAGE> default to '~/.shrinkwrap/build'
33
+ and '~/.shrinkwrap/package'. The user can override them by
34
+ setting the environment variables.""",
35
+ )
36
+
37
+ cmdp.add_argument(
38
+ "config",
39
+ metavar="config",
40
+ help="""Config to build. If the config exists relative to the
41
+ current directory that config is used. Else if the config
42
+ exists relative to the config store then it is used.""",
43
+ )
44
+
45
+ cmdp.add_argument(
46
+ "-b",
47
+ "--btvar",
48
+ metavar="key=value",
49
+ required=False,
50
+ default=[],
51
+ action="append",
52
+ help="""Override value for a single build-time variable defined
53
+ by the config. Specify option multiple times for multiple
54
+ variables. Overrides for variables that have a default
55
+ specified by the config are optional.""",
56
+ )
57
+
58
+ cmdp.add_argument(
59
+ "-s",
60
+ "--no-sync",
61
+ metavar="component",
62
+ required=False,
63
+ default=[],
64
+ action="append",
65
+ help="""Optionally specify any components whose git repos should
66
+ not be synced. For all other components, Shrinkwrap ensures
67
+ that all repos are clean and checked out at the correct
68
+ revision. Option can be specified multiple times.""",
69
+ )
70
+
71
+ cmdp.add_argument(
72
+ "--no-sync-all",
73
+ required=False,
74
+ default=False,
75
+ action="store_true",
76
+ help="""Do not sync repos for any component, as if --no-sync was
77
+ specified for every component in the config.""",
78
+ )
79
+
80
+ cmdp.add_argument(
81
+ "--force-sync",
82
+ metavar="component",
83
+ required=False,
84
+ default=[],
85
+ action="append",
86
+ help="""Synchronize the repo of the given component even if the local
87
+ source directory contains unsaved changes. YOUR CHANGES WILL BE
88
+ LOST! In addition, download updates from remote branches.""",
89
+ )
90
+
91
+ cmdp.add_argument(
92
+ "--force-sync-all",
93
+ required=False,
94
+ default=False,
95
+ action="store_true",
96
+ help="""Synchronize all components even if the local source directories
97
+ contain unsaved changes. YOUR CHANGES WILL BE LOST! In addition,
98
+ download all remote branch updates. Note that this will override
99
+ any 'sync: false' config option.""",
100
+ )
101
+
102
+ buildall.add_common_args(cmdp)
103
+
104
+ return cmd_name
105
+
106
+
107
+ def dispatch(args):
108
+ """
109
+ Part of the command interface expected by shrinkwrap.py. Called to
110
+ execute the subcommand, with the arguments the user passed on the
111
+ command line. The arguments comply with those requested in add_parser().
112
+ """
113
+ btvars = vars.parse(args.btvar, type="bt")
114
+ if args.no_sync_all:
115
+ args.no_sync = True
116
+ if args.force_sync_all:
117
+ args.force_sync = True
118
+ buildall.build([args.config], [btvars], args.no_sync, args.force_sync, args)
@@ -0,0 +1,214 @@
1
+ # Copyright (c) 2022, Arm Limited.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ import os
5
+ import yaml
6
+ import shrinkwrap.utils.config as config
7
+ import shrinkwrap.utils.graph as ugraph
8
+ import shrinkwrap.utils.runtime as runtime
9
+ import shrinkwrap.utils.workspace as workspace
10
+
11
+
12
+ cmd_name = os.path.splitext(os.path.basename(__file__))[0]
13
+
14
+
15
+ def dflt_jobs():
16
+ return min(os.cpu_count() // 2, 32)
17
+
18
+
19
+ def add_parser(parser, formatter):
20
+ """
21
+ Part of the command interface expected by shrinkwrap.py. Adds the
22
+ subcommand to the parser, along with all options and documentation.
23
+ Returns the subcommand name.
24
+ """
25
+ cmdp = parser.add_parser(
26
+ cmd_name,
27
+ formatter_class=formatter,
28
+ help="""Builds either all concrete standard configs or an
29
+ explicitly specified set of configs and packages them ready
30
+ to run.""",
31
+ epilog="""Custom config store(s) can be defined at at
32
+ <SHRINKWRAP_CONFIG> as a colon-separated list of
33
+ directories. Building is done at <SHRINKWRAP_BUILD> and
34
+ output is saved to <SHRINKWRAP_PACKAGE>. The package
35
+ includes all FW binaries, a manifest and a build.sh script
36
+ containing all the commands that were executed per config.
37
+ Any pre-existing config package directory is first deleted.
38
+ Shrinkwrap will always search its default config store even
39
+ if <SHRINKWRAP_CONFIG> is not defined. <SHRINKWRAP_BUILD>
40
+ and <SHRINKWRAP_PACKAGE> default to '~/.shrinkwrap/build'
41
+ and '~/.shrinkwrap/package'. The user can override them by
42
+ setting the environment variables.""",
43
+ )
44
+
45
+ cmdp.add_argument(
46
+ "configs",
47
+ metavar="yamlfile",
48
+ help="""A yaml file containing all the configs to be built. The
49
+ top level dictionary contains a 'configs' key, whose value
50
+ is a list of dictionaries, each with a 'config' key, whose
51
+ value is a config filename.""",
52
+ )
53
+
54
+ add_common_args(cmdp)
55
+
56
+ return cmd_name
57
+
58
+
59
+ def add_common_args(cmdp):
60
+ """
61
+ Common args shared between build and buildmulti.
62
+ """
63
+ cmdp.add_argument(
64
+ "-o",
65
+ "--overlay",
66
+ metavar="cfgfile",
67
+ required=False,
68
+ default=[],
69
+ action="append",
70
+ help="""Optional config file overlay to override run-time and
71
+ build-time settings. Only entries within the "build",
72
+ "buildex" and "run" sections are used. Applied to all
73
+ configs being built. Can be specified multiple times;
74
+ left-most overlay is the first overlay applied.""",
75
+ )
76
+
77
+ cmdp.add_argument(
78
+ "-t",
79
+ "--tasks",
80
+ required=False,
81
+ default=dflt_jobs(),
82
+ metavar="count",
83
+ type=int,
84
+ help="""Maximum number of "high-level" tasks that will be
85
+ performed in parallel by Shrinkwrap. Tasks include syncing
86
+ git repositories, building components and copying
87
+ artifacts. Default={}""".format(dflt_jobs()),
88
+ )
89
+
90
+ cmdp.add_argument(
91
+ "-j",
92
+ "--jobs",
93
+ required=False,
94
+ default=dflt_jobs(),
95
+ metavar="count",
96
+ type=int,
97
+ help="""Maximum number of low-level jobs that will be
98
+ performed in parallel by each component build task.
99
+ Default={}""".format(dflt_jobs()),
100
+ )
101
+
102
+ cmdp.add_argument(
103
+ "-v",
104
+ "--verbose",
105
+ required=False,
106
+ default=False,
107
+ action="store_true",
108
+ help="""If specified, the output from all executed commands will
109
+ be displayed. It is advisable to set tasks to 1 when
110
+ this option is selected.""",
111
+ )
112
+
113
+ cmdp.add_argument(
114
+ "-n",
115
+ "--dry-run",
116
+ required=False,
117
+ default=False,
118
+ action="store_true",
119
+ help="""If specified, <SHRINKWRAP_BUILD> and
120
+ <SHRINKWRAP_PACKAGE> will not be touched and none of the
121
+ build commands will be executed. Instead the set of
122
+ commands that would have been executed are output to stdout
123
+ as a bash script.""",
124
+ )
125
+
126
+ cmdp.add_argument(
127
+ "-c",
128
+ "--no-color",
129
+ required=False,
130
+ default=False,
131
+ action="store_true",
132
+ help="""If specified, logs will not be colorized.""",
133
+ )
134
+
135
+
136
+ def dispatch(args):
137
+ """
138
+ Part of the command interface expected by shrinkwrap.py. Called to
139
+ execute the subcommand, with the arguments the user passed on the
140
+ command line. The arguments comply with those requested in add_parser().
141
+ """
142
+ with open(args.configs) as file:
143
+ cfgs = yaml.safe_load(file)
144
+
145
+ configs = [c["config"] for c in cfgs["configs"]]
146
+ btvarss = [c["btvars"] for c in cfgs["configs"]]
147
+ build(configs, btvarss, [], [], args)
148
+
149
+
150
+ def build(configs, btvarss, nosync, force_sync, args):
151
+ """
152
+ Concurrently builds a list of configs. Intended to be called as a common
153
+ handler for the build and buildmulti commands.
154
+ """
155
+ clivars = {"jobs": args.jobs}
156
+ configs = config.load_resolveb_all(configs, args.overlay, clivars, btvarss)
157
+ graph = config.build_graph(configs, args.verbose, nosync, force_sync)
158
+
159
+ if args.dry_run:
160
+ script = ugraph.make_script(graph)
161
+ print(script)
162
+ else:
163
+ if args.verbose:
164
+ workspace.dump()
165
+
166
+ # Run under a runtime environment, which may just run commands
167
+ # natively on the host or may execute commands in a container,
168
+ # depending on what the user specified.
169
+ with runtime.Runtime(
170
+ name=args.runtime,
171
+ image=config.get_image(configs, args),
172
+ ssh_agent_keys=args.ssh_agent_keys,
173
+ ) as rt:
174
+
175
+ def add_volume(path, levels_up=0):
176
+ while levels_up:
177
+ path = os.path.dirname(path)
178
+ levels_up -= 1
179
+ os.makedirs(path, exist_ok=True)
180
+ rt.add_volume(path)
181
+
182
+ add_volume(workspace.build)
183
+ add_volume(workspace.package)
184
+ for c in workspace.configs():
185
+ add_volume(c)
186
+
187
+ for conf in configs:
188
+ for comp in conf["build"].values():
189
+ add_volume(comp["sourcedir"], 1)
190
+ add_volume(comp["builddir"])
191
+
192
+ for btvar in conf["buildex"]["btvars"].values():
193
+ if btvar["type"] == "path":
194
+ rt.add_volume(btvar["value"])
195
+
196
+ if workspace.project_cache:
197
+ add_volume(workspace.project_cache)
198
+
199
+ rt.start()
200
+
201
+ ugraph.execute(graph, args.tasks, args.verbose, not args.no_color)
202
+
203
+ for c in configs:
204
+ # Dump the config.
205
+ cfg_name = os.path.join(workspace.package, f"{c['name']}.yaml")
206
+ with open(cfg_name, "w") as cfg:
207
+ config.dump(c, cfg)
208
+
209
+ # Dump the script to build the config.
210
+ graph = config.build_graph([c], args.verbose, nosync, force_sync)
211
+ script = ugraph.make_script(graph)
212
+ build_name = os.path.join(workspace.package, c["name"], "build.sh")
213
+ with open(build_name, "w") as build:
214
+ build.write(script)