-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add bison/3.3.2 * remove windows-related patch * apply suggestions from code-review * bison: Update Conan conventions Automatically created by bincrafters-conventions 0.23.2 * add missing variable * bison 3.5.3 * m4 and flex are build_requirements * bison: create static package using MSVC * bison: remove shared option * bison: make it relocatable * bison: m4 is a requirement, not a build requirement * bison: windows is relocatable too now * bison: add mingw support * bison: remove environment defines from package_info * bison: Update Conan conventions Automatically created by bincrafters-conventions 0.23.2 * fix config.yaml * fix simple_output_script invocation * Revert "bison: Update Conan conventions" This reverts commit c2ae40c. * Revert "fix simple_output_script invocation" This reverts commit 163c624. * remove help2man and makinfo workaround Co-authored-by: bincrafters-user <bincrafters@gmail.com> Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com> Co-authored-by: Croydon <git@cr0ydon.com>
- Loading branch information
1 parent
f00c9c8
commit 94dcf63
Showing
11 changed files
with
1,358 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
sources: | ||
"3.5.3": | ||
sha256: "34e201d963156618a0ea5bc87220f660a1e08403dd3c7c7903d4f38db3f40039" | ||
url: "https://ftp.gnu.org/gnu/bison/bison-3.5.3.tar.gz" | ||
patches: | ||
"3.5.3": | ||
- patch_file: "patches/0001-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch" | ||
base_path: "source_subfolder" | ||
- patch_file: "patches/0002-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch" | ||
base_path: "source_subfolder" | ||
- patch_file: "patches/0003-3.5.3-msvc-changes.patch" | ||
base_path: "source_subfolder" | ||
- patch_file: "patches/0004-3.5.3-relocatable.patch" | ||
base_path: "source_subfolder" |
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,140 @@ | ||
from conans import ConanFile, AutoToolsBuildEnvironment, tools | ||
from contextlib import contextmanager | ||
import os | ||
|
||
|
||
class BisonConan(ConanFile): | ||
name = "bison" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://www.gnu.org/software/bison/" | ||
description = "Bison is a general-purpose parser generator" | ||
topics = ("conan", "bison", "parser") | ||
license = "GPL-3.0-or-later" | ||
exports_sources = "patches/**" | ||
|
||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"fPIC": True, | ||
} | ||
|
||
_autotools = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
extracted_dir = "bison-" + self.version | ||
os.rename(extracted_dir, self._source_subfolder) | ||
|
||
def requirements(self): | ||
self.requires("m4/1.4.18") | ||
|
||
def build_requirements(self): | ||
if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and \ | ||
tools.os_info.detect_windows_subsystem() != "msys2": | ||
self.build_requires("msys2/20190524") | ||
if self.settings.compiler == "Visual Studio": | ||
self.build_requires("automake/1.16.1") | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
del self.settings.compiler.libcxx | ||
del self.settings.compiler.cppstd | ||
|
||
@contextmanager | ||
def _build_context(self): | ||
if self.settings.compiler == "Visual Studio": | ||
with tools.vcvars(self.settings): | ||
build_env = { | ||
"CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), | ||
"CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), | ||
"CFLAGS": "-{}".format(self.settings.compiler.runtime), | ||
"LD": "link", | ||
"NM": "dumpbin -symbols", | ||
"STRIP": ":", | ||
"AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), | ||
"RANLIB": ":", | ||
} | ||
with tools.environment_append(build_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) | ||
args = [ | ||
"--enable-relocatable", | ||
"--disable-nls", | ||
"--datarootdir={}".format(os.path.join(self.package_folder, "bin", "share").replace("\\", "/")), | ||
] | ||
if self.settings.os == "Windows": | ||
self._autotools.defines.append("_WINDOWS") | ||
if self.settings.compiler == "Visual Studio": | ||
self._autotools.flags.append("-FS") | ||
self._autotools.configure(args=args, configure_dir=self._source_subfolder) | ||
return self._autotools | ||
|
||
def _patch_sources(self): | ||
for patch in self.conan_data["patches"][self.version]: | ||
tools.patch(**patch) | ||
|
||
if self.settings.os == "Windows": | ||
# replace embedded unix paths by windows paths | ||
tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), | ||
"echo '#define BINDIR \"$(bindir)\"';", | ||
"echo '#define BINDIR \"$(shell cygpath -m \"$(bindir)\")\"';") | ||
tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), | ||
"echo '#define PKGDATADIR \"$(pkgdatadir)\"';", | ||
"echo '#define PKGDATADIR \"$(shell cygpath -m \"$(pkgdatadir)\")\"';") | ||
tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), | ||
"echo '#define DATADIR \"$(datadir)\"';", | ||
"echo '#define DATADIR \"$(shell cygpath -m \"$(datadir)\")\"';") | ||
tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), | ||
"echo '#define DATAROOTDIR \"$(datarootdir)\"';", | ||
"echo '#define DATAROOTDIR \"$(shell cygpath -m \"$(datarootdir)\")\"';") | ||
|
||
tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), | ||
"dist_man_MANS = $(top_srcdir)/doc/bison.1", | ||
"dist_man_MANS =") | ||
tools.replace_in_file(os.path.join(self._source_subfolder, "src", "yacc.in"), | ||
"@prefix@", | ||
"${}_ROOT".format(self.name.upper())) | ||
tools.replace_in_file(os.path.join(self._source_subfolder, "src", "yacc.in"), | ||
"@bindir@", | ||
"${}_ROOT/bin".format(self.name.upper())) | ||
|
||
def build(self): | ||
self._patch_sources() | ||
with self._build_context(): | ||
env_build = self._configure_autotools() | ||
env_build.make() | ||
|
||
def package(self): | ||
with self._build_context(): | ||
env_build = self._configure_autotools() | ||
env_build.install() | ||
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) | ||
|
||
if self.settings.compiler == "Visual Studio": | ||
os.rename(os.path.join(self.package_folder, "lib", "liby.a"), | ||
os.path.join(self.package_folder, "lib", "y.lib")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["y"] | ||
|
||
self.output.info('Setting BISON_ROOT environment variable: {}'.format(self.package_folder)) | ||
self.env_info.BISON_ROOT = self.package_folder | ||
|
||
bindir = os.path.join(self.package_folder, "bin") | ||
self.output.info('Appending PATH environment variable: {}'.format(bindir)) | ||
self.env_info.PATH.append(bindir) |
29 changes: 29 additions & 0 deletions
29
recipes/bison/all/patches/0001-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch
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,29 @@ | ||
From dffa2a21edeba243ef76b75e0c2081ec15fe95bd Mon Sep 17 00:00:00 2001 | ||
From: SSE4 <tomskside@gmail.com> | ||
Date: Wed, 3 Apr 2019 19:48:12 +0700 | ||
Subject: [PATCH 3/4] 0003 | ||
|
||
--- | ||
lib/spawn-pipe.c | 4 ++-- | ||
1 file changed, 2 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/lib/spawn-pipe.c b/lib/spawn-pipe.c | ||
index 3af5167..09e9cad 100644 | ||
--- a/lib/spawn-pipe.c | ||
+++ b/lib/spawn-pipe.c | ||
@@ -137,10 +137,10 @@ create_pipe (const char *progname, | ||
prog_argv = prepare_spawn (prog_argv); | ||
|
||
if (pipe_stdout) | ||
- if (pipe2_safer (ifd, O_BINARY | O_CLOEXEC) < 0) | ||
+ if (pipe2_safer (ifd, O_TEXT | O_CLOEXEC) < 0) | ||
error (EXIT_FAILURE, errno, _("cannot create pipe")); | ||
if (pipe_stdin) | ||
- if (pipe2_safer (ofd, O_BINARY | O_CLOEXEC) < 0) | ||
+ if (pipe2_safer (ofd, O_TEXT | O_CLOEXEC) < 0) | ||
error (EXIT_FAILURE, errno, _("cannot create pipe")); | ||
/* Data flow diagram: | ||
* | ||
-- | ||
2.7.4.windows.1 | ||
|
26 changes: 26 additions & 0 deletions
26
recipes/bison/all/patches/0002-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch
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,26 @@ | ||
--- src/location.c | ||
+++ src/location.c | ||
@@ -268,6 +268,14 @@ caret_free (void) | ||
static bool | ||
caret_set_file (const char *file) | ||
{ | ||
+#if defined(_WIN32) | ||
+ /* ftell() is unusable on Windows in the face of text files | ||
+ that use just LF and not Windows-style CR-LF as newlines | ||
+ http://support.microsoft.com/kb/68337 */ | ||
+ char fopen_mode[3] = "rb"; | ||
+#else | ||
+ char fopen_mode[2] = "r"; | ||
+#endif | ||
/* If a different file than before, close and let the rest open | ||
the new one. */ | ||
if (caret_info.pos.file && caret_info.pos.file != file) | ||
@@ -278,7 +278,7 @@ caret_set_file (const char *file) | ||
if (!caret_info.pos.file) | ||
{ | ||
caret_info.pos.file = file; | ||
- if ((caret_info.file = fopen (caret_info.pos.file, "r"))) | ||
+ if ((caret_info.file = fopen (caret_info.pos.file, fopen_mode))) | ||
{ | ||
/* If the file is not regular (imagine #line 1 "/dev/stdin" | ||
in the input file for instance), don't try to quote the |
Oops, something went wrong.