Skip to content

Commit

Permalink
Merge branch 'master' into mpir-relocatable-macos
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceIm committed Feb 2, 2022
2 parents 0ae986e + a9b9f0f commit 1f6d6ff
Show file tree
Hide file tree
Showing 145 changed files with 2,227 additions and 496 deletions.
32 changes: 32 additions & 0 deletions .github/recipe_linter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"problemMatcher": [
{
"owner": "recipe_linter_errors",
"severity": "error",
"pattern": [
{
"regexp": "(\\S+):(\\d+):(\\d+):\\s(E\\d+):\\s(.+)\\s\\((\\S+)\\)",
"file": 1,
"line": 2,
"column": 3,
"message": 5,
"code": 4
}
]
},
{
"owner": "recipe_linter_warnings",
"severity": "warning",
"pattern": [
{
"regexp": "(\\S+):(\\d+):(\\d+):\\s(W\\d+):\\s(.+)\\s\\((\\S+)\\)",
"file": 1,
"line": 2,
"column": 3,
"message": 5,
"code": 4
}
]
}
]
}
57 changes: 57 additions & 0 deletions .github/runlint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os
import yaml
import requests
import packaging.version
import subprocess
import platform
import sys


def main(pr):
session = requests.session()
session.headers = {}
token = os.getenv("GH_TOKEN")
if token:
session.headers["Authorization"] = "token %s" % token

session.headers["Accept"] = "application/vnd.github.v3+json"
session.headers["User-Agent"] = "request"
session.auth = None
# if user and pw:
# session.auth = requests.auth.HTTPBasicAuth(user, pw)

github_server_url = os.getenv("GITHUB_SERVER_URL")
github_repo = os.getenv("GITHUB_REPOSITORY")

r = session.request("GET", f"{github_server_url}/{github_repo}/pull/{pr}.diff")
r.raise_for_status()
diff = r.text
packages = set()
for line in diff.split("\n"):
if line.startswith("+++ b/recipes/") or line.startswith("--- a/recipes/"):
parts = line.split("/")
if len(parts) >= 5:
packages.add(parts[2] + "/" + parts[3])
for line in packages:
package = line.split("/")[0]
version = None
folder = line.split("/")[1]
with open(os.path.join("recipes", package, "config.yml"), "r") as file:
config = yaml.safe_load(file)
for v in config["versions"]:
if config["versions"][v]["folder"] != folder:
continue
try:
if not version or packaging.version.Version(v) > packaging.version.Version(version):
version = v
except packaging.version.InvalidVersion:
print("Error parsing version %s for package %s in pr %s" % (v, package, pr))

if version:
shell = bool(platform.system() != "Windows")
command = "conan export %s %s/%s@" % (os.path.join("recipes", package, folder), package, version)
p = subprocess.run(command, shell=shell, check=False)

if __name__ == "__main__":
# execute only if run as a script
main(sys.argv[1])
33 changes: 33 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: run linters

on:
pull_request:

jobs:
lint:
env:
CONAN_YAMLLINT_WERR: 1
CONAN_PYLINT_WERR: 1
strategy:
fail-fast: false
matrix:
hook: ["yaml_linter", "recipe_linter"]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2.2.2
with:
python-version: "3.8"

- run: "pip3 install conan yamllint packaging pylint==2.10.2 astroid"

- name: install hook
run: |
conan config install https://github.com/conan-io/hooks.git
conan config set hooks.${{ matrix.hook }}
- name: run lint
run: |
echo "::add-matcher::.github/${{ matrix.hook }}.json"
python3 .github/runlint.py ${{ github.event.pull_request.number }}
18 changes: 18 additions & 0 deletions .github/yaml_linter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "yaml_linter",
"pattern": [
{
"regexp": "^\\[HOOK\\s-\\syaml_linter\\.py\\]\\spre_export\\(\\):\\s(.+):(\\d+):(\\d+):\\s\\[(\\S+)\\]\\s(.+)\\s\\((.+)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
13 changes: 11 additions & 2 deletions docs/faqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This section gathers the most common questions from the community related to pac
* [What is the policy for supported python versions?](#what-is-the-policy-for-supported-python-versions)
* [How to package libraries that depend on proprietary closed-source libraries?](#how-to-package-libraries-that-depend-on-proprietary-closed-source-libraries)
* [How to _protect_ my project from breaking changes in recipes?](#how-to-_protect_-my-project-from-breaking-changes-in-recipes)<!-- endToc -->
* [Why are version ranges not allowed?](#why-are-version-ranges-not-allowed)<!-- endToc -->

## What is the policy on recipe name collisions?

Expand Down Expand Up @@ -138,7 +139,9 @@ There are some recipes in `conan-center-index` that provide packages that contai

We decided that these packages (as long as they match the premises) should list all the settings needed to build, so building from sources will generate the expected binary, but they will **remove `compiler` setting inside the `package_id()` method**. As a consequence, the CI will generate packages only for one compiler reducing the workload in the pipeline and the number of possible package IDs.

Note about `build_type`.- We retain the `build_type` setting to make it possible for the users to _debug_ these installer packages. We considered removing this settings and it would be possible to compile these packages in _debug_ mode, but if we remove it from the packageID, the compiled package would override the existing _release_ binary, and it'd be quite inconvenient for the users to compile the binary every time they need to switch from _debug_ to _release_.
Notes about `build_type`:

We retain the `build_type` setting to make it possible for the users to _debug_ these installer packages. We considered removing this settings and it would be possible to compile these packages in _debug_ mode, but if we remove it from the packageID, the compiled package would override the existing _release_ binary, and it'd be quite inconvenient for the users to compile the binary every time they need to switch from _debug_ to _release_.

## Can I remove an option from recipe

Expand Down Expand Up @@ -187,7 +190,7 @@ def configure(self):
tools.check_min_cppstd(self, 14) 👈 Wrong!
```

This fails to cover the waste number of use cases for the following reasons:
This fails to cover the vast number of use cases for the following reasons:

1. `cppstd` is not configured in the `--detect`ed profiles generated by Conan, the majority of users simply do not have this setting.
2. A shocking number of projects override this setting within their respective build scripts, this setting does not get applied in those cases.
Expand Down Expand Up @@ -334,3 +337,9 @@ To isolate from this changes there are different strategies you can follow:
and lockfiles.

Keep reading in the [consuming recipes section](consuming_recipes.md).

## Why are version ranges not allowed?

Version ranges are a useful Conan feature, find the documentation [here](https://docs.conan.io/en/latest/versioning/version_ranges.html). However, in the context of ConanCenter they pose a few key challenges, most notably "Build Reproducibility".

If consumers try to download and build the recipe at a later time, it may resolve to a different package version that may not be compatible. In order to prevent these types of issues, we have decided to only allow exact requirements versions.
8 changes: 8 additions & 0 deletions recipes/aravis/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"0.8.20":
url: "https://github.com/AravisProject/aravis/releases/download/0.8.20/aravis-0.8.20.tar.xz"
sha256: "0c0eb5a76109f29180c09c7e6a23fd403633bf22bbe8468a0ae44995c4449f46"
patches:
"0.8.20":
- patch_file: "patches/0.8.19-gst-shared-lib.patch"
base_path: "source_subfolder"
169 changes: 169 additions & 0 deletions recipes/aravis/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
from conans import ConanFile, Meson, RunEnvironment, tools
from conans.errors import ConanInvalidConfiguration
import os
import glob


class AravisConan(ConanFile):
name = "aravis"
license = "LGPL-2.1-or-later"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/AravisProject/aravis"
description = "A vision library for genicam based cameras."
topics = ("usb", "camera")
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"usb": [True, False],
"packet_socket": [True, False],
"gst_plugin": [True, False],
"tools": [True, False],
"introspection": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"usb": True,
"packet_socket": True,
"gst_plugin": False,
"tools": True,
"introspection": False
}
generators = "pkg_config"

_meson = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

@property
def _aravis_api_version(self):
return ".".join(self.version.split(".")[0:2])

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

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if self.settings.os != "Linux":
del self.options.packet_socket

def configure(self):
if self.options.shared:
del self.options.fPIC
self.options["glib"].shared = True

def validate(self):
if self._is_msvc and self.settings.get_safe("compiler.runtime", "").startswith("MT"):
raise ConanInvalidConfiguration("Static MT/MTd runtime is not supported on Windows due to GLib issues")
if not self.options["glib"].shared and self.options.shared:
raise ConanInvalidConfiguration("Shared Aravis cannot link to static GLib")
if self.settings.os == "Macos":
raise ConanInvalidConfiguration("macOS builds are disabled until conan-io/conan#7324 gets merged to fix macOS SIP issue #8443")

def build_requirements(self):
self.build_requires("meson/0.60.2")
self.build_requires("pkgconf/1.7.4")
if self.options.introspection:
self.build_requires("gobject-introspection/1.70.0")

def requirements(self):
self.requires("glib/2.70.1")
self.requires("libxml2/2.9.12")
self.requires("zlib/1.2.11")
if self.options.usb:
self.requires("libusb/1.0.24")
if self.options.gst_plugin:
self.requires("gstreamer/1.19.2")
self.requires("gst-plugins-base/1.19.2")

def export_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)

def _patch_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)

def _configure_meson(self):
if self._meson:
return self._meson
defs = dict()
defs["wrap_mode"] = "nofallback"
defs["usb"] = "enabled" if self.options.usb else "disabled"
defs["gst-plugin"] = "enabled" if self.options.gst_plugin else "disabled"
defs["packet-socket"] = "enabled" if self.options.get_safe("packet_socket") else "disabled"
defs["introspection"] = "enabled" if self.options.introspection else "disabled"
defs["viewer"] = "disabled"
defs["tests"] = "false"
defs["documentation"] = "disabled"
if self.settings.get_safe("compiler.runtime"):
defs["b_vscrt"] = str(self.settings.compiler.runtime).lower()
self._meson = Meson(self)
self._meson.configure(defs=defs, source_folder=self._source_subfolder, build_folder=self._build_subfolder)
return self._meson

def build(self):
self._patch_sources()
with tools.environment_append(RunEnvironment(self).vars):
meson = self._configure_meson()
meson.build()

def _fix_library_names(self, path):
# https://github.com/mesonbuild/meson/issues/1412
if not self.options.shared and self._is_msvc:
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))
tools.rename(filename_old, filename_new)

def package(self):
self.copy("COPYING", src=self._source_subfolder, dst="licenses", keep_path=False)
with tools.environment_append(RunEnvironment(self).vars):
meson = self._configure_meson()
meson.install()

self._fix_library_names(os.path.join(self.package_folder, "lib"))
if self.options.gst_plugin:
self._fix_library_names(os.path.join(self.package_folder, "lib", "gstreamer-1.0"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.remove_files_by_mask(self.package_folder, "*.pdb")
if not self.options.tools:
tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "arv-*")

def package_id(self):
self.info.requires["glib"].full_package_mode()
if self.options.gst_plugin:
self.info.requires["gstreamer"].full_package_mode()
self.info.requires["gst-plugins-base"].full_package_mode()

def package_info(self):
aravis_name = "aravis-{}".format(self._aravis_api_version)
self.cpp_info.names["pkg_config"] = aravis_name
self.cpp_info.includedirs = [os.path.join("include", aravis_name)]
self.cpp_info.libs = [aravis_name]
if self.settings.os == "Linux":
self.cpp_info.system_libs.extend(["dl", "pthread", "m", "resolv"])
elif self.settings.os == "Windows":
self.cpp_info.system_libs.extend(["ws2_32", "iphlpapi"])

if self.options.tools:
bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bin_path))
self.env_info.PATH.append(bin_path)
if self.options.gst_plugin and self.options.shared:
gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0")
self.output.info("Appending GST_PLUGIN_PATH env var: {}".format(gst_plugin_path))
self.env_info.GST_PLUGIN_PATH.append(gst_plugin_path)
11 changes: 11 additions & 0 deletions recipes/aravis/all/patches/0.8.19-gst-shared-lib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/gst/meson.build
+++ b/gst/meson.build
@@ -15,7 +15,7 @@ gst_c_args = [

gst_plugin_filename = 'gstaravis.@0@'.format (aravis_api_version)

-gst_plugin = shared_library (gst_plugin_filename,
+gst_plugin = library (gst_plugin_filename,
gst_sources, gst_headers,
name_suffix: [],
link_with: aravis_library,
10 changes: 10 additions & 0 deletions recipes/aravis/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)

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

find_package(aravis REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} aravis::aravis)
Loading

0 comments on commit 1f6d6ff

Please sign in to comment.