diff --git a/packages/alsa_lib/project.bri b/packages/alsa_lib/project.bri index 6049a22..bc4bd9b 100644 --- a/packages/alsa_lib/project.bri +++ b/packages/alsa_lib/project.bri @@ -1,3 +1,4 @@ +import nushell from "nushell"; import * as std from "std"; export const project = { @@ -11,7 +12,7 @@ const source = Brioche.download( .unarchive("tar", "bzip2") .peel(); -export default function (): std.Recipe { +export default function alsaLib(): std.Recipe { const alsaLib = std.runBash` ./configure --prefix=/ make install DESTDIR="$BRIOCHE_OUTPUT" @@ -26,3 +27,54 @@ export default function (): std.Recipe { PKG_CONFIG_PATH: { append: [{ path: "lib/pkgconfig" }] }, }); } + +export async function test() { + const src = std.file(std.indoc` + #include + #include + + int main(void) + { + const char *alsa_version = snd_asoundlib_version(); + printf("%s", alsa_version); + + return 0; + } + `); + + const script = std.runBash` + cp "$src" main.c + gcc main.c -o main -lasound + ./main | tee "$BRIOCHE_OUTPUT" + ` + .dependencies(std.toolchain(), alsaLib()) + .env({ src: src }); + + const result = await script.toFile().read(); + + // Check that the result contains the expected version + const expected = `${project.version}`; + std.assert(result === expected, `expected '${expected}', got '${result}'`); + + return script; +} + +export function autoUpdate() { + const src = std.file(std.indoc` + let version = http get https://www.alsa-project.org/files/pub/lib + | lines + | where {|it| ($it | str contains "alsa-lib") and (not ($it | str contains ".sig")) } + | parse --regex '' + | sort-by --natural --reverse version + | get 0.version + + $env.project | from json | update version $version | to json + `); + + return std.withRunnable(std.directory(), { + command: "nu", + args: [src], + env: { project: JSON.stringify(project) }, + dependencies: [nushell()], + }); +}