First half of the work required for pkg-config generator.

pull/15/head
Jussi Pakkanen 11 years ago
parent 7575617280
commit 0384ca71f7
  1. 17
      build.py
  2. 32
      interpreter.py
  3. 8
      test cases/common/51 pkgconfig-gen/meson.build
  4. 5
      test cases/common/51 pkgconfig-gen/simple.c
  5. 6
      test cases/common/51 pkgconfig-gen/simple.h

@ -41,6 +41,7 @@ class Build:
self.configure_files = []
self.pot = []
self.subprojects = {}
self.pkgconfig_gens = []
def add_compiler(self, compiler):
if len(self.compilers) == 0:
@ -522,3 +523,19 @@ class ConfigurationData():
def keys(self):
return self.values.keys()
class PkgConfigGenerator():
def __init__(self, libraries, headers, name, description, version, filebase):
self.libraries = []
for l in libraries:
if hasattr(l, 'held_object'):
self.libraries.append(l.held_object)
else:
self.libraries.append(l)
self.headerdirs = {}
for h in headers:
self.headerdirs[h.subdir] = True
self.name = name
self.description = description
self.version = version
self.filebase = filebase

@ -278,7 +278,6 @@ class Headers(InterpreterObject):
return self.sources
class Data(InterpreterObject):
def __init__(self, subdir, sources, kwargs):
InterpreterObject.__init__(self)
self.subdir = subdir
@ -619,6 +618,7 @@ class Interpreter():
'get_option' : self.func_get_option,
'subproject' : self.func_subproject,
'is_subproject' : self.func_is_subproject,
'pkgconfig_gen' : self.func_pkgconfig_gen,
}
def get_build_def_files(self):
@ -735,6 +735,36 @@ class Interpreter():
def func_option(self, nodes, args, kwargs):
raise InterpreterException('Tried to call option() in build description file. All options must be in the option file.')
def func_pkgconfig_gen(self, nodes, args, kwargs):
if len(args) > 0:
raise InterpreterException('Pkgconfig_gen takes no positional arguments.')
libs = kwargs.get('libraries', [])
if not isinstance(libs, list):
libs = [libs]
for l in libs:
if not (isinstance(l, SharedLibraryHolder) or isinstance(l, StaticLibraryHolder)):
raise InterpreterException('Library argument not a library object.')
headers = kwargs.get('headers', [])
if not isinstance(headers, list):
headers = [headers]
for h in headers:
if not isinstance(h, Headers):
raise InterpreterException('Header argument not a Headers object.')
version = kwargs.get('version', '')
if not isinstance(version, str):
raise InterpreterException('Version must be a string.')
name = kwargs.get('name', None)
if not isinstance(name, str):
raise InterpreterException('Name not specified.')
filebase = kwargs.get('filebase', None)
if not isinstance(filebase, str):
raise InterpreterException('Filebase not specified.')
description = kwargs.get('description', None)
if not isinstance(description, str):
raise InterpreterException('Description is not a string.')
p = build.PkgConfigGenerator(libs, headers, name, description, version, filebase)
self.build.pkgconfig_gens.append(p)
def func_is_subproject(self, nodes, args, kwargs):
return self.subproject != ''

@ -0,0 +1,8 @@
project('pkgconfig-gen', 'c')
lib = shared_library('simple', 'simple.c', install : true)
libver = '1.0'
h = headers('simple.h')
pkgconfig_gen(libraries : lib, headers : h, version : libver,
name : 'libsimple', filebase : 'simple', description : 'This is a simple library.')

@ -0,0 +1,5 @@
#include"simple.h"
int simple_function() {
return 42;
}

@ -0,0 +1,6 @@
#ifndef SIMPLE_H_
#define SIMPLE_H_
int simple_function();
#endif
Loading…
Cancel
Save