diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.com> | 2020-11-16 17:23:51 +0300 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.com> | 2020-11-16 17:30:32 +0300 |
commit | b9f8ce999538aa1a8880a8e41202b9e70f514e71 (patch) | |
tree | d17e40f13e35a42c28a343afdb30af1cdbe54c38 | |
parent | 717477fd36f00c5f1b8dbb64ec4dadc602d5fc22 (diff) |
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
-rw-r--r-- | audio/audiofx/Cargo.toml | 2 | ||||
-rw-r--r-- | audio/claxon/Cargo.toml | 2 | ||||
-rw-r--r-- | audio/csound/Cargo.toml | 2 | ||||
-rw-r--r-- | audio/lewton/Cargo.toml | 2 | ||||
-rw-r--r-- | cargo_wrapper.py | 9 | ||||
-rw-r--r-- | generic/file/Cargo.toml | 2 | ||||
-rw-r--r-- | generic/sodium/Cargo.toml | 2 | ||||
-rw-r--r-- | generic/threadshare/Cargo.toml | 2 | ||||
-rw-r--r-- | meson.build | 31 | ||||
-rw-r--r-- | net/reqwest/Cargo.toml | 2 | ||||
-rw-r--r-- | net/rusoto/Cargo.toml | 2 | ||||
-rw-r--r-- | text/wrap/Cargo.toml | 2 | ||||
-rw-r--r-- | tutorial/Cargo.toml | 2 | ||||
-rw-r--r-- | utils/fallbackswitch/Cargo.toml | 2 | ||||
-rw-r--r-- | utils/togglerecord/Cargo.toml | 2 | ||||
-rw-r--r-- | video/cdg/Cargo.toml | 2 | ||||
-rw-r--r-- | video/closedcaption/Cargo.toml | 2 | ||||
-rw-r--r-- | video/dav1d/Cargo.toml | 2 | ||||
-rw-r--r-- | video/flavors/Cargo.toml | 2 | ||||
-rw-r--r-- | video/gif/Cargo.toml | 2 | ||||
-rw-r--r-- | video/rav1e/Cargo.toml | 2 | ||||
-rw-r--r-- | video/rspng/Cargo.toml | 2 |
22 files changed, 52 insertions, 28 deletions
diff --git a/audio/audiofx/Cargo.toml b/audio/audiofx/Cargo.toml index 85dd5fa93..6a264e0f9 100644 --- a/audio/audiofx/Cargo.toml +++ b/audio/audiofx/Cargo.toml @@ -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] diff --git a/audio/claxon/Cargo.toml b/audio/claxon/Cargo.toml index 149af82ca..2f8101c0d 100644 --- a/audio/claxon/Cargo.toml +++ b/audio/claxon/Cargo.toml @@ -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] diff --git a/audio/csound/Cargo.toml b/audio/csound/Cargo.toml index 034ea4cf1..0ef87902b 100644 --- a/audio/csound/Cargo.toml +++ b/audio/csound/Cargo.toml @@ -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]] diff --git a/audio/lewton/Cargo.toml b/audio/lewton/Cargo.toml index 1e5cef57f..444c9e7d3 100644 --- a/audio/lewton/Cargo.toml +++ b/audio/lewton/Cargo.toml @@ -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] diff --git a/cargo_wrapper.py b/cargo_wrapper.py index f951c514d..23c0dabc0 100644 --- a/cargo_wrapper.py +++ b/cargo_wrapper.py @@ -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) diff --git a/generic/file/Cargo.toml b/generic/file/Cargo.toml index ae0f4b24b..9493baf6c 100644 --- a/generic/file/Cargo.toml +++ b/generic/file/Cargo.toml @@ -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] diff --git a/generic/sodium/Cargo.toml b/generic/sodium/Cargo.toml index ebb68a00c..bb8119011 100644 --- a/generic/sodium/Cargo.toml +++ b/generic/sodium/Cargo.toml @@ -35,7 +35,7 @@ package="gstreamer-app" [lib] name = "gstsodium" -crate-type = ["cdylib", "rlib"] +crate-type = ["cdylib", "rlib", "staticlib"] path = "src/lib.rs" [[example]] diff --git a/generic/threadshare/Cargo.toml b/generic/threadshare/Cargo.toml index 1c8da3c45..531225689 100644 --- a/generic/threadshare/Cargo.toml +++ b/generic/threadshare/Cargo.toml @@ -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]] diff --git a/meson.build b/meson.build index ba36b173d..4ef622fba 100644 --- a/meson.build +++ b/meson.build @@ -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 diff --git a/net/reqwest/Cargo.toml b/net/reqwest/Cargo.toml index 367f6fc72..cc9a6b6ef 100644 --- a/net/reqwest/Cargo.toml +++ b/net/reqwest/Cargo.toml @@ -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] diff --git a/net/rusoto/Cargo.toml b/net/rusoto/Cargo.toml index 8e898bbc5..aecee5e9c 100644 --- a/net/rusoto/Cargo.toml +++ b/net/rusoto/Cargo.toml @@ -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] diff --git a/text/wrap/Cargo.toml b/text/wrap/Cargo.toml index 594e1855e..20ae8cfbb 100644 --- a/text/wrap/Cargo.toml +++ b/text/wrap/Cargo.toml @@ -20,7 +20,7 @@ package="gstreamer" [lib] name = "gstrstextwrap" -crate-type = ["cdylib", "rlib"] +crate-type = ["cdylib", "rlib", "staticlib"] path = "src/lib.rs" [build-dependencies] diff --git a/tutorial/Cargo.toml b/tutorial/Cargo.toml index 5c45fa9fd..f3f2e70f0 100644 --- a/tutorial/Cargo.toml +++ b/tutorial/Cargo.toml @@ -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] diff --git a/utils/fallbackswitch/Cargo.toml b/utils/fallbackswitch/Cargo.toml index 6f9994155..5084d0b25 100644 --- a/utils/fallbackswitch/Cargo.toml +++ b/utils/fallbackswitch/Cargo.toml @@ -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]] diff --git a/utils/togglerecord/Cargo.toml b/utils/togglerecord/Cargo.toml index 44c5ab5d2..627286395 100644 --- a/utils/togglerecord/Cargo.toml +++ b/utils/togglerecord/Cargo.toml @@ -23,7 +23,7 @@ either = "1.0" [lib] name = "gsttogglerecord" -crate-type = ["cdylib", "rlib"] +crate-type = ["cdylib", "rlib", "staticlib"] path = "src/lib.rs" [[example]] diff --git a/video/cdg/Cargo.toml b/video/cdg/Cargo.toml index 56a71e87f..604a5b03f 100644 --- a/video/cdg/Cargo.toml +++ b/video/cdg/Cargo.toml @@ -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] diff --git a/video/closedcaption/Cargo.toml b/video/closedcaption/Cargo.toml index 1518bdaff..b81088c62 100644 --- a/video/closedcaption/Cargo.toml +++ b/video/closedcaption/Cargo.toml @@ -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] diff --git a/video/dav1d/Cargo.toml b/video/dav1d/Cargo.toml index ee2eaca36..df6582ab0 100644 --- a/video/dav1d/Cargo.toml +++ b/video/dav1d/Cargo.toml @@ -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] diff --git a/video/flavors/Cargo.toml b/video/flavors/Cargo.toml index a383a99da..3636d5ac4 100644 --- a/video/flavors/Cargo.toml +++ b/video/flavors/Cargo.toml @@ -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] diff --git a/video/gif/Cargo.toml b/video/gif/Cargo.toml index 6973980a3..07995281b 100644 --- a/video/gif/Cargo.toml +++ b/video/gif/Cargo.toml @@ -18,7 +18,7 @@ once_cell = "1" [lib] name = "gstgif" -crate-type = ["cdylib", "rlib"] +crate-type = ["cdylib", "rlib", "staticlib"] path = "src/lib.rs" [[example]] diff --git a/video/rav1e/Cargo.toml b/video/rav1e/Cargo.toml index 758903edb..5ed1db609 100644 --- a/video/rav1e/Cargo.toml +++ b/video/rav1e/Cargo.toml @@ -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] diff --git a/video/rspng/Cargo.toml b/video/rspng/Cargo.toml index aa5da4d00..b7d524469 100644 --- a/video/rspng/Cargo.toml +++ b/video/rspng/Cargo.toml @@ -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] |