Difference between revisions of "AMBuild API (2.0)"

From AlliedModders Wiki
Jump to: navigation, search
m
m
Line 22: Line 22:
 
* ''buildPath'' - The absolute path to the build folder.
 
* ''buildPath'' - The absolute path to the build folder.
 
* ''buildFolder'' - The working directory of jobs in this context, relative to <tt>buildPath</tt>.
 
* ''buildFolder'' - The working directory of jobs in this context, relative to <tt>buildPath</tt>.
 +
 +
Methods:
 +
* ''SetBuildFolder(folder)'' - Sets the working directory of jobs in this context, relative to <tt>buildPath</tt>.
 +
** ''folder'' - A string representing the folder path. '.' and './' are allowed.
 +
** Returns <tt>None</tt>.
 +
* ''DetectCompilers()'' - Detects C and C++ compilers and raises an exception if neither are available or they do not match. Should only be called once.
 +
** Returns a <tt>Compiler</tt> object that is also accessible via the <tt>compiler</tt> attribute.

Revision as of 18:16, 17 October 2013

AMBuild scripts have access to the following object types:

  • Context: Exposed as the builder, this is the entry point for the API and is known as a configure context.
  • NodeBuilder: Represents a node in the dependency graph that may or may not be committed to the database.
  • Compiler: An abstraction representing a C++ compiler environment.
  • Vendor: An abstraction representing a C++ compiler vendor (GCC, MSVC, Clang, etc).

As a general rule, AMBuild uses the following conventions:

  • Methods starting with an upper-case letter are considered public API.
  • Methods starting with a lower-case letter are considered private and should not be used.
  • Properties and attributes ending with an underscore are considered private and should not be used.
  • Spaces are used instead of tabs, and two-space indents are preferred.

Contexts

Contexts are implemented in ambuild2/frontend/base_gen.py. They are the entry point for using AMBuild. They have the following properties:

  • compiler - An instance of a Compiler object, or None if DetectCompilers</t> was never called. Calling DetectCompilers will set the compiler field for this and all future contexts.
  • parent - The context that loaded the current context.
  • script - The path, relative to sourcePath, of the current build script.
  • sourcePath - The absolute path to the source tree.
  • options - The result of evaluating command-line options from configure.py, via the optparse module.
  • buildPath - The absolute path to the build folder.
  • buildFolder - The working directory of jobs in this context, relative to buildPath.

Methods:

  • SetBuildFolder(folder) - Sets the working directory of jobs in this context, relative to buildPath.
    • folder - A string representing the folder path. '.' and './' are allowed.
    • Returns None.
  • DetectCompilers() - Detects C and C++ compilers and raises an exception if neither are available or they do not match. Should only be called once.
    • Returns a Compiler object that is also accessible via the compiler attribute.