From 255f93071b71094f9d22329ba4eaea8884668e83 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 10 Aug 2022 14:58:22 -0400 Subject: [PATCH] +glib+meson+flex (#76) --- .github/workflows/build.yml | 2 +- .github/workflows/ci.yml | 2 +- projects/github.com/westes/flex/package.yml | 26 +++++++++++++++ projects/github.com/westes/flex/test.flex | 10 ++++++ projects/mesonbuild.com/meson.build | 2 ++ projects/mesonbuild.com/package.yml | 33 +++++++++++++++++++ projects/mesonbuild.com/test.c | 4 +++ projects/python.org/package.yml | 9 ++++++ scripts/_lib.ts | 18 +++++++++++ scripts/build.ts | 25 +++++++-------- scripts/sort.ts | 35 ++++++--------------- scripts/test.ts | 2 +- 12 files changed, 126 insertions(+), 42 deletions(-) create mode 100644 projects/github.com/westes/flex/package.yml create mode 100644 projects/github.com/westes/flex/test.flex create mode 100644 projects/mesonbuild.com/meson.build create mode 100644 projects/mesonbuild.com/package.yml create mode 100644 projects/mesonbuild.com/test.c create mode 100644 scripts/_lib.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 931e623e..ebc72822 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: - ubuntu-latest include: - os: macos-11 - container: "~" + container: ~ - os: ubuntu-latest container: ghcr.io/teaxyz/infuser:main container: ${{ matrix.container }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1cf40c54..aecab46b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,4 +23,4 @@ jobs: with: projects: ${{ needs.get-diff.outputs.diff }} secrets: inherit - if: ${{ needs.get-diff.outputs.diff != '' }} \ No newline at end of file + if: ${{ needs.get-diff.outputs.diff != '' }} diff --git a/projects/github.com/westes/flex/package.yml b/projects/github.com/westes/flex/package.yml new file mode 100644 index 00000000..e2cfbc76 --- /dev/null +++ b/projects/github.com/westes/flex/package.yml @@ -0,0 +1,26 @@ +distributable: + url: https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz + strip-components: 1 + +versions: + github: westes/flex + strip: /^flex / + +build: + dependencies: + tea.xyz/gx/cc: c99 + tea.xyz/gx/make: '*' + gnu.org/m4: 1 + script: | + ./configure --prefix={{ prefix }} + make --jobs {{ hw.concurrency }} install + +test: + dependencies: + tea.xyz/gx/cc: c99 + script: | + flex {{ pkg.pantry-prefix }}/test.flex + cc lex.yy.c -lfl + OUT=$(echo "Hello World" | ./a.out) + test "$OUT" = "Hello + World" diff --git a/projects/github.com/westes/flex/test.flex b/projects/github.com/westes/flex/test.flex new file mode 100644 index 00000000..9b9a3209 --- /dev/null +++ b/projects/github.com/westes/flex/test.flex @@ -0,0 +1,10 @@ +CHAR [a-z][A-Z] +%% +{CHAR}+ printf("%s", yytext); +[ \t\n]+ printf("\n"); +%% +int main() +{ + yyin = stdin; + yylex(); +} diff --git a/projects/mesonbuild.com/meson.build b/projects/mesonbuild.com/meson.build new file mode 100644 index 00000000..af381967 --- /dev/null +++ b/projects/mesonbuild.com/meson.build @@ -0,0 +1,2 @@ +project('hello', 'c') +executable('hello', 'test.c') diff --git a/projects/mesonbuild.com/package.yml b/projects/mesonbuild.com/package.yml new file mode 100644 index 00000000..e67c96b3 --- /dev/null +++ b/projects/mesonbuild.com/package.yml @@ -0,0 +1,33 @@ +distributable: + url: https://github.com/mesonbuild/meson/releases/download/{{ version }}/meson-{{ version }}.tar.gz + strip-components: 1 + +versions: + github: mesonbuild/meson/tags + +#FIXME +# we need to fix the virtual-env of this thing + +dependencies: + python.org: 3 + +build: + script: | + python3 -m venv {{prefix}}/libexec + {{prefix}}/libexec/bin/pip install -v --no-deps --no-binary :all: --ignore-installed meson + mkdir {{prefix}}/bin + ln -s {{prefix}}/libexec/bin/meson {{prefix}}/bin/meson + + # tidy up + find \ + {{prefix}}/libexec/bin \ + -name pip\* -o -name easy_install\* -o -name activate\* -o -name Activate.ps1 \ + | xargs rm + +test: + dependencies: + ninja-build.org: 1 + tea.xyz/gx/cc: c99 + script: | + meson {{ pkg.pantry-prefix }} + test -f build.ninja diff --git a/projects/mesonbuild.com/test.c b/projects/mesonbuild.com/test.c new file mode 100644 index 00000000..7bd19a45 --- /dev/null +++ b/projects/mesonbuild.com/test.c @@ -0,0 +1,4 @@ +main() { + puts("hi"); + return 0; +} diff --git a/projects/python.org/package.yml b/projects/python.org/package.yml index 3d68275e..2ebe85f9 100644 --- a/projects/python.org/package.yml +++ b/projects/python.org/package.yml @@ -62,6 +62,15 @@ build: # put data that doesn’t vary between pythons in a consistent place - --datarootdir="$SHARE" - --datadir="$SHARE" + + #FIXME get rid of these v* + OPENSSL_INCLUDES: /opt/openssl.org/v*/include + OPENSSL_LDFLAGS: -L/opt/openssl.org/v*/lib' + + #FIXME we should get the include path from the ncurses `.pc` files + CPATH: /opt/invisible-island.net/ncurses/v*/include/ncursesw:$CPATH + + # required for `setup.py` which is used to detect the libs for python’s modules diff: | diff --git a/setup.py b/setup.py index 85a2b26..4f2f742 100644 diff --git a/scripts/_lib.ts b/scripts/_lib.ts new file mode 100644 index 00000000..457c0e3e --- /dev/null +++ b/scripts/_lib.ts @@ -0,0 +1,18 @@ +import usePantry from "hooks/usePantry.ts" +import { PackageRequirement } from "types" + +export function get_build_deps(dry: Set) { + const pantry = usePantry() + + return async (pkg: PackageRequirement) => { + const deps = await pantry.getDeps(pkg) + if (dry.has(pkg.project)) { + // we hydrate the runtime deps of any build deps since if + // any of `dry` is a runtime dep of any build dep (obv. from another) + // pkg in the set we are building then it needs to be sorted first + return [...deps.runtime, ...deps.build] + } else { + return deps.runtime + } + } +} diff --git a/scripts/build.ts b/scripts/build.ts index 556bd58a..ae723cdb 100755 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -23,6 +23,12 @@ import { semver, PackageRequirement, Package } from "types" import { parsePackageRequirement } from "types" import hydrate from "prefab/hydrate.ts" import resolve from "prefab/resolve.ts" +import { get_build_deps } from "./_lib.ts" + +// +import { print } from "utils" +print("this because otherwise console.verbose is not defined lol") +// const pantry = usePantry() const cellar = useCellar() @@ -32,20 +38,10 @@ const dry = Deno.args.map(project => { return match ? match[1] : project }).map(parsePackageRequirement) -//FIXME this isn’t as specific as we are above const explicit_deps = new Set(dry.map(({ project }) => project)) -const build_deps = await (async () => { - const rv: PackageRequirement[] = [] - for (const pkg of dry) { - const foo = await pantry.getDeps(pkg) - rv.push(...foo.build) - } - return rv -})() - -const wet = await hydrate([...dry, ...build_deps]) -const gas = await resolve(await (async () => { +const wet = await hydrate(dry, get_build_deps(explicit_deps)) +const gas = async () => { const rv: PackageRequirement[] = [] for (const pkg of wet) { if (await cellar.isInstalled(pkg)) continue @@ -53,9 +49,10 @@ const gas = await resolve(await (async () => { rv.push(pkg) } return rv -})()) +} +const plasma = await resolve(await gas()) -for await (const pkg of gas) { +for await (const pkg of plasma) { console.log({ installing: pkg.project }) const installation = install(pkg) await link(installation) diff --git a/scripts/sort.ts b/scripts/sort.ts index 270f1b18..4e381c5b 100755 --- a/scripts/sort.ts +++ b/scripts/sort.ts @@ -13,37 +13,22 @@ args: ---*/ import { parsePackageRequirement } from "types" -import usePantry from "hooks/usePantry.ts" import hydrate from "prefab/hydrate.ts" +import { get_build_deps } from "./_lib.ts" + +// +import { print } from "utils" +print("this because otherwise console.verbose is not defined lol") +// const dry = Deno.args.map(project => { const match = project.match(/projects\/(.*)\/package.yml/) return match ? match[1] : project }).map(parsePackageRequirement) -const cum: string[] = [] const set = new Set(dry.map(x => x.project)) +const wet = await hydrate(dry, get_build_deps(set)) +const gas = wet.map(x => x.project) + .filter(x => set.has(x)) // we're only sorting `dry` so reject the rest -const pantry = usePantry() - -for (const pkg of dry) { - const deps = await pantry.getDeps(pkg) - const wet = await hydrate([...deps.runtime, ...deps.build]) - for (const {project: dep} of wet) { - if (set.has(dep)) { - cum.push(dep) - } - } - cum.push(pkg.project) -} - -const rv = new Array() -const newset = new Set() -for (const pkg of cum) { - if (!newset.has(pkg)) { - rv.push(pkg) - newset.add(pkg) - } -} - -console.log(`::set-output name=pkgs::${rv.join(" ")}`) +console.log(`::set-output name=pkgs::${gas.join(" ")}`) diff --git a/scripts/test.ts b/scripts/test.ts index f09e27d3..0c5bb475 100755 --- a/scripts/test.ts +++ b/scripts/test.ts @@ -15,7 +15,7 @@ args: import { parsePackage, semver, Path, PackageRequirement, PlainObject } from "types" import usePantry from "hooks/usePantry.ts" import useShellEnv, { expand } from "hooks/useShellEnv.ts" -import { run, undent, isPlainObject, isString } from "utils" +import { run, undent, isPlainObject } from "utils" import { validatePackageRequirement } from "utils/lvl2.ts" //TODO install any other deps