diff --git a/recipes/gst-plugins-ugly/all/conandata.yml b/recipes/gst-plugins-ugly/all/conandata.yml new file mode 100644 index 0000000000000..a6f4354cc6a61 --- /dev/null +++ b/recipes/gst-plugins-ugly/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.19.1": + url: "https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/archive/1.19.1/gst-plugins-ugly-1.19.1.tar.bz2" + sha256 : "b9ae94a04eaf9d93bc36500b3d7eda864f82142d2ce950c1e92a4288924227e6" diff --git a/recipes/gst-plugins-ugly/all/conanfile.py b/recipes/gst-plugins-ugly/all/conanfile.py new file mode 100644 index 0000000000000..b889700ec4e84 --- /dev/null +++ b/recipes/gst-plugins-ugly/all/conanfile.py @@ -0,0 +1,171 @@ +from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment +from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import msvc_runtime_flag +import glob +import os +import shutil + + +class GStPluginsUglyConan(ConanFile): + name = "gst-plugins-ugly" + description = "GStreamer is a development framework for creating applications like media players, video editors, " \ + "streaming media broadcasters and so on" + topics = ("gstreamer", "multimedia", "video", "audio", "broadcasting", "framework", "media") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gstreamer.freedesktop.org/" + license = "GPL-2.0-only" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_introspection": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_introspection": False, + } + _source_subfolder = "source_subfolder" + _build_subfolder = "build_subfolder" + exports_sources = ["patches/*.patch"] + + generators = "pkg_config" + + @property + def _is_msvc(self): + return self.settings.compiler == "Visual Studio" + + def validate(self): + if self.options.shared != self.options["gstreamer"].shared or \ + self.options.shared != self.options["glib"].shared or \ + self.options.shared != self.options["gst-plugins-base"].shared: + # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/133 + raise ConanInvalidConfiguration("GLib, GStreamer and GstPlugins must be either all shared, or all static") + if tools.Version(self.version) >= "1.18.2" and\ + self.settings.compiler == "gcc" and\ + tools.Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration( + "gst-plugins-ugly%s does not support gcc older than 5" % self.version + ) + if self.options.shared and str(msvc_runtime_flag(self)).startswith("MT"): + raise ConanInvalidConfiguration('shared build with static runtime is not supported due to the FlsAlloc limit') + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + self.options['gstreamer'].shared = self.options.shared + self.options['gst-plugins-base'].shared = self.options.shared + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def requirements(self): + self.requires("glib/2.70.1") + self.requires("gstreamer/1.19.1") + self.requires("gst-plugins-base/1.19.1") + + def build_requirements(self): + self.build_requires("meson/0.54.2") + if not tools.which("pkg-config"): + self.build_requires("pkgconf/1.7.4") + if self.settings.os == 'Windows': + self.build_requires("winflexbison/2.5.24") + else: + self.build_requires("bison/3.7.6") + self.build_requires("flex/2.6.4") + if self.options.with_introspection: + self.build_requires("gobject-introspection/1.68.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_meson(self): + defs = dict() + + def add_flag(name, value): + if name in defs: + defs[name] += " " + value + else: + defs[name] = value + + def add_compiler_flag(value): + add_flag("c_args", value) + add_flag("cpp_args", value) + + def add_linker_flag(value): + add_flag("c_link_args", value) + add_flag("cpp_link_args", value) + + meson = Meson(self) + if self.settings.compiler == "Visual Studio": + add_linker_flag("-lws2_32") + add_compiler_flag("-%s" % self.settings.compiler.runtime) + if int(str(self.settings.compiler.version)) < 14: + add_compiler_flag("-Dsnprintf=_snprintf") + if self.settings.get_safe("compiler.runtime"): + defs["b_vscrt"] = str(self.settings.compiler.runtime).lower() + defs["tools"] = "disabled" + defs["examples"] = "disabled" + defs["benchmarks"] = "disabled" + defs["tests"] = "disabled" + defs["wrap_mode"] = "nofallback" + defs["introspection"] = "enabled" if self.options.with_introspection else "disabled" + meson.configure(build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + defs=defs) + return meson + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.build() + + def _fix_library_names(self, path): + # regression in 1.16 + if self.settings.compiler == "Visual Studio": + with tools.chdir(path): + for filename_old in glob.glob("*.a"): + filename_new = filename_old[3:-2] + ".lib" + self.output.info("rename %s into %s" % (filename_old, filename_new)) + shutil.move(filename_old, filename_new) + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.install() + + self._fix_library_names(os.path.join(self.package_folder, "lib")) + self._fix_library_names(os.path.join(self.package_folder, "lib", "gstreamer-1.0")) + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "gstreamer-1.0", "pkgconfig")) + tools.remove_files_by_mask(self.package_folder, "*.pdb") + + def package_info(self): + + plugins = ["asf", + "dvdlpcmdec", + "dvdsub", + "realmedia", + "xingmux"] + + gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0") + if self.options.shared: + self.output.info("Appending GST_PLUGIN_PATH env var : %s" % gst_plugin_path) + self.cpp_info.bindirs.append(gst_plugin_path) + self.runenv_info.prepend_path("GST_PLUGIN_PATH", gst_plugin_path) + self.env_info.GST_PLUGIN_PATH.append(gst_plugin_path) + else: + self.cpp_info.defines.append("GST_PLUGINS_UGLY_STATIC") + self.cpp_info.libdirs.append(gst_plugin_path) + self.cpp_info.libs.extend(["gst%s" % plugin for plugin in plugins]) + + self.cpp_info.includedirs = ["include", os.path.join("include", "gstreamer-1.0")] diff --git a/recipes/gst-plugins-ugly/all/test_package/CMakeLists.txt b/recipes/gst-plugins-ugly/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..86125a5ca6402 --- /dev/null +++ b/recipes/gst-plugins-ugly/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gst-plugins-ugly CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} gst-plugins-ugly::gst-plugins-ugly) diff --git a/recipes/gst-plugins-ugly/all/test_package/conanfile.py b/recipes/gst-plugins-ugly/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/gst-plugins-ugly/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gst-plugins-ugly/all/test_package/test_package.cpp b/recipes/gst-plugins-ugly/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..9824c176d4b22 --- /dev/null +++ b/recipes/gst-plugins-ugly/all/test_package/test_package.cpp @@ -0,0 +1,34 @@ +#include +#include + +#ifdef GST_PLUGINS_UGLY_STATIC + +extern "C" +{ + GST_PLUGIN_STATIC_DECLARE(asf); +} + +#endif + +#include + +int main(int argc, char * argv[]) +{ + gst_init(&argc, &argv); + +#ifdef GST_PLUGINS_UGLY_STATIC + + GST_PLUGIN_STATIC_REGISTER(asf); + +#endif + + GstElement * asfdemux = gst_element_factory_make("asfdemux", NULL); + if (!asfdemux) { + std::cerr << "failed to create asfdemux element" << std::endl; + return -1; + } else { + std::cout << "asfdemux has been created successfully" << std::endl; + } + gst_object_unref(GST_OBJECT(asfdemux)); + return 0; +} diff --git a/recipes/gst-plugins-ugly/config.yml b/recipes/gst-plugins-ugly/config.yml new file mode 100644 index 0000000000000..e20650f02a0e5 --- /dev/null +++ b/recipes/gst-plugins-ugly/config.yml @@ -0,0 +1,3 @@ +versions: + "1.19.1": + folder: all