0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/lib
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
History 2023-10-15 13:33:16 -07:00
..
compiler_rt x86_64: implement float compare and cast builtins 2023-10-01 15:09:52 -04:00
docs autodoc: Add hidden class to [src] link when starting renderApi to only show it for functions (#17322) 2023-10-04 18:42:49 +02:00
include update C language headers to LLVM 17 2023-09-19 09:37:31 -07:00
init-exe std.Build: use Step.* instead of *Step 2023-05-03 20:55:29 -07:00
init-lib init-exe/init-lib template: fix use of install() and run() 2023-04-10 18:35:14 -07:00
libc glibc patch: remove some static asserts from fstatat 2023-10-13 19:32:54 -07:00
libcxx update libcxx to latest LLVM release/17.x 2023-09-19 09:37:53 -07:00
libcxxabi libcxxabi: update to LLVM 17 2023-09-19 09:37:31 -07:00
libunwind libunwind: update to LLVM 17 2023-09-19 09:37:31 -07:00
std Add preliminary support for Windows .manifest files 2023-10-15 13:33:16 -07:00
tsan update libcxx, libcxxabi, libunwind, and tsan to llvm 13 rc1 2021-08-16 23:32:13 -07:00
build_runner.zig zig build: add --fetch argument 2023-10-08 16:54:31 -07:00
c.zig std: finish cleanup up asm 2023-07-31 03:49:21 -04:00
compiler_rt.zig all: zig fmt and rename "@XToY" to "@YFromX" 2023-06-19 12:34:42 -07:00
ssp.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
test_runner.zig Build: fail tests that log errors, like zig test does 2023-08-25 15:36:25 -07:00
zig.h Remove @fabs, fabs and absCast/Int from std lib 2023-09-27 11:24:28 -07:00