all: move standalone libraries to libs/ subdirectory

The root dir of our repository has grown quite a lot the past few months.

I'd like to make it more clear where the bulk of the engine lives (`src/`) and
also make it more clear which Mach libraries are consumable as standalone projects.

As for the name of this directory, `libs` was my first choice but there's a bit of
a convention of that being external libraries in Zig projects _today_, while these
are libraries maintained as part of Mach in this repository - not external ones.

We will name this directory `libs`, and if we have a need for external libraries
we will use `external` or `deps` for that directory name. I considered other names
such as `components`, `systems`, `modules` (which are bad as they overlap with
major ECS / engine concepts), and it seems likely the official Zig package manager
will break the convention of using a `libs` dir anyway.

Performed via:

```sh
mkdir libs/
git mv freetype libs/
git mv basisu libs/
git mv gamemode libs/
git mv glfw libs/
git mv gpu libs/
git mv gpu-dawn libs/
git mv sysaudio libs/
git mv sysjs libs/
git mv ecs libs/
```

git-subtree-dir: glfw
git-subtree-mainline: 0d5b853443
git-subtree-split: 572d1144f11b353abdb64fff828b25a4f0fbb7ca

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>

git mv ecs libs/

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-26 13:29:04 -07:00 committed by Stephen Gutekanst
parent 79ec61396f
commit 0645429df9
240 changed files with 6 additions and 6 deletions

View file

@ -1,141 +0,0 @@
const std = @import("std");
const mem = std.mem;
const testing = std.testing;
const builtin = @import("builtin");
const Backend = if (builtin.cpu.arch == .wasm32) @import("webaudio.zig") else switch (builtin.os.tag) {
.linux,
.windows,
.macos,
.ios,
=> @import("soundio.zig"),
else => @compileError("unsupported os"),
};
pub const Error = Backend.Error;
pub const Device = Backend.Device;
pub const DeviceIterator = Backend.DeviceIterator;
pub const Mode = enum {
input,
output,
};
pub const Format = enum {
U8,
S16,
S24,
S32,
F32,
};
pub const DeviceDescriptor = struct {
mode: ?Mode = null,
format: ?Format = null,
is_raw: ?bool = null,
channels: ?u8 = null,
sample_rate: ?u32 = null,
id: ?[:0]const u8 = null,
name: ?[]const u8 = null,
};
const Audio = @This();
backend: Backend,
pub fn init() Error!Audio {
return Audio{
.backend = try Backend.init(),
};
}
pub fn deinit(self: Audio) void {
self.backend.deinit();
}
pub fn waitEvents(self: Audio) void {
self.backend.waitEvents();
}
pub fn requestDevice(self: Audio, config: DeviceDescriptor) Error!Device {
return self.backend.requestDevice(config);
}
pub fn inputDeviceIterator(self: Audio) DeviceIterator {
return self.backend.inputDeviceIterator();
}
pub fn outputDeviceIterator(self: Audio) DeviceIterator {
return self.backend.outputDeviceIterator();
}
test "list devices" {
const a = try init();
defer a.deinit();
var iter = a.inputDeviceIterator();
while (try iter.next()) |_| {}
}
test "connect to device" {
const a = try init();
defer a.deinit();
const d = try a.requestDevice(.{ .mode = .output });
defer d.deinit();
}
test "connect to device from descriptor" {
const a = try init();
defer a.deinit();
var iter = a.outputDeviceIterator();
var device_desc = (try iter.next()) orelse return error.NoDeviceFound;
const d = try a.requestDevice(device_desc);
defer d.deinit();
}
test "requestDevice behavior: null is_raw" {
const a = try init();
defer a.deinit();
var iter = a.outputDeviceIterator();
var device_desc = (try iter.next()) orelse return error.NoDeviceFound;
const bad_desc = DeviceDescriptor{
.is_raw = null,
.mode = device_desc.mode,
.id = device_desc.id,
};
try testing.expectError(error.InvalidParameter, a.requestDevice(bad_desc));
}
test "requestDevice behavior: null mode" {
const a = try init();
defer a.deinit();
var iter = a.outputDeviceIterator();
var device_desc = (try iter.next()) orelse return error.NoDeviceFound;
const bad_desc = DeviceDescriptor{
.is_raw = device_desc.is_raw,
.mode = null,
.id = device_desc.id,
};
try testing.expectError(error.InvalidParameter, a.requestDevice(bad_desc));
}
test "requestDevice behavior: invalid id" {
return error.SkipZigTest;
// const a = try init();
// defer a.deinit();
// var iter = a.outputDeviceIterator();
// var device_desc = (try iter.next()) orelse return error.NoDeviceFound;
// const bad_desc = DeviceDescriptor{
// .is_raw = device_desc.is_raw,
// .mode = device_desc.mode,
// .id = "wrong-id",
// };
// try testing.expectError(error.DeviceUnavailable, a.requestDevice(bad_desc));
}