diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 8efb5fb2b..2bfb82269 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -656,12 +656,15 @@ int dummy; incroot = self.environment.get_includedir() headers = self.build.get_headers() + srcdir = self.environment.get_source_dir() + builddir = self.environment.get_build_dir() for h in headers: outdir = h.get_custom_install_dir() if outdir is None: outdir = os.path.join(incroot, h.get_install_subdir()) for f in h.get_sources(): - abspath = os.path.join(self.environment.get_source_dir(), h.get_source_subdir(), f) + assert(isinstance(f, File)) + abspath = f.absolute_path(srcdir, builddir) i = [abspath, outdir] d.headers.append(i) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 1c562b61b..b20d98ccd 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -457,10 +457,9 @@ class IncludeDirsHolder(InterpreterObject): class Headers(InterpreterObject): - def __init__(self, src_subdir, sources, kwargs): + def __init__(self, sources, kwargs): InterpreterObject.__init__(self) self.sources = sources - self.source_subdir = src_subdir self.install_subdir = kwargs.get('subdir', '') self.custom_install_dir = kwargs.get('install_dir', None) if self.custom_install_dir is not None: @@ -473,9 +472,6 @@ class Headers(InterpreterObject): def get_install_subdir(self): return self.install_subdir - def get_source_subdir(self): - return self.source_subdir - def get_sources(self): return self.sources @@ -2155,9 +2151,9 @@ requirements use the version keyword argument instead.''') self.build.benchmarks.append(t) mlog.debug('Adding benchmark "', mlog.bold(args[0]), '".', sep='') - @stringArgs def func_install_headers(self, node, args, kwargs): - h = Headers(self.subdir, args, kwargs) + source_files = self.source_strings_to_files(args) + h = Headers(source_files, kwargs) self.build.headers.append(h) return h diff --git a/test cases/common/9 header install/installed_files.txt b/test cases/common/9 header install/installed_files.txt index b9e91a286..8af6c1fd0 100644 --- a/test cases/common/9 header install/installed_files.txt +++ b/test cases/common/9 header install/installed_files.txt @@ -1,3 +1,4 @@ usr/include/rootdir.h usr/include/subdir/subdir.h usr/include/vanished.h +usr/include/fileheader.h diff --git a/test cases/common/9 header install/meson.build b/test cases/common/9 header install/meson.build index 8c8ca7386..7f3ce5175 100644 --- a/test cases/common/9 header install/meson.build +++ b/test cases/common/9 header install/meson.build @@ -2,7 +2,10 @@ project('header install', 'c') as_array = ['subdir.h'] +subdir('vanishing_subdir') +subdir('sub') + h1 = install_headers('rootdir.h') h2 = install_headers(as_array, subdir : 'subdir') +h3 = install_headers(subheader) -subdir('vanishing_subdir') diff --git a/test cases/common/9 header install/sub/fileheader.h b/test cases/common/9 header install/sub/fileheader.h new file mode 100644 index 000000000..28e5c8dfe --- /dev/null +++ b/test cases/common/9 header install/sub/fileheader.h @@ -0,0 +1,3 @@ +#pragma once + +#define LIFE "Is life! Na naa, naa-na na." diff --git a/test cases/common/9 header install/sub/meson.build b/test cases/common/9 header install/sub/meson.build new file mode 100644 index 000000000..1ee0d1dd4 --- /dev/null +++ b/test cases/common/9 header install/sub/meson.build @@ -0,0 +1,2 @@ +subheader = files('fileheader.h') +