Windows build
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// the native libraries the desktop app uses through ffi. windows comes with neither sdl3 nor openal, so the app has its
|
||||
// own in desktop/windows/, which its windows build has inside it (see tools/compile.ts), with their credits and
|
||||
// licenses in credits.txt there. elsewhere it uses the system's.
|
||||
// they're the files of the libraries' releases. openal soft's "latest" builds need the visual c++ runtime, which not
|
||||
// every windows has, its releases' bin/Win64/soft_oal.dll only needs windows' own dlls
|
||||
import { existsSync } from "@std/fs";
|
||||
import { dirname, join } from "@std/path";
|
||||
|
||||
// the library's file on each os
|
||||
export type LibraryFiles = Partial<Record<typeof Deno.build.os, string>>;
|
||||
|
||||
// throws when there's no such library. one next to the executable comes first, so players can use their own build of
|
||||
// a library the app comes with, which openal soft's license asks for
|
||||
export function open_library<const S extends Deno.ForeignLibraryInterface>(
|
||||
name: string,
|
||||
files: LibraryFiles,
|
||||
symbols: S,
|
||||
): Deno.DynamicLibrary<S>["symbols"] {
|
||||
const file = files[Deno.build.os];
|
||||
if (!file) throw new Error(`There's no ${name} for ${Deno.build.os}`);
|
||||
const beside = join(dirname(Deno.execPath()), file);
|
||||
const own = new URL(`./${Deno.build.os}/${file}`, import.meta.url);
|
||||
const path = [beside, own].find((path) => existsSync(path)) ?? file;
|
||||
return Deno.dlopen(path, symbols).symbols;
|
||||
}
|
||||
|
||||
// who made the libraries the app comes with and their licenses, for the credits. undefined when it uses the system's
|
||||
export function library_credits(): string | undefined {
|
||||
try {
|
||||
return Deno.readTextFileSync(new URL(`./${Deno.build.os}/credits.txt`, import.meta.url));
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user