From 52b7f1a0960081521da0178e82ee83a5e4f5e803 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 24 Aug 2017 16:09:07 -0300 Subject: [PATCH] c#: Handle external dependencies from .pc files --- mesonbuild/backend/ninjabackend.py | 5 ++++- test cases/csharp/4 external dep/hello.txt | 1 + test cases/csharp/4 external dep/meson.build | 4 ++++ test cases/csharp/4 external dep/prog.cs | 8 ++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test cases/csharp/4 external dep/hello.txt create mode 100644 test cases/csharp/4 external dep/meson.build create mode 100644 test cases/csharp/4 external dep/prog.cs diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 1f6a80b98..e819ab2b2 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -967,7 +967,7 @@ int dummy; compiler = target.compilers['cs'] rel_srcs = [s.rel_to_builddir(self.build_to_src) for s in src_list] deps = [] - commands = target.extra_args.get('cs', []) + commands = CompilerArgs(compiler, target.extra_args.get('cs', [])) commands += compiler.get_buildtype_args(buildtype) if isinstance(target, build.Executable): commands.append('-target:exe') @@ -994,6 +994,9 @@ int dummy; rel_srcs.append(rel_src) deps.append(rel_src) + for dep in target.get_external_deps(): + commands.extend_direct(dep.get_link_args()) + elem = NinjaBuildElement(self.all_outputs, outputs, 'cs_COMPILER', rel_srcs) elem.add_dep(deps) elem.add_item('ARGS', commands) diff --git a/test cases/csharp/4 external dep/hello.txt b/test cases/csharp/4 external dep/hello.txt new file mode 100644 index 000000000..980a0d5f1 --- /dev/null +++ b/test cases/csharp/4 external dep/hello.txt @@ -0,0 +1 @@ +Hello World! diff --git a/test cases/csharp/4 external dep/meson.build b/test cases/csharp/4 external dep/meson.build new file mode 100644 index 000000000..004d25ffc --- /dev/null +++ b/test cases/csharp/4 external dep/meson.build @@ -0,0 +1,4 @@ +project('C# external library', 'cs') +glib_sharp_2 = dependency('glib-sharp-2.0') +e = executable('prog', 'prog.cs', dependencies: glib_sharp_2, install : true) +test('libtest', e, args: [join_paths(meson.current_source_dir(), 'hello.txt')]) diff --git a/test cases/csharp/4 external dep/prog.cs b/test cases/csharp/4 external dep/prog.cs new file mode 100644 index 000000000..9393fef5d --- /dev/null +++ b/test cases/csharp/4 external dep/prog.cs @@ -0,0 +1,8 @@ +using System; +using GLib; + +public class Prog { + static public void Main (string[] args) { + Console.WriteLine(GLib.FileUtils.GetFileContents(args[0])); + } +}