Skip to content

Commit

Permalink
feat(libpsl): add initial package (#224)
Browse files Browse the repository at this point in the history
* feat(libpsl): add initial package

Signed-off-by: Jérémy Audiger <[email protected]>

* refactor(alsa_lib): rename variable for consistency in main function

Signed-off-by: Jérémy Audiger <[email protected]>

---------

Signed-off-by: Jérémy Audiger <[email protected]>
  • Loading branch information
jaudiger authored Jan 30, 2025
1 parent 6c55f89 commit 2b804da
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/alsa_lib/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export async function test() {
int main(void)
{
const char *alsa_version = snd_asoundlib_version();
printf("%s", alsa_version);
const char *version = snd_asoundlib_version();
printf("%s", version);
return 0;
}
Expand Down
9 changes: 9 additions & 0 deletions packages/libpsl/brioche.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions packages/libpsl/project.bri
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import * as std from "std";
import nushell from "nushell";
import python from "python";

export const project = {
name: "libpsl",
version: "0.21.5",
};

const source = Brioche.download(
`https://github.com/rockdaboot/libpsl/releases/download/${project.version}/libpsl-${project.version}.tar.gz`,
)
.unarchive("tar", "gzip")
.peel();

export default function libPsl(): std.Recipe<std.Directory> {
const libpsl = std.runBash`
./configure --prefix=/
make install DESTDIR="$BRIOCHE_OUTPUT"
`
.workDir(source)
.dependencies(std.toolchain(), python())
.toDirectory();

return std.setEnv(libpsl, {
CPATH: { append: [{ path: "include" }] },
LIBRARY_PATH: { append: [{ path: "lib" }] },
PKG_CONFIG_PATH: { append: [{ path: "lib/pkgconfig" }] },
});
}

export async function test() {
const src = std.file(std.indoc`
#include <stdio.h>
#include <libpsl.h>
int main(void)
{
const char *version = psl_get_version();
printf("%s", version);
return 0;
}
`);

const script = std.runBash`
cp "$src" main.c
gcc main.c -o main -lpsl
./main | tee "$BRIOCHE_OUTPUT"
`
.dependencies(std.toolchain(), libPsl())
.env({ src: src });

const result = await script.toFile().read();

// Check that the result contains the expected version
const expected = `${project.version} (no IDNA support)`;
std.assert(result === expected, `expected '${expected}', got '${result}'`);

return script;
}

export function autoUpdate() {
const src = std.file(std.indoc`
let version = http get https://api.github.com/repos/rockdaboot/libpsl/releases/latest
| get tag_name
$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()],
});
}

0 comments on commit 2b804da

Please sign in to comment.