Skip to content

Commit

Permalink
edk2_initialize: add edk2_initialize
Browse files Browse the repository at this point in the history
Add the edk2_initialize invocable, which replaces edk2_setup and
edk2_ci_setup. stuart_init is able to initialize both repositories and
submodules.

Merges edk2_setup and edk2_ci_setup tests. Updates documentation.

Integration instructions:
* import from edk2toolext.invocables.edk2_initialize rather than
  .edk2_setup or .edk2_ci_setup inside the configuration file
* import Submodule and/or Repository instead of RequiredSubmodule
* Where the parent class is specified, switch from SetupSettingsManager
  or CiSetupSettingsManager to InitializeSettingsManager
* Use get_required_repositories and get_required_submodules instead of
  GetDependencies and GetRequiredSubmodules respectively
* Use Submodule instead of RequiredSubmodule and Repository instead of
  a dictionary.
  • Loading branch information
Javagedes committed May 19, 2023
1 parent 39305e5 commit ae7d55e
Show file tree
Hide file tree
Showing 24 changed files with 429 additions and 558 deletions.
1 change: 0 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"buildreport",
"buildreporting",
"cibuild",
"cisetup",
"cobertura",
"codecov",
"contoso",
Expand Down
8 changes: 4 additions & 4 deletions docs/contributor/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,21 @@ methods. Lets do that now.
### Before

```python
from edk2toolext.invocables.edk2_setup import SetupSettingsManager
from edk2toolext.invocables.edk2_initialize import InitializeSettingsManager
from edk2toolext.invocables.edk2_update import UpdateSettingsManager
from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager
class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager):
class SettingsManager(UpdateSettingsManager, InitializeSettingsManager, PrEvalSettingsManager):
... # Existing methods removed to save space
```

### After

```python
from edk2toolext.invocables.edk2_setup import SetupSettingsManager
from edk2toolext.invocables.edk2edk2_initialize_setup import InitializeSettingsManager
from edk2toolext.invocables.edk2_update import UpdateSettingsManager
from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager
from edk2toolext.invocables.my_new_invocable import MyNewInvocableSettingsManager # Path will be different
class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager, MyNewInvocableSettingsManager):
class SettingsManager(UpdateSettingsManager, InitializeSettingsManager, PrEvalSettingsManager, MyNewInvocableSettingsManager):
... # Existing methods removed to save space

def GetPlatformVersion(self):
Expand Down
6 changes: 3 additions & 3 deletions docs/user/features/creating_invocable.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Here's what we will be importing:
```python
import os
import logging
from edk2toolext.invocables.edk2_ci_setup import CiSetupSettingsManager
from edk2toolext.invocables.edk2_initialize import InitializeSettingsManager
from edk2toolext.invocables.edk2_update import UpdateSettingsManager
try:
from DriverBuilder import BinaryBuildSettingsManager
Expand Down Expand Up @@ -468,7 +468,7 @@ class SettingsManager(UpdateSettingsManager, CiSetupSettingsManager, BinaryBuild
```

The methods implemented here are a mix of our own settings class and other invocables such as stuart_update or
stuart_setup. Hopefully they're straightforward and easy to follow.
stuart_init. Hopefully they're straightforward and easy to follow.

## Conclusion

Expand Down Expand Up @@ -640,7 +640,7 @@ if __name__ == "__main__":
import os
import logging
from edk2toolext.environment.uefi_build import UefiBuilder
from edk2toolext.invocables.edk2_ci_setup import CiSetupSettingsManager
from edk2toolext.invocables.edk2_initialize import InitializeSettingsManager
from edk2toolext.invocables.edk2_update import UpdateSettingsManager
try:
from DriverBuilder_temp import BinaryBuildSettingsManager
Expand Down
14 changes: 4 additions & 10 deletions docs/user/features/sde.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ itself, stuart can now perform the minimal steps to enable building any given pl

NOTE:

- `stuart_setup` should only be required once per build machine, per platform being built. It is not necessary to run
- `stuart_init` should only be required once per build machine, per platform being built. It is not necessary to run
it regularly. Only when setting up a new personal workstation or starting to work with a platform that you haven't
used yet.
- The `stuart_setup` feature does not actually build the platform.
- The `stuart_setup` feature will NOT change branches in any submodule that already exists locally, or that has local
- The `stuart_init` feature does not actually build the platform.
- The `stuart_init` feature will NOT change branches in any submodule that already exists locally, or that has local
changes. This is to prevent accidental loss of work. If you would like the script to try making changes even in
these cases, use the "--FORCE" argument.
- The `stuart_setup` feature does not yet install dev singing certs. Those steps must still be performed manually.
- The `stuart_init` feature does not yet install dev singing certs. Those steps must still be performed manually.

### Updating

Expand All @@ -183,12 +183,6 @@ you will see a message prompting you to do so when you run `stuart_build` to bui
update, simply run the `stuart_update`. Any dependencies that match their current versions will be skipped and only
out-of-date dependencies will be refreshed.

### Setting Up for CI Build

Stuart CI Build works on a similar mechanism to `stuart_build` and expects to be have things setup and updated.
Git Modules are monitored and handled via the repo_resolver framework, which has more logic to it, and doesn't
handle submodules. `stuart_ci_setup` handles python defined git modules to clone into the code tree.

### Building

Building can be done with `stuart_build` or `stuart_ci_build`.
Expand Down
11 changes: 3 additions & 8 deletions docs/user/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ etc (and vise versa).
I'm glad you asked! Stuart has a variety of invocable tasks that he hopes will
be helpful for a wide variety workflows.

### stuart_setup
### stuart_init

Sets up the git repo based on the gitsubmodule file in your repo. It checks to make
sure the required repos as provided by settings manager are present.
Initializes the repo based on the configuration file. Can initialize submodules or
other repositories using `get_required_submodules()` or `get_required_repositories()`.

### stuart_update

Expand All @@ -114,11 +114,6 @@ active scopes currently defined. These scopes come from the settings manager.
Builds a platform. Requires an instance of `UefiBuilder` to be provided in
addition to the settings manager.

### stuart_ci_setup

Intended for CI environment setup. Given a list of required repos from the
settings manager, clone each of them in the workspace.

### stuart_ci_build

Given a list of packages, runs all plugins (for active scope) on each package.
Expand Down
16 changes: 8 additions & 8 deletions docs/user/integrate/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ are one [settings file](/features/settings_manager) away from a great
platform building experience.

The build process has three [stuart commands](/#what-can-i-ask-stuart-to-do)
to take your firmware code tree from freshly cloned to fully built: `stuart_setup`, `stuart_update`, `stuart_build`
to take your firmware code tree from freshly cloned to fully built: `stuart_init`, `stuart_update`, `stuart_build`
(hereby known has the "command(s)"). Behind the scenes, each command is an [Invocable](/features/invocable)
that has a corresponding [Settings Manager](/features/settings_manager) that the platform subclasses to provide
platform specific information.
Expand All @@ -27,7 +27,7 @@ provide functions used across all three commands and can be shared among the Set

1. [Edk2InvocableSettingsInterface](/api/edk2_invocable/#edk2toolext.edk2_invocable.Edk2InvocableSettingsInterface)
2. [MultiPkgAwareSettingsInterface](/api/invocables/edk2_multipkg_aware_invocable/#edk2toolext.invocables.edk2_multipkg_aware_invocable.MultiPkgAwareSettingsInterface)
3. [SetupSettingsManager](/api/invocables/edk2_setup/#edk2toolext.invocables.edk2_setup.SetupSettingsManager)
3. [InitializeSettingsManager](/api/invocables/edk2_initialize/#edk2toolext.invocables.edk2_initialize.InitializeSettingsManager)
4. [UpdateSettingsManager](/api/invocables/edk2_update/#edk2toolext.invocables.edk2_update.UpdateSettingsManager)
5. [BuildSettingsManager](/api/invocables/edk2_ci_build/#edk2toolext.invocables.edk2_ci_build.CiBuildSettingsManager)

Expand All @@ -39,13 +39,13 @@ spread across Edk2-Pytools (Extensions and Library).

Lets take a look at each command!

## Stuart Setup
## Stuart Init

`stuart_setup` is the first command and is responsible for setting up the code tree. Currently, this only involves
preparing the git submodules necessary for build. If you've created an [Omnicache](/tools/using_omnicache_tool/), here
`stuart_init` is the first command and is responsible for setting up the code tree. This involves preparing git
submodules and repos necessary for build. If you've created an [Omnicache](/tools/using_omnicache_tool/), here
is where you would use it to save on network bandwidth, disk space, and time when cloning repos. As you might expect,
`stuart_setup` does not automatically know what submodules are necessary for each platform; we must use the
[SetupSettingsManager](/api/invocables/edk2_setup/#edk2toolext.invocables.edk2_setup.SetupSettingsManager)
`stuart_init` does not automatically know what submodules are necessary for each platform; we must use the
[InitializeSettingsManager](/api/invocables/edk2_initialize/#edk2toolext.invocables.edk2_initialize.InitializeSettingsManager)
to provide that information.

!!! Note
Expand All @@ -57,7 +57,7 @@ to provide that information.
that multiple (or all) commands use, which is why they are in the parent class. Don't worry though! If you miss
overriding a required method, you'll raise a `NotImplementedError`!

**Review the `stuart_setup` specific settings manager [here](/api/invocables/edk2_setup/#edk2toolext.invocables.edk2_setup.SetupSettingsManager).**
**Review the `stuart_init` specific settings manager [here](/api/invocables/edk2_initialize/#edk2toolext.invocables.edk2_initialize.InitializeSettingsManager).**

## Stuart Update

Expand Down
6 changes: 3 additions & 3 deletions docs/user/integrate/manage.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ be tied to a platform either; they can be in the platform repository or in a
separate repository. Some examples of `CiBuildPlugins` are uncrustify audits,
guid audits, package builds, etc.

`stuart_ci_setup` can be called to clone whatever code repositories would be
`stuart_init` can be called to clone whatever code repositories would be
required for this operation. `stuart_update` can be called to download all the
tools the environment says it needs. From there, `stuart_ci_build` takes a list of
packages to look at and runs all plugins on each package.
Expand All @@ -35,7 +35,7 @@ Take a look all all the relevant invocables below:

- [Edk2InvocableSettingsInterface](/api/edk2_invocable/#edk2toolext.edk2_invocable.Edk2InvocableSettingsInterface)
- [MultiPkgAwareSettingsInterface](/api/invocables/edk2_multipkg_aware_invocable/#edk2toolext.invocables.edk2_multipkg_aware_invocable.MultiPkgAwareSettingsInterface)
- [CiSetupSettingsManager](/api/invocables/edk2_ci_setup/#edk2toolext.invocables.edk2_ci_setup.CiSetupSettingsManager)
- [InitializeSettingsManager](/api/invocables/edk2_initialize/#edk2toolext.invocables.edk2_initialize.InitializeSettingsManager)
- [UpdateSettingsManager](/api/invocables/edk2_update/#edk2toolext.invocables.edk2_update.UpdateSettingsManager)
- [CiBuildSettingsManager](/api/invocables/edk2_ci_setup/#edk2toolext.invocables.edk2_ci_setup.CiSetupSettingsManager)
- [CiBuildSettingsManager](/api/invocables/edk2_ci_build/#edk2toolext.invocables.edk2_ci_build.CiBuildSettingsManager)
- [PrEvalSettingsManager](/api/invocables/edk2_pr_eval/#edk2toolext.invocables.edk2_pr_eval.PrEvalSettingsManager)
24 changes: 12 additions & 12 deletions docs/user/integrate/porting.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ import os
import logging
from edk2toolext.environment.uefi_build import UefiBuilder
from edk2toolext.invocables.edk2_platform_build import BuildSettingsManager
from edk2toolext.invocables.edk2_setup import SetupSettingsManager
from edk2toolext.invocables.edk2_initialize import InitializeSettingsManager
from edk2toolext.invocables.edk2_update import UpdateSettingsManager
from edk2toollib.utility_functions import GetHostInfo
from edk2toolext.invocables.edk2_setup import RequiredSubmodule
from edk2toolext.invocables.edk2_initialize import Submodule

#
#==========================================================================
# PLATFORM BUILD ENVIRONMENT CONFIGURATION
#
class RpiSettingsManager(UpdateSettingsManager, SetupSettingsManager, BuildSettingsManager):
class RpiSettingsManager(UpdateSettingsManager, InitializeSettingsManager, BuildSettingsManager):
def __init__(self):
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
self.ws = SCRIPT_PATH
Expand All @@ -191,7 +191,7 @@ Right now we are importing the needed classes from the pytools as well as
defining a class which will provide the settings to stuart.

The three invocables that we have implemented settings for are `stuart_build`,
`stuart_update`, and `stuart_setup`. If you were to call one of these, you'd get
`stuart_update`, and `stuart_init`. If you were to call one of these, you'd get
an error on a non-implemented method.

Since our settings provider it is still missing a lot of functionality. While it
Expand All @@ -209,7 +209,7 @@ Let's focus on getting setup working. Let's add Scopes and RequiredSubmodules.
```python
...

class RpiSettingsManager(UpdateSettingsManager, SetupSettingsManager, BuildSettingsManager):
class RpiSettingsManager(UpdateSettingsManager, InitializeSettingsManager, BuildSettingsManager):
def __init__(self):
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
self.ws = SCRIPT_PATH
Expand All @@ -227,16 +227,16 @@ class RpiSettingsManager(UpdateSettingsManager, SetupSettingsManager, BuildSetti
These should be edk2 workspace relative paths '''
return ("RaspberryPi/RPi3", )

def GetRequiredSubmodules(self):
def get_required_submodules(self):
''' return iterable containing RequiredSubmodule objects.
If no RequiredSubmodules return an empty iterable
'''
return [
RequiredSubmodule("MU_BASECORE"),
RequiredSubmodule("Common/MU_OEM"),
RequiredSubmodule("Common/MU"),
RequiredSubmodule("Common/TIANO"),
RequiredSubmodule("Silicon/ARM/MU_TIANO"),
Submodule("MU_BASECORE"),
Submodule("Common/MU_OEM"),
Submodule("Common/MU"),
Submodule("Common/TIANO"),
Submodule("Silicon/ARM/MU_TIANO"),
]

def GetArchitecturesSupported(self):
Expand Down Expand Up @@ -267,7 +267,7 @@ platforms or select between different platforms.
Now if we call setup, we should see something like this:

```cmd
~/rpi$ stuart_setup -c RpiPlatformBuild.py
~/rpi$ stuart_init -c RpiPlatformBuild.py
SECTION - Init SDE
SECTION - Loading Plugins
SECTION - Start Invocable Tool
Expand Down
5 changes: 2 additions & 3 deletions docs/user/tools/using_omnicache_tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,13 @@ If you want to use a scheduled task here is one way to do it on Windows.
SCHTASKS /Create /XML "O_U.xml" /TN "Omnicache Updater"
```

## Using Omnicache for stuart_setup
## Using Omnicache for stuart_init

Set the environment variable **OMNICACHE_PATH** for automatic usage. To provide
a path manually:

```cmd
stuart_setup --omnicache <path>
stuart_ci_setup --omnicache <path>
stuart_init --omnicache <path>
```

## Using Omnicache for git clone
Expand Down
12 changes: 6 additions & 6 deletions docs/user/using/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edk2-pytool-extensions, then these commands will be available to execute as
seen below:

```cmd
stuart_setup -c path/to/SettingsFile.py
stuart_init -c path/to/SettingsFile.py
stuart_update -c path/to/SettingsFile.py
stuart_build -c path/to/SettingsFile.py
```
Expand All @@ -22,7 +22,7 @@ flags. Due to this **Your platform's build instructions is the single
source of truth.**

!!! tip
Once you've run `stuart_setup` and `stuart_update`, building your platform
Once you've run `stuart_init` and `stuart_update`, building your platform
again is as simple as executing `stuart_build -c path/to/SettingsFile.py`.

As you can see, Each of these commands has a single required flag `-c` that
Expand All @@ -39,13 +39,13 @@ of this file.**

Curious about what each command does? Check out the below sections.

## stuart_setup
## stuart_init

Stuart_setup is responsible for downloading all git submodule dependencies as
specified by your platform.
Stuart_init is responsible for downloading all git submodule dependencies and
repository dependencies as specified by your configuration file.

```cmd
stuart_setup -c path/to/SettingsFile.py
stuart_init -c path/to/SettingsFile.py
```

## stuart_update
Expand Down
10 changes: 5 additions & 5 deletions docs/user/using/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edk2-pytool-extensions, then these commands will be available to execute as
seen below:

```cmd
stuart_ci_setup -c path/to/CISettingsFile.py
stuart_init -c path/to/CISettingsFile.py
stuart_update -c path/to/CISettingsFile.py
stuart_ci_build -c path/to/CISettingsFile.py
```
Expand All @@ -33,13 +33,13 @@ of this file.**

Curious about what each command does? Check out the below sections.

## stuart_ci_setup
## stuart_init

Stuart_ci_setup is responsible for downloading all git submodule dependencies
required to perform all CI tasks.
Stuart_init is responsible for downloading all git submodule and repository
dependencies required to perform all CI tasks.

```cmd
stuart_ci_setup -c path/to/CISettingsFile.py
stuart_init -c path/to/CISettingsFile.py
```

## stuart_update
Expand Down
4 changes: 2 additions & 2 deletions edk2toolext/environment/repo_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
on the GitPython PyPi module. This module provides functionality to clone, checkout, and clean repos and
submodules along with providing common information about the repo or submodule.
The intent is to keep all git functionality consolidated in this module. Currently edk2_ci_setup.py,
edk2_setup.py, and git_dependency.py use this module to perform git operations.
The intent is to keep all git functionality consolidated in this module. Currently
edk2_initialize.py, and git_dependency.py use this module to perform git operations.
"""
import os
import logging
Expand Down
Loading

0 comments on commit ae7d55e

Please sign in to comment.