94 Commits

Author SHA1 Message Date
Andrew Kelley
b30ad74908 remove deprecated LazyPath.path union tag 2024-04-11 14:02:47 -07:00
Andrew Kelley
7fb5a0b18b introduce std.Build.path; deprecate LazyPath.relative
This adds the *std.Build owner to LazyPath so that lazy paths returned
from a dependency can be used in the application without friction or
footguns.

closes #19313
2024-04-10 15:02:20 -07:00
Carl Åstholm
eee5400b7d Account for dependency boundaries when duping headers
This is a temporary workaround that can be revered if/when 'path'
lazy paths are updated to encode which build root they are relative to.
2024-04-07 15:34:47 +02:00
Carl Åstholm
d99e44a157 Document added/updated functions
Also renames `addHeaders` to `addHeadersDirectory` for clarity.
2024-04-07 15:34:47 +02:00
Carl Åstholm
5af4e91e00 Oops, forgot to dupe installations in installLibraryHeaders
Added test coverage for `installLibraryHeaders`
2024-04-07 15:34:47 +02:00
Carl Åstholm
e16db29887 Implement WriteFile.addCopyDirectory 2024-04-07 15:34:47 +02:00
Carl Åstholm
2c7be4f8dd Create an include tree of installed headers for dependent modules 2024-04-07 15:34:46 +02:00
Carl Åstholm
0b7123f41d std.Build: correct behavior of Step.Compile.installHeader
Previously, `Step.Compile.installHeader` and friends would incorrectly
modify the default `install` top-level step, when the intent was for
headers to get bundled with and installed alongside an artifact. This
change set implements the intended behavior.

This carries with it some breaking changes; `installHeader` and
`installConfigHeader` both have new signatures, and
`installHeadersDirectory` and `installHeadersDirectoryOptions` have been
merged into `installHeaders`.
2024-04-07 15:32:44 +02:00
Jacob Young
eb723a4070 Update uses of @fieldParentPtr to use RLS 2024-03-30 20:50:48 -04:00
Jacob Young
e409afb79b Update uses of @fieldParentPtr to pass a pointer type 2024-03-30 20:50:48 -04:00
Ryan Liptak
4e428415e5 Build.Step.Compile: Add mingw_unicode_entry_point field
Corresponds to the `-municode` CLI flag
2024-03-27 10:06:06 +00:00
Tristan Ross
9d70d614ae
std.builtin: make link mode fields lowercase 2024-03-11 07:09:10 -07:00
Dillen Meijboom
377ecc6afb feat: add support for --enable-new-dtags and --disable-new-dtags 2024-03-06 17:52:05 -08:00
Jacob Young
d656c2a7ab test: rework how filtering works
* make test names contain the fully qualified name
 * make test filters match the fully qualified name
 * allow multiple test filters, where a test is skipped if it does not
   match any of the specified filters
2024-02-25 19:12:08 -08:00
David Rubin
3eacd1b2e5
change addCSourceFiles to use LazyPath instead Dependency (#19017)
Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
2024-02-24 16:12:04 -05:00
Andrew Kelley
54bbc73f85
Merge pull request #18712 from Vexu/std.options
std: make options a struct instance instead of a namespace
2024-02-09 13:38:42 -08:00
Andrew Kelley
105db13536 std.Build: implement --host-target, --host-cpu, --host-dynamic-linker
This also makes a long-overdue change of extracting common state from
Build into a shared Graph object.

Getting the semantics right for these flags turned out to be quite
tricky. In the end it works like this:
* The override only happens when the target is fully native, with no
  additional query parameters, such as versions or CPU features added.
* The override affects the resolved Target but leaves the original Query
  unmodified.
* The "is native?" detection logic operates on the original, unmodified
  query. This makes it possible to provide invalid host target
  information, causing confusing errors to occur. Don't do that.

There are some minor breaking changes to std.Build API such as the fact
that `b.zig_exe` is now moved to `b.graph.zig_exe`, as well as a handful
of other similar flags.
2024-02-02 20:43:01 -07:00
Jakub Konka
92deebcd66 cli+build: handle -ObjC flag and route it to MachO linker 2024-02-02 22:00:16 +01:00
Veikka Tuominen
a4f27e8987 remove std.io.Mode 2024-02-01 15:22:36 +02:00
Ian Johnson
27d2d8e81f Apply cflags from pkg-config to all dependent modules
Closes #18628

This commit splits the arguments obtained from pkg-config into two
groups, cflags and libs, and consistently applies the cflags to each
individual module linking the library while applying the libs only once
for each compilation.
2024-01-29 14:08:41 -08:00
Andrew Kelley
2dea375450 std.Build.Compile: handle modules sans root source files
Uses the new `-M[name][=src]` CLI syntax to omit the source when the
module does not have a zig root source file.

Only some kinds of link objects imply that this should happen.
2024-01-19 22:28:07 -07:00
Jakub Konka
a8b9f0cf22 std/Build/Step/Compile: do not propagate deps of complex addObject step 2024-01-14 23:07:21 +01:00
Carl Åstholm
0f9345ea9a Expose -f(no-)formatted-panics to the build system (again) 2024-01-13 22:07:34 -08:00
dhash
9bb6430318 Add support for --(no-)undefined-version
Co-authored-by: Motiejus Jakštys <motiejus@jakstys.lt>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
Co-authored-by: Samuel Cantero <scanterog@gmail.com>
Co-authored-by: Giorgos Georgiou <giorgos.georgiou@datadoghq.com>
Co-authored-by: Carl Åstholm <carl@astholm.se>
2024-01-09 17:24:11 +01:00
Andrew Kelley
60094cc3fc
Merge pull request #18491 from ziglang/fix-mod-link-obj-path
std.Build.Step.Compile: fix link object paths
2024-01-09 01:11:15 -08:00
Andrew Kelley
cf5a5dc8b5 std.Build.Step.Compile: fix link object paths
They were being resolved relative to the wrong owner.

closes #18460
2024-01-08 18:24:14 -07:00
Carl Åstholm
9c8c9b7cc8 Build: Use LazyPath for version scripts 2024-01-09 01:47:54 +02:00
Andrew Kelley
60958d135f std.Build.Step.Compile: fix passing wrong Builder to getPath
This resulted in an error building a transitive module dependency.
2024-01-02 18:22:11 -07:00
Andrew Kelley
eae6d45cde CLI: introduce global -I args for C include paths
This isn't technically needed since per-module -I args can suffice, but
this can produce very long CLI invocations when several --mod args are
combined with --search-prefix args since the -I args have to be repeated
for each module.

This is a partial revert of ecbe8bbf2df2ed4d473efbc32e0b6d7091fba76f.
2024-01-01 19:49:08 -07:00
Andrew Kelley
8fa4496909 std.Build.Step.Compile: fix search prefix lowering
Instead of adding -I and -L flags at the end of the CLI, they need to be
added for every module, after the module-specific flags.
2024-01-01 19:49:08 -07:00
Andrew Kelley
1ef4df9044 std.Build.Step.Compile: support modules with different args
Now that the CLI supports per-module settings, the build system takes
advantage of this when lowering a compilation to the command line.
2024-01-01 17:51:21 -07:00
Andrew Kelley
ca77c3bacc std.Build.Step.Compile: restore previous step name
Print using the target query rather than the resolved target. This makes
it print "native" when compiling for the native target.
2024-01-01 17:51:20 -07:00
Andrew Kelley
b92e30ff0b std.Build.ResolvedTarget: rename target field to result
This change is seemingly insignificant but I actually agonized over this
for three days. Some other things I considered:

* (status quo in master branch) make Compile step creation functions
  accept a Target.Query and delete the ResolvedTarget struct.
  - downside: redundantly resolve target queries many times
* same as before but additionally add a hash map to cache target query
  resolutions.
  - downside: now there is a hash map that doesn't actually need to
    exist, just to make the API more ergonomic.
* add is_native_os and is_native_abi fields to std.Target and use it
  directly as the result of resolving a target query.
  - downside: they really don't belong there. They would be available
    as comptime booleans via `@import("builtin")` but they should not
    be exposed that way.

With this change the downsides are:
* the option name of addExecutable and friends is `target` instead of
  `resolved_target` matching the type name.
  - upside: this does not break compatibility with existing build
    scripts
* you likely end up seeing `target.result.cpu.arch` rather than
  `target.cpu.arch`.
  - upside: this is an improvement over `target.target.cpu.arch` which
    it was before this commit.
  - downside: `b.host.target` is now `b.host.result`.
2024-01-01 17:51:18 -07:00
Andrew Kelley
dbdb87502d std.Target: add DynamicLinker 2024-01-01 17:51:18 -07:00
Andrew Kelley
3179f58c41 rename std.zig.CrossTarget to std.Target.Query 2024-01-01 17:51:18 -07:00
Andrew Kelley
04480f72d8 fix linker test regressions
Caused by problems with transitive dependencies
2024-01-01 17:51:18 -07:00
Andrew Kelley
142471fcc4 zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.

The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.

* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
  std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
  std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
  `std.Build.Module.addCMacro` is provided.
  - remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
  - use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
  - use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
  Along with other fields, those unspecified options will be inherited
  from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
  to get the host target.
2024-01-01 17:51:18 -07:00
Andrew Kelley
579f572cf2 zig build system: remove vcpkg integration
Instead of vcpkg, users are encouraged to use the Zig package manager to
fulfill dependencies on Windows.
2024-01-01 17:51:18 -07:00
Andrew Kelley
c20ad51c62 introduce std.Build.Module and extract some logic into it
This moves many settings from `std.Build.Step.Compile` and into
`std.Build.Module`, and then makes them transitive.

In other words, it adds support for exposing Zig modules in packages,
which are configured in various ways, such as depending on other link
objects, include paths, or even a different optimization mode.

Now, transitive dependencies will be included in the compilation, so you
can, for example, make a Zig module depend on some C source code, and
expose that Zig module in a package.

Currently, the compiler frontend autogenerates only one
`@import("builtin")` module for the entire compilation, however, a
future enhancement will be to make it honor the differences in modules,
so that modules can be compiled with different optimization modes, code
model, valgrind integration, or even target CPU feature set.

closes #14719
2024-01-01 17:51:18 -07:00
Carl Åstholm
779b8e2598 Expose -f(no-)formatted-panics to the build system 2023-12-16 04:08:05 +02:00
xdBronch
5de0636577 expose to build system 2023-11-13 14:57:51 +02:00
Luuk de Gram
c893f83715
cli: consolidate entry point flags 2023-11-03 12:48:53 +01:00
Luuk de Gram
938f9dea37
update linker tests
This updates all linker tests to include `no_entry` as well as changes
all tests to executable so they do not need to be updated later when
the in-house WebAssembly linker supports dynamic libraries.
2023-11-03 12:48:53 +01:00
Luuk de Gram
1cb7a01b25
wasm-linker: implement -fno-entry flag
This adds support for the `-fno-entry` and `-fentry` flags respectively, for
zig build-{exe/lib} and the build system. For `zig cc` we use the `--no-entry`
flag to be compatible with clang and existing tooling.

In `start.zig` we now make the main function optional when the target is
WebAssembly, as to allow for the build-exe command in combination with
`-fno-entry`.

When the execution model is set, and is set to 'reactor', we now verify
when an entry name is given it matches what is expected. When no entry
point is given, we set it to `_initialize` by default. This means the user
will also be met with an error when they use the reactor model, but did
not provide the correct function.
2023-11-03 12:48:52 +01:00
Jakub Konka
bc081901dc Step.Compile: differentiate between fuzzy and exact matches for compile errors 2023-10-25 11:40:16 +02:00
Jakub Konka
89563f07e3 build: match and ignore /?/ in expected compile errors 2023-10-24 22:08:36 +02:00
Jan Philipp Hafer
fd2239bde9 child_process + Build: rename exec to run + all related code
Justification: exec, execv etc are unix concepts and portable version
should be called differently.

Do no touch non-Zig code. Adjust error names as well, if associated.
Closes #5853.
2023-10-22 14:47:20 -04:00
Andrew Kelley
a361f37b1c
Merge pull request #17608 from squeek502/resinator-fixes
resinator: Fix `INCLUDE` var handling and sync with upstream
2023-10-20 03:49:14 -04:00
dweiller
db18b562ac std.Build: do not assume custom test runners support client-server mode 2023-10-20 02:39:17 -04:00
Ryan Liptak
8ec04b567e Error if an .rc file uses the 'preprocess only' or 'no preprocess' flags 2023-10-18 18:30:32 -07:00