nitc :: PkgconfigPhase :: defaultinit
# Detects the `pkgconfig` annotation on the module declaration only
private class PkgconfigPhase
super Phase
redef fun process_annotated_node(nmoduledecl, nat)
do
# Skip if we are not interested
if nat.name != "pkgconfig" then return
# Do some validity checks and print errors if the annotation is used incorrectly
var modelbuilder = toolcontext.modelbuilder
if not nmoduledecl isa AModuledecl then
modelbuilder.error(nat, "Syntax Error: only the declaration of modules may use `pkgconfig`.")
return
end
# retrieve module
var nmodule = nmoduledecl.parent.as(AModule)
var mmodule = nmodule.mmodule.as(not null)
# target pkgs
var pkgs = new Array[String]
var args = nat.n_args
if args.is_empty then
# use module name
pkgs.add(mmodule.name)
else
for arg in args do
var pkg = arg.as_string
if pkg == null then
modelbuilder.error(nat, "Syntax Error: `pkgconfig` expects its arguments to be the name of the package as String literals.")
return
end
pkgs.add(pkg)
end
end
for pkg in pkgs do
mmodule.pkgconfigs.add pkg
end
end
end
src/ffi/pkgconfig.nit:66,1--110,3