Module v.pkgconfig stdlib

v.pkgconfig
Version:
0.2.0
License:
MIT
Dependencies from vmod:
1
Imports:
4
Imported by:
1
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

  • semver

Imports

Imported by

Overview

v.pkgconfig

This module implements the pkg-config tool as a library in pure V.

Features:

  • Simple API, but still not stable, but shouldn't change much
  • Runs 2x faster than original pkg-config
  • Commandline tool that aims to be compatible with pkg-config
  • Resolve full path for .pc file given a name
  • Recursively parse all the dependencies
  • Find and replace all inner variables
  • Integration with V, so you can just do #pkgconfig r_core

Todo/Future/Wish:

  • 100% compatibility with pkg-config options
  • Stricter pc parsing logic, with better error reporting

Example

The commandline tool is available in vlib/v/pkgconfig/bin/pkgconfig.v

$ ./bin/pkgconfig -h
pkgconfig 0.3.3
-----------------------------------------------
Usage: pkgconfig [options] [ARGS]

Options:
  -V, --modversion          show version of module
  -d, --description         show pkg module description
  -h, --help                show this help message
  -D, --debug               show debug information
  -l, --list-all            list all pkgmodules
  -e, --exists              return 0 if pkg exists
  -V, --print-variables     display variable names
  -r, --print-requires      display requires of the module
  -a, --atleast-version <string>
                            return 0 if pkg version is at least the given one
      --exact-version <string>
                            return 0 if pkg version is at least the given one
  -v, --version             show version of this tool
  -c, --cflags              output all pre-processor and compiler flags
  -I, --cflags-only-I       show only -I flags from CFLAGS
      --cflags-only-other   show cflags without -I
  -s, --static              show --libs for static linking
  -l, --libs                output all linker flags
      --libs-only-l         show only -l from ldflags
  -L, --libs-only-L         show only -L from ldflags
      --libs-only-other     show flags not containing -l or -L
$

Using the API in your own programs:

import v.pkgconfig

opt := pkgconfig.Options{}
mut pc := pkgconfig.load('expat', opt) or { panic(err) }
println(pc.libs)

... will produce something like this:

['-L/usr/lib/x86_64-linux-gnu', '-lexpat']

Aliases

This section is empty.

Constants

This section is empty.

Sum types

This section is empty.

Functions

#fn atleast

fn atleast(v string) bool

#fn list

fn list() []string

#fn load

fn load(pkgname string, options Options) !&PkgConfig

#fn main

fn main(args []string) !&Main

Structs

#struct Main

pub struct Main {
pub mut:
	opt         &MainOptions = unsafe { nil }
	res         string
	has_actions bool
}

#fn (&Main) run

fn (mut m &Main) run() !string

#struct Options

pub struct Options {
pub:
	path              string
	debug             bool
	norecurse         bool
	only_description  bool
	use_default_paths bool = true
}

#struct PkgConfig

pub struct PkgConfig {
pub mut:
	options          Options
	name             string
	modname          string
	url              string
	version          string
	description      string
	libs             []string
	libs_private     []string
	cflags           []string
	paths            []string // TODO: move to options?
	vars             map[string]string
	requires         []string
	requires_private []string
	conflicts        []string
	loaded           []string
}

#fn (&PkgConfig) parse_list_no_comma

fn (mut pc &PkgConfig) parse_list_no_comma(s string) []string

#fn (&PkgConfig) parse_list

fn (mut pc &PkgConfig) parse_list(s string) []string

#fn (&PkgConfig) parse_line

fn (mut pc &PkgConfig) parse_line(s string) string

#fn (&PkgConfig) setvar

fn (mut pc &PkgConfig) setvar(line string)

#fn (&PkgConfig) parse

fn (mut pc &PkgConfig) parse(file string) bool

#fn (&PkgConfig) resolve

fn (mut pc &PkgConfig) resolve(pkgname string) !string

#fn (&PkgConfig) atleast

fn (mut pc &PkgConfig) atleast(v string) bool

#fn (&PkgConfig) extend

fn (mut pc &PkgConfig) extend(pcdep &PkgConfig) !string

#fn (&PkgConfig) load_requires

fn (mut pc &PkgConfig) load_requires() !

#fn (&PkgConfig) load_require

fn (mut pc &PkgConfig) load_require(dep string) !

#fn (&PkgConfig) add_path

fn (mut pc &PkgConfig) add_path(path string)

#fn (&PkgConfig) load_paths

fn (mut pc &PkgConfig) load_paths()

Interfaces

This section is empty.

Enums

This section is empty.