Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gobject-introspection 1.66.1 #4254

Merged
merged 2 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/gobject-introspection/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.66.1":
url: "https://download.gnome.org/sources/gobject-introspection/1.66/gobject-introspection-1.66.1.tar.xz"
sha256: "dd44a55ee5f426ea22b6b89624708f9e8d53f5cc94e5485c15c87cb30e06161d"
112 changes: 112 additions & 0 deletions recipes/gobject-introspection/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment
from conans.errors import ConanInvalidConfiguration
import os
import shutil
import glob


class GobjectIntrospectionConan(ConanFile):
name = "gobject-introspection"
description = "GObject introspection is a middleware layer between C libraries (using GObject) and language bindings"
topics = ("conan", "gobject-instrospection")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://gitlab.gnome.org/GNOME/gobject-introspection"
license = "LGPL-2.1"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
generators = "pkg_config"

@property
def _is_msvc(self):
return self.settings.compiler == "Visual Studio"

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
del self.options.fPIC
del self.options.fPIC
def validate(self):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had very strange bugs on CCI when using validate(self) the last days:
eg #4181 (comment) or #4182 (comment)
so I'm not very inclined to use it until we understand what happened. Can we wait to introduce it ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#4193 too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, validate is experimental and even missing from the Conan changelog :) Hope we would refactor recipes to use validate later.

if self.settings.os == "Windows":
raise ConanInvalidConfiguration("%s recipe does not support windows. Contributions are welcome!", self.name)

def build_requirements(self):
self.build_requires("meson/0.56.1")
self.build_requires("pkgconf/1.7.3")
if self.settings.os == "Windows":
self.build_requires("winflexbison/2.5.22")
else:
self.build_requires("flex/2.6.4")
self.build_requires("bison/3.7.1")

def requirements(self):
self.requires("glib/2.67.1")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_meson(self):
meson = Meson(self)
defs = dict()
defs["build_introspection_data"] = self.options["glib"].shared

meson.configure(
source_folder=self._source_subfolder,
args=["--wrap-mode=nofallback"],
build_folder=self._build_subfolder,
defs=defs,
)
return meson

def build(self):
tools.replace_in_file(
os.path.join(self._source_subfolder, "meson.build"),
"subdir('tests')",
"#subdir('tests')",
)
tools.replace_in_file(
os.path.join(self._source_subfolder, "meson.build"),
"if meson.version().version_compare('>=0.54.0')",
"if false",
)

with tools.environment_append(
VisualStudioBuildEnvironment(self).vars
if self._is_msvc
else {"PKG_CONFIG_PATH": self.build_folder}
):
meson = self._configure_meson()
meson.build()

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()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
shutil.move(
os.path.join(self.package_folder, "share"),
os.path.join(self.package_folder, "res"),
)
for pdb_file in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")):
os.unlink(pdb_file)

def package_info(self):
self.cpp_info.names["pkg_config"] = "gobject-introspection-1.0"
self.cpp_info.libs = ["girepository-1.0"]
self.cpp_info.includedirs.append(
os.path.join("include", "gobject-introspection-1.0")
)

bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH env var with: {}".format(bin_path))
self.env_info.PATH.append(bin_path)
8 changes: 8 additions & 0 deletions recipes/gobject-introspection/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
25 changes: 25 additions & 0 deletions recipes/gobject-introspection/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package", "pkg_config"

def build(self):
if self.settings.os != 'Windows':
self.run('g-ir-annotation-tool --version', run_environment=True)
self.run('g-ir-compiler --version', run_environment=True)
self.run('g-ir-generate --version', run_environment=True)
self.run('g-ir-inspect -h', run_environment=True)
self.run('g-ir-scanner --version', run_environment=True)

cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

12 changes: 12 additions & 0 deletions recipes/gobject-introspection/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>

#include "girepository.h"

int main(int argc, char **argv)
{
printf("gobject introspection version %d.%d.%d\n",
gi_get_major_version(),
gi_get_minor_version(),
gi_get_micro_version());
return 0;
}
3 changes: 3 additions & 0 deletions recipes/gobject-introspection/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.66.1":
folder: all