aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/ninjabackend.py19
-rwxr-xr-xrun_unittests.py11
-rw-r--r--test cases/common/5 linkstatic/libfile2.c3
-rw-r--r--test cases/common/5 linkstatic/libfile3.c3
-rw-r--r--test cases/common/5 linkstatic/libfile4.c3
-rw-r--r--test cases/common/5 linkstatic/meson.build2
6 files changed, 31 insertions, 10 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 1c856a1..dd0143c 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -23,6 +23,7 @@ from .backends import InstallData
from ..build import InvalidArguments
import os, sys, pickle, re
import subprocess, shutil
+from collections import OrderedDict
if mesonlib.is_windows():
quote_char = '"'
@@ -239,7 +240,7 @@ int dummy;
(relative to the build directory) of that type and the value
being the GeneratorList or CustomTarget that generated it.
"""
- srcs = {}
+ srcs = OrderedDict()
for gensrc in target.get_generated_sources():
for s in gensrc.get_outputs():
f = self.get_target_generated_dir(target, gensrc, s)
@@ -247,7 +248,7 @@ int dummy;
return srcs
def get_target_sources(self, target):
- srcs = {}
+ srcs = OrderedDict()
for s in target.get_sources():
# BuildTarget sources are always mesonlib.File files which are
# either in the source root, or generated with configure_file and
@@ -300,10 +301,10 @@ int dummy;
# Pre-existing target C/C++ sources to be built; dict of full path to
# source relative to build root and the original File object.
- target_sources = {}
+ target_sources = OrderedDict()
# GeneratedList and CustomTarget sources to be built; dict of the full
# path to source relative to build root and the generating target/list
- generated_sources = {}
+ generated_sources = OrderedDict()
# Array of sources generated by valac that have to be compiled
vala_generated_sources = []
if 'vala' in target.compilers:
@@ -939,10 +940,10 @@ int dummy;
the keys being the path to the file (relative to the build directory)
and the value being the object that generated or represents the file.
"""
- vala = {}
- vapi = {}
- others = {}
- othersgen = {}
+ vala = OrderedDict()
+ vapi = OrderedDict()
+ others = OrderedDict()
+ othersgen = OrderedDict()
# Split pre-existing sources
for s in t.get_sources():
# BuildTarget sources are always mesonlib.File files which are
@@ -1087,7 +1088,7 @@ int dummy;
args += ['--out-dir', target.subdir]
args += ['--emit', 'dep-info', '--emit', 'link']
orderdeps = [os.path.join(t.subdir, t.get_filename()) for t in target.link_targets]
- linkdirs = {}
+ linkdirs = OrderedDict()
for d in target.link_targets:
linkdirs[d.subdir] = True
for d in linkdirs.keys():
diff --git a/run_unittests.py b/run_unittests.py
index b9c1397..9391eae 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -136,5 +136,16 @@ class LinuxlikeTests(unittest.TestCase):
self.assertTrue('-Werror' in vala_command)
self.assertTrue('-Werror' in c_command)
+ def test_static_compile_order(self):
+ testdir = os.path.join(self.common_test_dir, '5 linkstatic')
+ self.init(testdir)
+ compdb = self.get_compdb()
+ # Rules will get written out in this order
+ self.assertTrue(compdb[0]['file'].endswith("libfile.c"))
+ self.assertTrue(compdb[1]['file'].endswith("libfile2.c"))
+ self.assertTrue(compdb[2]['file'].endswith("libfile3.c"))
+ self.assertTrue(compdb[3]['file'].endswith("libfile4.c"))
+ # FIXME: We don't have access to the linker command
+
if __name__ == '__main__':
unittest.main()
diff --git a/test cases/common/5 linkstatic/libfile2.c b/test cases/common/5 linkstatic/libfile2.c
new file mode 100644
index 0000000..89780f5
--- /dev/null
+++ b/test cases/common/5 linkstatic/libfile2.c
@@ -0,0 +1,3 @@
+int func2() {
+ return 2;
+}
diff --git a/test cases/common/5 linkstatic/libfile3.c b/test cases/common/5 linkstatic/libfile3.c
new file mode 100644
index 0000000..5e0d08b
--- /dev/null
+++ b/test cases/common/5 linkstatic/libfile3.c
@@ -0,0 +1,3 @@
+int func3() {
+ return 3;
+}
diff --git a/test cases/common/5 linkstatic/libfile4.c b/test cases/common/5 linkstatic/libfile4.c
new file mode 100644
index 0000000..3645c31
--- /dev/null
+++ b/test cases/common/5 linkstatic/libfile4.c
@@ -0,0 +1,3 @@
+int func4() {
+ return 4;
+}
diff --git a/test cases/common/5 linkstatic/meson.build b/test cases/common/5 linkstatic/meson.build
index c1cb8b6..1f02a5c 100644
--- a/test cases/common/5 linkstatic/meson.build
+++ b/test cases/common/5 linkstatic/meson.build
@@ -1,6 +1,6 @@
project('static library linking test', 'c')
-lib = build_target('mylib', 'libfile.c', target_type : 'static_library')
+lib = build_target('mylib', 'libfile.c', 'libfile2.c', 'libfile3.c', 'libfile4.c', target_type : 'static_library')
exe = executable('prog', 'main.c', link_with : lib)
test('runtest', exe)