~novakane/agertu

agertu/src/main.zig -rw-r--r-- 1.7 KiB
9ea83d8fHugo Machet build: Bump to version 2.0.0-dev 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// This file is part of agertu
//
// Copyright (C) 2021-2022 Hugo Machet
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

const std = @import("std");
const build_options = @import("build_options");
const mem = std.mem;
const os = std.os;

const fcft = @import("fcft");

const Backend = @import("Backend.zig");
const Config = @import("Config.zig");
const event_loop = @import("event_loop.zig");
const util = @import("util.zig");

pub var backend: Backend = undefined;

pub fn main() anyerror!void {
    const args = os.argv;
    if (args.len > 1) {
        if (mem.eql(u8, "-version", mem.span(args[1]))) {
            try std.io.getStdOut().writeAll(build_options.version ++ "\n");
            os.exit(0);
        } else {
            try std.io.getStdErr().writeAll("usage: -version\n");
            os.exit(1);
        }
    }

    if (@import("builtin").mode == .Debug) {
        _ = fcft.init(.auto, true, .debug);
    } else {
        _ = fcft.init(.auto, false, .err);
    }
    defer fcft.fini();

    var config: Config = .{};
    try config.init();
    defer config.deinit();

    try backend.init(config);
    defer backend.deinit();

    try event_loop.run();
}