summaryrefslogtreecommitdiff
path: root/doc/tutorial
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2025-02-17 16:53:53 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2025-02-17 16:57:45 +0100
commitc008c07656fff528c80add260397c7c7702aa2a8 (patch)
tree059be8f7a9f4ac3a7c3b7a93b9bf91be28f13b76 /doc/tutorial
parentf174823c4c079b5666247f6a5989fa37fee8c345 (diff)
downloadjustbuild-c008c07656fff528c80add260397c7c7702aa2a8.tar.gz
tutorial: update hello-world section
As our defaults rule supports flags common for C and C++ use them, especially as our example only uses common flags.
Diffstat (limited to 'doc/tutorial')
-rw-r--r--doc/tutorial/hello-world.md18
1 files changed, 12 insertions, 6 deletions
diff --git a/doc/tutorial/hello-world.md b/doc/tutorial/hello-world.md
index efffcfe3..dcad3ea0 100644
--- a/doc/tutorial/hello-world.md
+++ b/doc/tutorial/hello-world.md
@@ -202,22 +202,28 @@ In that module, we need to create the file
`tutorial-defaults/CC/TARGETS` that contains the target `"defaults"` and
specifies which toolchain and compile flags to use; it has to specify
the complete toolchain, but can specify a `"base"` toolchain to inherit
-from. In our case, we don't use any base, but specify all the required
-fields directly.
+from. In our case, we don't use any base.
``` {.jsonc srcname="tutorial-defaults/CC/TARGETS"}
{ "defaults":
{ "type": ["CC", "defaults"]
, "CC": ["cc"]
, "CXX": ["c++"]
- , "CFLAGS": ["-O2", "-Wall"]
- , "CXXFLAGS": ["-O2", "-Wall"]
+ , "ADD_COMPILE_FLAGS": ["-O2", "-Wall"]
, "AR": ["ar"]
, "PATH": ["/bin", "/usr/bin"]
}
}
```
+Here we used `"ADD_COMPILE_FLAGS"` to add flags for both, `C` and
+`C++` compilation. Those flags are added to the ones inherited
+from `"base"`, in our case (as we did not specify a `"base"`) the
+empty list. There are also `"ADD_CFLAGS"` and `"ADD_CXXFLAGS"` if
+we want to add flags for just `C` or just `C++`. Finally, there
+is also the possibility to explicitly specify `"CFLAGS"` and
+`"CXXFLAGS"` (completely ignoring anything inherited).
+
To use the project defaults, modify the existing `repos.json` to reflect
the following content:
@@ -277,7 +283,7 @@ INFO: Artifacts built, logical paths are:
$
```
-Note that the output binary may have changed due to different defaults.
+Note that the output binary has changed due to different defaults.
In this tutorial we simply set the correct parameters of the defaults target.
It is, however, not necessary to remember all the fields of a rule; we can
@@ -306,7 +312,7 @@ Modeling target dependencies
For demonstration purposes, we will separate the print statements into a
static library `greet`, which will become a dependency to our binary.
-Therefore, we create a new subdirectory `greet`
+Therefore, we create a new subdirectory `greet`
``` sh
$ mkdir -p ./greet