2013-10-20

remove AddDependency

← Older revision

Revision as of 23:36, 20 October 2013

(5 intermediate revisions by one user not shown)

Line 14:

Line 14:

 

=Contexts=

 

=Contexts=

 

 



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

+

Contexts are implemented in <tt>ambuild2/frontend/base_gen.py</tt>. They are the entry point for using AMBuild.

 

 

 

+

When using paths inside a context, it is important to note how AMBuild recognizes paths.

 

+

* ''source'' paths are any paths that are absolute. They must not resolve to a path inside the build folder. Source paths are considered inputs to the build.

 

+

* ''output'' paths are any paths that are relative. They are always relative to the build folder. Output paths are generated by the build process.

 

+

 

+

==Attributes==

 

* ''compiler'' - An instance of a <tt>Compiler</tt> object, or <tt>None</tt> if <tt>DetectCompilers</tt> was never called. Calling <tt>DetectCompilers</tt> will set the <tt>compiler</tt> field for this and all future contexts.

 

* ''compiler'' - An instance of a <tt>Compiler</tt> object, or <tt>None</tt> if <tt>DetectCompilers</tt> was never called. Calling <tt>DetectCompilers</tt> will set the <tt>compiler</tt> field for this and all future contexts.

 

* ''parent'' - The context that loaded the current context.

 

* ''parent'' - The context that loaded the current context.

Line 24:

Line 29:

 

* ''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
:

+

==
Methods
==

 

* ''SetBuildFolder(folder)'' - Sets the working directory of jobs in this context, relative to <tt>buildPath</tt>.

 

* ''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.

 

** ''folder'' - A string representing the folder path. '.' and './' are allowed.

Line 34:

Line 39:

 

** ''vars'' - An optional dictionary of global variables to set in each child build script. The dictionary is merged with the global variables passed into our current script. Variables with the same name are overridden by the new dictionary.

 

** ''vars'' - An optional dictionary of global variables to set in each child build script. The dictionary is merged with the global variables passed into our current script. Variables with the same name are overridden by the new dictionary.

 

** Returns <tt>None</tt>.

 

** Returns <tt>None</tt>.

 

+

* ''Add(taskbuilder)'' - Some jobs are too complex to use a single API call, and instead provide objects to assist in creation. These objects are finalized into the dependency graph with this function. Currently, the only complex jobs built-in are C/C++ compilation jobs.

 

+

** ''taskbuilder'' - The job builder instance.

 

+

** Returns a value based on the taskbuilder. For example, C++ objects return a 'CppNode' described under the Compiler section.

 

+

* ''AddSource(source_path)'' - Adds a source file as an object in the dependency graph. Source objects can be dependencies for other objects, but they themselves should not have dependencies. If a source file with the same path already exists, it will be re-used.

 

+

** ''source_path'' - An absolute path to the source file; it can be anywhere in the filesystem, except that it must not be in the build folder. Anything in the build folder is considered an output.

 

+

** Returns a <tt>NodeBuilder</tt> instance describing the dependency graph node.

 

+

* ''AddFolder(folder)'' - Ensures that a folder is created when performing a build. The folder is created relative to the context's local build folder.

 

+

** ''folder'' - A relative path specifying the folder. Folder chains can be created all at once; i.e. 'a/b/c' is a valid target even if 'a' or 'a/b' do not exist.

 

+

** Returns a <tt>NodeBuilder</tt> instance describing the folder creation node.

 

+

* ''AddSymlink(source, output_path)'' - Adds a job to the build that will perform a symlink. On systems where symlinks are not available, it is implemented as a copy.

 

+

* ''AddCopy(source, output_path)'' - Adds a job to the build that will perform a file copy.

 

+

** ''source'' - Either a string containing a source file path, or a source node, or an output node, representing the file that will be the source of the operation.

 

+

** ''output_path'' - One of the following:

 

+

*** A string path ending in a path separator, or <tt>'.'</tt>, or a string path containing a folder added via <tt>AddFolder()</tt>, representing the folder to copy or symlink the file to. It is relative to the context's local build folder.

 

+

*** A string path ending in a filename, representing the destination file of the operation. It is relative to the context's local build folder.

 

+

*** A folder node created via <tt>AddFolder()</tt>, representing the folder to copy or symlink the file to. In this case, the folder node's path is taken as-is and is not relative to the local build folder.

 

+

** Returns a <tt>NodeBuilder</tt> instance representing the node for this command in the dependency graph.

 

+

* ''AddCommand(argv, outputs)'' - Adds a custom command that will be executed manually. The working directory of the command is the context's local build folder. As created, the command has no dependencies. If it has source dependencies they can be specified via <tt>AddDependency</tt>.

 

+

** ''argv'' - The argument vector that will be passed to <tt>subprocess.Popen</tt>. <tt>argv[0]</tt> should be the executable.

 

+

** ''outputs'' - An iterable containing files that are outputs of this command. Each file must be a relative path from the context's local build folder.

 

+

** Returns a 2-tuple, containing:

 

+

*** A <tt>NodeBuilder</tt> instance representing the node for this command in the dependency graph.

 

+

*** A list of <tt>NodeBuilder</tt> instances, each instance corresponding to one of the output file paths specified.

Show more