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

re2c: add version 4.0.1 #25998

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 3 additions & 9 deletions recipes/re2c/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"4.0.1":
url: "https://github.com/skvadrik/re2c/releases/download/4.0.1/re2c-4.0.1.tar.xz"
sha256: "7c35d54fdf2c4b5981b80362d1c742aec4d011589673e02f2e9566f7e66c44af"
"3.1":
url: "https://github.com/skvadrik/re2c/releases/download/3.1/re2c-3.1.tar.xz"
sha256: "0ac299ad359e3f512b06a99397d025cfff81d3be34464ded0656f8a96676c029"
Expand All @@ -11,12 +14,3 @@ sources:
"2.1.1":
url: "https://github.com/skvadrik/re2c/releases/download/2.1.1/re2c-2.1.1.tar.xz"
sha256: "036ee264fafd5423141ebd628890775aa9447a4c4068a6307385d7366fe711f8"
"2.0.3":
url: "https://github.com/skvadrik/re2c/releases/download/2.0.3/re2c-2.0.3.tar.xz"
sha256: "b2bc1eb8aaaa21ff2fcd26507b7e6e72c5e3d887e58aa515c2155fb17d744278"
"1.3":
url: "https://github.com/skvadrik/re2c/releases/download/1.3/re2c-1.3.tar.xz"
sha256: "f37f25ff760e90088e7d03d1232002c2c2672646d5844fdf8e0d51a5cd75a503"
patches:
"2.0.3":
- patch_file: "patches/2.0.3-0001-add-missing-include.patch"
68 changes: 14 additions & 54 deletions recipes/re2c/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import os

from conan import ConanFile
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rmdir, replace_in_file
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version

required_conan_version = ">=1.53.0"
required_conan_version = ">=2.1"


class Re2CConan(ConanFile):
Expand All @@ -21,10 +20,6 @@ class Re2CConan(ConanFile):
package_type = "application"
settings = "os", "arch", "compiler", "build_type"

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def export_sources(self):
export_conandata_patches(self)

Expand All @@ -33,54 +28,24 @@ def configure(self):
self.settings.rm_safe("compiler.libcxx")

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

def package_id(self):
del self.info.settings.compiler

def build_requirements(self):
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
self.tool_requires("winflexbison/2.5.24")
if is_msvc(self):
self.tool_requires("cccl/1.3")

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

def generate(self):
VirtualBuildEnv(self).generate()
tc = AutotoolsToolchain(self)
tc.configure_args.append("--disable-benchmarks")
env = tc.environment()
if is_msvc(self):
tc.extra_cxxflags.append("-EHsc")
env.define("CC", "cccl -FS")
env.define("CXX", "cccl -FS")
env.define("LD", "cccl")
env.define("CXXLD", "cccl")
tc.generate(env)

def _patch_sources(self):
apply_conandata_patches(self)
# Don't copy benchmark files, which cause the build to fail on Windows
replace_in_file(self, os.path.join(self.source_folder, "configure"),
'"$ac_config_files Makefile ',
'"$ac_config_files Makefile" #',
strict=False)
replace_in_file(self, os.path.join(self.source_folder, "configure"),
'"$ac_config_links ',
'"$ac_config_links" #',
strict=False)
tc = CMakeToolchain(self)
tc.cache_variables["RE2C_REBUILD_DOCS"] = False
tc.cache_variables["RE2C_BUILD_BENCHMARKS"] = False
tc.generate()

def build(self):
self._patch_sources()
with chdir(self, self.source_folder):
autotools = Autotools(self)
autotools.configure()
autotools.make(args=["V=1"])
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, "LICENSE",
Expand All @@ -95,9 +60,9 @@ def package(self):
src=os.path.join(self.source_folder, "include"),
dst=os.path.join(self.package_folder, "include"),
keep_path=False)
with chdir(self, self.source_folder):
autotools = Autotools(self)
autotools.install()

cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
Expand All @@ -108,8 +73,3 @@ def package_info(self):

include_dir = os.path.join(self.package_folder, "include")
self.buildenv_info.define("RE2C_STDLIB_DIR", include_dir)

# TODO: to remove in conan v2
bin_path = os.path.join(self.package_folder, "bin")
self.env_info.PATH.append(bin_path)
self.env_info.RE2C_STDLIB_DIR = include_dir
6 changes: 2 additions & 4 deletions recipes/re2c/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"4.0.1":
folder: "all"
"3.1":
folder: "all"
"3.0":
Expand All @@ -7,7 +9,3 @@ versions:
folder: "all"
"2.1.1":
folder: "all"
"2.0.3":
folder: "all"
"1.3":
folder: "all"