diff options
author | Himbeer <himbeer@disroot.org> | 2024-07-31 16:54:34 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-07-31 16:54:34 +0200 |
commit | 07ca84475f66a1aa804ee28124a6c4a1ec519ceb (patch) | |
tree | e848d55b6a0e65e9bc77ab8f860eaa1e40d2a8b1 | |
parent | 50a346960a5a4a64bb3ce20e12d46e08b8244784 (diff) |
hello_world: Use srvre_sys library
-rw-r--r-- | examples/hello_world/build.zig | 7 | ||||
-rw-r--r-- | examples/hello_world/build.zig.zon | 40 | ||||
-rw-r--r-- | examples/hello_world/src/main.zig | 20 |
3 files changed, 17 insertions, 50 deletions
diff --git a/examples/hello_world/build.zig b/examples/hello_world/build.zig index 61c46d2..63c8626 100644 --- a/examples/hello_world/build.zig +++ b/examples/hello_world/build.zig @@ -26,6 +26,11 @@ pub fn build(b: *std.Build) void { // set a preferred release mode, allowing the user to decide how to optimize. const optimize = b.standardOptimizeOption(.{}); + const srvre_sys = b.dependency("srvre_sys", .{ + .target = target, + .optimize = optimize, + }); + const exe = b.addExecutable(.{ .name = "hello_world", .root_source_file = b.path("src/main.zig"), @@ -33,6 +38,8 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); + exe.root_module.addImport("srvre_sys", srvre_sys.module("srvre_sys")); + // This declares intent for the executable to be installed into the // standard location when the user invokes the "install" step (the default // step when running `zig build`). diff --git a/examples/hello_world/build.zig.zon b/examples/hello_world/build.zig.zon index 479f58d..2761d5d 100644 --- a/examples/hello_world/build.zig.zon +++ b/examples/hello_world/build.zig.zon @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Zig contributors +// SPDX-FileCopyrightText: 2024 Himbeer <himbeer@disroot.org> // // SPDX-License-Identifier: MIT @@ -19,42 +20,11 @@ // Once all dependencies are fetched, `zig build` no longer requires // internet connectivity. .dependencies = .{ - // See `zig fetch --save <url>` for a command-line interface for adding dependencies. - //.example = .{ - // // When updating this field to a new URL, be sure to delete the corresponding - // // `hash`, otherwise you are communicating that you expect to find the old hash at - // // the new URL. - // .url = "https://example.com/foo.tar.gz", - // - // // This is computed from the file contents of the directory of files that is - // // obtained after fetching `url` and applying the inclusion rules given by - // // `paths`. - // // - // // This field is the source of truth; packages do not come from a `url`; they - // // come from a `hash`. `url` is just one of many possible mirrors for how to - // // obtain a package matching this `hash`. - // // - // // Uses the [multihash](https://multiformats.io/multihash/) format. - // .hash = "...", - // - // // When this is provided, the package is found in a directory relative to the - // // build root. In this case the package's hash is irrelevant and therefore not - // // computed. This field and `url` are mutually exclusive. - // .path = "foo", - - // // When this is set to `true`, a package is declared to be lazily - // // fetched. This makes the dependency only get fetched if it is - // // actually used. - // .lazy = false, - //}, + .srvre_sys = .{ + .url = "https://codeberg.org/Himbeer/srvre_sys/archive/f469f25308cf4e3f6a7f6ccdd9a8f634e10452a2.tar.gz", + .hash = "1220ec0ff680d96104969de102f8a9dc85ea3c379297788659def198f04fb7cfd839", + }, }, - - // Specifies the set of files and directories that are included in this package. - // Only files and directories listed here are included in the `hash` that - // is computed for this package. - // Paths are relative to the build root. Use the empty string (`""`) to refer to - // the build root itself. - // A directory listed here means that all files within, recursively, are included. .paths = .{ // This makes *all* files, recursively, included in this package. It is generally // better to explicitly list the files and directories instead, to insure that diff --git a/examples/hello_world/src/main.zig b/examples/hello_world/src/main.zig index 6f1b546..d45eea1 100644 --- a/examples/hello_world/src/main.zig +++ b/examples/hello_world/src/main.zig @@ -2,22 +2,12 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later -export fn _start() void { - main(); -} +const srvre_sys = @import("srvre_sys"); +const os = srvre_sys.os; + +usingnamespace srvre_sys; pub fn main() void { const s = "Hello from U-mode init\r\n"; - asm volatile ( - \\ li a7, 100001 - \\ ecall - : - : [s] "{a0}" (s.ptr), - [n] "{a1}" (s.len), - ); - - asm volatile ( - \\ li a7, 100003 - \\ ecall - ::: "a7"); + _ = os.consoleWrite(s) catch unreachable; } |