blob: 2413c56ff85bfc271402eb3cc89ad26a81ca8f91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
.. _developing_workspaces:
Workspaces
==========
In this section we will cover the use of BuildStream's workspaces feature when
devloping a BuildStream project.
.. note::
This example is distributed with BuildStream
in the `doc/examples/developing
<https://gitlab.com/BuildStream/buildstream/tree/master/doc/examples/developing>`_
subdirectory.
We will start with the project used in the :ref:`running commands <tutorial_running_commands>`
tutorial. Recall the element hello.bst, which builds the bellow C file:
.. literalinclude:: ../../examples/developing/files/src/hello.c
:language: c
Suppose we now want to alter the functionality of the *hello* command. We can
make changes to the source code of Buildstream elements by making use of
BuildStream's workspace command.
Opening a workspace
-------------------
First we need to open a workspace, we can do this by running
.. raw:: html
:file: ../sessions/developing-workspace-open.html
This command has created the workspace_hello directory in which you can see
the source for the hello.bst element, i.e. hello.c and the corresponding
makefile.
You can view existing workspaces using
.. raw:: html
:file: ../sessions/developing-workspace-list.html
Making code changes
-------------------
Let's say we want to alter the message printed when the hello command is run.
We can open workspace_hello/hello.c and make the following change:
.. literalinclude:: ../../examples/developing/update.patch
:language: diff
Now, rebuild the hello.bst element.
.. raw:: html
:file: ../sessions/developing-build-after-changes.html
Note that if you run the command from inside the workspace, the element name is optional.
.. raw:: html
:file: ../sessions/developing-build-after-changes-workspace.html
Now running the hello command using bst shell:
.. raw:: html
:file: ../sessions/developing-shell-after-changes.html
This gives us the new message we changed in hello.c.
From this point we have several options. If the source is under version control
we can commit our changes and push them to the remote repository.
Making bigger changes
---------------------
The first time you build with your workspace BuildStream behaves very similarly to
normal. However for subsequent builds it does not run the configuration commands and
only runs the build commands. This can result in significant speed ups as the configuration
commands can be slow (maybe 20+ minutes for a moderate sized element)
Sometimes you do need to rerun the configuration command for a open workspace, this
can be done by resetting the workspace, and then running a build. However this will
cause all of your incremental work to be lost. In this case running a soft reset will
reset the trigger to run the configuration commands but will not change any files in you
workspace.
Reasons to soft reset a workspace include:
* changing the configuration command of a element.
* adding a new source that the configure command will spot and enable more code.
The soft reset can be performed by:
.. raw:: html
:file: ../sessions/developing-soft-reset.html
Then the next build will include the configuration commands. You must reset the workspace
every time you wish to trigger the configuration commands as only the first build
after the reset will run them.
Closing your workspace
----------------------
If we want to close the workspace and come back to our changes later, we can
.. raw:: html
:file: ../sessions/developing-close-workspace.html
We can then reopen the workspace later using:
.. raw:: html
:file: ../sessions/developing-reopen-workspace.html
The --no-checkout option tells BuildStream not to check the source out but to
instead hard-link to the workspace_hello directory.
Alternatively, if we wish to discard the changes we can use
.. raw:: html
:file: ../sessions/developing-reset-workspace.html
This resets the workspace to its original state.
To discard the workspace completely we can do:
.. raw:: html
:file: ../sessions/developing-discard-workspace.html
This will close the workspace and completely remove the workspace_hello
directory.
|