-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
545d345
commit cf0d1d6
Showing
6 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
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 | ||
self.options.shared = True | ||
|
||
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
8
recipes/gobject-introspection/all/test_package/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
recipes/gobject-introspection/all/test_package/conanfile.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
11 changes: 11 additions & 0 deletions
11
recipes/gobject-introspection/all/test_package/test_package.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#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()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"1.66.1": | ||
folder: all |