source | issues

bu user manual

Targets

Targets are build targets, which generally involve a target name, some options, and some actions to run in that target.

A simple hello world build script might have a target called “hello”. A target is defined in a source file as a name followed by zero or more options followed by a colon (:) character, like so:

hello:
    echo hello world

output:

1
2
3
4
5
6
7
8
9
======================= [bu 0.1] Starts (<string>:hello) =======================

!sh {}
       1 echo hello world
> 0
       1 hello world
] hello

======================== [bu 0.1] Ends (<string>:hello) ========================

The part of the target echo hello world is the only action defined in that target, and there are zero options defined.

Actions

Each target is composed of one or more actions. These actions are executed consecutively. An action is defined by using an action statement within a target. If the action statement is omitted, the default action type (shell) is used.

The content of the action is executed by the action type as a single block of text. The content block must be indented relative to the toplevel.

Back to our hello world example:

hello:
    echo hello world

output:

1
2
3
4
5
6
7
8
9
======================= [bu 0.1] Starts (<string>:hello) =======================

!sh {}
       1 echo hello world
> 0
       1 hello world
] hello

======================== [bu 0.1] Ends (<string>:hello) ========================

In our simple hello world example, the action is echo hello world and since the action type is omitted, a shell action is used. The same example can be written explicitly specifying a shell action like so:

hello:
    !sh
    echo hello world

output:

1
2
3
4
5
6
7
8
9
======================= [bu 0.1] Starts (<string>:hello) =======================

!sh {}
       1 echo hello world
> 0
       1 hello world
] hello

======================== [bu 0.1] Ends (<string>:hello) ========================

Action content need not only be a single line, the entire block follwing the the !sh statement is executed by the same shell:

hello:
    !sh
    export TEST=1
    echo $TEST

output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
======================= [bu 0.1] Starts (<string>:hello) =======================

!sh {}
       1 export TEST=1
       2 echo $TEST
> 0
       1 1
] hello

======================== [bu 0.1] Ends (<string>:hello) ========================

Multiple actions can be contained in a target. In this case each action is executed in a separate shell:

hello:
    !sh
    echo hello world
    !sh
    echo hello world

output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
======================= [bu 0.1] Starts (<string>:hello) =======================

!sh {}
       1 echo hello world
> 0
       1 hello world
!sh {}
       1 echo hello world
> 0
       1 hello world
] hello

======================== [bu 0.1] Ends (<string>:hello) ========================

Actions may also be Python scripts. The Python indent level must be consistent and relative to the first line of the action, and inconsistent indenting is an error:

hello:
    !py
    for i in range(3):
        print 'Hello World'

output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
======================= [bu 0.1] Starts (<string>:hello) =======================

!py {}
       1 for i in range(3):
       2     print 'Hello World'
> 0
       1 Hello World
       2 Hello World
       3 Hello World
] hello

======================== [bu 0.1] Ends (<string>:hello) ========================

Indenting that is inconsistent with the first line of content is erroneous for the bu parser (remember that all action content must have an indent):

hello:
    !py
    print 'Hello World'
   print 'Hello World'

output:

1

However actual python indentation errors will be detected by the Python compiler:

hello:
    !py
    print 'Hello World'
     print 'Hello World'

output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
======================= [bu 0.1] Starts (<string>:hello) =======================

!py {}
       1 print 'Hello World'
       2  print 'Hello World'
> 1
       1 Traceback (most recent call last):
       2   File "", line 38, in execute
       3   File "<string>", line 2
       4      print 'Hello World'
       5     ^
       6  IndentationError: unexpected indent
] hello

======================== [bu 0.1] Ends (<string>:hello) ========================

References

An action may be a link to another target in the same build script, which will cause a dependency. Reference actions are defined by using @ operator with the target name, for example:

hello_world:
    @hello
    @world

hello:
    echo Hello

world:
    echo World

output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
==================== [bu 0.1] Starts (<string>:hello_world) ====================

!sh {}
       1 echo Hello
> 0
       1 Hello
!sh {}
       1 echo World
> 0
       1 World
] hello_world

===================== [bu 0.1] Ends (<string>:hello_world) =====================