docs: update examples with += env operator and env usage docs
- foo.kap: document all three env operators (=, ?=, +=) in header, demonstrate += in env block with comments - postgres.kap: demonstrate += for appending security hardening flags - config.kap: demonstrate system-level += for inherited flags
This commit is contained in:
@@ -67,6 +67,8 @@ system {
|
|||||||
|
|
||||||
env {
|
env {
|
||||||
CFLAGS = "-O2 -march=native"
|
CFLAGS = "-O2 -march=native"
|
||||||
|
// packages inherit this appended flag
|
||||||
|
CFLAGS += "-pipe"
|
||||||
LDFLAGS = "-Wl,--as-needed"
|
LDFLAGS = "-Wl,--as-needed"
|
||||||
MAKEFLAGS = "-j8"
|
MAKEFLAGS = "-j8"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,17 @@
|
|||||||
*
|
*
|
||||||
* The backend generators handle all translation. Package authors only
|
* The backend generators handle all translation. Package authors only
|
||||||
* need to pick the semantic type that describes their daemon's behaviour.
|
* need to pick the semantic type that describes their daemon's behaviour.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ENV OPERATORS
|
||||||
|
* =============
|
||||||
|
* key = "val" hard set — overwrites any existing value
|
||||||
|
* key ?= "val" soft set — only applied if key is not already set
|
||||||
|
* key += "val" append — adds to existing value with a space separator
|
||||||
|
*
|
||||||
|
* Order matters. Subsequent entries in the same env block can append to
|
||||||
|
* earlier ones. System-level env (from config.kap) is applied before
|
||||||
|
* package env, so packages can += to flags set globally.
|
||||||
*/
|
*/
|
||||||
package "foo" {
|
package "foo" {
|
||||||
const version = "1.2.3"
|
const version = "1.2.3"
|
||||||
@@ -101,8 +112,12 @@ package "foo" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
env {
|
env {
|
||||||
|
// hard set — overwrites any existing CFLAGS
|
||||||
CFLAGS = "-O2 -march=native"
|
CFLAGS = "-O2 -march=native"
|
||||||
|
// append — now CFLAGS is "-O2 -march=native -pipe"
|
||||||
|
CFLAGS += "-pipe"
|
||||||
LDFLAGS = "-Wl,--as-needed"
|
LDFLAGS = "-Wl,--as-needed"
|
||||||
|
// soft set — only added if CFLAGS isn't already defined
|
||||||
CFLAGS ?= "-g"
|
CFLAGS ?= "-g"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ package "postgresql" {
|
|||||||
|
|
||||||
env {
|
env {
|
||||||
CFLAGS = "-O2"
|
CFLAGS = "-O2"
|
||||||
|
// append security hardening flags
|
||||||
|
CFLAGS += "-D_FORTIFY_SOURCE=2"
|
||||||
LDFLAGS = "-Wl,--as-needed"
|
LDFLAGS = "-Wl,--as-needed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user