Fix build api breaks and morale (#85)

* fix build api breaks

* fix ci

* zig parser api update
wch-ch32v003
Matt Knight 2 years ago committed by Matt Knight
parent 0838f5809a
commit f42d279890

@ -16,12 +16,6 @@ jobs:
windows-latest, windows-latest,
macos-latest, macos-latest,
] ]
mode: [
debug,
release-safe,
release-fast,
release-small,
]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -34,14 +28,9 @@ jobs:
with: with:
version: master version: master
- name: Build and Test Debug - name: Build and Test
if: ${{ matrix.mode == 'debug' }}
run: zig build test run: zig build test
- name: Build and Test Release
if: ${{ matrix.mode != 'debug' }}
run: zig build test -D${{ matrix.mode }}
crosscompile-from-windows: crosscompile-from-windows:
runs-on: windows-latest runs-on: windows-latest
strategy: strategy:

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2022 Jimmi Holst Christensen Copyright (c) 2023 Jimmi Holst Christensen
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

@ -46,7 +46,7 @@ pub fn main() !void {
\\ \\
); );
// Initalize our diagnostics, which can be used for reporting useful errors. // Initialize our diagnostics, which can be used for reporting useful errors.
// This is optional. You can also pass `.{}` to `clap.parse` if you don't // This is optional. You can also pass `.{}` to `clap.parse` if you don't
// care about the extra information `Diagnostics` provides. // care about the extra information `Diagnostics` provides.
var diag = clap.Diagnostic{}; var diag = clap.Diagnostic{};
@ -171,7 +171,7 @@ pub fn main() !void {
// Skip exe argument // Skip exe argument
_ = iter.next(); _ = iter.next();
// Initalize our diagnostics, which can be used for reporting useful errors. // Initialize our diagnostics, which can be used for reporting useful errors.
// This is optional. You can also leave the `diagnostic` field unset if you // This is optional. You can also leave the `diagnostic` field unset if you
// don't care about the extra information `Diagnostic` provides. // don't care about the extra information `Diagnostic` provides.
var diag = clap.Diagnostic{}; var diag = clap.Diagnostic{};

@ -79,7 +79,7 @@ pub const Values = enum {
/// * "-abc=value" /// * "-abc=value"
/// * "-abcvalue" /// * "-abcvalue"
/// * Long ("--long-param"): Should be used for less common parameters, or when no single /// * Long ("--long-param"): Should be used for less common parameters, or when no single
/// character can describe the paramter. /// character can describe the parameter.
/// * They can take a value two different ways. /// * They can take a value two different ways.
/// * "--long-param value" /// * "--long-param value"
/// * "--long-param=value" /// * "--long-param=value"
@ -722,7 +722,7 @@ pub fn Result(
/// `T` can be any type and `Error` can be any error. You can pass `clap.parsers.default` if you /// `T` can be any type and `Error` can be any error. You can pass `clap.parsers.default` if you
/// just wonna get something up and running. /// just wonna get something up and running.
/// ///
/// Caller ownes the result and should free it by calling `result.deinit()` /// Caller owns the result and should free it by calling `result.deinit()`
pub fn parseEx( pub fn parseEx(
comptime Id: type, comptime Id: type,
comptime params: []const Param(Id), comptime params: []const Param(Id),
@ -744,7 +744,7 @@ pub fn parseEx(
}; };
while (try stream.next()) |arg| { while (try stream.next()) |arg| {
// TODO: We cannot use `try` inside the inline for because of a compiler bug that // TODO: We cannot use `try` inside the inline for because of a compiler bug that
// generates an infinit loop. For now, use a variable to store the error // generates an infinite loop. For now, use a variable to store the error
// and use `try` outside. The downside of this is that we have to use // and use `try` outside. The downside of this is that we have to use
// `anyerror` :( // `anyerror` :(
var res: anyerror!void = {}; var res: anyerror!void = {};
@ -1045,11 +1045,11 @@ pub const Help = struct {
pub const HelpOptions = struct { pub const HelpOptions = struct {
/// Render the description of a parameter in a simular way to how markdown would render /// Render the description of a parameter in a simular way to how markdown would render
/// such a string. This means that single newlines wont be respected unless followed by /// such a string. This means that single newlines won't be respected unless followed by
/// bullet points or other markdown elements. /// bullet points or other markdown elements.
markdown_lite: bool = true, markdown_lite: bool = true,
/// Wether `help` should print the description of a parameter on a new line instead of after /// Whether `help` should print the description of a parameter on a new line instead of after
/// the parameter names. This options works together with `description_indent` to change /// the parameter names. This options works together with `description_indent` to change
/// where descriptions are printed. /// where descriptions are printed.
/// ///
@ -1071,7 +1071,7 @@ pub const HelpOptions = struct {
/// changes the output. /// changes the output.
description_indent: usize = 8, description_indent: usize = 8,
/// How much to indent each paramter. /// How much to indent each parameter.
/// ///
/// indent=0, description_on_new_line=false, description_indent=4 /// indent=0, description_on_new_line=false, description_indent=4
/// ///
@ -1088,7 +1088,7 @@ pub const HelpOptions = struct {
indent: usize = 4, indent: usize = 4,
/// The maximum width of the help message. `help` will try to break the description of /// The maximum width of the help message. `help` will try to break the description of
/// paramters into multiple lines if they exeed this maximum. Setting this to the width /// parameters into multiple lines if they exceed this maximum. Setting this to the width
/// of the terminal is a nice way of using this option. /// of the terminal is a nice way of using this option.
max_width: usize = std.math.maxInt(usize), max_width: usize = std.math.maxInt(usize),
@ -1722,7 +1722,7 @@ pub fn usage(stream: anytype, comptime Id: type, params: []const Param(Id)) !voi
const prefix = if (param.names.short) |_| "-" else "--"; const prefix = if (param.names.short) |_| "-" else "--";
const name = if (param.names.short) |*s| const name = if (param.names.short) |*s|
// Seems the zig compiler is being a little wierd. I doesn't allow me to write // Seems the zig compiler is being a little weird. I doesn't allow me to write
// @as(*const [1]u8, s) // @as(*const [1]u8, s)
@ptrCast([*]const u8, s)[0..1] @ptrCast([*]const u8, s)[0..1]
else else

@ -15,7 +15,7 @@ pub fn main() !void {
\\ \\
); );
// Initalize our diagnostics, which can be used for reporting useful errors. // Initialize our diagnostics, which can be used for reporting useful errors.
// This is optional. You can also pass `.{}` to `clap.parse` if you don't // This is optional. You can also pass `.{}` to `clap.parse` if you don't
// care about the extra information `Diagnostics` provides. // care about the extra information `Diagnostics` provides.
var diag = clap.Diagnostic{}; var diag = clap.Diagnostic{};

@ -28,7 +28,7 @@ pub fn main() !void {
// Skip exe argument // Skip exe argument
_ = iter.next(); _ = iter.next();
// Initalize our diagnostics, which can be used for reporting useful errors. // Initialize our diagnostics, which can be used for reporting useful errors.
// This is optional. You can also leave the `diagnostic` field unset if you // This is optional. You can also leave the `diagnostic` field unset if you
// don't care about the extra information `Diagnostic` provides. // don't care about the extra information `Diagnostic` provides.
var diag = clap.Diagnostic{}; var diag = clap.Diagnostic{};

@ -4,9 +4,9 @@ const zlib = @import("test/zig-zlib/zlib.zig");
pub fn build(b: *std.build.Builder) !void { pub fn build(b: *std.build.Builder) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions(); const optimize = b.standardOptimizeOption(.{});
const xml2 = try libxml2.create(b, target, mode, .{ const xml2 = try libxml2.create(b, target, optimize, .{
// We don't have the required libs so don't build these // We don't have the required libs so don't build these
.iconv = false, .iconv = false,
.lzma = false, .lzma = false,
@ -15,7 +15,7 @@ pub fn build(b: *std.build.Builder) !void {
xml2.step.install(); xml2.step.install();
// Tests that we can depend on other libraries like zlib // Tests that we can depend on other libraries like zlib
const xml2_with_libs = try libxml2.create(b, target, mode, .{ const xml2_with_libs = try libxml2.create(b, target, optimize, .{
// We don't have the required libs so don't build these // We don't have the required libs so don't build these
.iconv = false, .iconv = false,
.lzma = false, .lzma = false,
@ -23,11 +23,13 @@ pub fn build(b: *std.build.Builder) !void {
// Testing this // Testing this
.zlib = true, .zlib = true,
}); });
const z = zlib.create(b, target, mode); const z = zlib.create(b, target, optimize);
z.link(xml2_with_libs.step, .{}); z.link(xml2_with_libs.step, .{});
const static_binding_test = b.addTest("test/basic.zig"); const static_binding_test = b.addTest(.{
static_binding_test.setBuildMode(mode); .root_source_file = .{ .path = "test/basic.zig" },
.optimize = optimize,
});
xml2.link(static_binding_test); xml2.link(static_binding_test);
const test_step = b.step("test", "Run tests"); const test_step = b.step("test", "Run tests");

@ -1,5 +1,21 @@
{ {
"nodes": { "nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1659877975,
@ -71,15 +87,16 @@
}, },
"zig": { "zig": {
"inputs": { "inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1671668597, "lastModified": 1675466928,
"narHash": "sha256-oD+Zx3IeXx2d91AiD5O74P4582iRPTPabCt6HDhagSo=", "narHash": "sha256-H4D7cT/I6SptKVNoIiq+DuEKHhYDi3O8SzkjC+gLxSk=",
"owner": "mitchellh", "owner": "mitchellh",
"repo": "zig-overlay", "repo": "zig-overlay",
"rev": "64fcf1f2efcc63e97830e203f8e64ca20137ffa2", "rev": "ca04c57ef44b2f6f8d182dbc4eae50986aa2006e",
"type": "github" "type": "github"
}, },
"original": { "original": {

@ -92,12 +92,14 @@ pub const Options = struct {
pub fn create( pub fn create(
b: *std.build.Builder, b: *std.build.Builder,
target: std.zig.CrossTarget, target: std.zig.CrossTarget,
mode: std.builtin.Mode, optimize: std.builtin.OptimizeMode,
opts: Options, opts: Options,
) !Library { ) !Library {
const ret = b.addStaticLibrary("xml2", null); const ret = b.addStaticLibrary(.{
ret.setTarget(target); .name = "xml2",
ret.setBuildMode(mode); .target = target,
.optimize = optimize,
});
var flags = std.ArrayList([]const u8).init(b.allocator); var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit(); defer flags.deinit();

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save