Skip to content

Commit

Permalink
Merge branch 'conan-io:master' into autoconf-conan-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jellespijker authored Sep 5, 2022
2 parents 6ae0e3d + d8863a9 commit 2108ccd
Show file tree
Hide file tree
Showing 249 changed files with 3,898 additions and 1,603 deletions.
4 changes: 4 additions & 0 deletions .c3i/authorized_users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -924,3 +924,7 @@ authorized_users:
- "Nomalah"
- "kambala-decapitator"
- "rainman110"
- "jiangshipengv8"
- "BjoernAtBosch"
- "dubvulture"
- "ZbigniewRA"
2 changes: 2 additions & 0 deletions .github/workflows/on-push-do-doco.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: docs_markdown_toc
on:
workflow_dispatch:
inputs: {}
push:
branches:
- master
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

### 1-September-2022 - 10:21 CEST

- [feature] Avoid `test_v?_package` folders that don't match the Conan version.
- [feature] Keep at least 3 days of job logs.
- [fix] Properly encode GitHub API URLs.
- [fix] Replace invalid chars when generating profiles.
- [refactor] Refactors around the GitHub classes implementation.

### 18-August-2022 - 15:21 CEST

- [fix] Conan v2: Check recipe revision only if it has been successfully exported.
Expand Down
30 changes: 30 additions & 0 deletions linter/check_import_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import re
from email.mime import base
from pylint.checkers import BaseChecker
from pylint.interfaces import IAstroidChecker
from astroid import nodes, Const, AssignName


class ImportTools(BaseChecker):
"""
Import tools following pattern 'from conan.tools.xxxx import yyyyy'
"""

__implements__ = IAstroidChecker

name = "conan-import-tools"
msgs = {
"E9011": (
"Import tools following pattern 'from conan.tools.xxxx import yyyyy' (https://docs.conan.io/en/latest/reference/conanfile/tools.html).",
"conan-import-tools",
"Import tools following pattern 'from conan.tools.xxxx import yyyyy' (https://docs.conan.io/en/latest/reference/conanfile/tools.html).",
),
}

def visit_importfrom(self, node: nodes.ImportFrom) -> None:
basename = node.modname
names = [name for name, _ in node.names]
if basename == 'conan' and 'tools' in names:
self.add_message("conan-import-tools", node=node)
elif re.match(r'conan\.tools\.[^.]+\..+', basename):
self.add_message("conan-import-tools", node=node)
2 changes: 2 additions & 0 deletions linter/conanv2_test_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from linter.check_import_conanfile import ImportConanFile
from linter.check_no_test_package_name import NoPackageName
from linter.check_import_errors import ImportErrorsConanException, ImportErrorsConanInvalidConfiguration, ImportErrors
from linter.check_import_tools import ImportTools


def register(linter: PyLinter) -> None:
Expand All @@ -16,3 +17,4 @@ def register(linter: PyLinter) -> None:
linter.register_checker(ImportErrors(linter))
linter.register_checker(ImportErrorsConanException(linter))
linter.register_checker(ImportErrorsConanInvalidConfiguration(linter))
linter.register_checker(ImportTools(linter))
2 changes: 2 additions & 0 deletions linter/conanv2_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from linter.check_package_name import PackageName
from linter.check_import_conanfile import ImportConanFile
from linter.check_import_errors import ImportErrorsConanException, ImportErrorsConanInvalidConfiguration, ImportErrors
from linter.check_import_tools import ImportTools


def register(linter: PyLinter) -> None:
Expand All @@ -16,3 +17,4 @@ def register(linter: PyLinter) -> None:
linter.register_checker(ImportErrors(linter))
linter.register_checker(ImportErrorsConanException(linter))
linter.register_checker(ImportErrorsConanInvalidConfiguration(linter))
linter.register_checker(ImportTools(linter))
68 changes: 53 additions & 15 deletions recipes/argh/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,73 @@
from conans import ConanFile, tools
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get, save
from conan.tools.layout import basic_layout
import os
import textwrap

required_conan_version = ">=1.50.0"


class ArgparseConan(ConanFile):
name = "argh"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/adishavit/argh"
topics = ("conan", "argh", "argument", "parsing")
topics = ("argh", "argument", "parsing")
license = "BSD-3"
description = "Frustration-free command line processing"
settings = "compiler"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _source_subfolder(self):
return os.path.join(self.source_folder, "source_subfolder")
def package_id(self):
self.info.clear()

def validate(self):
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, 11)
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 11)

def layout(self):
basic_layout(self, src_folder="src")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("argh-{}".format(self.version), self._source_subfolder)
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def build(self):
pass

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
self.copy("argh.h", src=self._source_subfolder, dst=os.path.join("include", "argh"))
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "argh.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include"))

def package_id(self):
self.info.header_only()
# TODO: to remove in conan v2 once cmake_find_package* generators removed
self._create_cmake_module_alias_targets(
os.path.join(self.package_folder, self._module_file_rel_path),
{"argh": "argh::argh"},
)

def _create_cmake_module_alias_targets(self, module_file, targets):
content = ""
for alias, aliased in targets.items():
content += textwrap.dedent(f"""\
if(TARGET {aliased} AND NOT TARGET {alias})
add_library({alias} INTERFACE IMPORTED)
set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
endif()
""")
save(self, module_file, content)

@property
def _module_file_rel_path(self):
return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake")

def package_info(self):
self.cpp_info.includedirs.append(os.path.join("include", "argh"))
self.cpp_info.set_property("cmake_file_name", "argh")
self.cpp_info.set_property("cmake_target_name", "argh")
self.cpp_info.bindirs = []
self.cpp_info.frameworkdirs = []
self.cpp_info.libdirs = []
self.cpp_info.resdirs = []

# TODO: to remove in conan v2 once legacy generators removed
self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
11 changes: 5 additions & 6 deletions recipes/argh/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(argh REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
target_link_libraries(${PROJECT_NAME} PRIVATE argh)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
19 changes: 14 additions & 5 deletions recipes/argh/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

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

def test(self):
if not tools.cross_building(self.settings):
self.run(os.path.join("bin", "test_package"))
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
11 changes: 11 additions & 0 deletions recipes/argh/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

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

find_package(argh REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE argh)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
16 changes: 16 additions & 0 deletions recipes/argh/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
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):
self.run(os.path.join("bin", "test_package"))
4 changes: 0 additions & 4 deletions recipes/argparse/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ sources:
patches:
"2.4":
- patch_file: "patches/0001-v2.3-add-missing-include.patch"
base_path: "source_subfolder"
"2.3":
- patch_file: "patches/0001-v2.3-add-missing-include.patch"
base_path: "source_subfolder"
"2.2":
- patch_file: "patches/0001-v2.2-add-missing-include.patch"
base_path: "source_subfolder"
"2.1":
- patch_file: "patches/0001-v2.1-add-missing-include.patch"
base_path: "source_subfolder"
77 changes: 41 additions & 36 deletions recipes/argparse/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.files import apply_conandata_patches, copy, get
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
import os

required_conan_version = ">=1.43.0"
required_conan_version = ">=1.50.0"


class ArgparseConan(ConanFile):
Expand All @@ -15,63 +19,64 @@ class ArgparseConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"

@property
def _compiler_required_cpp17(self):
def _min_cppstd(self):
return "17"

@property
def _compilers_minimum_version(self):
return {
"gcc": "7" if tools.Version(self.version) <= "2.1" else "8",
"clang": "5" if tools.Version(self.version) <= "2.1" else "7",
"gcc": "7" if Version(self.version) <= "2.1" else "8",
"clang": "5" if Version(self.version) <= "2.1" else "7",
# trantor/2.5 uses [[maybe_unused]] in range-based for loop
# Visual Studio 15 doesn't support it:
# https://developercommunity.visualstudio.com/t/compiler-bug-on-parsing-maybe-unused-in-range-base/209488
"Visual Studio": "15" if tools.Version(self.version) < "2.5" else "16",
"Visual Studio": "15" if Version(self.version) < "2.5" else "16",
"msvc": "191" if Version(self.version) < "2.5" else "192",
"apple-clang": "10",
}

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

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

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

def build(self):
self._patch_sources()
for p in self.conan_data.get("patches", {}).get(self.version, []):
copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder)

def package_id(self):
self.info.header_only()
self.info.clear()

def validate(self):
if self.settings.get_safe("compiler.cppstd"):
tools.check_min_cppstd(self, "17")
try:
minimum_required_compiler_version = self._compiler_required_cpp17[str(self.settings.compiler)]
if tools.Version(self.settings.compiler.version) < minimum_required_compiler_version:
raise ConanInvalidConfiguration("This package requires c++17 support. The current compiler does not support it.")
except KeyError:
self.output.warn("This recipe has no support for the current compiler. Please consider adding it.")
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.",
)

if tools.Version(self.version) > "2.1" and self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libstdc++":
if Version(self.version) > "2.1" and self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libstdc++":
raise ConanInvalidConfiguration("This recipe does not permit >2.1 with clang and stdlibc++. There may be an infrastructure issue in CCI.")

def layout(self):
basic_layout(self, src_folder="src")

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

def build(self):
apply_conandata_patches(self)

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
if tools.Version(self.version) <= "2.1":
self.copy("*.hpp", src=os.path.join(self._source_subfolder, "include"), dst=os.path.join("include", "argparse"))
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
if Version(self.version) <= "2.1":
include_dst = os.path.join(self.package_folder, "include", "argparse")
else:
self.copy("*.hpp", src=os.path.join(self._source_subfolder, "include"), dst="include")
include_dst = os.path.join(self.package_folder, "include")
copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=include_dst)

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "argparse")
self.cpp_info.set_property("cmake_target_name", "argparse::argparse")
self.cpp_info.set_property("pkg_config_name", "argparse")
if tools.Version(self.version) <= "2.1":
if Version(self.version) <= "2.1":
self.cpp_info.includedirs.append(os.path.join("include", "argparse"))
self.cpp_info.bindirs = []
self.cpp_info.frameworkdirs = []
Expand Down
7 changes: 2 additions & 5 deletions recipes/argparse/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package)

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

find_package(argparse REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} argparse::argparse)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
target_link_libraries(${PROJECT_NAME} PRIVATE argparse::argparse)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
Loading

0 comments on commit 2108ccd

Please sign in to comment.