-
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
Showing
8 changed files
with
198 additions
and
179 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 |
---|---|---|
|
@@ -15,20 +15,5 @@ sources: | |
url: "https://github.com/skvadrik/re2c/releases/download/1.3/re2c-1.3.tar.xz" | ||
sha256: "f37f25ff760e90088e7d03d1232002c2c2672646d5844fdf8e0d51a5cd75a503" | ||
patches: | ||
"3.0": | ||
- patch_file: "patches/0001-add-msvc_cl-sh.patch" | ||
base_path: "" | ||
"2.2": | ||
- patch_file: "patches/0001-add-msvc_cl-sh.patch" | ||
base_path: "" | ||
"2.1.1": | ||
- patch_file: "patches/0001-add-msvc_cl-sh.patch" | ||
base_path: "" | ||
"2.0.3": | ||
- patch_file: "patches/0001-add-msvc_cl-sh.patch" | ||
base_path: "" | ||
- patch_file: "patches/2.0.3-0001-add-missing-include.patch" | ||
Check warning on line 19 in recipes/re2c/all/conandata.yml GitHub Actions / Lint changed files (YAML files)conandata.yml schema warning
Check warning on line 19 in recipes/re2c/all/conandata.yml GitHub Actions / Lint changed files (YAML files)conandata.yml schema warning
|
||
base_path: "source_subfolder" | ||
"1.3": | ||
- patch_file: "patches/0001-add-msvc_cl-sh.patch" | ||
base_path: "" |
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 |
---|---|---|
@@ -1,95 +1,104 @@ | ||
from conans import AutoToolsBuildEnvironment, ConanFile, tools | ||
from contextlib import contextmanager | ||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
from conan import ConanFile | ||
from conan.tools.env import Environment | ||
from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rmdir | ||
from conan.tools.gnu import Autotools, AutotoolsToolchain | ||
from conan.tools.layout import basic_layout | ||
from conan.tools.microsoft import is_msvc, unix_path | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class Re2CConan(ConanFile): | ||
name = "re2c" | ||
description = "re2c is a free and open-source lexer generator for C, C++ and Go." | ||
topics = ("re2c", "lexer", "language", "tokenizer", "flex") | ||
license = "Unlicense" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "http://re2c.org/" | ||
license = "Unlicense" | ||
settings = "os", "arch", "build_type", "compiler" | ||
topics = ("lexer", "language", "tokenizer", "flex") | ||
|
||
_autotools = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
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): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
self.copy(patch["patch_file"]) | ||
export_conandata_patches(self) | ||
copy(self, "msvc_cl.sh", src=self.recipe_folder, dst=self.export_sources_folder) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
del self.settings.compiler.cppstd | ||
del self.settings.compiler.libcxx | ||
self.settings.rm_safe("compiler.cppstd") | ||
self.settings.rm_safe("compiler.libcxx") | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def package_id(self): | ||
del self.info.settings.compiler | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], | ||
destination=self._source_subfolder, strip_root=True) | ||
|
||
def build_requirements(self): | ||
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): | ||
self.build_requires("msys2/cci.latest") | ||
|
||
@contextmanager | ||
def _build_context(self): | ||
if self.settings.compiler == "Visual Studio": | ||
with tools.vcvars(self): | ||
env = { | ||
"CC": "{} -nologo".format(tools.unix_path(os.path.join(self.build_folder, "msvc_cl.sh"))), | ||
"CXX": "{} -nologo".format(tools.unix_path(os.path.join(self.build_folder, "msvc_cl.sh"))), | ||
"LD": "{} -nologo".format(tools.unix_path(os.path.join(self.build_folder, "msvc_cl.sh"))), | ||
"CXXLD": "{} -nologo".format(tools.unix_path(os.path.join(self.build_folder, "msvc_cl.sh"))), | ||
"AR": "lib", | ||
} | ||
with tools.environment_append(env): | ||
yield | ||
else: | ||
yield | ||
|
||
def _configure_autotools(self): | ||
if self._autotools: | ||
return self._autotools | ||
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||
if self.settings.compiler == "Visual Studio": | ||
self._autotools.flags.append("-FS") | ||
self._autotools.cxx_flags.append("-EHsc") | ||
self._autotools.configure(configure_dir=self._source_subfolder) | ||
return self._autotools | ||
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") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = AutotoolsToolchain(self) | ||
if is_msvc(self): | ||
tc.cxxflags.append("-FS") | ||
tc.cxxflags.append("-EHsc") | ||
tc.generate() | ||
|
||
if is_msvc(self): | ||
env = Environment() | ||
automake_conf = self.dependencies.build["automake"].conf_info | ||
ar_wrapper = unix_path(self, automake_conf.get("user.automake:lib-wrapper", check_type=str)) | ||
msvc_cl_path = unix_path(self, os.path.join(self.source_folder, "msvc_cl.sh")) | ||
env.define("CC", msvc_cl_path) | ||
env.define("CXX", msvc_cl_path) | ||
env.define("LD", msvc_cl_path) | ||
env.define("CXXLD", msvc_cl_path) | ||
env.define("AR", f'{ar_wrapper} "lib -nologo"') | ||
env.vars(self).save_script("conanbuild_msvc") | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
with self._build_context(): | ||
autotools = self._configure_autotools() | ||
apply_conandata_patches(self) | ||
with chdir(self, self.source_folder): | ||
autotools = Autotools(self) | ||
autotools.configure() | ||
autotools.make(args=["V=1"]) | ||
|
||
def package(self): | ||
self.copy("LICENSE", src=self._source_subfolder, dst="licenses", keep_path=False) | ||
self.copy("NO_WARRANTY", src=self._source_subfolder, dst="licenses", keep_path=False) | ||
with self._build_context(): | ||
autotools = self._configure_autotools() | ||
copy(self, "LICENSE", | ||
src=self.source_folder, | ||
dst=os.path.join(self.package_folder, "licenses"), | ||
keep_path=False) | ||
copy(self, "NO_WARRANTY", | ||
src=self.source_folder, | ||
dst=os.path.join(self.package_folder, "licenses"), | ||
keep_path=False) | ||
with chdir(self, self.source_folder): | ||
autotools = Autotools(self) | ||
autotools.install() | ||
|
||
tools.rmdir(os.path.join(self.package_folder, "share")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
|
||
def package_info(self): | ||
self.cpp_info.frameworkdirs = [] | ||
self.cpp_info.libdirs = [] | ||
self.cpp_info.resdirs = [] | ||
self.cpp_info.includedirs = [] | ||
|
||
# TODO: to remove in conan v2 | ||
bin_path = os.path.join(self.package_folder, "bin") | ||
self.output.info("Appending PATH environment variable: {}".format(bin_path)) | ||
self.output.info(f"Appending PATH environment variable: {bin_path}") | ||
self.env_info.PATH.append(bin_path) |
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,87 @@ | ||
#!/bin/sh | ||
clopts=() | ||
ldopts=() | ||
sources=0 | ||
link=0 | ||
while test $# -gt 0; do | ||
case "$1" in | ||
-lm | -pthread | -lpthread | -std=c++98) | ||
# ignore | ||
;; | ||
-Xlinker) | ||
shift | ||
;; | ||
-W* | -w* | -pedantic) | ||
# ignore warnings | ||
;; | ||
-D*) | ||
clopts+=("$1") | ||
;; | ||
-I*) | ||
clopts+=("$1") | ||
;; | ||
-l*) | ||
ldopts+=("`echo "$1.lib" | sed "s/^-l//"`") | ||
;; | ||
-LIBPATH*) | ||
ldopts+=("$1") | ||
;; | ||
-L*) | ||
ldopts+=("`echo "$1" | sed "s/^-L/-LIBPATH:/"`") | ||
;; | ||
*.obj | *.o) | ||
link=1 | ||
ldopts+=("$1") | ||
;; | ||
-Wl,*) | ||
for linkarg in `echo '$1' | sed -e 's/-Wl,//' -e 's/,/ /'`; do | ||
ldopts+=("${linkarg}") | ||
done | ||
;; | ||
*.lib) | ||
ldopts+=("$1") | ||
;; | ||
-o) | ||
shift | ||
case "$1" in | ||
*.dll | *.exe) | ||
link=1 | ||
ldopts+=("-out:$1") | ||
;; | ||
*.o | *.obj) | ||
link=0 | ||
clopts+=("-Fo$1") | ||
;; | ||
esac | ||
;; | ||
-implib* | -IMPLIB*) | ||
ldopts+=("$1") | ||
;; | ||
-c | *.c | *.C | *.cxx | *.cpp | *.cc | *.CC) | ||
sources=1 | ||
clopts+=("$1") | ||
;; | ||
*) | ||
clopts+=("$1") | ||
;; | ||
esac | ||
shift | ||
done | ||
args="${clopts[@]}" | ||
if test $link = 1; then | ||
if test $sources = 0; then | ||
args="${ldopts[@]}" | ||
cat <<-EOF | ||
Creating program/library | ||
** ld options: "$args" | ||
EOF | ||
LINK= exec link -nologo $args | ||
else | ||
args="$args -link ${ldopts[@]}" | ||
fi | ||
fi | ||
cat <<-EOF | ||
Compiling source | ||
** cl options: "$args" | ||
EOF | ||
LINK= exec cl -nologo $args |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,11 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package C) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_custom_command(OUTPUT test_package.c | ||
COMMAND re2c -W "${PROJECT_SOURCE_DIR}/syntax.re" -o test_package.c | ||
COMMAND re2c -W "${CMAKE_CURRENT_LIST_DIR}/syntax.re" -o test_package.c | ||
) | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) |
Oops, something went wrong.