meson: add support for static build

There is no way to dynamically ask Cargo to build static or dynamic lib
so we have to build both and pick the one we care when doing the meson
processing.

Fix #88
This commit is contained in:
Guillaume Desmottes 2020-11-16 15:23:51 +01:00
parent 717477fd36
commit b9f8ce9995
22 changed files with 52 additions and 28 deletions

View file

@ -20,7 +20,7 @@ nnnoiseless = { version = "0.3", default-features = false }
[lib]
name = "gstrsaudiofx"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[dev-dependencies]

View file

@ -18,7 +18,7 @@ atomic_refcell = "0.1"
[lib]
name = "gstclaxon"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -19,7 +19,7 @@ byte-slice-cast = "1.0"
[lib]
name = "gstcsound"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[[example]]

View file

@ -19,7 +19,7 @@ lazy_static = "1.0"
[lib]
name = "gstlewton"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -27,6 +27,12 @@ if len(extra_env) > 0:
if command == 'build':
# cargo build
ext = sys.argv[8]
# when using --default-library=both 2 extensions are passed
try:
ext2 = sys.argv[9]
except IndexError:
ext2 = None
cargo_cmd = ['cargo', 'build', '--all-targets',
'--manifest-path', os.path.join(
meson_current_source_dir, 'Cargo.toml'),
@ -56,3 +62,6 @@ if command == 'build':
# Copy so files to build dir
for f in glob.glob(os.path.join(cargo_target_dir, target, '*.' + ext)):
shutil.copy(f, meson_build_dir)
if ext2:
for f in glob.glob(os.path.join(cargo_target_dir, target, '*.' + ext2)):
shutil.copy(f, meson_build_dir)

View file

@ -15,7 +15,7 @@ lazy_static = "1.0"
[lib]
name = "gstrsfile"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -35,7 +35,7 @@ package="gstreamer-app"
[lib]
name = "gstsodium"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[[example]]

View file

@ -36,7 +36,7 @@ socket2 = { version = "0.3", features = ["reuseport"] }
[lib]
name = "gstthreadshare"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[[example]]

View file

@ -15,11 +15,14 @@ cargo_wrapper = find_program('cargo_wrapper.py')
system = build_machine.system()
if system == 'windows'
ext = 'dll'
ext_dynamic = 'dll'
ext_static = 'lib'
elif system == 'darwin'
ext = 'dylib'
ext_dynamic = 'dylib'
ext_static = 'a'
else
ext = 'so'
ext_dynamic = 'so'
ext_static = 'a'
endif
plugins_rep = {
@ -82,10 +85,22 @@ endif
output = []
foreach p, lib : plugins_rep
# Add the plugin file as output
output += [lib + '.' + ext]
endforeach
extensions = []
# Add the plugin file as output
if get_option('default_library') == 'shared' or get_option('default_library') == 'both'
extensions += [ext_dynamic]
foreach p, lib : plugins_rep
output += [lib + '.' + ext_dynamic]
endforeach
endif
if get_option('default_library') == 'static' or get_option('default_library') == 'both'
extensions += [ext_static]
foreach p, lib : plugins_rep
output += [lib + '.' + ext_static]
endforeach
endif
# Need to depends on all gstreamer-rs deps to ensure they are built
# before gstreamer-rs when building with gst-build.
@ -143,7 +158,7 @@ rs_plugins = custom_target('gst-plugins-rs',
target,
exclude,
extra_env_str,
ext])
extensions])
# FIXME: raises a warning as the target has multiple outputs and meson will use
# only the first one. All the plugins have the same basedir, hence

View file

@ -24,7 +24,7 @@ hyper = "0.13"
[lib]
name = "gstreqwest"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -34,7 +34,7 @@ serde_json = "1"
[lib]
name = "gstrusoto"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -20,7 +20,7 @@ package="gstreamer"
[lib]
name = "gstrstextwrap"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -19,7 +19,7 @@ once_cell = "1.0"
[lib]
name = "gstrstutorial"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -27,7 +27,7 @@ gst-check = { package = "gstreamer-check", git = "https://gitlab.freedesktop.org
[lib]
name = "gstfallbackswitch"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[[example]]

View file

@ -23,7 +23,7 @@ either = "1.0"
[lib]
name = "gsttogglerecord"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[[example]]

View file

@ -21,7 +21,7 @@ lazy_static = "1.0"
[lib]
name = "gstcdg"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -46,7 +46,7 @@ package="gstreamer-check"
[lib]
name = "gstrsclosedcaption"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -17,7 +17,7 @@ lazy_static = "1.0"
[lib]
name = "gstrsdav1d"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -21,7 +21,7 @@ smallvec = "1.0"
[lib]
name = "gstrsflv"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -18,7 +18,7 @@ once_cell = "1"
[lib]
name = "gstgif"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[[example]]

View file

@ -18,7 +18,7 @@ lazy_static = "1.0"
[lib]
name = "gstrav1e"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]

View file

@ -19,7 +19,7 @@ atomic_refcell = "0.1"
[lib]
name = "gstrspng"
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib", "staticlib"]
path = "src/lib.rs"
[build-dependencies]