these are old changes, but I believe part of 0.11 from a while back
This commit is contained in:
parent
c364efd8e8
commit
cfdf4a3141
|
@ -3,8 +3,8 @@ const CopyStep = @This();
|
|||
|
||||
step: std.build.Step,
|
||||
builder: *std.build.Builder,
|
||||
from_path: []const u8 = null,
|
||||
to_path: []const u8 = null,
|
||||
from_path: ?[]const u8 = null,
|
||||
to_path: ?[]const u8 = null,
|
||||
|
||||
pub fn create(
|
||||
b: *std.build.Builder,
|
||||
|
@ -29,8 +29,8 @@ pub fn create(
|
|||
|
||||
fn make(step: *std.build.Step) !void {
|
||||
const self = @fieldParentPtr(CopyStep, "step", step);
|
||||
std.fs.copyFileAbsolute(self.from_path, self.to_path, .{}) catch |e| {
|
||||
std.log.err("Error copying {s} to {s}: {s}", .{ self.from_path, self.to_path, e });
|
||||
std.fs.copyFileAbsolute(self.from_path.?, self.to_path.?, .{}) catch |e| {
|
||||
std.log.err("Error copying {s} to {s}: {}", .{ self.from_path.?, self.to_path.?, e });
|
||||
std.os.exit(1);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ url: []const u8,
|
|||
name: []const u8,
|
||||
branch: ?[]const u8 = null,
|
||||
sha: []const u8,
|
||||
path: []const u8 = null,
|
||||
path: ?[]const u8 = null,
|
||||
sha_check: ShaCheck = .warn,
|
||||
fetch_enabled: bool,
|
||||
|
||||
|
@ -82,12 +82,12 @@ fn hasDependency(step: *const std.build.Step, dep_candidate: *const std.build.St
|
|||
fn make(step: *std.build.Step) !void {
|
||||
const self = @fieldParentPtr(GitRepoStep, "step", step);
|
||||
|
||||
std.fs.accessAbsolute(self.path, std.fs.File.OpenFlags{ .read = true }) catch {
|
||||
std.fs.accessAbsolute(self.path.?, .{ .mode = .read_only }) catch {
|
||||
const branch_args = if (self.branch) |b| &[2][]const u8{ " -b ", b } else &[2][]const u8{ "", "" };
|
||||
if (!self.fetch_enabled) {
|
||||
std.debug.print("Error: git repository '{s}' does not exist\n", .{self.path});
|
||||
std.debug.print("Error: git repository '{s}' does not exist\n", .{self.path.?});
|
||||
std.debug.print(" Use -Dfetch to download it automatically, or run the following to clone it:\n", .{});
|
||||
std.debug.print(" git clone {s}{s}{s} {s} && git -C {3s} checkout {s} -b for_ziget\n", .{ self.url, branch_args[0], branch_args[1], self.path, self.sha });
|
||||
std.debug.print(" git clone {s}{s}{s} {s} && git -C {3s} checkout {s} -b for_ziget\n", .{ self.url, branch_args[0], branch_args[1], self.path.?, self.sha });
|
||||
std.os.exit(1);
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ fn make(step: *std.build.Step) !void {
|
|||
try args.append(self.url);
|
||||
// TODO: clone it to a temporary location in case of failure
|
||||
// also, remove that temporary location before running
|
||||
try args.append(self.path);
|
||||
try args.append(self.path.?);
|
||||
if (self.branch) |branch| {
|
||||
try args.append("-b");
|
||||
try args.append(branch);
|
||||
|
@ -112,7 +112,7 @@ fn make(step: *std.build.Step) !void {
|
|||
try run(self.builder, &[_][]const u8{
|
||||
"git",
|
||||
"-C",
|
||||
self.path,
|
||||
self.path.?,
|
||||
"checkout",
|
||||
self.sha,
|
||||
"-b",
|
||||
|
@ -123,7 +123,7 @@ fn make(step: *std.build.Step) !void {
|
|||
try run(self.builder, &[_][]const u8{
|
||||
"git",
|
||||
"-C",
|
||||
self.path,
|
||||
self.path.?,
|
||||
"submodule",
|
||||
"update",
|
||||
"--init",
|
||||
|
@ -144,7 +144,7 @@ fn checkSha(self: GitRepoStep) !void {
|
|||
.argv = &[_][]const u8{
|
||||
"git",
|
||||
"-C",
|
||||
self.path,
|
||||
self.path.?,
|
||||
"rev-parse",
|
||||
"HEAD",
|
||||
},
|
||||
|
@ -187,8 +187,7 @@ fn run(builder: *std.build.Builder, argv: []const []const u8) !void {
|
|||
std.log.debug("[RUN] {s}", .{msg.items});
|
||||
}
|
||||
|
||||
const child = try std.ChildProcess.init(argv, builder.allocator);
|
||||
defer child.deinit();
|
||||
var child = std.ChildProcess.init(argv, builder.allocator);
|
||||
|
||||
child.stdin_behavior = .Ignore;
|
||||
child.stdout_behavior = .Inherit;
|
||||
|
|
|
@ -44,7 +44,7 @@ fn make(step: *std.build.Step) !void {
|
|||
\\pub const abbreviated_hash = "{s}";
|
||||
\\pub const commit_date = "{s}";
|
||||
\\pub const branch = "{s}";
|
||||
\\pub const dirty = {b};
|
||||
\\pub const dirty = {};
|
||||
\\pub const pretty_version = "{s}";
|
||||
, .{
|
||||
version.hash,
|
||||
|
|
|
@ -68,7 +68,7 @@ pub fn build(b: *Builder) !void {
|
|||
test_step.dependOn(&version.step);
|
||||
|
||||
var codegen: ?*std.build.Step = null;
|
||||
if (target.getOs().tag == .linux) {
|
||||
if (target.getOs().tag == .linux and false) {
|
||||
// TODO: Support > linux with RunStep
|
||||
// std.build.RunStep.create(null,null).cwd(std.fs.path.resolve(b.build_root, "codegen")).addArgs(...)
|
||||
codegen = b.step("gen", "Generate zig service code from smithy models");
|
||||
|
@ -116,7 +116,7 @@ fn getDependency(comptime lib_prefix: []const u8, comptime name: []const u8, com
|
|||
|
||||
return std.build.Pkg{
|
||||
.name = name,
|
||||
.path = .{ .path = path },
|
||||
.source = .{ .path = path },
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ pub fn getZfetchPackage(b: *std.build.Builder, comptime lib_prefix: []const u8)
|
|||
|
||||
return std.build.Pkg{
|
||||
.name = "zfetch",
|
||||
.path = .{ .path = lib_prefix ++ "/src/main.zig" },
|
||||
.source = .{ .path = lib_prefix ++ "/src/main.zig" },
|
||||
.dependencies = dependencies,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,12 +8,16 @@ const std = @import("std");
|
|||
|
||||
pub fn addTestStep(b: *std.build.Builder, mode: std.builtin.Mode, packages: []std.build.Pkg) !*std.build.Step {
|
||||
const test_step = b.step("test", "Run all tests");
|
||||
var src_dir = try std.fs.openDirAbsolute(try std.fs.path.resolve(b.allocator, &[_][]const u8{
|
||||
const src_path = try std.fs.path.resolve(b.allocator, &[_][]const u8{
|
||||
b.build_root,
|
||||
"src",
|
||||
}), .{ .iterate = true });
|
||||
});
|
||||
defer b.allocator.free(src_path);
|
||||
var src_dir = try std.fs.openDirAbsolute(src_path, .{});
|
||||
defer src_dir.close();
|
||||
var iterator = src_dir.iterate();
|
||||
var iterable = try src_dir.openIterableDir(".", .{});
|
||||
defer iterable.close();
|
||||
var iterator = iterable.iterate();
|
||||
while (try iterator.next()) |entry| {
|
||||
if (std.mem.endsWith(u8, entry.name, ".zig")) {
|
||||
const name = try std.fmt.allocPrint(b.allocator, "src/{s}", .{entry.name});
|
||||
|
|
|
@ -40,11 +40,11 @@ pub fn build(b: *std.build.Builder) !void {
|
|||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
const test_step = b.step("test", "Run library tests");
|
||||
var build_dir = try std.fs.openDirAbsolute(b.build_root, .{});
|
||||
defer build_dir.close();
|
||||
var src_dir = try build_dir.openDir("src", .{ .iterate = true });
|
||||
var src_dir = try std.fs.openDirAbsolute(b.build_root, .{});
|
||||
defer src_dir.close();
|
||||
var iterator = src_dir.iterate();
|
||||
var iterable = try src_dir.openIterableDir(".", .{});
|
||||
defer iterable.close();
|
||||
var iterator = iterable.iterate();
|
||||
while (try iterator.next()) |entry| {
|
||||
if (std.mem.endsWith(u8, entry.name, ".zig") and
|
||||
!std.mem.eql(u8, entry.name, "main.zig"))
|
||||
|
|
|
@ -65,7 +65,7 @@ fn processFile(arg: []const u8, stdout: anytype, manifest: anytype) !void {
|
|||
}
|
||||
|
||||
fn generateServicesForFilePath(allocator: std.mem.Allocator, comptime terminator: []const u8, path: []const u8, writer: anytype) ![][]const u8 {
|
||||
const file = try std.fs.cwd().openFile(path, .{ .read = true, .write = false });
|
||||
const file = try std.fs.cwd().openFile(path, .{});
|
||||
defer file.close();
|
||||
return try generateServices(allocator, terminator, file, writer);
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ fn generateServices(allocator: std.mem.Allocator, comptime _: []const u8, file:
|
|||
try writer.print("pub const sigv4_name: []const u8 = \"{s}\";\n", .{sigv4_name});
|
||||
try writer.print("pub const name: []const u8 = \"{s}\";\n", .{name});
|
||||
// TODO: This really should just be ".whatevs". We're fully qualifying here, which isn't typical
|
||||
try writer.print("pub const aws_protocol: smithy.AwsProtocol = smithy.{s};\n\n", .{aws_protocol});
|
||||
try writer.print("pub const aws_protocol: smithy.AwsProtocol = smithy.{};\n\n", .{aws_protocol});
|
||||
_ = try writer.write("pub const service_metadata: struct {\n");
|
||||
try writer.print(" version: []const u8 = \"{s}\",\n", .{version});
|
||||
try writer.print(" sdk_id: []const u8 = \"{s}\",\n", .{sdk_id});
|
||||
|
@ -218,7 +218,7 @@ fn generateServices(allocator: std.mem.Allocator, comptime _: []const u8, file:
|
|||
try writer.print(" sigv4_name: []const u8 = \"{s}\",\n", .{sigv4_name});
|
||||
try writer.print(" name: []const u8 = \"{s}\",\n", .{name});
|
||||
// TODO: This really should just be ".whatevs". We're fully qualifying here, which isn't typical
|
||||
try writer.print(" aws_protocol: smithy.AwsProtocol = smithy.{s},\n", .{aws_protocol});
|
||||
try writer.print(" aws_protocol: smithy.AwsProtocol = smithy.{},\n", .{aws_protocol});
|
||||
_ = try writer.write("} = .{};\n");
|
||||
|
||||
// Operations
|
||||
|
@ -591,15 +591,15 @@ fn generateComplexTypeFor(shape_id: []const u8, members: []smithy.TypeMember, ty
|
|||
var found_name_trait = false;
|
||||
for (member.traits) |trait| {
|
||||
switch (trait) {
|
||||
.json_name => {
|
||||
.json_name => |n| {
|
||||
found_name_trait = true;
|
||||
field_name_mappings.appendAssumeCapacity(.{ .snake = try state.allocator.dupe(u8, snake_case_member), .original = trait.json_name });
|
||||
field_name_mappings.appendAssumeCapacity(.{ .snake = try state.allocator.dupe(u8, snake_case_member), .original = n });
|
||||
},
|
||||
.xml_name => {
|
||||
.xml_name => |n| {
|
||||
found_name_trait = true;
|
||||
field_name_mappings.appendAssumeCapacity(.{ .snake = try state.allocator.dupe(u8, snake_case_member), .original = trait.xml_name });
|
||||
field_name_mappings.appendAssumeCapacity(.{ .snake = try state.allocator.dupe(u8, snake_case_member), .original = n });
|
||||
},
|
||||
.http_query => http_query_mappings.appendAssumeCapacity(.{ .snake = try state.allocator.dupe(u8, snake_case_member), .original = trait.http_query }),
|
||||
.http_query => |n| http_query_mappings.appendAssumeCapacity(.{ .snake = try state.allocator.dupe(u8, snake_case_member), .original = n }),
|
||||
.http_header => http_header_mappings.appendAssumeCapacity(.{ .snake = try state.allocator.dupe(u8, snake_case_member), .original = trait.http_header }),
|
||||
.http_payload => {
|
||||
// Don't assert as that will be optimized for Release* builds
|
||||
|
|
|
@ -58,12 +58,12 @@ pub const Client = struct {
|
|||
/// parameters. If all parameters are known at comptime, the call function
|
||||
/// may be simpler to use. request parameter here refers to the action
|
||||
/// constant from the model, e.g. Request(services.lambda.list_functions)
|
||||
pub fn Request(comptime action: anytype) type {
|
||||
pub fn Request(comptime request_action: anytype) type {
|
||||
return struct {
|
||||
const ActionRequest = action.Request;
|
||||
const FullResponseType = FullResponse(action);
|
||||
const Self = @This();
|
||||
const action = action;
|
||||
const action = request_action;
|
||||
const meta_info = ActionRequest.metaInfo();
|
||||
const service_meta = meta_info.service_metadata;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ const US_ISOB_EAST_1_HASH = std.hash_map.hashString("us-isob-east-1");
|
|||
|
||||
const log = std.log.scoped(.awshttp);
|
||||
|
||||
const amazon_root_ca_1 = @embedFile("../Amazon_Root_CA_1.pem");
|
||||
const amazon_root_ca_1 = @embedFile("Amazon_Root_CA_1.pem");
|
||||
|
||||
pub const default_root_ca = amazon_root_ca_1;
|
||||
|
||||
|
|
10
src/date.zig
10
src/date.zig
|
@ -389,26 +389,26 @@ test "Convert timestamp to datetime" {
|
|||
|
||||
try std.testing.expectEqual(DateTime{ .year = 2020, .month = 11, .day = 1, .hour = 5, .minute = 6, .second = 7 }, timestampToDateTime(1604207167));
|
||||
// Get time for date: https://wtools.io/convert-date-time-to-unix-time
|
||||
try std.testing.expectEqual(DateTime{ .year = 2015, .month = 08, .day = 30, .hour = 12, .minute = 36, .second = 00 }, timestampToDateTime(1440938160));
|
||||
try std.testing.expectEqual(DateTime{ .year = 2015, .month = 8, .day = 30, .hour = 12, .minute = 36, .second = 0 }, timestampToDateTime(1440938160));
|
||||
}
|
||||
|
||||
test "Convert datetime to timestamp" {
|
||||
try std.testing.expectEqual(@as(i64, 1598607147), try dateTimeToTimestamp(DateTime{ .year = 2020, .month = 8, .day = 28, .hour = 9, .minute = 32, .second = 27 }));
|
||||
try std.testing.expectEqual(@as(i64, 1604207167), try dateTimeToTimestamp(DateTime{ .year = 2020, .month = 11, .day = 1, .hour = 5, .minute = 6, .second = 7 }));
|
||||
try std.testing.expectEqual(@as(i64, 1440938160), try dateTimeToTimestamp(DateTime{ .year = 2015, .month = 08, .day = 30, .hour = 12, .minute = 36, .second = 00 }));
|
||||
try std.testing.expectEqual(@as(i64, 1440938160), try dateTimeToTimestamp(DateTime{ .year = 2015, .month = 8, .day = 30, .hour = 12, .minute = 36, .second = 0 }));
|
||||
}
|
||||
|
||||
test "Convert ISO8601 string to timestamp" {
|
||||
try std.testing.expectEqual(DateTime{ .year = 2020, .month = 8, .day = 28, .hour = 9, .minute = 32, .second = 27 }, try parseIso8601ToDateTime("20200828T093227"));
|
||||
try std.testing.expectEqual(DateTime{ .year = 2020, .month = 8, .day = 28, .hour = 9, .minute = 32, .second = 27 }, try parseIso8601ToDateTime("2020-08-28T9:32:27Z"));
|
||||
try std.testing.expectEqual(DateTime{ .year = 2020, .month = 11, .day = 1, .hour = 5, .minute = 6, .second = 7 }, try parseIso8601ToDateTime("2020-11-01T5:06:7Z"));
|
||||
try std.testing.expectEqual(DateTime{ .year = 2015, .month = 08, .day = 30, .hour = 12, .minute = 36, .second = 00 }, try parseIso8601ToDateTime("2015-08-30T12:36:00.000Z"));
|
||||
try std.testing.expectEqual(DateTime{ .year = 2015, .month = 8, .day = 30, .hour = 12, .minute = 36, .second = 0 }, try parseIso8601ToDateTime("2015-08-30T12:36:00.000Z"));
|
||||
}
|
||||
test "Convert datetime to timestamp before 1970" {
|
||||
try std.testing.expectEqual(@as(i64, -449392815), try dateTimeToTimestamp(DateTime{ .year = 1955, .month = 10, .day = 05, .hour = 16, .minute = 39, .second = 45 }));
|
||||
try std.testing.expectEqual(@as(i64, -449392815), try dateTimeToTimestamp(DateTime{ .year = 1955, .month = 10, .day = 5, .hour = 16, .minute = 39, .second = 45 }));
|
||||
}
|
||||
|
||||
test "Convert whatever AWS is sending us to timestamp" {
|
||||
const string_date = "Fri, 03 Jun 2022 18:12:36 GMT";
|
||||
try std.testing.expectEqual(DateTime{ .year = 2022, .month = 06, .day = 03, .hour = 18, .minute = 12, .second = 36 }, try parseEnglishToDateTime(string_date));
|
||||
try std.testing.expectEqual(DateTime{ .year = 2022, .month = 6, .day = 3, .hour = 18, .minute = 12, .second = 36 }, try parseEnglishToDateTime(string_date));
|
||||
}
|
||||
|
|
6
src/git_version-orig.zig
Normal file
6
src/git_version-orig.zig
Normal file
|
@ -0,0 +1,6 @@
|
|||
pub const hash = "a662f6f674e66aa4cff435553e2593b7fd0a9aef";
|
||||
pub const abbreviated_hash = "a662f6f";
|
||||
pub const commit_date = "2022-06-05 18:34:39 -0700";
|
||||
pub const branch = "HEAD -> master, origin/master";
|
||||
pub const dirty = true;
|
||||
pub const pretty_version = "version a662f6f, committed at 2022-06-05 18:34:39 -0700 (dirty)";
|
|
@ -64,9 +64,7 @@ pub fn main() anyerror!void {
|
|||
defer tests.deinit();
|
||||
var args = std.process.args();
|
||||
var first = true;
|
||||
while (args.next(allocator)) |arg_or_error| {
|
||||
const arg = try arg_or_error;
|
||||
defer allocator.free(arg);
|
||||
while (args.next()) |arg| {
|
||||
if (first)
|
||||
std.log.info("{s} {s}", .{ arg, version.pretty_version });
|
||||
first = false;
|
||||
|
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||
const service_list = @import("models/service_manifest.zig");
|
||||
const expectEqualStrings = std.testing.expectEqualStrings;
|
||||
|
||||
pub fn Services(service_imports: anytype) type {
|
||||
pub fn Services(comptime service_imports: anytype) type {
|
||||
if (service_imports.len == 0) return services;
|
||||
// From here, the fields of our structure can be generated at comptime...
|
||||
var fields: [serviceCount(service_imports)]std.builtin.TypeInfo.StructField = undefined;
|
||||
|
@ -12,7 +12,7 @@ pub fn Services(service_imports: anytype) type {
|
|||
item.* = .{
|
||||
.name = @tagName(service_imports[i]),
|
||||
.field_type = @TypeOf(import_field),
|
||||
.default_value = import_field,
|
||||
.default_value = &import_field,
|
||||
.is_comptime = false,
|
||||
.alignment = 0,
|
||||
};
|
||||
|
|
|
@ -69,7 +69,7 @@ fn deinitObject(allocator: std.mem.Allocator, obj: anytype) void {
|
|||
// should we just use json parse options?
|
||||
pub const ParseOptions = struct {
|
||||
allocator: ?std.mem.Allocator = null,
|
||||
match_predicate: ?fn (a: []const u8, b: []const u8, options: xml.PredicateOptions) anyerror!bool = null,
|
||||
match_predicate_ptr: ?*const fn (a: []const u8, b: []const u8, options: xml.PredicateOptions) anyerror!bool = null,
|
||||
};
|
||||
|
||||
pub fn parse(comptime T: type, source: []const u8, options: ParseOptions) !Parsed(T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user