aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2021-09-22 13:03:23 -0700
committerEli Schwartz <eschwartz93@gmail.com>2021-10-04 22:42:27 -0400
commit6b8f10cf6b1ee603ad7f584f7be8340e6974fb4f (patch)
treee50aa039a9ca32db8193efe658765d295ba982bd
parenta161873948ec328848f9eec816d99cc52cd74631 (diff)
downloadmeson-6b8f10cf6b1ee603ad7f584f7be8340e6974fb4f.zip
meson-6b8f10cf6b1ee603ad7f584f7be8340e6974fb4f.tar.gz
meson-6b8f10cf6b1ee603ad7f584f7be8340e6974fb4f.tar.bz2
backend/vs: Generate dependencies for CustomTargetIndex for a CustomTarget.
Test & fix.
-rw-r--r--mesonbuild/build.py2
-rw-r--r--test cases/common/245 custom target index source/code_source.c6
-rw-r--r--test cases/common/245 custom target index source/copyfile.py6
-rw-r--r--test cases/common/245 custom target index source/copyfile2.py7
-rw-r--r--test cases/common/245 custom target index source/header_source.h1
-rw-r--r--test cases/common/245 custom target index source/main.c6
-rw-r--r--test cases/common/245 custom target index source/meson.build50
7 files changed, 78 insertions, 0 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 339bb43..311732e 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -2334,6 +2334,8 @@ class CustomTarget(Target, CommandBase):
for c in self.sources:
if isinstance(c, (BuildTarget, CustomTarget)):
deps.append(c)
+ if isinstance(c, CustomTargetIndex):
+ deps.append(c.target)
return deps
def get_transitive_build_target_deps(self) -> T.Set[T.Union[BuildTarget, 'CustomTarget']]:
diff --git a/test cases/common/245 custom target index source/code_source.c b/test cases/common/245 custom target index source/code_source.c
new file mode 100644
index 0000000..484955b
--- /dev/null
+++ b/test cases/common/245 custom target index source/code_source.c
@@ -0,0 +1,6 @@
+extern int genfunc(void);
+
+int genfunc(void)
+{
+ return 0;
+}
diff --git a/test cases/common/245 custom target index source/copyfile.py b/test cases/common/245 custom target index source/copyfile.py
new file mode 100644
index 0000000..ff42ac3
--- /dev/null
+++ b/test cases/common/245 custom target index source/copyfile.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+
+import sys
+import shutil
+
+shutil.copyfile(sys.argv[1], sys.argv[2])
diff --git a/test cases/common/245 custom target index source/copyfile2.py b/test cases/common/245 custom target index source/copyfile2.py
new file mode 100644
index 0000000..efbfc28
--- /dev/null
+++ b/test cases/common/245 custom target index source/copyfile2.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+
+import sys
+import shutil
+
+shutil.copyfile(sys.argv[1], sys.argv[2])
+shutil.copyfile(sys.argv[3], sys.argv[4])
diff --git a/test cases/common/245 custom target index source/header_source.h b/test cases/common/245 custom target index source/header_source.h
new file mode 100644
index 0000000..e06c9de
--- /dev/null
+++ b/test cases/common/245 custom target index source/header_source.h
@@ -0,0 +1 @@
+extern int genfunc(void);
diff --git a/test cases/common/245 custom target index source/main.c b/test cases/common/245 custom target index source/main.c
new file mode 100644
index 0000000..c1c2b09
--- /dev/null
+++ b/test cases/common/245 custom target index source/main.c
@@ -0,0 +1,6 @@
+#include "gen.h"
+
+int main(void)
+{
+ return genfunc();
+}
diff --git a/test cases/common/245 custom target index source/meson.build b/test cases/common/245 custom target index source/meson.build
new file mode 100644
index 0000000..4dc54d4
--- /dev/null
+++ b/test cases/common/245 custom target index source/meson.build
@@ -0,0 +1,50 @@
+project('custom target index source', 'c')
+
+# Test that using a custom target index as a sourcefile works correctly
+
+copy1 = find_program('copyfile.py')
+copy2 = find_program('copyfile2.py')
+
+step_1 = custom_target('step_1',
+ input: ['code_source.c', files('header_source.h')],
+ output: ['step_1.c', 'step_1.h'],
+ command: [copy2, '@INPUT0@', '@OUTPUT0@', '@INPUT1@', '@OUTPUT1@'],
+ build_by_default: false)
+
+# test custom target with a single CustomTargetIndex input
+step_2_c = custom_target('step_2_c',
+ input: step_1[0],
+ output: 'step_2.c',
+ command: [copy1, '@INPUT0@', '@OUTPUT0@'],
+ build_by_default: false)
+
+step_2_h = custom_target('step_2_h',
+ input: step_1[1],
+ output: 'step_2.h',
+ command: [copy1, '@INPUT0@', '@OUTPUT0@'],
+ build_by_default: false,
+)
+
+# test custom target with multiple CustomTargetIndex inputs
+gen = custom_target('step_3',
+ input: [step_2_c, step_2_h],
+ output: ['gen.c', 'gen.h'],
+ command: [copy2, '@INPUT0@', '@OUTPUT0@', '@INPUT1@', '@OUTPUT1@'],
+ build_by_default: false)
+gen_c = gen[0]
+gen_h = gen[1]
+
+exe_separate = executable('exe_separate',
+ ['main.c', gen_c, gen_h],
+ build_by_default: false,
+ install: false,
+)
+
+exe_together = executable('exe_together',
+ ['main.c', gen],
+ build_by_default: false,
+ install: false,
+)
+
+test('exe_separate', exe_separate)
+test('exe_together', exe_together)