Commit graph

92 commits

Author SHA1 Message Date
Lue
a1fe671db8
all: build: fix sdkPath for relative @src.file / fix autocompletion with ZLS / IDEs (#661)
* all: build: fix sdkPath for relative @src.file

Prior to this commit, the build system heavily assumed that the result
`@src.file` would always be absolute, but this is no longer
guaranteed, likely due to there being no such thing as an "absolute
path" in WASI.

It appears that for normal invocations of `zig build`, it is safe to
assume that `@src.file` is absolute. However, when ZLS uses a custom
`build_runner.zig` to collect build configuration, `@src.file` is
actually relative to the current working directory, at least on my
system. For a while, this led to ZLS completions breaking entirely,
but presently it actually causes ZLS to crash!

The solution is not as simple as using relative `sdkPath` results
as-is, because the build system may attempt to resolve these paths
relative to build root, when the paths are actually relative to the
current working directory.

This leads to a sticky situation: the current working directory is a
runtime concept, but `@src.file` is resolved at compile time. However,
it appears that the build runner does not change current working
directory in between compilation and execution, so it is probably safe
to calculate `sdkPath` using runtime current working directory.

Still, this requires major changes with how `sdkPath` works, since
runtime computation and allocations are required. So pretty much
anything that relied on `sdkPath` being comptime-known has been
refactored in this commit.

The most severe result of this is that, for example, `gpu.pkg` can no
longer be a comptime-known constant: it has to be a runtime function
that takes a `*Builder` and returns a `Pkg`.

This commit deals with usages of `*.pkg` and `sdkPath` within Mach
itself, but projects that depend on Mach such as `mach-examples` will
almost certainly require changes as well.

* all: update README to reflect change in pkg usage

For details on updating your code to use this version, see: 88b1106953

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Co-authored-by: Stephen Gutekanst <stephen@hexops.com>
2023-01-02 01:23:46 -07:00
Ali Chraghi
7df12a0cae sysjs: automatically cast numbers to f64 & remove dead code 2022-12-25 13:36:03 -07:00
Ali Chraghi
f9b3ac2106 sysaudio: add webaudio backend 2022-12-25 13:36:03 -07:00
Benjaaaa
052d3a7da8
mach: fix compiler error regarding zig changes (#645) 2022-12-25 13:19:48 -07:00
Ali Chraghi
dc3f4b4c00 sysaudio:wasapi: wait for audio client to be ready 2022-12-18 18:02:31 -07:00
Ali Chraghi
0f3e28bc2a sysaudio: rewrite in zig
removes libsoundio dependency
2022-12-18 18:02:31 -07:00
Eric Joldasov
3397497cc9 sysaudio: use undefined in enums
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2022-12-14 02:18:21 -07:00
Slava Mostovoy
9b9852b56e
sysaudio: add ability to provide system_sdk options (#619) 2022-11-20 11:45:07 -07:00
Ali Chraghi
82e10f4f28
all: build: thisDir improvements (#570)
* build:all: thisDir improvements

more performant output, usage code reducement and compileError for wrong usage

* glfw: update deprecated code
2022-09-29 08:41:46 -07:00
Stephen Gutekanst
87fd2f82f6 sysaudio: add TODO regarding CI tests 2022-09-20 02:30:45 -07:00
Ali Chraghi
fe9ec5ba15 sysaudio: skip most tests
until we find a better way to test sysaudio via CI

a usable device may not be in the first index
2022-09-20 02:30:45 -07:00
Ali Chraghi
cb9fa97b31 sysaudio: move DataCallback into main.zig 2022-09-18 17:09:54 -07:00
locriacyber
b8c48d6321
all: remove ineffective _ = variable assignments (#530)
Lastest Zig complains about this, so they must removed to build.
2022-09-14 09:42:29 -07:00
Stephen Gutekanst
8113ca370d all: remove support for stage1
With almost all tests/examples working on all platforms now with the new compiler,
https://github.com/hexops/mach/issues/180, it's time to remove stage1 support.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-09-10 00:09:30 -07:00
Louis Pearson
70f4514c66 sysaudio: fix compile for web 2022-09-09 22:39:35 -07:00
Stephen Gutekanst
b72c2c978f sysaudio: target a desired buffer size / latency instead of assuming maximum
On most platforms the maximum amount of frames we can write is reasonable and
provides rarely noticable latency, but on some platforms (e.g. Windows prior
to Mason's patch) this is not true. It's a good idea therefor to target a
desired buffer size / number of frames to write per update, which is also exactly
what we must decide on the WebAudio backend. For now this is hard-coded in sysaudio
but we will expose this as a config option soon.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-09-09 22:34:43 -07:00
Stephen Gutekanst
c009ff3f90 sysaudio: fix buffer size on Windows
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-09-09 22:32:17 -07:00
Stephen Gutekanst
2ba7e48ac2 {sysjs,mach}: correctly pass sysjs dependency to sdk
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-09-09 21:55:38 -07:00
Stephen Gutekanst
7511392a02 sysaudio: switch to sdk builder pattern for system_sdk access
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-09-10 04:06:16 +00:00
Louis Pearson
f29c3aac08 sysaudio: fix clicking by tracking frame_offset
The offset into the planar_buffer was not being stored, so any time
multiple iterations occured the beginning of the wave was copied again,
instead of correctly copying the next part of the planar_buffer.
2022-09-10 04:06:16 +00:00
NewbLuck
46c4ea4ebd
all: update to use latest Zig master APIs (#521)
Co-authored-by: Scott Johnson <scott.johnson@furniturerow.com>
2022-09-10 02:07:30 +00:00
Louis Pearson
0e71daf504
{sysaudio,examples}: get sysaudio running on linux, separate audio configuration and descriptor (#518)
* Get sysaudio working on linux
* Separate audio configuration and descriptor
* Config/Descriptor -> Options/Properties
- Rename sysaudio DeviceConfig and DeviceDescriptor to Device.Options and Device.Properties
- example: Convert buffer before passing to renderWithType
* make Device.start() idempotent
2022-09-09 08:58:03 -07:00
Stephen Gutekanst
f807c85232 all: zig fmt
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-09-08 10:22:43 -07:00
Ali Chraghi
d96cc72859 sysaudio:build: remove 4th argument 2022-09-07 21:24:47 -07:00
Ali Chraghi
ad981944d4 all: revert cimport workaround 2022-09-07 21:24:47 -07:00
NewbLuck
5dfd677a37
sysaudio: add missing bool param to soundio call (#492) 2022-08-29 23:46:25 -07:00
NewbLuck
d9bd4d7d79
sysaudio: link missing library for Windows (#493) 2022-08-29 23:39:01 -07:00
NewbLuck
5d565f1f74
sysaudio: update tests to add needed allocator parameters (#491) 2022-08-29 23:37:30 -07:00
Stephen Gutekanst
ca3ac4ddad sysaudio: update soundio to correct windows build issues
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-29 22:51:32 -07:00
Ali Chraghi
80266c577e build: make libs tests seprate step 2022-08-29 05:59:52 -07:00
Stephen Gutekanst
22f14ee1ed sysaudio: libsoundio backend now functional
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-28 23:37:56 -07:00
Stephen Gutekanst
052be9a684 sysaudio: soundio: add pause wrapper
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-28 23:37:56 -07:00
Stephen Gutekanst
1dc3a4cba8 {sysaudio,examples}: add support for multiple channels
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-28 23:37:56 -07:00
Stephen Gutekanst
a18938a84f sysaudio: various fixes to WebAudio backend
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-28 23:37:56 -07:00
Stephen Gutekanst
09ec61b5cd sysaudio: add soundio_pkg as dependency of sysaudio.pkg
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-28 23:37:56 -07:00
Ali Chraghi
47bdb5ea03 build: don't install libs, fix glfw shared lib compilation,
standardilize `buildXXX` funcs
2022-08-28 10:45:09 -07:00
Stephen Gutekanst
1e0fa20622 all: employ self-hosted @cImport hack only on Darwin targets
This is an poor approximation for the host OS running Darwin, which
is good enough for now. In practice this means macOS works but can't
cross-compile (until the cImport issue is fixed in Zig itself), but
Windows/Linux are unaffected and should be able to build natively and
cross-compile.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-27 11:19:57 -07:00
Ali Chraghi
b9e00fdbb6 build: fix memory leaks 2022-08-27 11:05:36 -07:00
Stephen Gutekanst
45896bd6f5 sysaudio: improve self-hosted compiler support
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-26 18:53:54 -07:00
Stephen Gutekanst
f756af8bcd sysaudio: improve self-hosted compiler support (use darwin @cImport workaround)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-26 18:53:02 -07:00
Stephen Gutekanst
3011ed0ea4 all: update pull request template to reflect new libs/ dir
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-26 15:12:04 -07:00
Stephen Gutekanst
0645429df9 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>
2022-08-26 15:12:04 -07:00