aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmeson_install.py12
-rw-r--r--ninjabackend.py2
-rwxr-xr-xrustrunner.py5
-rw-r--r--test cases/rust/3 staticlib/installed_files.txt2
-rw-r--r--test cases/rust/3 staticlib/meson.build5
-rw-r--r--test cases/rust/3 staticlib/prog.rs3
-rw-r--r--test cases/rust/3 staticlib/stuff.rs3
7 files changed, 31 insertions, 1 deletions
diff --git a/meson_install.py b/meson_install.py
index 3333071..1c50f9c 100755
--- a/meson_install.py
+++ b/meson_install.py
@@ -110,10 +110,20 @@ def check_for_stampfile(fname):
(base, suffix) = os.path.splitext(fname)
files = glob(base + '-*' + suffix)
if len(files) > 1:
- print("Stale library files in build dir. Can't install.")
+ print("Stale dynamic library files in build dir. Can't install.")
sys.exit(1)
if len(files) == 1:
return files[0]
+ elif fname.endswith('.a') or fname.endswith('.lib'):
+ if os.stat(fname).st_size == 0:
+ (base, suffix) = os.path.splitext(fname)
+ files = glob(base + '-*' + '.rlib')
+ if len(files) > 1:
+ print("Stale static library files in build dir. Can't install.")
+ sys.exit(1)
+ if len(files) == 1:
+ return files[0]
+
return fname
def install_targets(d):
diff --git a/ninjabackend.py b/ninjabackend.py
index cdef50a..7a36f6f 100644
--- a/ninjabackend.py
+++ b/ninjabackend.py
@@ -508,6 +508,8 @@ class NinjaBackend(backends.Backend):
cratetype = 'bin'
elif isinstance(target, build.SharedLibrary):
cratetype = 'dylib'
+ elif isinstance(target, build.StaticLibrary):
+ cratetype = 'lib'
else:
raise InvalidArguments('Unknown target type for rustc.')
args.append(cratetype)
diff --git a/rustrunner.py b/rustrunner.py
index 4af196b..57e6124 100755
--- a/rustrunner.py
+++ b/rustrunner.py
@@ -30,6 +30,11 @@ def delete_old_crates(target_name, target_type):
crates = glob.glob(base + '-*' + suffix)
crates = [(os.stat(i).st_mtime, i) for i in crates]
[os.unlink(c[1]) for c in sorted(crates)[:-1]]
+ if target_type == 'lib':
+ (base, suffix) = os.path.splitext(target_name)
+ crates = glob.glob(base + '-*' + '.rlib') # Rust does not use .a
+ crates = [(os.stat(i).st_mtime, i) for i in crates]
+ [os.unlink(c[1]) for c in sorted(crates)[:-1]]
def invoke_rust(rustc_command):
return subprocess.call(rustc_command, shell=False)
diff --git a/test cases/rust/3 staticlib/installed_files.txt b/test cases/rust/3 staticlib/installed_files.txt
new file mode 100644
index 0000000..4c3dfed
--- /dev/null
+++ b/test cases/rust/3 staticlib/installed_files.txt
@@ -0,0 +1,2 @@
+bin/prog
+lib/libstuff-e4d2ee75-1.0.rlib
diff --git a/test cases/rust/3 staticlib/meson.build b/test cases/rust/3 staticlib/meson.build
new file mode 100644
index 0000000..6769564
--- /dev/null
+++ b/test cases/rust/3 staticlib/meson.build
@@ -0,0 +1,5 @@
+project('rust static library', 'rust')
+
+l = static_library('stuff', 'stuff.rs', install : true)
+e = executable('prog', 'prog.rs', link_with : l, install : true)
+test('linktest', e)
diff --git a/test cases/rust/3 staticlib/prog.rs b/test cases/rust/3 staticlib/prog.rs
new file mode 100644
index 0000000..fbf3181
--- /dev/null
+++ b/test cases/rust/3 staticlib/prog.rs
@@ -0,0 +1,3 @@
+extern crate stuff;
+
+fn main() { println!("printing: {}", stuff::explore()); }
diff --git a/test cases/rust/3 staticlib/stuff.rs b/test cases/rust/3 staticlib/stuff.rs
new file mode 100644
index 0000000..5e1dcc2
--- /dev/null
+++ b/test cases/rust/3 staticlib/stuff.rs
@@ -0,0 +1,3 @@
+#![crate_id = "stuff#1.0"]
+
+pub fn explore() -> &'static str { "librarystring" }