From dc90621902e3772b0e0e3491c8ebda8111ae23e6 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 2 Sep 2022 10:51:31 -0400 Subject: [PATCH] test +librsvg (#115) --- projects/gnome.org/librsvg/package.yml | 21 +++++++------- projects/gnome.org/librsvg/test.c | 6 ++++ scripts/build.ts | 14 ++++------ scripts/filter.ts | 38 ++++++++++++++++++++++++++ scripts/test.ts | 38 ++++++++------------------ 5 files changed, 71 insertions(+), 46 deletions(-) create mode 100644 projects/gnome.org/librsvg/test.c create mode 100755 scripts/filter.ts diff --git a/projects/gnome.org/librsvg/package.yml b/projects/gnome.org/librsvg/package.yml index 38bc8bc9..86d4101a 100644 --- a/projects/gnome.org/librsvg/package.yml +++ b/projects/gnome.org/librsvg/package.yml @@ -21,19 +21,20 @@ build: gnome.org/gobject-introspection: 1 python.org: 3 script: | - if test {{ hw.platform }} = linux; then - #FIXME so linux configure finds shared-mime-info - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/share/pkgconfig" - #FIXME so linux build finds the shared-mime-info cache - export XDG_DATA_DIRS="$XDG_DATA_DIRS:/usr/share" - fi - ./configure \ --prefix={{ prefix }} \ --enable-pixbuf-loader=yes \ --enable-introspection=yes \ --disable-Bsymbolic - make V=1 - make install + make --jobs {{hw.concurrency}} install -test: true #FIXME \ No newline at end of file +test: + dependencies: + freedesktop.org/pkg-config: ^0.29 + tea.xyz/gx/cc: c99 + script: | + cc test.c $CFLAGS $LDFLAGS + ./a.out + env: + CFLAGS: $(pkg-config --cflags librsvg-2.0) #FIXME should be in env automatically + LDFLAGS: $(pkg-config --libs librsvg-2.0) diff --git a/projects/gnome.org/librsvg/test.c b/projects/gnome.org/librsvg/test.c new file mode 100644 index 00000000..c3245b56 --- /dev/null +++ b/projects/gnome.org/librsvg/test.c @@ -0,0 +1,6 @@ +#include + +int main(int argc, char *argv[]) { + RsvgHandle *handle = rsvg_handle_new(); + return 0; +} diff --git a/scripts/build.ts b/scripts/build.ts index b7786fe2..92d3ac29 100755 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -21,16 +21,14 @@ import build from "prefab/build.ts" import { Package, parsePackageRequirement, semver } from "types" import useFlags from "hooks/useFlags.ts" import usePlatform from "hooks/usePlatform.ts" +import hydrate from "prefab/hydrate.ts" useFlags() const pantry = usePantry() const cellar = useCellar() -const dry = Deno.args.map(project => { - const match = project.match(/projects\/(.*)\/package.yml/) - return match ? match[1] : project -}).map(parsePackageRequirement) +const dry = Deno.args.map(parsePackageRequirement) const rv: Package[] = [] for (const pkgrq of dry) { @@ -39,11 +37,6 @@ for (const pkgrq of dry) { if (!version) throw "no-version-found" const pkg = { project: pkgrq.project, version } - if (Deno.env.get("SKIP") && await cellar.isInstalled(pkg)) { - console.log({ skipping: pkg.project }) - continue - } - console.log({ building: pkgrq.project }) // Get the source @@ -59,7 +52,10 @@ for (const pkgrq of dry) { }) } + //TODO this was already calculated in `sort` and should not be recalculated const deps = await pantry.getDeps(pkg) + const wet = await hydrate(deps.runtime, pkg => pantry.getDeps(pkg).then(x => x.runtime)) + deps.runtime.push(...wet.pkgs) const env = usePlatform().platform == 'darwin' ? {MACOSX_DEPLOYMENT_TARGET: ['11.0']} diff --git a/scripts/filter.ts b/scripts/filter.ts new file mode 100755 index 00000000..deb83646 --- /dev/null +++ b/scripts/filter.ts @@ -0,0 +1,38 @@ +#!/usr/bin/env -S tea -E + +/*--- +args: + - deno + - run + - --allow-net + - --allow-run + - --allow-read + - --allow-write + - --allow-env + - --import-map={{ srcroot }}/import-map.json +---*/ + +import { parsePackageRequirement } from "types" +import useCellar from "hooks/useCellar.ts" +import useFlags from "hooks/useFlags.ts" + +useFlags() + +/// filters out everything that is already installed + +const cellar = useCellar() +const desired_filter = !!Deno.env.get("INVERT") + +const rv: string[] = [] +for (const pkg of Deno.args.map(parsePackageRequirement)) { + const isInstalled = !!await cellar.isInstalled(pkg) + if (isInstalled == desired_filter) { + rv.push(pkg.project) + } +} + +if (Deno.env.get("GITHUB_ACTIONS")) { + console.log(`::set-output name=pkgs::${rv.join(" ")}\n`) +} else { + console.log(rv.join("\n")) +} diff --git a/scripts/test.ts b/scripts/test.ts index d3b211f1..ca788868 100755 --- a/scripts/test.ts +++ b/scripts/test.ts @@ -12,11 +12,10 @@ args: - --import-map={{ srcroot }}/import-map.json ---*/ -import { parsePackage, semver, Path, PackageRequirement, PlainObject, parsePackageRequirement } from "types" +import { parsePackage, semver, Path, PackageRequirement, parsePackageRequirement } from "types" import usePantry from "hooks/usePantry.ts" import useShellEnv, { expand } from "hooks/useShellEnv.ts" -import { run, undent, isPlainObject } from "utils" -import { validatePackageRequirement } from "utils/lvl2.ts" +import { run, undent } from "utils" import useFlags from "hooks/useFlags.ts" import useCellar from "hooks/useCellar.ts" import resolve from "prefab/resolve.ts" @@ -24,14 +23,12 @@ import install from "prefab/install.ts" import hydrate from "prefab/hydrate.ts" import { lvl1 as link } from "prefab/link.ts" -const { debug } = useFlags() +const { debug, magic } = useFlags() const cellar = useCellar() - -//TODO install any other deps - const pantry = usePantry() + const pkg = await (async () => { - if (Deno.args[1] == "--magic") { + if (magic) { const i = await cellar.resolve(parsePackageRequirement(Deno.args[0])) return i.pkg } else { @@ -44,11 +41,14 @@ const self = { constraint: new semver.Range(pkg.version.toString()) } const [yml] = await pantry.getYAML(pkg) -const deps: PackageRequirement[] = [self, ...await get_deps()] +const deps = (await hydrate(self, async (pkg, dry) => { + const { runtime, test } = await pantry.getDeps(pkg) + return dry ? [...runtime, ...test] : runtime +})).pkgs await install_if_needed(deps) -const env = await useShellEnv(deps) +const env = await useShellEnv([self, ...deps]) let text = undent` #!/bin/bash @@ -69,7 +69,6 @@ try { text += `export FIXTURE="${fixture}"\n\n` } - const cwd = tmp.join("wd").mkdir() text += `cd "${cwd}"\n\n` @@ -90,22 +89,7 @@ try { if (!debug) tmp.rm({ recursive: true }) } -async function get_deps() { - const rv: PackageRequirement[] = [] - attempt(yml.dependencies) - attempt(yml.test.dependencies) - const { pkgs } = await hydrate(rv, pkg => pantry.getDeps(pkg).then(x=>x.runtime)) - return pkgs - - function attempt(obj: PlainObject) { - if (isPlainObject(obj)) - for (const [project, constraint] of Object.entries(obj)) { - const pkg = validatePackageRequirement({ project, constraint }) - if (pkg) rv.push(pkg) - } - } -} - +//TODO install step should do this for test requirements also async function install_if_needed(deps: PackageRequirement[]) { const needed: PackageRequirement[] = [] for await (const rq of deps) {