Lyricdev
GitHub

LYR-RES0016

a module made from a C header lies in the package's source too

error · spec 15-project

Reported when the module a bindings entry makes — geo in app is app.geo — is also a file under the package's src/, gen/ or tests/: one module path would name two modules. Nothing is built; the exit code is 1.

Explanation

A module made from a header is a module of the package like any other: bindings = [{ header = "native/geo.h", module = "geo" }] in the package app makes app.geo, which import app.geo { … } reads. A file src/geo.lyr would be app.geo too, and the build does not choose between them.

Give one of them another name. A common shape keeps the made module apart — module = "c.geo", or module = "sys" — and writes the package's own, friendlier functions in src/geo.lyr on top of it.

Wrong

//- lyric.toml
[package]
name = "app"
version = "0.1.0"

[native]
bindings = [{ header = "native/geo.h", module = "geo" }]
//- native/geo.h
int geo_add(int a, int b);
//- src/geo.lyr
pub fn add(a: int, b: int): int {
    return a + b;
}
//- src/main.lyr
fn main(): void {
}
//- lyric.toml
[package]
name = "app"
version = "0.1.0"

[native]
bindings = [{ header = "native/geo.h", module = "sys" }]
//- native/geo.h
int geo_add(int a, int b);
//- src/geo.lyr
pub fn add(a: int, b: int): int {
    return a + b;
}
//- src/main.lyr
fn main(): void {
}