aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manual tests/6 hg wrap/meson.build (renamed from manual tests/10 hg wrap/meson.build)0
-rw-r--r--manual tests/6 hg wrap/prog.c (renamed from manual tests/10 hg wrap/prog.c)0
-rw-r--r--manual tests/6 hg wrap/subprojects/samplesubproject.wrap (renamed from manual tests/10 hg wrap/subprojects/samplesubproject.wrap)0
-rw-r--r--mesonbuild/backend/ninjabackend.py12
-rw-r--r--mesonbuild/build.py8
-rw-r--r--mesonbuild/interpreter.py35
-rw-r--r--mesonbuild/mesonlib.py9
-rw-r--r--mesonbuild/modules/gnome.py15
-rw-r--r--mesonbuild/modules/pkgconfig.py2
-rw-r--r--test cases/common/12 data/fileobject_datafile.dat1
-rw-r--r--test cases/common/12 data/installed_files.txt1
-rw-r--r--test cases/common/12 data/meson.build1
12 files changed, 55 insertions, 29 deletions
diff --git a/manual tests/10 hg wrap/meson.build b/manual tests/6 hg wrap/meson.build
index c7ac004..c7ac004 100644
--- a/manual tests/10 hg wrap/meson.build
+++ b/manual tests/6 hg wrap/meson.build
diff --git a/manual tests/10 hg wrap/prog.c b/manual tests/6 hg wrap/prog.c
index df38000..df38000 100644
--- a/manual tests/10 hg wrap/prog.c
+++ b/manual tests/6 hg wrap/prog.c
diff --git a/manual tests/10 hg wrap/subprojects/samplesubproject.wrap b/manual tests/6 hg wrap/subprojects/samplesubproject.wrap
index 6d3b3f2..6d3b3f2 100644
--- a/manual tests/10 hg wrap/subprojects/samplesubproject.wrap
+++ b/manual tests/6 hg wrap/subprojects/samplesubproject.wrap
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 00a09fc..8efb5fb 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -681,18 +681,16 @@ int dummy;
def generate_data_install(self, d):
data = self.build.get_data()
+ srcdir = self.environment.get_source_dir()
+ builddir = self.environment.get_build_dir()
for de in data:
assert(isinstance(de, build.Data))
subdir = de.install_dir
for f in de.sources:
- plain_f = os.path.split(f)[1]
- if de.in_sourcetree:
- srcprefix = self.environment.get_source_dir()
- else:
- srcprefix = self.environment.get_build_dir()
- srcabs = os.path.join(srcprefix, de.source_subdir, f)
+ assert(isinstance(f, mesonlib.File))
+ plain_f = os.path.split(f.fname)[1]
dstabs = os.path.join(subdir, plain_f)
- i = [srcabs, dstabs]
+ i = [f.absolute_path(srcdir, builddir), dstabs]
d.data.append(i)
def generate_subdir_install(self, d):
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 42cdc57..0e23777 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1393,11 +1393,13 @@ class ConfigurationData():
# A bit poorly named, but this represents plain data files to copy
# during install.
class Data():
- def __init__(self, in_sourcetree, source_subdir, sources, install_dir):
- self.in_sourcetree = in_sourcetree
- self.source_subdir = source_subdir
+ def __init__(self, sources, install_dir):
self.sources = sources
self.install_dir = install_dir
+ if not isinstance(self.sources, list):
+ self.sources = [self.sources]
+ for s in self.sources:
+ assert(isinstance(s, File))
class InstallScript:
def __init__(self, cmd_arr):
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 235d55a..1c562b6 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -483,15 +483,11 @@ class Headers(InterpreterObject):
return self.custom_install_dir
class DataHolder(InterpreterObject):
- def __init__(self, in_sourcetree, source_subdir, sources, kwargs):
+ def __init__(self, sources, install_dir):
super().__init__()
- kwsource = mesonlib.stringlistify(kwargs.get('sources', []))
- sources += kwsource
- check_stringlist(sources)
- install_dir = kwargs.get('install_dir', None)
if not isinstance(install_dir, str):
raise InterpreterException('Custom_install_dir must be a string.')
- self.held_object = build.Data(in_sourcetree, source_subdir, sources, install_dir)
+ self.held_object = build.Data(sources, install_dir)
def get_source_subdir(self):
return self.held_object.source_subdir
@@ -2203,9 +2199,19 @@ requirements use the version keyword argument instead.''')
self.evaluate_codeblock(codeblock)
self.subdir = prev_subdir
- @stringArgs
def func_install_data(self, node, args, kwargs):
- data = DataHolder(True, self.subdir, args, kwargs)
+ kwsource = mesonlib.stringlistify(kwargs.get('sources', []))
+ raw_sources = args + kwsource
+ sources = []
+ source_strings = []
+ for s in raw_sources:
+ if isinstance(s, mesonlib.File):
+ sources.append(s)
+ else:
+ source_strings.append(s)
+ sources += self.source_strings_to_files(source_strings)
+ install_dir = kwargs.get('install_dir', None)
+ data = DataHolder(sources, install_dir)
self.build.data.append(data.held_object)
return data
@@ -2235,11 +2241,12 @@ requirements use the version keyword argument instead.''')
raise InterpreterException('Output must be a string.')
if os.path.split(output)[0] != '':
raise InterpreterException('Output file name must not contain a subdirectory.')
+ (ofile_path, ofile_fname) = os.path.split(os.path.join(self.subdir, output))
+ ofile_abs = os.path.join(self.environment.build_dir, ofile_path, ofile_fname)
if 'configuration' in kwargs:
conf = kwargs['configuration']
if not isinstance(conf, ConfigurationDataHolder):
raise InterpreterException('Argument "configuration" is not of type configuration_data')
- ofile_abs = os.path.join(self.environment.build_dir, self.subdir, output)
if inputfile is not None:
# Normalize the path of the conffile to avoid duplicates
# This is especially important to convert '/' to '\' on Windows
@@ -2261,8 +2268,10 @@ requirements use the version keyword argument instead.''')
(res.stdout, res.stderr))
else:
raise InterpreterException('Configure_file must have either "configuration" or "command".')
- if isinstance(kwargs.get('install_dir', None), str):
- self.build.data.append(DataHolder(False, self.subdir, [output], kwargs).held_object)
+ idir = kwargs.get('install_dir', None)
+ if isinstance(idir, str):
+ cfile = mesonlib.File.from_built_file(ofile_path, ofile_fname)
+ self.build.data.append(DataHolder([cfile], idir).held_object)
return mesonlib.File.from_built_file(self.subdir, output)
@stringArgs
@@ -2364,10 +2373,6 @@ requirements use the version keyword argument instead.''')
@stringArgs
@noKwargs
def func_join_paths(self, node, args, kwargs):
- if isinstance(args, str):
- st = (args,)
- else:
- st = tuple(args)
return os.path.join(*args).replace('\\', '/')
def flatten(self, args):
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 943a23e..b92be5f 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -58,6 +58,12 @@ class File:
else:
return os.path.join(build_to_src, self.subdir, self.fname)
+ def absolute_path(self, srcdir, builddir):
+ if self.is_built:
+ return os.path.join(builddir, self.subdir, self.fname)
+ else:
+ return os.path.join(srcdir, self.subdir, self.fname)
+
def endswith(self, ending):
return self.fname.endswith(ending)
@@ -70,6 +76,9 @@ class File:
def __hash__(self):
return hash((self.fname, self.subdir, self.is_built))
+ def relative_name(self):
+ return os.path.join(self.subdir, self.fname)
+
def get_compiler_for_source(compilers, src):
for comp in compilers:
if comp.can_compile(src):
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 777fda8..114114d 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -715,7 +715,7 @@ can not be used with the current version of glib-compiled-resources, due to
known_kwargs = ['comments', 'eprod', 'fhead', 'fprod', 'ftail',
'identifier_prefix', 'symbol_prefix', 'template',
'vhead', 'vprod', 'vtail']
- known_custom_target_kwargs = ['install', 'install_dir', 'build_always',
+ known_custom_target_kwargs = ['install_dir', 'build_always',
'depends', 'depend_files']
c_template = h_template = None
install_header = False
@@ -724,8 +724,16 @@ can not be used with the current version of glib-compiled-resources, due to
sources = [value] + sources
elif arg == 'c_template':
c_template = value
+ if 'template' in kwargs:
+ raise MesonException('Mkenums does not accept both '
+ 'c_template and template keyword '
+ 'arguments at the same time.')
elif arg == 'h_template':
h_template = value
+ if 'template' in kwargs:
+ raise MesonException('Mkenums does not accept both '
+ 'h_template and template keyword '
+ 'arguments at the same time.')
elif arg == 'install_header':
install_header = value
elif arg in known_kwargs:
@@ -913,13 +921,13 @@ can not be used with the current version of glib-compiled-resources, due to
vapi_args = ret + self._vapi_args_to_command('--pkg=', 'packages', kwargs, accept_vapi=True)
return vapi_args, vapi_depends, vapi_packages, vapi_includes
- def _generate_deps(self, state, library, packages, indir):
+ def _generate_deps(self, state, library, packages, install_dir):
outdir = state.environment.scratch_dir
fname = os.path.join(outdir, library + '.deps')
with open(fname, 'w') as ofile:
for package in packages:
ofile.write(package + '\n')
- return build.Data(False, outdir, [fname], indir)
+ return build.Data(mesonlib.File(True, outdir, fname), install_dir)
def _get_vapi_link_with(self, target):
link_with = []
@@ -985,6 +993,7 @@ can not be used with the current version of glib-compiled-resources, due to
# We shouldn't need this locally but we install it
deps_target = self._generate_deps(state, library, vapi_packages, install_dir)
+ # XXX WRONG, state objects must not be modified! Fix this!
state.data.append(deps_target)
vapi_target = VapiTarget(vapi_output, state.subdir, custom_kwargs)
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
index 3ecb40d..9f50b0e 100644
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -138,7 +138,7 @@ class PkgConfigModule:
self.generate_pkgconfig_file(state, libs, subdirs, name, description, url,
version, pcfile, pub_reqs, priv_reqs,
conflicts, priv_libs)
- return build.Data(False, state.environment.get_scratch_dir(), [pcfile], pkgroot)
+ return build.Data(mesonlib.File(True, state.environment.get_scratch_dir(), pcfile), pkgroot)
def initialize():
return PkgConfigModule()
diff --git a/test cases/common/12 data/fileobject_datafile.dat b/test cases/common/12 data/fileobject_datafile.dat
new file mode 100644
index 0000000..872aa5a
--- /dev/null
+++ b/test cases/common/12 data/fileobject_datafile.dat
@@ -0,0 +1 @@
+This is a data file that is installed via a File object.
diff --git a/test cases/common/12 data/installed_files.txt b/test cases/common/12 data/installed_files.txt
index 3d4b12c..8651e3a 100644
--- a/test cases/common/12 data/installed_files.txt
+++ b/test cases/common/12 data/installed_files.txt
@@ -1,4 +1,5 @@
usr/share/progname/datafile.dat
+usr/share/progname/fileobject_datafile.dat
usr/share/progname/vanishing.dat
usr/share/progname/vanishing2.dat
etc/etcfile.dat
diff --git a/test cases/common/12 data/meson.build b/test cases/common/12 data/meson.build
index 80f3835..7494abc 100644
--- a/test cases/common/12 data/meson.build
+++ b/test cases/common/12 data/meson.build
@@ -1,6 +1,7 @@
project('data install test', 'c')
install_data(sources : 'datafile.dat', install_dir : 'share/progname')
install_data(sources : 'etcfile.dat', install_dir : '/etc')
+install_data(files('fileobject_datafile.dat'), install_dir : 'share/progname')
subdir('vanishing')