fplutil
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
fplutil.buildutil.common.BuildEnvironment Class Reference

Class representing the build environment we will be building in. More...

Inheritance diagram for fplutil.buildutil.common.BuildEnvironment:
fplutil.buildutil.android.BuildEnvironment fplutil.buildutil.linux.BuildEnvironment

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'
 

Detailed Description

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.

Class Attributes
GIT Name of the git binary. MAKE Name of the make binary.

Member Function Documentation

def fplutil.buildutil.common.BuildEnvironment.add_arguments (   parser)
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.

Parameters
parserThe argparse.ArgumentParser instance to use.
def fplutil.buildutil.common.BuildEnvironment.build_defaults ( )
static

Helper function to set build defaults.

Returns
A dict containing appropriate defaults for a build.
def fplutil.buildutil.common.BuildEnvironment.get_project_directory (   self,
  path = '.' 
)

Retrieve an absolute path relative to the project_directory.

Parameters
pathRelative from the project_directory.
Returns
Absolute path of the specified 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.)

Exceptions
SubCommandErrorAn error was returned from running git.
ToolPathErrorGit 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.

Parameters
dirlistA list of directories to archive, relative to the value of the project_directory property.
archive_pathA path to the zipfile to create, relative to the value of the output_directory property.
copytoOptional argument specifying an absolute directory path to copy the archive to on success.
excludeOptional list of directory names to filter from dir trees in dirlist. Subdirectories with these names will be skipped when writing the archive.
Exceptions
IOErrorAn 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.

Exceptions
SubCommandErrorMake invocation failed or returned an error.
ToolPathErrorMake 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().

Parameters
argvA list of process arguments starting with the binary name, in the form returned by shlex.
captureBoolean to control if output is captured or not.
cwdOptional path relative to the project directory to run process in for commands that do not allow specifying this, such as ant.
shellOptional argument to tell subprocess to allow for shell features.
stdinString to send to the standard input of the process.
Returns
A tuple of (stdout, stderr), or (None, None) if capture=False.
Exceptions
SubCommandErrorProcess return code was nonzero.

Member Data Documentation

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.


The documentation for this class was generated from the following file: