zig/lib/std/Build/Step
Ryan Liptak 5f15acc463 Add preliminary support for Windows .manifest files
An embedded manifest file is really just XML data embedded as a RT_MANIFEST resource (ID = 24). Typically, the Windows-only 'Manifest Tool' (`mt.exe`) is used to embed manifest files, and `mt.exe` also seems to perform some transformation of the manifest data before embedding, but in testing it doesn't seem like the transformations are necessary to get the intended result.

So, to handle embedding manifest files, Zig now takes the following approach:

- Generate a .rc file with the contents `1 24 "path-to-manifest.manifest"`
- Compile that generated .rc file into a .res file
- Link the .res file into the final binary

This effectively achieves the same thing as `mt.exe` minus the validation/transformations of the XML data that it performs.

How this is used:

On the command line:
```
zig build-exe main.zig main.manifest
```
(on the command line, specifying a .manifest file when the target object format is not COFF is an error)

or in build.zig:

```
const exe = b.addExecutable(.{
    .name = "manifest-test",
    .root_source_file = .{ .path = "main.zig" },
    .target = target,
    .optimize = optimize,
    .win32_manifest = .{ .path = "main.manifest" },
});
```
(in build.zig, the manifest file is ignored if the target object format is not COFF)

Note: Currently, only one manifest file can be specified per compilation. This is because the ID of the manifest resource is currently always 1. Specifying multiple manifests could be supported if a way for the user to specify an ID for each manifest is added (manifest IDs must be a u16).

Closes #17406

options
2023-10-15 13:33:16 -07:00
..
CheckFile.zig Build.zig rename orgy (aka: #16353). Renames FileSource to LazyPath and removes functions that take literal paths instead of LazyPath. 2023-07-30 11:18:50 -07:00
CheckObject.zig std.macho: remove alignment from LoadCommandIterator 2023-10-03 14:55:17 -07:00
Compile.zig Add preliminary support for Windows .manifest files 2023-10-15 13:33:16 -07:00
ConfigHeader.zig std.Build.ConfigHeader: override include guard option for blank style (#17310) 2023-09-28 19:30:42 -04:00
Fmt.zig std.Build: use Step.* instead of *Step 2023-05-03 20:55:29 -07:00
InstallArtifact.zig std.Build.Step.InstallArtifact: disable emit-h 2023-07-30 17:22:54 -07:00
InstallDir.zig Add include_extensions to InstallDir Options (#17300) 2023-09-29 18:50:37 -04:00
InstallFile.zig Build.zig rename orgy (aka: #16353). Renames FileSource to LazyPath and removes functions that take literal paths instead of LazyPath. 2023-07-30 11:18:50 -07:00
ObjCopy.zig build/ObjCopy: strip debug info to a separate elf file. 2023-08-12 09:54:35 +02:00
Options.zig package manager: write deps in a flat format, eliminating the FQN concept 2023-09-15 14:04:23 -07:00
RemoveDir.zig std.Build: use Step.* instead of *Step 2023-05-03 20:55:29 -07:00
Run.zig Step.Run: change cwd to ?Build.LazyPath (#17418) 2023-10-10 18:39:44 -04:00
TranslateC.zig Allow Step.TranslateC to not link libc 2023-09-23 17:41:11 -07:00
WriteFile.zig std.Build.Step.WriteFile: fix call to nonexistent function 2023-07-31 14:23:57 +02:00