Replacement for --pkg-begin ... --pkg-end command-line options

(Assuming 0.12.0 master.)

Relevant excerpt from zig build-exe --help:

Global Compile Options:
  --dep [[import=]name]     Add an entry to the next module's import table
  -M[name][=src]            Create a module based on the current per-module settings.
                            The first module is the main module.
                            "std" can be configured by omitting src
                            After a -M argument, per-module settings are reset.

Per-Module Compile Options:
  -target [name]            <arch><sub>-<os>-<abi> see the targets command
  -O [mode]                 Choose what to optimize for
  (... omitted for brevity ...)

Per-Module Link Options:
  -l[lib], --library [lib]       Link against system library (only if actually used)
  (... omitted for brevity ...)

The per-module options you specify apply to the next module defined with an -M option (--dep is also per-module option), which completes the defininition of that module and “pops” it off the stack. Some per-module options will be inherited by dependencies; for example, if you specify -OReleaseSafe for the main module (the first -M module) but not for dependencies, they will also compiled under the ReleaseSafe optimize mode.

In practice an invocation will look something like zig build-exe -target x86_64-windows-gnu -OReleaseSafe --dep foo --dep bar -Mroot=main.zig -Mfoo=foo.zig -Mbar=bar.zig.

2 Likes