Merge pull request #236 from mesonbuild/depmanifest2

Add version numbers to projects and generate a dep manifest.
pull/238/head
Jussi Pakkanen 9 years ago
commit 7c6e99149b
  1. 12
      backends.py
  2. 3
      build.py
  3. 18
      interpreter.py
  4. 1
      ninjabackend.py
  5. 1
      test cases/common/49 subproject/installed_files.txt
  6. 8
      test cases/common/49 subproject/meson.build
  7. 6
      test cases/common/49 subproject/subprojects/sublib/meson.build

@ -16,6 +16,7 @@ import os, pickle
import build
import dependencies
import mesonlib
import json
from coredata import MesonException
class TestSerialisation:
@ -303,3 +304,14 @@ class Backend():
ofile.write(' ')
ofile.write('\n')
def generate_depmf_install(self, d):
if self.build.dep_manifest_name is None:
return
ifilename = os.path.join(self.environment.get_build_dir(), 'depmf.json')
ofilename = os.path.join(self.environment.get_prefix(), self.build.dep_manifest_name)
mfobj = {'type': 'dependency manifest',
'version': '1.0'}
mfobj['projects'] = self.build.dep_manifest
open(ifilename, 'w').write(json.dumps(mfobj))
d.data.append([ifilename, ofilename])

@ -57,6 +57,7 @@ class Build:
def __init__(self, environment):
self.project_name = 'name of master project'
self.project_version = None
self.environment = environment
self.projects = {}
self.targets = {}
@ -74,6 +75,8 @@ class Build:
self.pkgconfig_gens = []
self.install_scripts = []
self.install_dirs = []
self.dep_manifest_name = None
self.dep_manifest = {}
def has_language(self, language):
for i in self.compilers:

@ -723,6 +723,8 @@ class MesonMain(InterpreterObject):
'source_root' : self.source_root_method,
'build_root' : self.build_root_method,
'add_install_script' : self.add_install_script_method,
'install_dependency_manifest': self.install_dependency_manifest_method,
'project_version': self.project_version_method,
})
def add_install_script_method(self, args, kwargs):
@ -791,6 +793,16 @@ class MesonMain(InterpreterObject):
def is_subproject_method(self, args, kwargs):
return self.interpreter.is_subproject()
def install_dependency_manifest_method(self, args, kwargs):
if len(args) != 1:
raise InterpreterException('Must specify manifest install file name')
if not isinstance(args[0], str):
raise InterpreterException('Argument must be a string.')
self.build.dep_manifest_name = args[0]
def project_version_method(self, args, kwargs):
return self.build.dep_manifest[self.interpreter.active_projectname]
class Interpreter():
def __init__(self, build, subproject='', subdir='', subproject_dir='subprojects'):
@ -1168,7 +1180,9 @@ class Interpreter():
subi.subprojects = self.subprojects
subi.subproject_stack = self.subproject_stack + [dirname]
current_active = self.active_projectname
subi.run()
self.active_projectname = current_active
mlog.log('\nSubproject', mlog.bold(dirname), 'finished.')
self.build.subprojects[dirname] = True
self.subprojects.update(subi.subprojects)
@ -1202,11 +1216,11 @@ class Interpreter():
def func_project(self, node, args, kwargs):
if len(args) < 2:
raise InvalidArguments('Not enough arguments to project(). Needs at least the project name and one language')
if list(kwargs.keys()) != ['subproject_dir'] and len(kwargs) != 0:
raise InvalidArguments('project() only accepts the keyword argument "subproject_dir"')
if not self.is_subproject():
self.build.project_name = args[0]
self.active_projectname = args[0]
self.build.dep_manifest[args[0]] = kwargs.get('version', 'undefined')
if self.subproject in self.build.projects:
raise InvalidCode('Second call to project().')
if not self.is_subproject() and 'subproject_dir' in kwargs:

@ -383,6 +383,7 @@ class NinjaBackend(backends.Backend):
elem.add_item('DESC', 'Installing files.')
elem.add_item('COMMAND', [sys.executable, install_script, install_data_file])
elem.add_item('pool', 'console')
self.generate_depmf_install(d)
self.generate_target_install(d)
self.generate_header_install(d)
self.generate_man_install(d)

@ -1,2 +1,3 @@
usr/bin/user
usr/lib/libsublib.so
usr/share/sublib/sublib.depmf

@ -1,7 +1,11 @@
project('subproj user', 'c')
project('subproj user', 'c', version : '2.3.4')
sub = subproject('sublib')
if meson.project_version() != '2.3.4'
error('Incorrect master project version string:' + meson.project_version())
endif
if meson.is_subproject()
error('Claimed to be a subproject even though we are the master project.')
endif
@ -11,3 +15,5 @@ lib = sub.get_variable('l')
e = executable('user', 'user.c', include_directories : inc, link_with : lib, install : true)
test('subdirtest', e)
meson.install_dependency_manifest('share/sublib/sublib.depmf')

@ -1,9 +1,13 @@
project('subproject', 'c')
project('subproject', 'c', version : '1.0.0')
if not meson.is_subproject()
error('Claimed to be master project even though we are a subproject.')
endif
if meson.project_version() != '1.0.0'
error('Incorrect version string in subproject.')
endif
i = include_directories('include')
l = shared_library('sublib', 'sublib.c', include_directories : i, install : true,
c_args : '-DBUILDING_SUB=2')

Loading…
Cancel
Save