+glib+meson+flex (#76)

This commit is contained in:
Max Howell 2022-08-10 14:58:22 -04:00 committed by GitHub
parent 2540f4e031
commit cfb4e7e1f2
5 changed files with 88 additions and 40 deletions

View file

@ -0,0 +1,56 @@
distributable:
url: https://download.gnome.org/sources/glib/{{ version.major }}.{{ version.minor }}/glib-{{ version }}.tar.xz
strip-components: 1
versions:
github: GNOME/glib/tags
ignore: 2.73.x
#FIXME 2.73.2 onwards depends on PCRE2 (10.x)
# lol at bumping a dep in a *PATCH* release, semver is for the weak apparently
dependencies:
gnu.org/gettext: ^0.21
sourceware.org/libffi: 3
pcre.org: 8
build:
dependencies:
tea.xyz/gx/cc: c99
mesonbuild.com: ^0.63
ninja-build.org: 1
freedesktop.org/pkg-config: ^0.29
python.org: 3 #TODO ^3.5
script: |
meson out $ARGS
cd out
ninja -v
ninja install
cd {{prefix}}/lib/pkgconfig
sed -i.bak -e 's|Libs: -L${libdir} -lglib-2.0 -lintl|Libs: -L${libdir} -lglib-2.0 -L/opt/gnu.org/gettext/v*/lib -lintl -L/opt/pcre.org/v1/include -lpcre|' ./glib-2.0.pc
sed -i.bak -e 's|Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include|Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include -I/opt/gnu.org/gettext/v*/include -I/opt/pcre.org/v1/include|' ./glib-2.0.pc
rm *.bak
#REF https://github.com/Homebrew/homebrew-core/blob/d0e65698ccd502335bea68ce879ae02e1735db0d/Formula/glib.rb#L66-L67
#FIXME hardcoded paths ^^
env:
ARGS:
- --prefix={{prefix}}
- --wrap-mode=nofallback
- --buildtype=release
# tests fail to build with `error: target emulation unknown: -m or at least one .o file required`
- -Dtests=false
test:
dependencies:
tea.xyz/gx/cc: c99
freedesktop.org/pkg-config: ^0.29
script: |
cc $CFLAGS $LDFLAGS {{ pkg.pantry-prefix }}/test.c
./a.out
env:
# using pkg-config as pixman puts its headers in `include/pixman-1`
LDFLAGS: $(pkg-config --libs glib-2.0)
CFLAGS: $(pkg-config --cflags glib-2.0)

View file

@ -0,0 +1,10 @@
#include <string.h>
#include <glib.h>
int main(void)
{
gchar *result_1, *result_2;
char *str = "string";
result_1 = g_convert(str, strlen(str), "ASCII", "UTF-8", NULL, NULL, NULL);
result_2 = g_convert(result_1, strlen(result_1), "UTF-8", "ASCII", NULL, NULL, NULL);
return (strcmp(str, result_2) == 0) ? 0 : 1;
}

View file

@ -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"
//<FIXME>
import { print } from "utils"
print("this because otherwise console.verbose is not defined lol")
//</FIXME>
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 isnt 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)

View file

@ -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"
//<FIXME>
import { print } from "utils"
print("this because otherwise console.verbose is not defined lol")
//</FIXME>
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<string>()
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(" ")}`)

View file

@ -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