mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 05:16:10 +01:00
Removed Conan1 build.py file using conan package tools that are no longer supported
This commit is contained in:
parent
1078e7e95b
commit
a606d1dfe6
@ -1,94 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
from cpt.packager import ConanMultiPackager
|
||||
from cpt.ci_manager import CIManager
|
||||
from cpt.printer import Printer
|
||||
|
||||
|
||||
class BuilderSettings(object):
|
||||
@property
|
||||
def username(self):
|
||||
""" Set catchorg as package's owner
|
||||
"""
|
||||
return os.getenv("CONAN_USERNAME", "catchorg")
|
||||
|
||||
@property
|
||||
def login_username(self):
|
||||
""" Set Bintray login username
|
||||
"""
|
||||
return os.getenv("CONAN_LOGIN_USERNAME", "horenmar")
|
||||
|
||||
@property
|
||||
def upload(self):
|
||||
""" Set Catch2 repository to be used on upload.
|
||||
The upload server address could be customized by env var
|
||||
CONAN_UPLOAD. If not defined, the method will check the branch name.
|
||||
Only devel or CONAN_STABLE_BRANCH_PATTERN will be accepted.
|
||||
The devel branch will be pushed to testing channel, because it does
|
||||
not match the stable pattern. Otherwise it will upload to stable
|
||||
channel.
|
||||
"""
|
||||
return os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/catchorg/catch2")
|
||||
|
||||
@property
|
||||
def upload_only_when_stable(self):
|
||||
""" Force to upload when running over tag branch
|
||||
"""
|
||||
return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", "True").lower() in ["true", "1", "yes"]
|
||||
|
||||
@property
|
||||
def stable_branch_pattern(self):
|
||||
""" Only upload the package the branch name is like a tag
|
||||
"""
|
||||
return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+")
|
||||
|
||||
@property
|
||||
def reference(self):
|
||||
""" Read project version from branch create Conan reference
|
||||
"""
|
||||
return os.getenv("CONAN_REFERENCE", "catch2/{}".format(self._version))
|
||||
|
||||
@property
|
||||
def channel(self):
|
||||
""" Default Conan package channel when not stable
|
||||
"""
|
||||
return os.getenv("CONAN_CHANNEL", "testing")
|
||||
|
||||
@property
|
||||
def _version(self):
|
||||
""" Get version name from cmake file
|
||||
"""
|
||||
pattern = re.compile(r"project\(Catch2 LANGUAGES CXX VERSION (\d+\.\d+\.\d+)\)")
|
||||
version = "latest"
|
||||
with open("CMakeLists.txt") as file:
|
||||
for line in file:
|
||||
result = pattern.search(line)
|
||||
if result:
|
||||
version = result.group(1)
|
||||
return version
|
||||
|
||||
@property
|
||||
def _branch(self):
|
||||
""" Get branch name from CI manager
|
||||
"""
|
||||
printer = Printer(None)
|
||||
ci_manager = CIManager(printer)
|
||||
return ci_manager.get_branch()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
settings = BuilderSettings()
|
||||
builder = ConanMultiPackager(
|
||||
reference=settings.reference,
|
||||
channel=settings.channel,
|
||||
upload=settings.upload,
|
||||
upload_only_when_stable=False,
|
||||
stable_branch_pattern=settings.stable_branch_pattern,
|
||||
login_username=settings.login_username,
|
||||
username=settings.username,
|
||||
test_folder=os.path.join(".conan", "test_package"))
|
||||
builder.add()
|
||||
builder.run()
|
46
conanfile.py
Normal file → Executable file
46
conanfile.py
Normal file → Executable file
@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
from conans import ConanFile, CMake, tools
|
||||
from conan import ConanFile, tools
|
||||
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
|
||||
from conan.tools import files
|
||||
|
||||
|
||||
class CatchConan(ConanFile):
|
||||
name = "catch2"
|
||||
@ -14,30 +17,45 @@ class CatchConan(ConanFile):
|
||||
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
|
||||
generators = "cmake"
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.generate()
|
||||
|
||||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
|
||||
def _configure_cmake(self):
|
||||
cmake = CMake(self)
|
||||
cmake.definitions["BUILD_TESTING"] = "OFF"
|
||||
cmake.definitions["CATCH_INSTALL_DOCS"] = "OFF"
|
||||
cmake.definitions["CATCH_INSTALL_EXTRAS"] = "ON"
|
||||
cmake.configure(build_folder="build")
|
||||
|
||||
# These are option variables. The toolchain in conan 2 doesn't appear to
|
||||
# set these correctly so you have to do it in the configure variables.
|
||||
cmake.configure(variables= {
|
||||
"BUILD_TESTING": "OFF",
|
||||
"CATCH_INSTALL_DOCS": "OFF",
|
||||
"CATCH_INSTALL_EXTRAS": "ON",
|
||||
}
|
||||
)
|
||||
return cmake
|
||||
|
||||
|
||||
def build(self):
|
||||
# We need this workaround until the toolchains feature
|
||||
# to inject stuff like MD/MT
|
||||
line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")'
|
||||
tools.replace_in_file("CMakeLists.txt", line_to_replace,
|
||||
'''{}
|
||||
include("{}/conanbuildinfo.cmake")
|
||||
conan_basic_setup()'''.format(line_to_replace, self.install_folder.replace("\\", "/")))
|
||||
# # We need this workaround until the toolchains feature
|
||||
# # to inject stuff like MD/MT
|
||||
# line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")'
|
||||
# replacement_text = '''{}
|
||||
# include("{}/conanbuildinfo.cmake")
|
||||
# conan_basic_setup()'''.format(line_to_replace, self.package_folder.replace("\\", "/"))
|
||||
|
||||
# files.replace_in_file(self, f"{self.source_folder}/CMakeLists.txt", line_to_replace, replacement_text)
|
||||
|
||||
cmake = self._configure_cmake()
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
self.copy(pattern="LICENSE.txt", dst="licenses")
|
||||
files.copy(self, pattern="LICENSE.txt", src='.', dst="licenses")
|
||||
cmake = self._configure_cmake()
|
||||
cmake.install()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user