authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-20 23:30:51-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-20 23:30:51-07:00
log9f363cd679a60be6d9a4378f9a50c050fde9708d
tree25ac02b1b31c6a8e05f354911a6110c5c4805e24
parentf645022d16361865e24582d28f1e62312fbc73bb

zig init: also create a build.zig.zon


3 files changed, 63 insertions(+), 0 deletions(-)

lib/init/build.zig.zon created+61
......@@ -0,0 +1,61 @@
1.{
2 .name = "$",
3 // This is a [Semantic Version](https://semver.org/).
4 // In a future version of Zig it will be used for package deduplication.
5 .version = "0.0.0",
6
7 // This field is optional.
8 // This is currently advisory only; Zig does not yet do anything
9 // with this value.
10 //.minimum_zig_version = "0.11.0",
11
12 // This field is optional.
13 // Each dependency must either provide a `url` and `hash`, or a `path`.
14 // `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
15 // Once all dependencies are fetched, `zig build` no longer requires
16 // Internet connectivity.
17 .dependencies = .{
18 // A future version of Zig will provide a `zig add <url>` subcommand
19 // for easily adding dependencies.
20 //.example = .{
21 // // When updating this field to a new URL, be sure to delete the corresponding
22 // // `hash`, otherwise you are communicating that you expect to find the old hash at
23 // // the new URL.
24 // .url = "https://example.com/foo.tar.gz",
25 //
26 // // This is computed from the file contents of the directory of files that is
27 // // obtained after fetching `url` and applying the inclusion rules given by
28 // // `paths`.
29 // //
30 // // This field is the source of truth; packages do not come from an `url`; they
31 // // come from a `hash`. `url` is just one of many possible mirrors for how to
32 // // obtain a package matching this `hash`.
33 // //
34 // // Uses the [multihash](https://multiformats.io/multihash/) format.
35 // .hash = "...",
36 //
37 // // When this is provided, the package is found in a directory relative to the
38 // // build root. In this case the package's hash is irrelevant and therefore not
39 // // computed.
40 // .path = "foo",
41 //},
42 },
43
44 // Specifies the set of files and directories that are included in this package.
45 // Only files and directories listed here are included in the `hash` that
46 // is computed for this package.
47 // Paths are relative to the build root. Use the empty string (`""`) to refer to
48 // the build root itself.
49 // A directory listed here means that all files within, recursively, are included.
50 .paths = .{
51 // This makes *all* files, recursively, included in this package. It is generally
52 // better to explicitly list the files and directories instead, to insure that
53 // fetching from tarballs, file system paths, and version control all result
54 // in the same contents hash.
55 "",
56 // For example...
57 //"build.zig",
58 //"build.zig.zon",
59 //"src",
60 },
61}
src/main.zig+1
......@@ -4883,6 +4883,7 @@ pub fn cmdInit(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
48834883 const max_bytes = 10 * 1024 * 1024;
48844884 const template_paths = [_][]const u8{
48854885 "build.zig",
4886 "build.zig.zon",
48864887 "src" ++ s ++ "main.zig",
48874888 "src" ++ s ++ "root.zig",
48884889 };
test/tests.zig+1
......@@ -783,6 +783,7 @@ pub fn addCliTests(b: *std.Build) *Step {
783783 init_exe.setName("zig init");
784784 init_exe.expectStdOutEqual("");
785785 init_exe.expectStdErrEqual("info: created build.zig\n" ++
786 "info: created build.zig.zon\n" ++
786787 "info: created src" ++ s ++ "main.zig\n" ++
787788 "info: created src" ++ s ++ "root.zig\n" ++
788789 "info: see `zig build --help` for a menu of options\n");