fplutil
An open source project by
FPL.
|
Class representing the build environment we will be building in. More...
Public Member Functions | |
def | run_subprocess |
Run a subprocess as specified by the given argument list. More... | |
def | run_make |
Run make based on the specified build environment. More... | |
def | make_archive |
Archive build artifacts at the specified directory paths. More... | |
def | git_clean |
Cleans build directory back to last git commit. More... | |
def | get_project_directory |
Retrieve an absolute path relative to the project_directory. More... | |
Static Public Member Functions | |
def | build_defaults |
Helper function to set build defaults. More... | |
def | add_arguments |
Add module-specific command line arguments to an argparse parser. More... | |
Public Attributes | |
project_directory | |
The top-level project directory to build. More... | |
output_directory | |
The top level directory to copy the build archive to. More... | |
enable_git_clean | |
Boolean value to enable cleaning for git-based projects. More... | |
make_path | |
Path to the make binary, for make-based projects. More... | |
git_path | |
Path to the git binary, for projects based on git. More... | |
make_flags | |
Flags to pass to make, for make-based projects. More... | |
cpu_count | |
Number of CPU cores to use while building. More... | |
verbose | |
Boolean to enable verbose message output. More... | |
clean | |
Boolean value which specifies whether to clean the project. More... | |
host_os_name | |
Lowercased name of host operating system. More... | |
host_architecture | |
Lowercased name of host machine architecture. More... | |
Static Public Attributes | |
string | GIT = 'git' |
string | MAKE = 'make' |
Class representing the build environment we will be building in.
This class resolves and exposes various build parameters as properties, which can be customized by users before building. It also provides methods to accomplish common build tasks such as executing build tools and archiving the resulting build artifacts. It is subclassed to provide platform-specific build tasks.
|
static |
Add module-specific command line arguments to an argparse parser.
This will take an argument parser and add arguments appropriate for this module. It will also set appropriate default values.
parser | The argparse.ArgumentParser instance to use. |
|
static |
Helper function to set build defaults.
def fplutil.buildutil.common.BuildEnvironment.get_project_directory | ( | self, | |
path = '.' |
|||
) |
Retrieve an absolute path relative to the project_directory.
path | Relative from the project_directory. |
def fplutil.buildutil.common.BuildEnvironment.git_clean | ( | self | ) |
Cleans build directory back to last git commit.
Some build systems like CMake have no way to clean up their build cruft they create. This function checks it is being run at the top of a git repository; then, if enabled in the environment, resets the git repository back to its last git commit.
This will erase ALL CHANGES in the current directory after the last git commit, including any build output or edited files. Use with caution. Primarily intended for automated builds, and only does anything if the '-w' or '–git_clean' flags are passed to the argument parser (or env is otherwise modified to enable this.)
SubCommandError | An error was returned from running git. |
ToolPathError | Git not found in configured build environment or $PATH. |
def fplutil.buildutil.common.BuildEnvironment.make_archive | ( | self, | |
dirlist, | |||
archive_path, | |||
copyto = None , |
|||
exclude = None |
|||
) |
Archive build artifacts at the specified directory paths.
Creates a zip archive containing the contents of all the directories specified in dirlist. All dirlist paths are relative from the project top directory.
dirlist | A list of directories to archive, relative to the value of the project_directory property. |
archive_path | A path to the zipfile to create, relative to the value of the output_directory property. |
copyto | Optional argument specifying an absolute directory path to copy the archive to on success. |
exclude | Optional list of directory names to filter from dir trees in dirlist. Subdirectories with these names will be skipped when writing the archive. |
IOError | An error occurred writing or copying the archive. |
def fplutil.buildutil.common.BuildEnvironment.run_make | ( | self | ) |
Run make based on the specified build environment.
This will execute make using the configured environment, passing it the flags specified in the cmake_flags property.
SubCommandError | Make invocation failed or returned an error. |
ToolPathError | Make not found in configured build environment or $PATH. |
def fplutil.buildutil.common.BuildEnvironment.run_subprocess | ( | self, | |
argv, | |||
capture = False , |
|||
cwd = None , |
|||
shell = False , |
|||
stdin = None |
|||
) |
Run a subprocess as specified by the given argument list.
Runs a process via popen().
argv | A list of process arguments starting with the binary name, in the form returned by shlex. |
capture | Boolean to control if output is captured or not. |
cwd | Optional path relative to the project directory to run process in for commands that do not allow specifying this, such as ant. |
shell | Optional argument to tell subprocess to allow for shell features. |
stdin | String to send to the standard input of the process. |
SubCommandError | Process return code was nonzero. |
fplutil.buildutil.common.BuildEnvironment.clean |
Boolean value which specifies whether to clean the project.
fplutil.buildutil.common.BuildEnvironment.cpu_count |
Number of CPU cores to use while building.
fplutil.buildutil.common.BuildEnvironment.enable_git_clean |
Boolean value to enable cleaning for git-based projects.
fplutil.buildutil.common.BuildEnvironment.git_path |
Path to the git binary, for projects based on git.
fplutil.buildutil.common.BuildEnvironment.host_architecture |
Lowercased name of host machine architecture.
fplutil.buildutil.common.BuildEnvironment.host_os_name |
Lowercased name of host operating system.
fplutil.buildutil.common.BuildEnvironment.make_flags |
Flags to pass to make, for make-based projects.
fplutil.buildutil.common.BuildEnvironment.make_path |
Path to the make binary, for make-based projects.
fplutil.buildutil.common.BuildEnvironment.output_directory |
The top level directory to copy the build archive to.
fplutil.buildutil.common.BuildEnvironment.project_directory |
The top-level project directory to build.
fplutil.buildutil.common.BuildEnvironment.verbose |
Boolean to enable verbose message output.