Merge pull request #168 from SamTebbs33/feature/add-standardTargetOptions

Use the standardTargetOptions for built targets
This commit is contained in:
Edward Dean 2020-06-23 13:00:23 +01:00 committed by GitHub
commit 2d3ea3a81b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -28,7 +28,9 @@ zig build
```Shell ```Shell
zig build run zig build run
``` ```
or if you want to wait for a gdb connection: or if you want to wait for a gdb connection:
```Shell ```Shell
zig build debug-run zig build debug-run
``` ```
@ -68,9 +70,8 @@ Available test modes:
* `-D[build-mode]=`: Boolean (default `false`). * `-D[build-mode]=`: Boolean (default `false`).
* **build**: Build a certain build mode (*release-safe*, *release-fast*, *release-small*). Don't set in order to use the *debug* build mode. * **build**: Build a certain build mode (*release-safe*, *release-fast*, *release-small*). Don't set in order to use the *debug* build mode.
* **test**: Test a certain build mode (*release-safe*, *release-fast*, *release-small*). Don't set in order to use the *debug* build mode. * **test**: Test a certain build mode (*release-safe*, *release-fast*, *release-small*). Don't set in order to use the *debug* build mode.
* `-Darch=`: String (default `x86`). Currently the only supported value is `x86`. * `-Dtarget=`: String (default `i386-freestanding`). The standard target options for building with zig. Currently supported targets:
* **build**: Build for a certain architecture. * `i386-freestanding`
* **test**: Test a certain architecture.
* `-Ddisable-display`: Boolean (default `false`) * `-Ddisable-display`: Boolean (default `false`)
* This disables the display output of QEMU. * This disables the display output of QEMU.

View file

@ -19,12 +19,10 @@ const x86_i686 = CrossTarget{
}; };
pub fn build(b: *Builder) !void { pub fn build(b: *Builder) !void {
const arch = b.option([]const u8, "arch", "Architecture to build for: x86") orelse "x86"; const target = b.standardTargetOptions(.{ .whitelist = &[_]CrossTarget{x86_i686}, .default_target = x86_i686 });
const target: CrossTarget = if (std.mem.eql(u8, "x86", arch)) const arch = switch (target.getCpuArch()) {
x86_i686 .i386 => "x86",
else { else => unreachable,
std.debug.warn("Unsupported or unknown architecture '{}'\n", .{arch});
unreachable;
}; };
const fmt_step = b.addFmt(&[_][]const u8{ const fmt_step = b.addFmt(&[_][]const u8{