Fix user guide examples for task dependencies
This commit is contained in:
parent
33b606ccb1
commit
d4ec07dd7a
@ -265,21 +265,17 @@ which they were added.
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
task "build" do
|
proj_env = env do |env|
|
||||||
env do |env|
|
env.Program("^/proj.elf", glob("src/**/*.c"))
|
||||||
env.Program("^^/proj.elf", glob("src/**/*.c"))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
task "flash", deps: "build" do
|
task "flash" do
|
||||||
sh "nrfjprog", "-f", "NRF52", "--program", env.expand("^^/proj.elf")
|
sh "nrfjprog", "-f", "NRF52", "--program", proj_env.expand("^/proj.elf")
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
In this example, the `flash` task depends on the `build` task.
|
In this example, the `flash` task would first build the proj.elf target and
|
||||||
So if the project had not yet been built, and the user executes
|
then flash it to target with the nrfjprog program.
|
||||||
`./rscons flash`, the project would first be built and then flashed to the
|
|
||||||
target.
|
|
||||||
|
|
||||||
If the `task` method is called again with the name of an already existing task,
|
If the `task` method is called again with the name of an already existing task,
|
||||||
the task is not overwritten, but rather modified.
|
the task is not overwritten, but rather modified.
|
||||||
@ -287,6 +283,34 @@ Any newly specified dependencies are added to the current dependencies.
|
|||||||
Any action block is appended to the task's list of action blocks to execute
|
Any action block is appended to the task's list of action blocks to execute
|
||||||
when the task is executed.
|
when the task is executed.
|
||||||
|
|
||||||
|
For example, with the `Rsconscript`:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
task "a" do
|
||||||
|
puts "A"
|
||||||
|
end
|
||||||
|
|
||||||
|
task "b" do
|
||||||
|
puts "B"
|
||||||
|
end
|
||||||
|
|
||||||
|
task "c", depends: "a" do
|
||||||
|
puts "C1"
|
||||||
|
end
|
||||||
|
|
||||||
|
task "c", depends: "b" do
|
||||||
|
puts "C2"
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
The following behavior is observed:
|
||||||
|
|
||||||
|
$ ./rscons c
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C1
|
||||||
|
C2
|
||||||
|
|
||||||
Note that for a simple project, the build script may not need to define any
|
Note that for a simple project, the build script may not need to define any
|
||||||
tasks at all and could just make use of the Rscons built-in default task (see
|
tasks at all and could just make use of the Rscons built-in default task (see
|
||||||
${#Default Task}).
|
${#Default Task}).
|
||||||
@ -378,7 +402,7 @@ argument (task name) automatically filled in by the shortcut method.
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
default deps: "unpack_compiler" do
|
default depends: "unpack_compiler" do
|
||||||
puts "default task"
|
puts "default task"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@ -386,7 +410,7 @@ end
|
|||||||
is equivalent to:
|
is equivalent to:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
task "default", deps: "unpack_compiler" do
|
task "default", depends: "unpack_compiler" do
|
||||||
puts "default task"
|
puts "default task"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@ -463,11 +487,11 @@ task "build" do
|
|||||||
...
|
...
|
||||||
end
|
end
|
||||||
|
|
||||||
task "flash" do
|
task "flash", depends: "build" do
|
||||||
...
|
...
|
||||||
end
|
end
|
||||||
|
|
||||||
default deps: "build"
|
default depends: "build"
|
||||||
```
|
```
|
||||||
|
|
||||||
Then when the user runs `./rscons` the "build" task will be executed.
|
Then when the user runs `./rscons` the "build" task will be executed.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user