Skip to content

Commit aac7b03

Browse files
committed
Merge branch 'master' into zig-develop
2 parents 69ffe49 + e0e09fb commit aac7b03

File tree

5 files changed

+117
-87
lines changed

5 files changed

+117
-87
lines changed

.gitea/workflows/zig-previous.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: AWS-Zig Build
22
on:
3+
workflow_dispatch:
34
push:
45
branches:
56
- 'zig-0.13'

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
AWS SDK for Zig
22
===============
33

4-
[Zig 0.13](https://ziglang.org/download/#release-0.13.0):
4+
[Zig 0.14](https://ziglang.org/download/#release-0.14.0):
55

6-
[![Build Status: Zig 0.13.0](https://git.lerch.org/lobo/aws-sdk-for-zig/actions/workflows/build.yaml/badge.svg)](https://git.lerch.org/lobo/aws-sdk-for-zig/actions?workflow=build.yaml&state=closed)
6+
[![Build Status: Zig 0.14.0](https://git.lerch.org/lobo/aws-sdk-for-zig/actions/workflows/build.yaml/badge.svg)](https://git.lerch.org/lobo/aws-sdk-for-zig/actions?workflow=build.yaml&state=closed)
77

8-
[Last Mach Nominated Zig Version](https://machengine.org/about/nominated-zig/):
8+
[Last Mach Nominated Zig Version](https://machengine.org/docs/nominated-zig/):
99

1010
[![Build Status: Mach nominated](https://git.lerch.org/lobo/aws-sdk-for-zig/actions/workflows/zig-mach.yaml/badge.svg)](https://git.lerch.org/lobo/aws-sdk-for-zig/actions?workflow=zig-mach.yaml&state=closed)
1111

1212
[Nightly Zig](https://ziglang.org/download/):
1313

1414
[![Build Status: Zig Nightly](https://git.lerch.org/lobo/aws-sdk-for-zig/actions/workflows/zig-nightly.yaml/badge.svg)](https://git.lerch.org/lobo/aws-sdk-for-zig/actions?workflow=zig-nightly.yaml&state=closed)
1515

16-
**NOTE ON BUILD STATUS**: The nightly/mach nominated version of this currently
17-
panics under CI, but I have not yet reproduced this panic. Running manually on
18-
multiple machines appears to be working properly
16+
[Zig 0.13](https://ziglang.org/download/#release-0.13.0):
17+
18+
[![Build Status: Zig 0.13.0](https://git.lerch.org/lobo/aws-sdk-for-zig/actions/workflows/zig-previous.yaml/badge.svg)](https://git.lerch.org/lobo/aws-sdk-for-zig/actions?workflow=zig-previous.yaml&state=closed)
19+
1920

2021
Current executable size for the demo is 980k after compiling with -Doptimize=ReleaseSmall
21-
in x86_linux, and will vary based on services used. Tested targets:
22+
in x86_64-linux, and will vary based on services used. Tested targets:
2223

2324
* x86_64-linux
2425
* riscv64-linux
@@ -30,39 +31,56 @@ in x86_linux, and will vary based on services used. Tested targets:
3031

3132
Tested targets are built, but not continuously tested, by CI.
3233

33-
Zig-Develop Branch
34-
------------------
34+
Branches
35+
--------
3536

36-
This branch is intended for use with the in-development version of Zig. This
37-
starts with 0.12.0-dev.3180+83e578a18. This is aligned with [Mach Engine's Nominated
38-
Zig Versions](https://machengine.org/about/nominated-zig/). Nightly zig versions
39-
are difficult to keep up with and there is no special effort made there, build
40-
status is FYI (and used as a canary for nominated zig versions).
37+
* **master**: This branch tracks the latest released zig version
38+
* **zig-0.13**: This branch tracks the previous released zig version (0.13 currently).
39+
Support for the previous version is best effort, generally
40+
degrading over time. Fixes will generally appear in master, then
41+
backported into the previous version.
42+
* **zig-mach**: This branch tracks the latest mach nominated version. A separate
43+
branch is necessary as mach nominated is usually, but not always,
44+
more recent than the latest production zig. Support for the mach
45+
version is best effort.
46+
* **zig-develop**: This branch tracks zig nightly, and is used mainly as a canary
47+
for breaking changes that will need to be dealt with when
48+
a new mach nominated version or new zig release appear.
49+
Expect significant delays in any build failures.
50+
51+
Other branches/tags exist but are unsupported
4152

4253
Building
4354
--------
4455

4556
`zig build` should work. It will build the code generation project, fetch model
4657
files from upstream AWS Go SDK v2, run the code generation, then build the main
47-
project with the generated code. Testing can be done with `zig test`.
58+
project with the generated code. Testing can be done with `zig build test`. Note that
59+
this command tests on all supported architectures, so for a faster testing
60+
process, use `zig build smoke-test` instead.
4861

62+
To make development even faster, a build option is provided to avoid the use of
63+
LLVM. To use this, use the command `zig build -Dno-llvm smoke-test`. This
64+
can reduce build/test time 300%. Note, however, native code generation in zig
65+
is not yet complete, so you may see errors.
4966

5067
Using
5168
-----
5269

5370
This is designed for use with the Zig package manager, and exposes a module
5471
called "aws". Set up `build.zig.zon` and add the dependency/module to your project
5572
as normal and the package manager should do its thing. A full example can be found
56-
in [/example](example/README.md).
73+
in [/example](example/build.zig.zon). This can also be used at build time in
74+
a downstream project's `build.zig`.
5775

5876
Configuring the module and/or Running the demo
5977
----------------------------------------------
6078

6179
This library mimics the aws c libraries for it's work, so it operates like most
6280
other 'AWS things'. [/src/main.zig](src/main.zig) gives you a handful of examples
6381
for working with services. For local testing or alternative endpoints, there's
64-
no real standard, so there is code to look for `AWS_ENDPOINT_URL` environment
65-
variable that will supersede all other configuration.
82+
no real standard, so there is code to look for an environment variable
83+
`AWS_ENDPOINT_URL` variable that will supersede all other configuration.
6684

6785
Limitations
6886
-----------
@@ -83,13 +101,6 @@ TODO List:
83101
* Implement timeouts and other TODO's in the code
84102
* Add option to cache signature keys
85103

86-
Services without TLS 1.3 support
87-
--------------------------------
88-
89-
All AWS services should support TLS 1.3 at this point, but there are many regions
90-
and several partitions, and not all of them have been tested, so your mileage
91-
may vary. If something doesn't work, please submit an issue to let others know.
92-
93104
Dependency tree
94105
---------------
95106

build.zig

Lines changed: 78 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ pub fn build(b: *Builder) !void {
3434
"no-llvm",
3535
"Disable LLVM",
3636
) orelse false;
37-
3837
const broken_windows = b.option(
3938
bool,
4039
"broken-windows",
4140
"Windows is broken in this environment (do not run Windows tests)",
4241
) orelse false;
42+
const no_bin = b.option(bool, "no-bin", "skip emitting binary") orelse false;
4343
// TODO: Embed the current git version in the code. We can do this
4444
// by looking for .git/HEAD (if it exists, follow the ref to /ref/heads/whatevs,
4545
// grab that commit, and use b.addOptions/exe.addOptions to generate the
@@ -67,17 +67,6 @@ pub fn build(b: *Builder) !void {
6767
const smithy_module = smithy_dep.module("smithy");
6868
exe.root_module.addImport("smithy", smithy_module); // not sure this should be here...
6969

70-
// Expose module to others
71-
_ = b.addModule("aws", .{
72-
.root_source_file = b.path("src/aws.zig"),
73-
.imports = &.{.{ .name = "smithy", .module = smithy_module }},
74-
});
75-
76-
// Expose module to others
77-
_ = b.addModule("aws-signing", .{
78-
.root_source_file = b.path("src/aws_signing.zig"),
79-
.imports = &.{.{ .name = "smithy", .module = smithy_module }},
80-
});
8170
// TODO: This does not work correctly due to https://github.com/ziglang/zig/issues/16354
8271
//
8372
// We are working here with kind of a weird dependency though. So we can do this
@@ -100,51 +89,73 @@ pub fn build(b: *Builder) !void {
10089
const run_step = b.step("run", "Run the app");
10190
run_step.dependOn(&run_cmd.step);
10291

103-
const gen_step = blk: {
104-
const cg = b.step("gen", "Generate zig service code from smithy models");
92+
const cg = b.step("gen", "Generate zig service code from smithy models");
10593

106-
const cg_exe = b.addExecutable(.{
107-
.name = "codegen",
108-
.root_source_file = b.path("codegen/src/main.zig"),
109-
// We need this generated for the host, not the real target
110-
.target = b.graph.host,
111-
.optimize = if (b.verbose) .Debug else .ReleaseSafe,
112-
});
113-
cg_exe.use_llvm = !no_llvm;
114-
cg_exe.root_module.addImport("smithy", smithy_dep.module("smithy"));
115-
var cg_cmd = b.addRunArtifact(cg_exe);
116-
cg_cmd.addArg("--models");
117-
cg_cmd.addArg(try std.fs.path.join(
118-
b.allocator,
119-
&[_][]const u8{
120-
try b.dependency("models", .{}).path("").getPath3(b, null).toString(b.allocator),
121-
models_subdir,
122-
},
123-
));
124-
cg_cmd.addArg("--output");
125-
cg_cmd.addDirectoryArg(b.path("src/models"));
126-
if (b.verbose)
127-
cg_cmd.addArg("--verbose");
128-
// cg_cmd.step.dependOn(&fetch_step.step);
129-
// TODO: this should use zig_exe from std.Build
130-
// codegen should store a hash in a comment
131-
// this would be hash of the exe that created the file
132-
// concatenated with hash of input json. this would
133-
// allow skipping generated files. May not include hash
134-
// of contents of output file as maybe we want to tweak
135-
// manually??
136-
//
137-
// All the hashes can be in service_manifest.zig, which
138-
// could be fun to just parse and go nuts. Top of
139-
// file, generator exe hash. Each import has comment
140-
// with both input and output hash and we can decide
141-
// later about warning on manual changes...
142-
143-
cg.dependOn(&cg_cmd.step);
144-
break :blk cg;
145-
};
146-
147-
exe.step.dependOn(gen_step);
94+
const cg_exe = b.addExecutable(.{
95+
.name = "codegen",
96+
.root_source_file = b.path("codegen/src/main.zig"),
97+
// We need this generated for the host, not the real target
98+
.target = b.graph.host,
99+
.optimize = if (b.verbose) .Debug else .ReleaseSafe,
100+
});
101+
cg_exe.root_module.addImport("smithy", smithy_module);
102+
var cg_cmd = b.addRunArtifact(cg_exe);
103+
cg_cmd.addArg("--models");
104+
cg_cmd.addArg(try std.fs.path.join(
105+
b.allocator,
106+
&[_][]const u8{
107+
try b.dependency("models", .{}).path("").getPath3(b, null).toString(b.allocator),
108+
models_subdir,
109+
},
110+
));
111+
cg_cmd.addArg("--output");
112+
const cg_output_dir = cg_cmd.addOutputDirectoryArg("src/models");
113+
if (b.verbose)
114+
cg_cmd.addArg("--verbose");
115+
// cg_cmd.step.dependOn(&fetch_step.step);
116+
// TODO: this should use zig_exe from std.Build
117+
// codegen should store a hash in a comment
118+
// this would be hash of the exe that created the file
119+
// concatenated with hash of input json. this would
120+
// allow skipping generated files. May not include hash
121+
// of contents of output file as maybe we want to tweak
122+
// manually??
123+
//
124+
// All the hashes can be in service_manifest.zig, which
125+
// could be fun to just parse and go nuts. Top of
126+
// file, generator exe hash. Each import has comment
127+
// with both input and output hash and we can decide
128+
// later about warning on manual changes...
129+
130+
cg.dependOn(&cg_cmd.step);
131+
132+
exe.step.dependOn(cg);
133+
134+
// This allows us to have each module depend on the
135+
// generated service manifest.
136+
const service_manifest_module = b.createModule(.{
137+
.root_source_file = cg_output_dir.path(b, "service_manifest.zig"),
138+
.target = target,
139+
.optimize = optimize,
140+
});
141+
service_manifest_module.addImport("smithy", smithy_module);
142+
143+
exe.root_module.addImport("service_manifest", service_manifest_module);
144+
145+
// Expose module to others
146+
_ = b.addModule("aws", .{
147+
.root_source_file = b.path("src/aws.zig"),
148+
.imports = &.{
149+
.{ .name = "smithy", .module = smithy_module },
150+
.{ .name = "service_manifest", .module = service_manifest_module },
151+
},
152+
});
153+
154+
// Expose module to others
155+
_ = b.addModule("aws-signing", .{
156+
.root_source_file = b.path("src/aws_signing.zig"),
157+
.imports = &.{.{ .name = "smithy", .module = smithy_module }},
158+
});
148159

149160
// Similar to creating the run step earlier, this exposes a `test` step to
150161
// the `zig build --help` menu, providing a way for the user to request
@@ -174,8 +185,9 @@ pub fn build(b: *Builder) !void {
174185
.target = b.resolveTargetQuery(t),
175186
.optimize = optimize,
176187
});
177-
unit_tests.root_module.addImport("smithy", smithy_dep.module("smithy"));
178-
unit_tests.step.dependOn(gen_step);
188+
unit_tests.root_module.addImport("smithy", smithy_module);
189+
unit_tests.root_module.addImport("service_manifest", service_manifest_module);
190+
unit_tests.step.dependOn(cg);
179191
unit_tests.use_llvm = !no_llvm;
180192

181193
const run_unit_tests = b.addRunArtifact(unit_tests);
@@ -199,11 +211,16 @@ pub fn build(b: *Builder) !void {
199211
.optimize = optimize,
200212
});
201213
smoke_test.use_llvm = !no_llvm;
202-
smoke_test.root_module.addImport("smithy", smithy_dep.module("smithy"));
203-
smoke_test.step.dependOn(gen_step);
214+
smoke_test.root_module.addImport("smithy", smithy_module);
215+
smoke_test.root_module.addImport("service_manifest", service_manifest_module);
216+
smoke_test.step.dependOn(cg);
204217

205218
const run_smoke_test = b.addRunArtifact(smoke_test);
206219

207220
smoke_test_step.dependOn(&run_smoke_test.step);
208-
b.installArtifact(exe);
221+
if (no_bin) {
222+
b.getInstallStep().dependOn(&exe.step);
223+
} else {
224+
b.installArtifact(exe);
225+
}
209226
}

build.zig.zon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"build.zig",
77
"build.zig.zon",
88
"src",
9+
"codegen",
910
"README.md",
1011
"LICENSE",
1112
},

src/servicemodel.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const service_list = @import("models/service_manifest.zig");
2+
const service_list = @import("service_manifest");
33
const expectEqualStrings = std.testing.expectEqualStrings;
44

55
pub fn Services(comptime service_imports: anytype) type {

0 commit comments

Comments
 (0)