-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e75415
commit a28193c
Showing
11 changed files
with
203 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,56 @@ | ||
Contexts | ||
======== | ||
|
||
*Contexts* are used in ``rabs`` to provide dynamic hierarchical scoping for symbols. Symbols defined in a context are visible in any child contexts, and can be overridden without affecting the parent context. Each context has an associated path for identification which is also used as a prefix for targets created within the context. | ||
|
||
The root :file:`build.rabs` file is executed in the root context. New contexts are created using :mini:`subdir()` or :mini:`scope()`, using the current context as the parent. | ||
|
||
.. code-block:: mini | ||
subdir("directory") :> Will load directory/build.rabs in child context | ||
scope("test";) do | ||
:> Inside child context | ||
end | ||
Build Contexts | ||
-------------- | ||
|
||
Some targets (e.g. file targets) can be anywhere in the project and thus cannot be bound to a specific context. This means that flags or other settings (e.g. compilation flags) cannot be bound to targets. | ||
|
||
However, the build function for each target should only be set once. ``rabs`` remembers the context where the build function for each target was set and uses the same context when performing the build. | ||
|
||
Example | ||
~~~~~~~ | ||
|
||
.. code-block:: mini | ||
:< ROOT >: | ||
CFLAGS := ["-pipe"] | ||
fun compile_c(Target) do | ||
let Source := Target % "c" | ||
execute("cc", CFLAGS, Source, "-o", Target) | ||
end | ||
let Objects := [ | ||
file("main.o"), | ||
file("test.o") | ||
] | ||
file("main.o") => compile_c | ||
scope("test";) do | ||
CFLAGS := old + ["-O3"] | ||
file("test.o") => compile_c | ||
end | ||
DEFAULT[Objects] | ||
In this example, :file:`main.o` will be compiled using just ``-pipe`` for *CFLAGS* but :file:`test.o` will be compiled using ``-pipe -O3``. | ||
|
||
Default Targets | ||
--------------- | ||
|
||
Each directory context defines a :mini:`DEFAULT` :doc:`meta target </targets/meta>`. If a directory context is not the root context then its :mini:`DEFAULT` target is automatically added as a dependency of the parent context's :mini:`DEFAULT` target. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
Expression Targets | ||
================== | ||
|
||
An expression target represents a computable value. Expression targets can be used for capturing the output of config generation tools (e.g. :file:`pkg-config`) preventing the need to run them unnecessarily at each build. | ||
|
||
To create an expression target, call the built-in :mini:`expr(Name)` function with a name that is unique to the current context. Calling :mini:`expr(Name)` with a name that already of an existing expr target in the current context will simply return the existing target. | ||
|
||
.. code-block:: mini | ||
var ExprTarget := expr("GTK_CFLAGS") | ||
ExprTarget => fun(Target) do | ||
shell("pkg-config --cflags gtk+-3.0"):trim | ||
end | ||
Build Function | ||
-------------- | ||
|
||
When an expression target is used as a value (e.g. in a shell command), it is replaced by the value returned by the target's build function. Most common types of value are supported, booleans, numbers, strings, lists and maps are the most important. | ||
|
||
Update Detection | ||
---------------- | ||
|
||
An expression target is considered updated when the value computed by its build function has changed (using the Minilang hash method). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
Meta Targets | ||
============ | ||
|
||
A meta target represents a target with no other properties other than a build function and dependencies on other targets. | ||
|
||
To create a meta target, call the built-in :mini:`meta(Name)` function with a name that is unique to the current context. Calling :mini:`meta(Name)` with a name that already of an existing meta target in the current context will simply return the existing target. | ||
|
||
.. code-block:: mini | ||
var MetaTarget := meta("TESTS") | ||
Each directory :doc:`context </contexts>` defines a :mini:`DEFAULT` meta target. If a directory context is not the root context then its :mini:`DEFAULT` target is automatically added as a dependency of the parent context's :mini:`DEFAULT` target. | ||
|
||
Build Function | ||
-------------- | ||
|
||
The build function for a meta target can do anything. The result of the build function is ignored (excluding errors). | ||
|
||
Update Detection | ||
---------------- | ||
|
||
A meta target is considered updated if any of its dependencies has been updated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
Scan Targets | ||
============ | ||
|
||
A scan target represents a computable list of other targets that is updated as required. | ||
|
||
To create a scan target, call the :mini:`:scan(Name)` method on another *base* target. Calling :mini:`:scan(Name)` with a name of an existing scan target for the same base target will simply return the existing target. | ||
|
||
.. code-block:: mini | ||
var FileTarget := file("test.o") | ||
var ScanTarget := FileTarget:scan("HEADERS") | ||
Build Function | ||
-------------- | ||
|
||
The build function for a scan target should return a list of targets. Each of the targets returned is then updated if necessary. | ||
|
||
.. note:: | ||
|
||
The targets returned by a scan target's build function are not automatically considered dependencies of the scan target itself. In some cases (e.g. C include files), this behaviour is required in which case the dependencies need to be added explicitly. Since the list of targets is not known until the scan target's build function is run, the only way to do this is to use the :mini:`check(Targets)` which will add :mini:`Targets` as dependencies to the current building target. | ||
|
||
Update Detection | ||
---------------- | ||
|
||
A scan target is considered updated when any of its list of targets has been updated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
Symbol Targets | ||
============== | ||
|
||
A symbol target represents a context-specific value binding. | ||
|
||
Symbol targets are created automatically whenever an undeclared identifier is used. They can be created explicitly using the :mini:`symbol(Name)` function, in cases where the name is created programmatically. | ||
|
||
.. code-block:: mini | ||
var SymbolTarget := SYMBOL | ||
When symbols are used in any code, they are resolved in the current context. Thus the same symbol in the same function may resolve to different values depending on the current context when the function is called. This is used to have context specific flags or settings in general purpose build functions. See :doc:`/contexts` for an example. | ||
|
||
Using a symbol while building a target also adds that symbol as a dependency to that target. In some cases, it may be necessary to explicitly add a symbol as a dependency to a target even if it is not used within the target's build function. Since using a symbol in any code automatically resolves to the symbols value, the symbol name must be added as a string instead. | ||
|
||
.. code-block:: mini | ||
var FileTarget := file("test.o") | ||
FileTarget["SYMBOL"] | ||
Build Function | ||
-------------- | ||
|
||
Symbols should not have build functions. | ||
|
||
Update Detection | ||
---------------- | ||
|
||
A symbol is considered updated if its value changes. Note that if the value of a symbol is another target, the update status of that target does not affect the symbol's update status. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,31 @@ | ||
Virtual Mounts | ||
============== | ||
|
||
Virtual mounts allow directories to be overlayed, which in turn allows source and build directories to be kept separate without adding a lot of path overhead to the build functions. | ||
|
||
Virtual mounts are created using the :mini:`vmount(Path, Source)` function. Both :mini:`Path` and :mini:`Source` should be directory paths. :mini:`Path` must be a relative path to the current context path, :mini:`Source` can be either relative or absolute. | ||
|
||
Once created, virtual mounts are visible project wide. | ||
|
||
.. code-block:: mini | ||
vmount("build", "source") | ||
Path Resolution | ||
--------------- | ||
|
||
Whenever a file target is used, it is first resolved to an absolute path. Each virtual mount :mini:`vmount(Path, Source)` adds creates two possible resolutions for the file path, the original and one with :mini:`Path` replaced with :mini:`Source`. Virtual mounts are considered in reverse order, later virtual mounts are applied first. | ||
|
||
Resolving a file target to a path involves checking each possible resolution for an existing file or directory. If found, the path of the existing file or directory is returned. Otherwise the first possible resolution, i.e. without any vmount replacements, is returned. | ||
|
||
.. code-block:: mini | ||
vmount("a", "b") | ||
vmount("a/c", "d") | ||
file("a/c/test") :> Tries "a/c/test", "d/test", "b/c/test" in that order | ||
.. note:: mini | ||
|
||
When using :mini:`subdir` with a virtual mount, the target path should be used, not the source, even though the :file:`build.rabs` file likely in the source directory. ``rabs`` will treat the target path as part of the project and only use the source directory for finding files, including the :file:`build.rabs` file. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters