Compare commits

...

10 Commits

Author SHA1 Message Date
Aleksandr Vodyanov
ed400deb22 [DO-1345] fix build for linux (!19)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/19
2025-03-05 18:20:56 +03:00
Aleksandr Vodyanov
d0bb8ff38d [DO-981] fix qt package info (!17)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/17
2025-02-25 14:03:04 +03:00
aleksandr.vodyanov
a82e89a1bc [DO-1345] fixed windows packages (!16)
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/16
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.team>
Co-committed-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.team>
2025-02-25 13:53:43 +03:00
Aleksandr Vodyanov
3759e1163f [DO-981] qt package (!15)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/15
2025-02-13 12:25:48 +03:00
Aleksandr Vodyanov
60445ac09e [DO-983][DO-985] add tiff and zstd packages (!14)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/14
2024-12-26 16:03:17 +03:00
Aleksandr Vodyanov
70e3dea3f3 [DO-982] add sqlite package (!13)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/13
2024-12-26 14:53:49 +03:00
Aleksandr Vodyanov
0d5cfacb2e [DO-977] add libyuv package (!12)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/12
2024-12-26 13:56:22 +03:00
Aleksandr Vodyanov
28d4363c15 [DO-974] add libjpeg_turbo package (!11)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/11
2024-12-26 12:12:17 +03:00
Aleksandr Vodyanov
c807f2514e [DO-973] harfbuzz package (!10)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/10
2024-12-26 12:02:17 +03:00
Aleksandr Vodyanov
39afe6a1dd [DO-971] ffmpeg recipe with requirements (!9)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/9
2024-12-25 17:47:28 +03:00
652 changed files with 35499 additions and 48 deletions

View File

@@ -0,0 +1,63 @@
sources:
"3.8.2":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-ftp_gnu_org/gnu/bison/bison-3.8.2.tar.gz"
sha256: "06c9e13bdf7eb24d4ceb6b59205a4f67c2c7e7213119644430fe82fbd14a0abb"
"3.7.6":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-ftp_gnu_org/gnu/bison/bison-3.7.6.tar.gz"
sha256: "69dc0bb46ea8fc307d4ca1e0b61c8c355eb207d0b0c69f4f8462328e74d7b9ea"
"3.7.1":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-ftp_gnu_org/gnu/bison/bison-3.7.1.tar.gz"
sha256: "1dd952839cf0d5a8178c691eeae40dc48fa50d18dcce648b1ad9ae0195367d13"
"3.5.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-ftp_gnu_org/gnu/bison/bison-3.5.3.tar.gz"
sha256: "34e201d963156618a0ea5bc87220f660a1e08403dd3c7c7903d4f38db3f40039"
patches:
"3.8.2":
- patch_file: "patches/0001-3.8-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch"
patch_description: "use O_TEXT instead of O_BINARY for pipe"
patch_type: "portability"
- patch_file: "patches/0002-3.7.6-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch"
patch_description: "windows: open source file in binary mode"
patch_type: "portability"
- patch_file: "patches/0005-gnulib-limit-search-range-of-_setmaxstdio.patch"
patch_description: "msvc: limit search range of _setmaxstdio"
patch_type: "portability"
"3.7.6":
- patch_file: "patches/0001-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch"
patch_description: "use O_TEXT instead of O_BINARY for pipe"
patch_type: "portability"
- patch_file: "patches/0002-3.7.6-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch"
patch_description: "windows: open source file in binary mode"
patch_type: "portability"
- patch_file: "patches/0005-gnulib-limit-search-range-of-_setmaxstdio.patch"
patch_description: "msvc: limit search range of _setmaxstdio"
patch_type: "portability"
"3.7.1":
- patch_file: "patches/0001-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch"
patch_description: "use O_TEXT instead of O_BINARY for pipe"
patch_type: "portability"
- patch_file: "patches/0002-3.7.1-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch"
patch_description: "windows: open source file in binary mode"
patch_type: "portability"
- patch_file: "patches/0005-gnulib-limit-search-range-of-_setmaxstdio.patch"
patch_description: "msvc: limit search range of _setmaxstdio"
patch_type: "portability"
- patch_file: "patches/0006-dont-link-bison-against-libreadline.patch"
patch_description: "Don't link bison against libreadline"
patch_type: "portability"
"3.5.3":
- patch_file: "patches/0001-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch"
patch_description: "use O_TEXT instead of O_BINARY for pipe"
patch_type: "portability"
- patch_file: "patches/0002-3.5.3-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch"
patch_description: "windows: open source file in binary mode"
patch_type: "portability"
- patch_file: "patches/0003-3.5.3-msvc-changes.patch"
patch_description: "windows: fix build"
patch_type: "portability"
- patch_file: "patches/0004-3.5.3-relocatable.patch"
patch_description: "Relocatable"
patch_type: "portability"
- patch_file: "patches/0005-gnulib-limit-search-range-of-_setmaxstdio.patch"
patch_description: "msvc: limit search range of _setmaxstdio"
patch_type: "portability"

View File

@@ -0,0 +1,168 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, replace_in_file
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, unix_path
import os
required_conan_version = ">=1.54.0"
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 = ("bison", "parser")
license = "GPL-3.0-or-later"
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
}
default_options = {
"fPIC": True,
}
@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
def layout(self):
basic_layout(self, src_folder="src")
def requirements(self):
self.requires("m4/1.4.19")
def validate(self):
if is_msvc(self) and self.version == "3.8.2":
raise ConanInvalidConfiguration(
f"{self.ref} is not yet ready for Visual Studio, use previous version "
"or open a pull request on https://github.com/conan-io/conan-center-index/pulls"
)
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")
if is_msvc(self):
self.tool_requires("automake/1.16.5")
if self.settings.os != "Windows":
self.tool_requires("flex/2.6.4")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = AutotoolsToolchain(self)
tc.configure_args.extend([
"--enable-relocatable",
"--disable-nls",
"--datarootdir=${prefix}/res",
])
if self.settings.compiler == "apple-clang":
tc.configure_args.append("gl_cv_compiler_check_decl_option=")
if is_msvc(self):
# Avoid a `Assertion Failed Dialog Box` during configure with build_type=Debug
# Visual Studio does not support the %n format flag:
# https://docs.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions
# Because the %n format is inherently insecure, it is disabled by default. If %n is encountered in a format string,
# the invalid parameter handler is invoked, as described in Parameter Validation. To enable %n support, see _set_printf_count_output.
tc.configure_args.extend([
"gl_cv_func_printf_directive_n=no",
"gl_cv_func_snprintf_directive_n=no",
"gl_cv_func_snprintf_directive_n=no",
])
tc.extra_cflags.append("-FS")
env = tc.environment()
if is_msvc(self):
automake_conf = self.dependencies.build["automake"].conf_info
compile_wrapper = unix_path(self, automake_conf.get("user.automake:compile-wrapper", check_type=str))
ar_wrapper = unix_path(self, automake_conf.get("user.automake:lib-wrapper", check_type=str))
env.define("CC", f"{compile_wrapper} cl -nologo")
env.define("CXX", f"{compile_wrapper} cl -nologo")
env.define("LD", "link -nologo")
env.define("AR", f"{ar_wrapper} lib")
env.define("NM", "dumpbin -symbols")
env.define("OBJDUMP", ":")
env.define("RANLIB", ":")
env.define("STRIP", ":")
tc.generate(env)
def _patch_sources(self):
apply_conandata_patches(self)
makefile = os.path.join(self.source_folder, "Makefile.in")
yacc = os.path.join(self.source_folder, "src", "yacc.in")
if self.settings.os == "Windows":
# replace embedded unix paths by windows paths
replace_in_file(self, makefile,
"echo '#define BINDIR \"$(bindir)\"';",
"echo '#define BINDIR \"$(shell cygpath -m \"$(bindir)\")\"';")
replace_in_file(self, makefile,
"echo '#define PKGDATADIR \"$(pkgdatadir)\"';",
"echo '#define PKGDATADIR \"$(shell cygpath -m \"$(pkgdatadir)\")\"';")
replace_in_file(self, makefile,
"echo '#define DATADIR \"$(datadir)\"';",
"echo '#define DATADIR \"$(shell cygpath -m \"$(datadir)\")\"';")
replace_in_file(self, makefile,
"echo '#define DATAROOTDIR \"$(datarootdir)\"';",
"echo '#define DATAROOTDIR \"$(shell cygpath -m \"$(datarootdir)\")\"';")
replace_in_file(self, makefile,
"dist_man_MANS = $(top_srcdir)/doc/bison.1",
"dist_man_MANS =")
replace_in_file(self, yacc, "@prefix@", "$CONAN_BISON_ROOT")
replace_in_file(self, yacc, "@bindir@", "$CONAN_BISON_ROOT/bin")
def build(self):
self._patch_sources()
autotools = Autotools(self)
autotools.configure()
autotools.install()
def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
autotools.install()
if is_msvc(self):
rename(self, 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.includedirs = []
self.cpp_info.libs = ["y"]
self.cpp_info.resdirs = ["res"]
bison_root = self.package_folder.replace("\\", "/")
self.buildenv_info.define_path("CONAN_BISON_ROOT", bison_root)
pkgdir = os.path.join(self.package_folder, "res", "bison")
self.buildenv_info.define_path("BISON_PKGDATADIR", pkgdir)
# yacc is a shell script, so requires a shell (such as bash)
yacc = os.path.join(self.package_folder, "bin", "yacc").replace("\\", "/")
self.conf_info.define("user.bison:yacc", yacc)
# TODO: to remove in conan v2
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
self.env_info.CONAN_BISON_ROOT = self.package_folder.replace("\\", "/")
self.env_info.BISON_PKGDATADIR = pkgdir
self.user_info.YACC = yacc

View File

@@ -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
@@ -213,10 +213,10 @@ create_pipe (const char *progname,
xalloc_die ();
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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,26 @@
--- src/location.c
+++ src/location.c
@@ -256,6 +256,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)
@@ -266,7 +266,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

View File

@@ -0,0 +1,26 @@
--- src/location.c
+++ src/location.c
@@ -258,6 +258,14 @@
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)
@@ -268,7 +268,7 @@
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

View File

@@ -0,0 +1,261 @@
src/parse-gram.y and src/scan-gram.l should be modified as well,
but aren't to avoid a dependency on a already-built flex and bison.
--- src/location.c
+++ src/location.c
@@ -25,9 +25,13 @@
#include <mbswidth.h>
#include <quotearg.h>
#include <stdio.h> /* fileno */
+#ifndef _WIN32
#include <sys/ioctl.h>
+#endif
#include <sys/stat.h> /* fstat */
+#ifndef _WIN32
#include <termios.h>
+#endif
#ifdef WINSIZE_IN_PTEM
# include <sys/stream.h>
--- src/parse-gram.c
+++ src/parse-gram.c
@@ -991,7 +991,7 @@ tron (yyo);
case 43: /* "character literal" */
#line 217 "src/parse-gram.y"
- { fputs (char_name (((*yyvaluep).CHAR)), yyo); }
+ { fputs (char_name (((*yyvaluep).CHAR_LITERAL)), yyo); }
#line 996 "src/parse-gram.c"
break;
@@ -1027,7 +1027,7 @@ tron (yyo);
case 56: /* "integer" */
#line 234 "src/parse-gram.y"
- { fprintf (yyo, "%d", ((*yyvaluep).INT)); }
+ { fprintf (yyo, "%d", ((*yyvaluep).INTEGER)); }
#line 1032 "src/parse-gram.c"
break;
@@ -2216,13 +2216,13 @@ yyreduce:
case 12:
#line 330 "src/parse-gram.y"
- { expected_sr_conflicts = (yyvsp[0].INT); }
+ { expected_sr_conflicts = (yyvsp[0].INTEGER); }
#line 2221 "src/parse-gram.c"
break;
case 13:
#line 331 "src/parse-gram.y"
- { expected_rr_conflicts = (yyvsp[0].INT); }
+ { expected_rr_conflicts = (yyvsp[0].INTEGER); }
#line 2227 "src/parse-gram.c"
break;
@@ -2775,7 +2775,7 @@ yyreduce:
case 102:
#line 679 "src/parse-gram.y"
- { grammar_current_rule_dprec_set ((yyvsp[0].INT), (yylsp[0])); }
+ { grammar_current_rule_dprec_set ((yyvsp[0].INTEGER), (yylsp[0])); }
#line 2780 "src/parse-gram.c"
break;
@@ -2787,13 +2787,13 @@ yyreduce:
case 104:
#line 683 "src/parse-gram.y"
- { grammar_current_rule_expect_sr ((yyvsp[0].INT), (yylsp[0])); }
+ { grammar_current_rule_expect_sr ((yyvsp[0].INTEGER), (yylsp[0])); }
#line 2792 "src/parse-gram.c"
break;
case 105:
#line 685 "src/parse-gram.y"
- { grammar_current_rule_expect_rr ((yyvsp[0].INT), (yylsp[0])); }
+ { grammar_current_rule_expect_rr ((yyvsp[0].INTEGER), (yylsp[0])); }
#line 2798 "src/parse-gram.c"
break;
@@ -2860,9 +2860,9 @@ yyreduce:
complain_indent (&loc, complaint, &indent,
_("definition of %s"), var);
}
- (yyval.id) = symbol_get (char_name ((yyvsp[0].CHAR)), (yylsp[0]));
+ (yyval.id) = symbol_get (char_name ((yyvsp[0].CHAR_LITERAL)), (yylsp[0]));
symbol_class_set ((yyval.id), token_sym, (yylsp[0]), false);
- symbol_user_token_number_set ((yyval.id), (yyvsp[0].CHAR), (yylsp[0]));
+ symbol_user_token_number_set ((yyval.id), (yyvsp[0].CHAR_LITERAL), (yylsp[0]));
}
#line 2868 "src/parse-gram.c"
break;
--- src/parse-gram.h
+++ src/parse-gram.h
@@ -122,7 +122,7 @@ extern int gram_debug;
BRACED_CODE = 40,
BRACED_PREDICATE = 41,
BRACKETED_ID = 42,
- CHAR = 43,
+ CHAR_LITERAL = 43,
COLON = 44,
EPILOGUE = 45,
EQUAL = 46,
@@ -135,7 +135,7 @@ extern int gram_debug;
TAG = 53,
TAG_ANY = 54,
TAG_NONE = 55,
- INT = 56,
+ INTEGER = 56,
PERCENT_PARAM = 57,
PERCENT_UNION = 58,
PERCENT_EMPTY = 59
@@ -162,7 +162,7 @@ union GRAM_STYPE
/* code_props_type */
code_props_type code_props_type;
/* "integer" */
- int INT;
+ int INTEGER;
/* int.opt */
int yytype_81;
/* named_ref.opt */
@@ -226,7 +226,7 @@ union GRAM_STYPE
/* variable */
uniqstr variable;
/* "character literal" */
- unsigned char CHAR;
+ unsigned char CHAR_LITERAL;
/* value */
value_type value;
#line 233 "src/parse-gram.h"
--- src/reader.c
+++ src/reader.c
@@ -803,7 +803,7 @@ check_and_convert_grammar (void)
$accept: %start $end. */
{
- symbol_list *p = symbol_list_sym_new (accept, empty_loc);
+ symbol_list *p = symbol_list_sym_new (bison_accept, empty_loc);
p->rhs_loc = grammar->rhs_loc;
p->next = symbol_list_sym_new (startsymbol, empty_loc);
p->next->next = symbol_list_sym_new (endtoken, empty_loc);
--- src/reduce.c
+++ src/reduce.c
@@ -160,9 +160,9 @@ inaccessable_symbols (void)
bitset Pp = bitset_create (nrules, BITSET_FIXED);
/* If the start symbol isn't useful, then nothing will be useful. */
- if (bitset_test (N, accept->content->number - ntokens))
+ if (bitset_test (N, bison_accept->content->number - ntokens))
{
- bitset_set (V, accept->content->number);
+ bitset_set (V, bison_accept->content->number);
while (1)
{
@@ -301,7 +301,7 @@ nonterminals_reduce (void)
for (item_number *rhsp = rules[r].rhs; 0 <= *rhsp; ++rhsp)
if (ISVAR (*rhsp))
*rhsp = symbol_number_as_item_number (nterm_map[*rhsp - ntokens]);
- accept->content->number = nterm_map[accept->content->number - ntokens];
+ bison_accept->content->number = nterm_map[bison_accept->content->number - ntokens];
}
nsyms -= nuseless_nonterminals;
@@ -381,7 +381,7 @@ reduce_grammar (void)
{
reduce_print ();
- if (!bitset_test (N, accept->content->number - ntokens))
+ if (!bitset_test (N, bison_accept->content->number - ntokens))
complain (&startsymbol_loc, fatal,
_("start symbol %s does not derive any sentence"),
startsymbol->tag);
--- src/scan-gram.c
+++ src/scan-gram.c
@@ -2223,12 +2223,12 @@ YY_RULE_SETUP
case 65:
YY_RULE_SETUP
#line 308 "/Users/akim/src/gnu/bison/src/scan-gram.l"
-RETURN_VALUE (INT, scan_integer (yytext, 10, *loc));
+RETURN_VALUE (INTEGER, scan_integer (yytext, 10, *loc));
YY_BREAK
case 66:
YY_RULE_SETUP
#line 309 "/Users/akim/src/gnu/bison/src/scan-gram.l"
-RETURN_VALUE (INT, scan_integer (yytext, 16, *loc));
+RETURN_VALUE (INTEGER, scan_integer (yytext, 16, *loc));
YY_BREAK
/* Identifiers may not start with a digit. Yet, don't silently
accept "1FOO" as "1 FOO". */
@@ -2575,21 +2575,21 @@ YY_RULE_SETUP
{
STRING_FINISH;
loc->start = token_start;
- val->CHAR = last_string[0];
+ val->CHAR_LITERAL = last_string[0];
/* FIXME: Eventually, make these errors. */
if (last_string[0] == '\0')
{
complain (loc, Wother, _("empty character literal"));
/* '\0' seems dangerous even if we are about to complain. */
- val->CHAR = '\'';
+ val->CHAR_LITERAL = '\'';
}
else if (last_string[1] != '\0')
complain (loc, Wother,
_("extra characters in character literal"));
STRING_FREE;
BEGIN INITIAL;
- return CHAR;
+ return CHAR_LITERAL;
}
YY_BREAK
case 95:
--- src/symtab.c
+++ src/symtab.c
@@ -52,7 +52,7 @@ static semantic_type **semantic_types_sorted = NULL;
symbol *errtoken = NULL;
symbol *undeftoken = NULL;
symbol *endtoken = NULL;
-symbol *accept = NULL;
+symbol *bison_accept = NULL;
symbol *startsymbol = NULL;
location startsymbol_loc;
@@ -843,9 +843,9 @@ symbols_new (void)
symbol_free);
/* Construct the accept symbol. */
- accept = symbol_get ("$accept", empty_loc);
- accept->content->class = nterm_sym;
- accept->content->number = nvars++;
+ bison_accept = symbol_get ("$accept", empty_loc);
+ bison_accept->content->class = nterm_sym;
+ bison_accept->content->number = nvars++;
/* Construct the error token */
errtoken = symbol_get ("error", empty_loc);
--- src/symtab.h
+++ src/symtab.h
@@ -248,7 +248,7 @@ extern symbol *endtoken;
/** The genuine start symbol.
$accept: start-symbol $end */
-extern symbol *accept;
+extern symbol *bison_accept;
/** The user start symbol. */
extern symbol *startsymbol;
--- src/ielr.c
+++ src/ielr.c
@@ -429,7 +429,7 @@
check all predecessors' goto follows for the LHS. */
if (item_number_is_rule_number (ritem[s->items[item] - 2]))
{
- aver (lhs != accept->content->number);
+ aver (lhs != bison_accept->content->number);
for (state **predecessor = predecessors[s->number];
*predecessor;
++predecessor)

View File

@@ -0,0 +1,753 @@
--- Makefile.in
+++ Makefile.in
@@ -637,10 +637,10 @@ am_src_bison_OBJECTS = src/bison-AnnotationList.$(OBJEXT) \
src/bison-main.$(OBJEXT) src/bison-muscle-tab.$(OBJEXT) \
src/bison-named-ref.$(OBJEXT) src/bison-nullable.$(OBJEXT) \
src/bison-output.$(OBJEXT) src/bison-parse-gram.$(OBJEXT) \
- src/bison-print-graph.$(OBJEXT) src/bison-print-xml.$(OBJEXT) \
- src/bison-print.$(OBJEXT) src/bison-reader.$(OBJEXT) \
- src/bison-reduce.$(OBJEXT) src/bison-relation.$(OBJEXT) \
- src/bison-scan-code-c.$(OBJEXT) \
+ src/bison-pathtools.$(OBJEXT) src/bison-print-graph.$(OBJEXT) \
+ src/bison-print-xml.$(OBJEXT) src/bison-print.$(OBJEXT) \
+ src/bison-reader.$(OBJEXT) src/bison-reduce.$(OBJEXT) \
+ src/bison-relation.$(OBJEXT) src/bison-scan-code-c.$(OBJEXT) \
src/bison-scan-gram-c.$(OBJEXT) \
src/bison-scan-skel-c.$(OBJEXT) src/bison-state.$(OBJEXT) \
src/bison-symlist.$(OBJEXT) src/bison-symtab.$(OBJEXT) \
@@ -878,6 +878,7 @@ am__depfiles_remade = examples/c++/$(DEPDIR)/simple-simple.Po \
src/$(DEPDIR)/bison-named-ref.Po \
src/$(DEPDIR)/bison-nullable.Po src/$(DEPDIR)/bison-output.Po \
src/$(DEPDIR)/bison-parse-gram.Po \
+ src/$(DEPDIR)/bison-pathtools.Po \
src/$(DEPDIR)/bison-print-graph.Po \
src/$(DEPDIR)/bison-print-xml.Po src/$(DEPDIR)/bison-print.Po \
src/$(DEPDIR)/bison-reader.Po src/$(DEPDIR)/bison-reduce.Po \
@@ -3169,6 +3170,8 @@ src_bison_SOURCES = \
src/output.c \
src/output.h \
src/parse-gram.y \
+ src/pathtools.c \
+ src/pathtools.h \
src/print-graph.c \
src/print-graph.h \
src/print-xml.c \
@@ -3992,6 +3995,8 @@ src/bison-output.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/bison-parse-gram.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
+src/bison-pathtools.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
src/bison-print-graph.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/bison-print-xml.$(OBJEXT): src/$(am__dirstamp) \
@@ -4317,6 +4322,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/bison-nullable.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/bison-output.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/bison-parse-gram.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/bison-pathtools.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/bison-print-graph.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/bison-print-xml.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/bison-print.Po@am__quote@ # am--include-marker
@@ -7283,6 +7289,20 @@ src/bison-parse-gram.obj: src/parse-gram.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_bison_CPPFLAGS) $(CPPFLAGS) $(src_bison_CFLAGS) $(CFLAGS) -c -o src/bison-parse-gram.obj `if test -f 'src/parse-gram.c'; then $(CYGPATH_W) 'src/parse-gram.c'; else $(CYGPATH_W) '$(srcdir)/src/parse-gram.c'; fi`
+src/bison-pathtools.o: src/pathtools.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_bison_CPPFLAGS) $(CPPFLAGS) $(src_bison_CFLAGS) $(CFLAGS) -MT src/bison-pathtools.o -MD -MP -MF src/$(DEPDIR)/bison-pathtools.Tpo -c -o src/bison-pathtools.o `test -f 'src/pathtools.c' || echo '$(srcdir)/'`src/pathtools.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/bison-pathtools.Tpo src/$(DEPDIR)/bison-pathtools.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/pathtools.c' object='src/bison-pathtools.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_bison_CPPFLAGS) $(CPPFLAGS) $(src_bison_CFLAGS) $(CFLAGS) -c -o src/bison-pathtools.o `test -f 'src/pathtools.c' || echo '$(srcdir)/'`src/pathtools.c
+
+src/bison-pathtools.obj: src/pathtools.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_bison_CPPFLAGS) $(CPPFLAGS) $(src_bison_CFLAGS) $(CFLAGS) -MT src/bison-pathtools.obj -MD -MP -MF src/$(DEPDIR)/bison-pathtools.Tpo -c -o src/bison-pathtools.obj `if test -f 'src/pathtools.c'; then $(CYGPATH_W) 'src/pathtools.c'; else $(CYGPATH_W) '$(srcdir)/src/pathtools.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/bison-pathtools.Tpo src/$(DEPDIR)/bison-pathtools.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/pathtools.c' object='src/bison-pathtools.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_bison_CPPFLAGS) $(CPPFLAGS) $(src_bison_CFLAGS) $(CFLAGS) -c -o src/bison-pathtools.obj `if test -f 'src/pathtools.c'; then $(CYGPATH_W) 'src/pathtools.c'; else $(CYGPATH_W) '$(srcdir)/src/pathtools.c'; fi`
+
src/bison-print-graph.o: src/print-graph.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_bison_CPPFLAGS) $(CPPFLAGS) $(src_bison_CFLAGS) $(CFLAGS) -MT src/bison-print-graph.o -MD -MP -MF src/$(DEPDIR)/bison-print-graph.Tpo -c -o src/bison-print-graph.o `test -f 'src/print-graph.c' || echo '$(srcdir)/'`src/print-graph.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/bison-print-graph.Tpo src/$(DEPDIR)/bison-print-graph.Po
@@ -9079,6 +9099,7 @@ distclean: distclean-recursive
-rm -f src/$(DEPDIR)/bison-nullable.Po
-rm -f src/$(DEPDIR)/bison-output.Po
-rm -f src/$(DEPDIR)/bison-parse-gram.Po
+ -rm -f src/$(DEPDIR)/bison-pathtools.Po
-rm -f src/$(DEPDIR)/bison-print-graph.Po
-rm -f src/$(DEPDIR)/bison-print-xml.Po
-rm -f src/$(DEPDIR)/bison-print.Po
@@ -9464,6 +9485,7 @@ maintainer-clean: maintainer-clean-recursive
-rm -f src/$(DEPDIR)/bison-nullable.Po
-rm -f src/$(DEPDIR)/bison-output.Po
-rm -f src/$(DEPDIR)/bison-parse-gram.Po
+ -rm -f src/$(DEPDIR)/bison-pathtools.Po
-rm -f src/$(DEPDIR)/bison-print-graph.Po
-rm -f src/$(DEPDIR)/bison-print-xml.Po
-rm -f src/$(DEPDIR)/bison-print.Po
--- src/files.c
+++ src/files.c
@@ -1,4 +1,5 @@
/* Open and close files for Bison.
+ rse-gram.Po
Copyright (C) 1984, 1986, 1989, 1992, 2000-2015, 2018-2020 Free
Software Foundation, Inc.
@@ -35,6 +36,7 @@
#include "files.h"
#include "getargs.h"
#include "gram.h"
+#include "pathtools.h"
/* Initializing some values below (such SPEC_NAME_PREFIX to 'yy') is
tempting, but don't do that: for the time being our handling of the
@@ -417,7 +419,11 @@ pkgdatadir (void)
else
{
char const *cp = getenv ("BISON_PKGDATADIR");
- return cp ? cp : relocate2 (PKGDATADIR, &relocate_buffer);
+ if (cp) {
+ return cp;
+ }
+ const char *_dir = single_path_relocation(BINDIR, PKGDATADIR);
+ return _dir;
}
}
--- src/local.mk
+++ src/local.mk
@@ -71,6 +71,8 @@ src_bison_SOURCES = \
src/output.c \
src/output.h \
src/parse-gram.y \
+ src/pathtools.c \
+ src/pathtools.h \
src/print-graph.c \
src/print-graph.h \
src/print-xml.c \
--- src/output.c
+++ src/output.c
@@ -21,6 +21,7 @@
#include <config.h>
#include "system.h"
+#include <configmake.h>
#include <filename.h> /* IS_PATH_WITH_DIR */
#include <get-errno.h>
#include <path-join.h>
@@ -41,6 +42,7 @@
#include "scan-skel.h"
#include "symtab.h"
#include "tables.h"
+#include "pathtools.h"
static struct obstack format_obstack;
@@ -573,7 +575,7 @@ static void
output_skeleton (void)
{
/* Compute the names of the package data dir and skeleton files. */
- char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
+ char const *m4 = (m4 = getenv ("M4")) ? m4 : "m4" EXEEXT; //single_path_relocation(BINDIR, M4);
char const *datadir = pkgdatadir ();
char *skeldir = xpath_join (datadir, "skeletons");
char *m4sugar = xpath_join (datadir, "m4sugar/m4sugar.m4");
--- /dev/null
+++ src/pathtools.c
@@ -0,0 +1,536 @@
+/*
+ .Some useful path tools.
+ .ASCII only for now.
+ .Written by Ray Donnelly in 2014.
+ .Licensed under CC0 (and anything.
+ .else you need to license it under).
+ .No warranties whatsoever.
+ .email: <mingw.android@gmail.com>.
+ */
+
+#include "config.h"
+#if defined(__APPLE__)
+#include <stdlib.h>
+#else
+#include <stddef.h>
+#include <malloc.h>
+#endif
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#if defined(__linux__)
+#include <alloca.h>
+#endif
+#include <unistd.h>
+
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
+/* If you don't define this, then get_executable_path()
+ can only use argv[0] which will often not work well */
+#define IMPLEMENT_SYS_GET_EXECUTABLE_PATH
+
+#if defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH)
+#if defined(__linux__)
+/* Nothing needed, unistd.h is enough. */
+#elif defined(__APPLE__)
+#include <mach-o/dyld.h>
+#elif defined(_WIN32)
+#define WIN32_MEAN_AND_LEAN
+#include <windows.h>
+#include <psapi.h>
+#endif
+#endif /* defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) */
+
+#include "pathtools.h"
+
+char *
+malloc_copy_string(char const * original)
+{
+ char * result = (char *) malloc (sizeof (char*) * strlen (original)+1);
+ if (result != NULL)
+ {
+ strcpy (result, original);
+ }
+ return result;
+}
+
+void
+sanitise_path(char * path)
+{
+ size_t path_size = strlen (path);
+
+ /* Replace any '\' with '/' */
+ char * path_p = path;
+ while ((path_p = strchr (path_p, '\\')) != NULL)
+ {
+ *path_p = '/';
+ }
+ /* Replace any '//' with '/' */
+ path_p = path;
+ while ((path_p = strstr (path_p, "//")) != NULL)
+ {
+ memmove (path_p, path_p + 1, path_size--);
+ }
+ return;
+}
+
+char *
+get_relative_path(char const * from_in, char const * to_in)
+{
+ size_t from_size = (from_in == NULL) ? 0 : strlen (from_in);
+ size_t to_size = (to_in == NULL) ? 0 : strlen (to_in);
+ size_t max_size = (from_size + to_size) * 2 + 4;
+ char * scratch_space = (char *) alloca (from_size + 1 + to_size + 1 + max_size + max_size);
+ char * from;
+ char * to;
+ char * common_part;
+ char * result;
+ size_t count;
+
+ /* No to, return "./" */
+ if (to_in == NULL)
+ {
+ return malloc_copy_string ("./");
+ }
+
+ /* If alloca failed or no from was given return a copy of to */
+ if ( from_in == NULL
+ || scratch_space == NULL )
+ {
+ return malloc_copy_string (to_in);
+ }
+
+ from = scratch_space;
+ strcpy (from, from_in);
+ to = from + from_size + 1;
+ strcpy (to, to_in);
+ common_part = to + to_size + 1;
+ result = common_part + max_size;
+ simplify_path (from);
+ simplify_path (to);
+
+ result[0] = '\0';
+
+ size_t match_size_dirsep = 0; /* The match size up to the last /. Always wind back to this - 1 */
+ size_t match_size = 0; /* The running (and final) match size. */
+ size_t largest_size = (from_size > to_size) ? from_size : to_size;
+ int to_final_is_slash = (to[to_size-1] == '/') ? 1 : 0;
+ char from_c;
+ char to_c;
+ for (match_size = 0; match_size < largest_size; ++match_size)
+ {
+ /* To simplify the logic, always pretend the strings end with '/' */
+ from_c = (match_size < from_size) ? from[match_size] : '/';
+ to_c = (match_size < to_size) ? to[match_size] : '/';
+
+ if (from_c != to_c)
+ {
+ if (from_c != '\0' || to_c != '\0')
+ {
+ match_size = match_size_dirsep;
+ }
+ break;
+ }
+ else if (from_c == '/')
+ {
+ match_size_dirsep = match_size;
+ }
+ }
+ strncpy (common_part, from, match_size);
+ common_part[match_size] = '\0';
+ from += match_size;
+ to += match_size;
+ size_t ndotdots = 0;
+ char const* from_last = from + strlen(from) - 1;
+ while ((from = strchr (from, '/')) && from != from_last)
+ {
+ ++ndotdots;
+ ++from;
+ }
+ for (count = 0; count < ndotdots; ++count)
+ {
+ strcat(result, "../");
+ }
+ if (strlen(to) > 0)
+ {
+ strcat(result, to+1);
+ }
+ /* Make sure that if to ends with '/' result does the same, and
+ vice-versa. */
+ size_t size_result = strlen(result);
+ if ((to_final_is_slash == 1)
+ && (!size_result || result[size_result-1] != '/'))
+ {
+ strcat (result, "/");
+ }
+ else if (!to_final_is_slash
+ && size_result && result[size_result-1] == '/')
+ {
+ result[size_result-1] = '\0';
+ }
+
+ return malloc_copy_string (result);
+}
+
+void
+simplify_path(char * path)
+{
+ ssize_t n_toks = 1; /* in-case we need an empty initial token. */
+ ssize_t i, j;
+ size_t tok_size;
+ size_t in_size = strlen (path);
+ int it_ended_with_a_slash = (path[in_size - 1] == '/') ? 1 : 0;
+ char * result = path;
+ sanitise_path(result);
+ char * result_p = result;
+
+ do
+ {
+ ++n_toks;
+ ++result_p;
+ } while ((result_p = strchr (result_p, '/')) != NULL);
+
+ result_p = result;
+ char ** toks = (char **) alloca (sizeof (char const*) * n_toks);
+ n_toks = 0;
+ do
+ {
+ if (result_p > result)
+ {
+ *result_p++ = '\0';
+ }
+ else if (*result_p == '/')
+ {
+ /* A leading / creates an empty initial token. */
+ toks[n_toks++] = result_p;
+ *result_p++ = '\0';
+ }
+ toks[n_toks++] = result_p;
+ } while ((result_p = strchr (result_p, '/')) != NULL);
+
+ /* Remove all non-leading '.' and any '..' we can match
+ with an earlier forward path (i.e. neither '.' nor '..') */
+ for (i = 1; i < n_toks; ++i)
+ {
+ int removals[2] = { -1, -1 };
+ if ( strcmp (toks[i], "." ) == 0)
+ {
+ removals[0] = i;
+ }
+ else if ( strcmp (toks[i], ".." ) == 0)
+ {
+ /* Search backwards for a forward path to collapse.
+ If none are found then the .. also stays. */
+ for (j = i - 1; j > -1; --j)
+ {
+ if ( strcmp (toks[j], "." )
+ && strcmp (toks[j], ".." ) )
+ {
+ removals[0] = j;
+ removals[1] = i;
+ break;
+ }
+ }
+ }
+ for (j = 0; j < 2; ++j)
+ {
+ if (removals[j] >= 0) /* Can become -2 */
+ {
+ --n_toks;
+ memmove (&toks[removals[j]], &toks[removals[j]+1], (n_toks - removals[j])*sizeof (char*));
+ --i;
+ if (!j)
+ {
+ --removals[1];
+ }
+ }
+ }
+ }
+ result_p = result;
+ for (i = 0; i < n_toks; ++i)
+ {
+ tok_size = strlen(toks[i]);
+ memcpy (result_p, toks[i], tok_size);
+ result_p += tok_size;
+ if ((!i || tok_size) && ((i < n_toks - 1) || it_ended_with_a_slash == 1))
+ {
+ *result_p = '/';
+ ++result_p;
+ }
+ }
+ *result_p = '\0';
+}
+
+/* Returns actual_to by calculating the relative path from -> to and
+ applying that to actual_from. An assumption that actual_from is a
+ dir is made, and it may or may not end with a '/' */
+char const *
+get_relocated_path (char const * from, char const * to, char const * actual_from)
+{
+ char const * relative_from_to = get_relative_path (from, to);
+ char * actual_to = (char *) malloc (strlen(actual_from) + 2 + strlen(relative_from_to));
+ return actual_to;
+}
+
+int
+get_executable_path(char const * argv0, char * result, ssize_t max_size)
+{
+ char * system_result = (char *) alloca (max_size);
+ ssize_t system_result_size = -1;
+ ssize_t result_size = -1;
+
+ if (system_result != NULL)
+ {
+#if defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH)
+#if defined(__linux__)
+ system_result_size = readlink("/proc/self/exe", system_result, max_size);
+#elif defined(__APPLE__)
+ uint32_t bufsize = (uint32_t)max_size;
+ if (_NSGetExecutablePath(system_result, &bufsize) == 0)
+ {
+ system_result_size = (ssize_t)bufsize;
+ }
+#elif defined(_WIN32)
+ unsigned long bufsize = (unsigned long)max_size;
+ system_result_size = GetModuleFileNameA(NULL, system_result, bufsize);
+ if (system_result_size == 0 || system_result_size == (ssize_t)bufsize)
+ {
+ /* Error, possibly not enough space. */
+ system_result_size = -1;
+ }
+ else
+ {
+ /* Early conversion to unix slashes instead of more changes
+ everywhere else .. */
+ char * winslash;
+ system_result[system_result_size] = '\0';
+ while ((winslash = strchr (system_result, '\\')) != NULL)
+ {
+ *winslash = '/';
+ }
+ }
+#else
+#warning "Don't know how to get executable path on this system"
+#endif
+#endif /* defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) */
+ }
+ /* Use argv0 as a default in-case of failure */
+ if (system_result_size != -1)
+ {
+ strncpy (result, system_result, system_result_size);
+ result[system_result_size] = '\0';
+ }
+ else
+ {
+ if (argv0 != NULL)
+ {
+ strncpy (result, argv0, max_size);
+ result[max_size-1] = '\0';
+ }
+ else
+ {
+ result[0] = '\0';
+ }
+ }
+ result_size = strlen (result);
+ return result_size;
+}
+
+char const *
+strip_n_prefix_folders(char const * path, size_t n)
+{
+ if (path == NULL)
+ {
+ return NULL;
+ }
+
+ if (path[0] != '/')
+ {
+ return path;
+ }
+
+ char const * last = path;
+ while (n-- && path != NULL)
+ {
+ last = path;
+ path = strchr (path + 1, '/');
+ }
+ return (path == NULL) ? last : path;
+}
+
+void
+strip_n_suffix_folders(char * path, size_t n)
+{
+ if (path == NULL)
+ {
+ return;
+ }
+ while (n--)
+ {
+ if (strrchr (path + 1, '/'))
+ {
+ *strrchr (path + 1, '/') = '\0';
+ }
+ else
+ {
+ return;
+ }
+ }
+ return;
+}
+
+size_t
+split_path_list(char const * path_list, char split_char, char *** arr)
+{
+ size_t path_count;
+ size_t path_list_size;
+ char const * path_list_p;
+
+ path_list_p = path_list;
+ if (path_list == NULL || path_list[0] == '\0')
+ {
+ return 0;
+ }
+ path_list_size = strlen (path_list);
+
+ path_count = 0;
+ do
+ {
+ ++path_count;
+ ++path_list_p;
+ }
+ while ((path_list_p = strchr (path_list_p, split_char)) != NULL);
+
+ /* allocate everything in one go. */
+ char * all_memory = (char *) malloc (sizeof (char *) * path_count + strlen(path_list) + 1);
+ if (all_memory == NULL)
+ return 0;
+ *arr = (char **)all_memory;
+ all_memory += sizeof (char *) * path_count;
+
+ path_count = 0;
+ path_list_p = path_list;
+ char const * next_path_list_p = 0;
+ do
+ {
+ next_path_list_p = strchr (path_list_p, split_char);
+ if (next_path_list_p != NULL)
+ {
+ ++next_path_list_p;
+ }
+ size_t this_size = (next_path_list_p != NULL)
+ ? next_path_list_p - path_list_p - 1
+ : &path_list[path_list_size] - path_list_p;
+ memcpy (all_memory, path_list_p, this_size);
+ all_memory[this_size] = '\0';
+ (*arr)[path_count++] = all_memory;
+ all_memory += this_size + 1;
+ } while ((path_list_p = next_path_list_p) != NULL);
+
+ return path_count;
+}
+
+char *
+get_relocated_path_list(char const * from, char const * to_path_list)
+{
+ char exe_path[32768];
+ char * temp;
+ get_executable_path (NULL, &exe_path[0], sizeof (exe_path) / sizeof (exe_path[0]));
+ if ((temp = strrchr (exe_path, '/')) != NULL)
+ {
+ temp[1] = '\0';
+ }
+
+ char **arr = NULL;
+ /* Ask Alexey why he added this. Are we not 100% sure
+ that we're dealing with unix paths here? */
+ char split_char = ':';
+ if (strchr (to_path_list, ';'))
+ {
+ split_char = ';';
+ }
+ size_t count = split_path_list (to_path_list, split_char, &arr);
+ int result_size = 1 + (count - 1); /* count - 1 is for ; delim. */
+ size_t exe_path_size = strlen (exe_path);
+ size_t i;
+ /* Space required is:
+ count * (exe_path_size + strlen (rel_to_datadir))
+ rel_to_datadir upper bound is:
+ (count * strlen (from)) + (3 * num_slashes (from))
+ + strlen(arr[i]) + 1.
+ .. pathalogically num_slashes (from) is strlen (from)
+ (from = ////////) */
+ size_t space_required = (count * (exe_path_size + 4 * strlen (from))) + count - 1;
+ for (i = 0; i < count; ++i)
+ {
+ space_required += strlen (arr[i]);
+ }
+ char * scratch = (char *) alloca (space_required);
+ if (scratch == NULL)
+ return NULL;
+ for (i = 0; i < count; ++i)
+ {
+ char * rel_to_datadir = get_relative_path (from, arr[i]);
+ scratch[0] = '\0';
+ arr[i] = scratch;
+ strcat (scratch, exe_path);
+ strcat (scratch, rel_to_datadir);
+ simplify_path (arr[i]);
+ size_t arr_i_size = strlen (arr[i]);
+ result_size += arr_i_size;
+ scratch = arr[i] + arr_i_size + 1;
+ }
+ char * result = (char *) malloc (result_size);
+ if (result == NULL)
+ {
+ return NULL;
+ }
+ result[0] = '\0';
+ for (i = 0; i < count; ++i)
+ {
+ strcat (result, arr[i]);
+ if (i != count-1)
+ {
+#if defined(_WIN32)
+ strcat (result, ";");
+#else
+ strcat (result, ":");
+#endif
+ }
+ }
+ free ((void*)arr);
+ return result;
+}
+
+char *
+single_path_relocation(const char *from, const char *to)
+{
+ char exe_path[PATH_MAX];
+ get_executable_path (NULL, &exe_path[0], sizeof(exe_path)/sizeof(exe_path[0]));
+ if (strrchr (exe_path, '/') != NULL)
+ {
+ strrchr (exe_path, '/')[1] = '\0';
+ }
+ char * rel_to_datadir = get_relative_path (from, to);
+ strcat (exe_path, rel_to_datadir);
+ simplify_path (&exe_path[0]);
+ return malloc_copy_string(exe_path);
+}
+
+char *
+pathlist_relocation(const char *from_path, const char *to_path_list)
+{
+ static char stored_path[PATH_MAX];
+ static int stored = 0;
+ if (stored == 0)
+ {
+ char const * relocated = get_relocated_path_list(from_path, to_path_list);
+ strncpy (stored_path, relocated, PATH_MAX);
+ stored_path[PATH_MAX-1] = '\0';
+ free ((void *)relocated);
+ stored = 1;
+ }
+ return stored_path;
+}
--- /dev/null
+++ src/pathtools.h
@@ -0,0 +1,53 @@
+/*
+ .Some useful path tools.
+ .ASCII only for now.
+ .Written by Ray Donnelly in 2014.
+ .Licensed under CC0 (and anything.
+ .else you need to license it under).
+ .No warranties whatsoever.
+ .email: <mingw.android@gmail.com>.
+ */
+
+#ifndef PATHTOOLS_H
+#define PATHTOOLS_H
+
+#include <unistd.h>
+#if defined(__APPLE__)
+#include <stdlib.h>
+#else
+#include <malloc.h>
+#endif
+#include <stdio.h>
+
+char * malloc_copy_string(char const * original);
+
+/* In-place replaces any '\' with '/' and any '//' with '/' */
+void sanitise_path(char * path);
+
+/* Uses a host OS specific function to determine the path of the executable,
+ if IMPLEMENT_SYS_GET_EXECUTABLE_PATH is defined, otherwise uses argv0. */
+int get_executable_path(char const * argv0, char * result, ssize_t max_size);
+
+/* Where possible, in-place removes occourances of '.' and 'path/..' */
+void simplify_path(char * path);
+
+/* Allocates (via malloc) and returns the path to get from from to to. */
+char * get_relative_path(char const * from, char const * to);
+
+size_t split_path_list(char const * path_list, char split_char, char *** arr);
+
+/* Advances path along by the amount that removes n prefix folders. */
+char const *
+strip_n_prefix_folders(char const * path, size_t n);
+
+/* NULL terminates path to remove n suffix folders. */
+void
+strip_n_suffix_folders(char * path, size_t n);
+
+char const * get_relocated_path (char const * from, char const * to, char const * actual_from);
+char * get_relocated_path_list(char const * from, char const * to_path_list);
+
+char * single_path_relocation(const char *from, const char *to);
+char * pathlist_relocation(const char *from_path, const char *to_path_list);
+
+#endif /* PATHTOOLS_H */
--
2.21.1

View File

@@ -0,0 +1,38 @@
This avoid showing a `Assertion Failed Dialog Box` during configure and running bison with the assertion failur:
```
Expression: new_maximum >= _IOB_ENTRIES && new_maximum <= _NHANDLE_
```
msdn documentation of _setmaxstdio at
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio
Summary:
maximum of 8192 is a hard upper limit for the number of simultaneously open files accessed through the C run-time library.
Kudos to @SSE4 for finding the rootcause at
https://github.com/conan-io/conan-center-index/pull/2334#issuecomment-668171405
--- lib/getdtablesize.c
+++ lib/getdtablesize.c
@@ -79,12 +79,18 @@ getdtablesize (void)
freed when we call _setmaxstdio with the original value. */
int orig_max_stdio = _getmaxstdio ();
unsigned int bound;
- for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
+#ifdef _MSC_VER
+# define BOUND_START 0x2000
+#else
+# define BOUND_START 0x10000
+#endif
+ for (bound = BOUND_START; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
;
_setmaxstdio_nothrow (orig_max_stdio);
dtablesize = bound;
}
return dtablesize;
+#undef BOUND_START
}
#else

View File

@@ -0,0 +1,14 @@
build: don't link bison against libreadline
Reported by Paul Smith <psmith@gnu.org>.
https://lists.gnu.org/r/bug-bison/2020-10/msg00001.html
--- a/Makefile.in
+++ b/Makefile.in
@@ -3456,7 +3456,6 @@
$(LIB_SETLOCALE_NULL) \
$(LIBICONV) \
$(LIBINTL) \
- $(LIBREADLINE) \
$(LIBTEXTSTYLE)
@ENABLE_YACC_TRUE@nodist_bin_SCRIPTS = src/yacc

View File

@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)
find_package(BISON REQUIRED)
set(BISON_VARS
BISON_FOUND
BISON_EXECUTABLE
BISON_VERSION
)
foreach(BISON_VAR ${BISON_VARS})
message("${BISON_VAR}: ${${BISON_VAR}}")
if(NOT ${BISON_VAR})
message(FATAL_ERROR "${BISON_VAR} NOT FOUND")
endif()
endforeach()
bison_target(McParser mc_parser.yy "${CMAKE_CURRENT_BINARY_DIR}/mc_parser.cpp")
add_library(${PROJECT_NAME} STATIC ${BISON_McParser_OUTPUTS})

View File

@@ -0,0 +1,38 @@
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.microsoft import unix_path
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "VirtualBuildEnv", "VirtualRunEnv"
test_type = "explicit"
win_bash = True
@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)
def layout(self):
cmake_layout(self)
def build_requirements(self):
self.tool_requires(self.tested_reference_str)
if self._settings_build.os == "Windows":
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
@property
def _mc_parser_source(self):
return os.path.join(self.source_folder, "mc_parser.yy")
def test(self):
self.run("bison --version")
self.run("yacc --version")
self.run(f"bison -d {unix_path(self, self._mc_parser_source)}")

View File

@@ -0,0 +1,42 @@
%{
#include <iostream>
#include <string>
#include <map>
#include <cstdlib> //-- I need this for atoi
using namespace std;
int yylex();
int yyerror(const char *p) { cerr << "Error!" << endl; return 42; }
%}
%union {
int val;
char sym;
};
%token <val> NUM
%token <sym> OPA OPM LP RP STOP
%type <val> exp term sfactor factor res
%%
run: res run | res /* forces bison to process many stmts */
res: exp STOP { cout << $1 << endl; }
exp: exp OPA term { $$ = ($2 == '+' ? $1 + $3 : $1 - $3); }
| term { $$ = $1; }
term: term OPM factor { $$ = ($2 == '*' ? $1 * $3 : $1 / $3); }
| sfactor { $$ = $1; }
sfactor: OPA factor { $$ = ($1 == '+' ? $2 : -$2); }
| factor { $$ = $1; }
factor: NUM { $$ = $1; }
| LP exp RP { $$ = $2; }
%%
int main()
{
yyparse();
return 0;
}

9
recipes/bison/config.yml Normal file
View File

@@ -0,0 +1,9 @@
versions:
"3.8.2":
folder: all
"3.7.6":
folder: all
"3.7.1":
folder: all
"3.5.3":
folder: all

View File

@@ -1,13 +1,13 @@
sources:
"1.1.0":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/brotli"
branch: "v1.1.0"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/brotli/archive/v1.1.0.tar.gz"
sha256: "e720a6ca29428b803f4ad165371771f5398faba397edf6778837a18599ea13ff"
"1.0.9":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/brotli"
branch: "v1.0.9"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/brotli/archive/v1.0.9.tar.gz"
sha256: "f9e8d81d0405ba66d181529af42a3354f838c939095ff99930da6aa9cdf6fe46"
"1.0.7":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/brotli"
branch: "v1.0.7"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/brotli/archive/v1.0.7.tar.gz"
sha256: "4c61bfb0faca87219ea587326c467b95acb25555b53d1a421ffa3c8a9296ee2c"
patches:
"1.1.0":
- patch_file: "patches/1.1.0-target-props.patch"

View File

@@ -1,7 +1,7 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.tools.scm import Version, Git
from conan.tools.scm import Version
import os
required_conan_version = ">=1.53.0"
@@ -54,11 +54,7 @@ class BrotliConan(ConanFile):
cmake_layout(self, src_folder="src")
def source(self):
#get(self, **self.conan_data["sources"][self.version], strip_root=True)
git = Git(self)
sources = self.conan_data["sources"][self.version]
clone_args = ['--depth', '1', '--branch', sources["branch"]]
git.clone(url=sources["url"], target=self.source_folder, args=clone_args)
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)

View File

@@ -21,6 +21,6 @@ class TestPackageConan(ConanFile):
cmake.build()
def test(self):
if can_run(self):
if can_run(self) and (self.settings.compiler != "gcc" or self.settings.os != "Windows"):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -1,10 +1,9 @@
sources:
"1.0.8":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/bzip2"
branch: bzip2-1.0.8
url: "https://nexus.avroid.tech/repository/all-raw-proxy-sourceware_org/pub/bzip2/bzip2-1.0.8.tar.gz"
sha256: "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269"
"1.0.6":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/bzip2"
branch: bzip2-1.0.6
url: "https://nexus.avroid.tech/repository/all-raw-proxy-sourceware_org/pub/bzip2/bzip2-1.0.6.tar.gz"
sha256: "a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd"
patches:
"1.0.6":

View File

@@ -1,7 +1,7 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, save
from conan.tools.scm import Version, Git
from conan.tools.scm import Version
import os
import textwrap
@@ -47,11 +47,7 @@ class Bzip2Conan(ConanFile):
cmake_layout(self, src_folder="src")
def source(self):
#get(self, **self.conan_data["sources"][self.version], strip_root=True)
git = Git(self)
sources = self.conan_data["sources"][self.version]
clone_args = ['--depth', '1', '--branch', sources["branch"]]
git.clone(url=sources["url"], target=self.source_folder, args=clone_args)
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)

View File

@@ -0,0 +1,16 @@
sources:
"cci.20231129":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/9d809924011af8ff49dadbda1499dc5193f1659c.tar.gz"
sha256: "0d769b7e3cc7d16205f4cc8988f869910db19f2d274db005c1ed74e961936d34"
"cci.20230118":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/3dc310302210c1891ffcfb12ae67b11a3ad3a150.tar.gz"
sha256: "f2f4df6d2b01036f36c5e372954e536881cdd59f5c2461c67aa0a92c6d755c61"
"cci.20220618":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/082deffc80ce517f81dc2f3aebe6ba671fcd09c9.tar.gz"
sha256: "4379348ec3127b37e854a0a66f85ea1d3c606e5f3a6dce235dc9c69ce663c026"
"cci.20220228":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/6288930068efc8dff4f3c0b95f062fc5ddceba04.tar.gz"
sha256: "9e9e937b3569320d23d8b1c8c26ed3603affe55c3e4a3e49622e8a2c6d6e1696"
"cci.20201217":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/pytorch/cpuinfo/archive/5916273f79a21551890fd3d56fc5375a78d1598d.tar.gz"
sha256: "f3c16d5d393d6d1fa6b6ed8621dd0a535552df9bc88cbba739375dde38a93142"

View File

@@ -0,0 +1,113 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, replace_in_file, rmdir
from conan.tools.microsoft import is_msvc
import os
required_conan_version = ">=1.53.0"
class CpuinfoConan(ConanFile):
name = "cpuinfo"
description = "cpuinfo is a library to detect essential for performance " \
"optimization information about host CPU."
license = "BSD-2-Clause"
topics = ("cpu", "cpuid", "cpu-cache", "cpu-model", "instruction-set", "cpu-topology")
homepage = "https://github.com/pytorch/cpuinfo"
url = "https://github.com/conan-io/conan-center-index"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"log_level": ["default", "debug", "info", "warning", "error", "fatal", "none"],
}
default_options = {
"shared": False,
"fPIC": True,
"log_level": "default",
}
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if is_msvc(self):
# Only static for msvc
# Injecting CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS is not sufficient since there are global symbols
del self.options.shared
self.package_type = "static-library"
if self.options.get_safe("shared"):
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
# cpuinfo
tc.cache_variables["CPUINFO_LIBRARY_TYPE"] = "default"
tc.cache_variables["CPUINFO_RUNTIME_TYPE"] = "default"
tc.cache_variables["CPUINFO_LOG_LEVEL"] = self.options.log_level
tc.variables["CPUINFO_BUILD_TOOLS"] = False
tc.variables["CPUINFO_BUILD_UNIT_TESTS"] = False
tc.variables["CPUINFO_BUILD_MOCK_TESTS"] = False
tc.variables["CPUINFO_BUILD_BENCHMARKS"] = False
# clog (always static)
tc.cache_variables["CLOG_RUNTIME_TYPE"] = "default"
tc.variables["CLOG_BUILD_TESTS"] = False
tc.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True)
tc.generate()
def _patch_sources(self):
cmakelists = os.path.join(self.source_folder, "CMakeLists.txt")
# Fix install dir of dll
replace_in_file(
self,
cmakelists,
"LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}",
"LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}",
)
if self.version < "cci.20230118":
# Honor fPIC option
replace_in_file(self, cmakelists, "SET_PROPERTY(TARGET clog PROPERTY POSITION_INDEPENDENT_CODE ON)", "")
def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "cpuinfo")
self.cpp_info.set_property("pkg_config_name", "libcpuinfo")
if self.version < "cci.20230118":
self.cpp_info.components["clog"].libs = ["clog"]
cpuinfo_clog_target = "clog" if self.version < "cci.20220618" else "cpuinfo::clog"
self.cpp_info.components["clog"].set_property("cmake_target_name", cpuinfo_clog_target)
self.cpp_info.components["cpuinfo"].set_property("cmake_target_name", "cpuinfo::cpuinfo")
self.cpp_info.components["cpuinfo"].libs = ["cpuinfo"]
if self.version < "cci.20230118":
self.cpp_info.components["cpuinfo"].requires = ["clog"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["cpuinfo"].system_libs.append("pthread")
if self.settings.os == "Android":
self.cpp_info.components["cpuinfo"].system_libs.append("log")

View File

@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES C)
find_package(cpuinfo REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
if ((${CPUINFO_VERSION} GREATER_EQUAL "20220618") AND (${CPUINFO_VERSION} LESS "20230118"))
# in that version range cpuinfo exposed cpuinfo::clog. Check that is available through conan recipe
target_link_libraries(${PROJECT_NAME} PRIVATE cpuinfo::cpuinfo cpuinfo::clog)
else ()
target_link_libraries(${PROJECT_NAME} PRIVATE cpuinfo::cpuinfo)
endif()
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99)

View File

@@ -0,0 +1,31 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["CPUINFO_VERSION"] = str(self.dependencies["cpuinfo"].ref.version).split('.')[1]
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,23 @@
#include <cpuinfo.h>
#include <stdio.h>
int main() {
bool initialized = cpuinfo_initialize();
if (!initialized) {
printf("cpuinfo doesn't support this platforn\n");
return 0;
}
printf("processors count: %u\n", cpuinfo_get_processors_count());
printf("cores count: %u\n", cpuinfo_get_cores_count());
printf("clusters count: %u\n", cpuinfo_get_clusters_count());
printf("packages count: %u\n", cpuinfo_get_packages_count());
printf("uarchs count: %u\n", cpuinfo_get_uarchs_count());
printf("l1i caches count: %u\n", cpuinfo_get_l1i_caches_count());
printf("l1d caches count: %u\n", cpuinfo_get_l1d_caches_count());
printf("l2 count: %u\n", cpuinfo_get_l2_caches_count());
printf("l3 count: %u\n", cpuinfo_get_l3_caches_count());
printf("l4 count: %u\n", cpuinfo_get_l4_caches_count());
cpuinfo_deinitialize();
return 0;
}

View File

@@ -0,0 +1,11 @@
versions:
"cci.20231129":
folder: all
"cci.20230118":
folder: all
"cci.20220618":
folder: all
"cci.20220228":
folder: all
"cci.20201217":
folder: all

View File

@@ -0,0 +1,13 @@
sources:
"1.4.3":
url: "http://nexus.avroid.tech/repository/all-raw-proxy-code_videolan_org/videolan/dav1d/-/archive/1.4.3/dav1d-1.4.3.tar.gz"
sha256: "88a023e58d955e0886faf49c72940e0e90914a948a8e60c1326ce3e09e7a6099"
"1.4.1":
url: "http://nexus.avroid.tech/repository/all-raw-proxy-code_videolan_org/videolan/dav1d/-/archive/1.4.1/dav1d-1.4.1.tar.gz"
sha256: "8d407dd5fe7986413c937b14e67f36aebd06e1fa5cfec679d10e548476f2d5f8"
"1.3.0":
url: "http://nexus.avroid.tech/repository/all-raw-proxy-code_videolan_org/videolan/dav1d/-/archive/1.3.0/dav1d-1.3.0.tar.gz"
sha256: "6d8be2741c505c47f8f1ced3c9cc427759243436553d01d1acce201f87b39e71"
"1.2.1":
url: "http://nexus.avroid.tech/repository/all-raw-proxy-code_videolan_org/videolan/dav1d/-/archive/1.2.1/dav1d-1.2.1.tar.gz"
sha256: "4e33eb61ec54c768a16da0cf8fa0928b4c4593f5f804a3c887d4a21c318340b2"

View File

@@ -0,0 +1,134 @@
from conan import ConanFile
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get, replace_in_file, rm, rmdir
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson, MesonToolchain
from conan.tools.microsoft import is_msvc
import os
required_conan_version = ">=1.53.0"
class Dav1dConan(ConanFile):
name = "dav1d"
description = "dav1d is a new AV1 cross-platform decoder, open-source, and focused on speed, size and correctness."
homepage = "https://www.videolan.org/projects/dav1d.html"
topics = ("av1", "codec", "video", "decoding")
license = "BSD-2-Clause"
url = "https://github.com/conan-io/conan-center-index"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"bit_depth": ["all", 8, 16],
"with_tools": [True, False],
"assembly": [True, False],
"with_avx512": ["deprecated", True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"bit_depth": "all",
"with_tools": True,
"assembly": True,
"with_avx512": "deprecated",
}
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if is_msvc(self) and self.settings.build_type == "Debug":
# debug builds with assembly often causes linker hangs or LNK1000
self.options.assembly = False
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
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.options.with_avx512
def validate(self):
if self.options.with_avx512 != "deprecated":
self.output.warning("The 'with_avx512' option is deprecated and has no effect")
def build_requirements(self):
self.tool_requires("meson/[>=1.4.0<2]")
if self.options.assembly:
self.tool_requires("nasm/2.16.01")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = MesonToolchain(self)
tc.project_options["enable_tests"] = False
tc.project_options["enable_asm"] = self.options.assembly
tc.project_options["enable_tools"] = self.options.with_tools
if self.options.bit_depth == "all":
tc.project_options["bitdepths"] = "8,16"
else:
tc.project_options["bitdepths"] = str(self.options.bit_depth)
tc.generate()
def _patch_sources(self):
replace_in_file(self, os.path.join(self.source_folder, "meson.build"),
"subdir('doc')", "")
def build(self):
self._patch_sources()
if self.settings.os == "Windows" and self.settings.compiler == "gcc":
replace_in_file(self,
os.path.join(self.source_folder, "meson.build"),
"find_program('nasm'",
"find_program('nasm.exe'",
)
meson = Meson(self)
meson.configure()
meson.build()
def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
meson = Meson(self)
meson.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
fix_apple_shared_install_name(self)
fix_msvc_libname(self)
def package_info(self):
self.cpp_info.set_property("pkg_config_name", "dav1d")
self.cpp_info.libs = ["dav1d"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["dl", "pthread"])
# TODO: to remove in conan v2
if self.options.with_tools:
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
def fix_msvc_libname(conanfile, remove_lib_prefix=True):
"""remove lib prefix & change extension to .lib in case of cl like compiler"""
from conan.tools.files import rename
import glob
if not conanfile.settings.get_safe("compiler.runtime"):
return
libdirs = getattr(conanfile.cpp.package, "libdirs")
for libdir in libdirs:
for ext in [".dll.a", ".dll.lib", ".a"]:
full_folder = os.path.join(conanfile.package_folder, libdir)
for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")):
libname = os.path.basename(filepath)[0:-len(ext)]
if remove_lib_prefix and libname[0:3] == "lib":
libname = libname[3:]
rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib"))

View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
find_package(dav1d REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE dav1d::dav1d)

View File

@@ -0,0 +1,26 @@
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", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,9 @@
#include "dav1d/dav1d.h"
#include <stdio.h>
int main()
{
printf("dav1d version: %s\n", dav1d_version());
return 0;
}

9
recipes/dav1d/config.yml Normal file
View File

@@ -0,0 +1,9 @@
versions:
"1.4.3":
folder: "all"
"1.4.1":
folder: "all"
"1.3.0":
folder: "all"
"1.2.1":
folder: "all"

View File

@@ -0,0 +1,29 @@
sources:
"1.15.8":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-dbus_freedesktop_org/releases/dbus/dbus-1.15.8.tar.xz"
sha256: "84fc597e6ec82f05dc18a7d12c17046f95bad7be99fc03c15bc254c4701ed204"
"1.15.6":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-dbus_freedesktop_org/releases/dbus/dbus-1.15.6.tar.xz"
sha256: "f97f5845f9c4a5a1fb3df67dfa9e16b5a3fd545d348d6dc850cb7ccc9942bd8c"
"1.15.2":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-dbus_freedesktop_org/releases/dbus/dbus-1.15.2.tar.xz"
sha256: "7e640803084af59f5e477b7ded11fd888b5380910a895c51ca3aedd63c0626ca"
"1.15.0":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-dbus_freedesktop_org/releases/dbus/dbus-1.15.0.tar.xz"
sha256: "5073c8cb9ad20226647bb38f4965182b762a6e1f595ccdc8e59411014bfd640a"
patches:
"1.15.8":
- patch_file: "patches/0001-meson-Use-check_header-to-confirm-headers-work.patch"
patch_type: "portability"
patch_description: "Fix build with Visual Studio 2022"
patch_source: "https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/454"
"1.15.2":
- patch_file: "patches/0003-meson-monotonic-clock-check.patch"
patch_type: "portability"
patch_description: "Fix detection of necessary monotonic clock functions in pthread"
patch_source: "https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/352"
"1.15.0":
- patch_file: "patches/0003-meson-monotonic-clock-check.patch"
patch_type: "portability"
patch_description: "Fix detection of necessary monotonic clock functions in pthread"
patch_source: "https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/352"

View File

@@ -0,0 +1,224 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, replace_in_file, rm, rmdir, save
from conan.tools.gnu import PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson, MesonToolchain
from conan.tools.scm import Version
import os
import textwrap
required_conan_version = ">=1.64.0 <2 || >=2.2.0"
class DbusConan(ConanFile):
name = "dbus"
# license is AFL-2.1 OR GPL-2.0-or-later with several other compatible licenses for smaller sections of code
license = "(AFL-2.1 OR GPL-2.0-or-later) AND DocumentRef-COPYING"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.freedesktop.org/wiki/Software/dbus"
description = "D-Bus is a simple system for interprocess communication and coordination."
topics = "bus", "interprocess", "message"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
short_paths = True
options = {
"shared": [True, False],
"fPIC": [True, False],
"dbus_user": [None, "ANY"],
"message_bus": [True, False],
"system_socket": [None, "ANY"],
"system_pid_file": [None, "ANY"],
"with_x11": [True, False],
"with_systemd": [True, False],
"with_selinux": [True, False],
"session_socket_dir": [None, "ANY"],
}
default_options = {
"shared": False,
"fPIC": True,
"dbus_user": "messagebus",
"message_bus": False,
"system_socket": None,
"system_pid_file": None,
"with_x11": False,
"with_systemd": False,
"with_selinux": False,
"session_socket_dir": "/tmp",
}
@property
def _has_message_bus_option(self):
return Version(self.version) > "1.15.2"
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os not in ["Linux", "FreeBSD"]:
del self.options.with_systemd
del self.options.with_x11
del self.options.with_selinux
if self.settings.os == "Windows":
del self.options.fPIC
if not self._has_message_bus_option:
self.options.rm_safe("message_bus")
def configure(self):
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
if self.options.shared:
self.options.rm_safe("fPIC")
if not self.options.get_safe("message_bus"):
self.options.rm_safe("dbus_user")
def layout(self):
basic_layout(self, src_folder="src")
def requirements(self):
self.requires("expat/[>=2.6.2 <3]")
if self.options.get_safe("with_systemd"):
self.requires("libsystemd/253.6")
if self.options.get_safe("with_selinux"):
self.requires("libselinux/3.6")
if self.options.get_safe("with_x11"):
# X11 is only linked into an executable and should not be propagated as a library dependency.
# It should still be provided in a VirtualRunEnv context, though,
# but Conan as of v2.2 does not yet provide a fine-grained enough control over this.
self.requires("xorg/system", visible=False)
def package_id(self):
# The dbus_user option only effects the installation of dbus during the package method.
# Otherwise, it only appears in the system.conf file in the package.
self.info.options.rm_safe("dbus_user")
def validate(self):
if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < 7:
raise ConanInvalidConfiguration(f"{self.ref} requires at least gcc 7.")
def build_requirements(self):
self.tool_requires("meson/[>=1.4.0]")
if not self.conf.get("tools.gnu:pkg_config",check_type=str):
self.tool_requires("pkgconf/[>=2.1.0]")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = MesonToolchain(self)
tc.project_options["asserts"] = not is_apple_os(self)
tc.project_options["checks"] = False
tc.project_options["datadir"] = os.path.join("res", "share")
tc.project_options["sysconfdir"] = os.path.join("res", "etc")
tc.project_options["doxygen_docs"] = "disabled"
tc.project_options["ducktype_docs"] = "disabled"
tc.project_options["qt_help"] = "disabled"
tc.project_options["modular_tests"] = "disabled"
tc.project_options["selinux"] = "enabled" if self.options.get_safe("with_selinux") else "disabled"
if self.options.session_socket_dir:
tc.project_options["session_socket_dir"] = str(self.options.session_socket_dir)
tc.project_options["systemd"] = "enabled" if self.options.get_safe("with_systemd") else "disabled"
if self.options.get_safe("with_systemd"):
tc.project_options["systemd_system_unitdir"] = "/res/lib/systemd/system"
tc.project_options["systemd_user_unitdir"] = "/res/usr/lib/systemd/system"
if self._has_message_bus_option:
tc.project_options["message_bus"] = bool(self.options.message_bus)
if self.options.get_safe("dbus_user"):
tc.project_options["dbus_user"] = str(self.options.dbus_user)
if self.options.system_pid_file:
tc.project_options["system_pid_file"] = str(self.options.system_pid_file)
if self.options.system_socket:
tc.project_options["system_socket"] = str(self.options.system_socket)
if is_apple_os(self):
tc.project_options["launchd_agent_dir"] = os.path.join("res", "LaunchAgents")
tc.project_options["x11_autolaunch"] = "enabled" if self.options.get_safe("with_x11") else "disabled"
tc.project_options["xml_docs"] = "disabled"
tc.generate()
deps = PkgConfigDeps(self)
deps.generate()
def _patch_sources(self):
apply_conandata_patches(self)
replace_in_file(self, os.path.join(self.source_folder, "meson.build"),
"subdir('test')", "# subdir('test')")
def build(self):
self._patch_sources()
meson = Meson(self)
meson.configure()
meson.build()
def package(self):
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "*", os.path.join(self.source_folder, "LICENSES"), os.path.join(self.package_folder, "licenses"))
meson = Meson(self)
meson.install()
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
rmdir(self, os.path.join(self.package_folder, "res", "share", "doc"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
fix_apple_shared_install_name(self)
if self.settings.os == "Windows" and not self.options.shared:
rename(self, os.path.join(self.package_folder, "lib", "libdbus-1.a"), os.path.join(self.package_folder, "lib", "dbus-1.lib"))
# 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),
{"dbus-1": "dbus-1::dbus-1"}
)
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.set_property("cmake_file_name", "DBus1")
self.cpp_info.set_property("cmake_target_name", "dbus-1")
self.cpp_info.set_property("pkg_config_name", "dbus-1")
self.cpp_info.includedirs.extend([
os.path.join("include", "dbus-1.0"),
os.path.join("lib", "dbus-1.0", "include"),
])
self.cpp_info.resdirs = ["res"]
self.cpp_info.libs = ["dbus-1"]
if self.settings.os == "Linux":
self.cpp_info.system_libs.append("rt")
if self.settings.os == "Windows":
self.cpp_info.system_libs.extend(["iphlpapi", "ws2_32"])
else:
self.cpp_info.system_libs.append("pthread")
if not self.options.shared:
self.cpp_info.defines.append("DBUS_STATIC_BUILD")
self.cpp_info.requires.append("expat::expat")
if self.options.get_safe("with_systemd"):
self.cpp_info.requires.append("libsystemd::libsystemd")
if self.options.get_safe("with_selinux"):
self.cpp_info.requires.append("libselinux::selinux")
# TODO: to remove in conan v2 once cmake_find_package_* & pkg_config generators removed
self.cpp_info.filenames["cmake_find_package"] = "DBus1"
self.cpp_info.filenames["cmake_find_package_multi"] = "DBus1"
self.cpp_info.names["cmake_find_package"] = "dbus-1"
self.cpp_info.names["cmake_find_package_multi"] = "dbus-1"
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]
self.cpp_info.names["pkg_config"] = "dbus-1"

View File

@@ -0,0 +1,46 @@
From e52ccaf7c3abf9d0adccfd001c1417ce08a7f335 Mon Sep 17 00:00:00 2001
From: Thomas Sondergaard <Thomas.Sondergaard@mi.medical.canon>
Date: Thu, 4 Jan 2024 17:45:46 +0100
Subject: [PATCH] meson: Use check_header to confirm headers work
instead of using has_header use check_header to confirm the header
works. This is necessary to get the meson build to work with Visual
Studio 2022. It has <stdatomic.h> but it does not actually work when
compiling a C program. A minimal C program that include <stdatomic.h>
fails with the following errors:
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(36): error C2061: syntax error: identifier 'atomic_bool'
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(36): error C2059: syntax error: ';'
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(37): error C2061: syntax error: identifier 'atomic_char'
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(37): error C2059: syntax error: ';'
...
...
check_header is consistent with CMake's
check_include_file(stdatomic.h HAVE_STDATOMIC_H)
which is why the CMake-based build of dbus works with Visual Studio
2022, while the meson build doesn't.
Fixes #494
---
meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 17b2a837..19b41cd9 100644
--- a/meson.build
+++ b/meson.build
@@ -705,7 +705,7 @@ check_headers = [
foreach header : check_headers
macro = 'HAVE_' + header.underscorify().to_upper()
- config.set(macro, cc.has_header(header, args: compile_args_c) ? 1 : false)
+ config.set(macro, cc.check_header(header, args: compile_args_c) ? 1 : false)
endforeach
execinfo = cc.find_library('execinfo', required: false)
--
2.43.0.windows.1

View File

@@ -0,0 +1,15 @@
diff --git a/meson.build b/meson.build
index 3b5b182c..4e400a52 100644
--- a/meson.build
+++ b/meson.build
@@ -328,7 +328,9 @@ data_config.set('top_builddir', meson.project_build_root())
threads = dependency('threads')
config.set(
'HAVE_MONOTONIC_CLOCK',
- cc.has_header_symbol('pthread.h', 'CLOCK_MONOTONIC', args: compile_args_c),
+ cc.has_header_symbol('pthread.h', 'CLOCK_MONOTONIC', args: compile_args_c)
+ and cc.has_header_symbol('pthread.h', 'pthread_condattr_setclock', args: compile_args_c)
+ and cc.has_header_symbol('time.h', 'clock_getres', args: compile_args_c),
)
glib = dependency(

View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
find_package(DBus1 REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE dbus-1)

View File

@@ -0,0 +1,27 @@
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", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str, run=True)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
self.run("dbus-monitor --help", env="conanrun")
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,13 @@
#include <stdio.h>
#include <dbus/dbus.h>
int main() {
int major_version = 0;
int minor_version = 0;
int micro_version = 0;
dbus_get_version(&major_version, &minor_version, &micro_version);
printf("D-Bus version: v%i.%i.%i\n", major_version, minor_version, micro_version);
return 0;
}

9
recipes/dbus/config.yml Normal file
View File

@@ -0,0 +1,9 @@
versions:
"1.15.8":
folder: all
"1.15.6":
folder: all
"1.15.2":
folder: all
"1.15.0":
folder: all

View File

@@ -1,22 +1,22 @@
sources:
"3.3.0":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/double-conversion"
branch: "v3.3.0"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/double-conversion/archive/refs/tags/v3.3.0.tar.gz"
sha256: "04ec44461850abbf33824da84978043b22554896b552c5fd11a9c5ae4b4d296e"
"3.2.1":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/double-conversion"
branch: "v3.2.1"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/double-conversion/archive/v3.2.1.tar.gz"
sha256: "e40d236343cad807e83d192265f139481c51fc83a1c49e406ac6ce0a0ba7cd35"
"3.2.0":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/double-conversion"
branch: "v3.2.0"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/double-conversion/archive/v3.2.0.tar.gz"
sha256: "3dbcdf186ad092a8b71228a5962009b5c96abde9a315257a3452eb988414ea3b"
"3.1.7":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/double-conversion"
branch: "v3.1.7"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/double-conversion/archive/v3.1.7.tar.gz"
sha256: "a0204d6ab48223f2c8f53a932014e7f245125e7a5267764b1fbeebe4fa0ee8b9"
"3.1.6":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/double-conversion"
branch: "v3.1.6"
url: https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/double-conversion/archive/v3.1.6.tar.gz
sha256: 8a79e87d02ce1333c9d6c5e47f452596442a343d8c3e9b234e8a62fce1b1d49c
"3.1.5":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/double-conversion"
branch: "v3.1.5"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/double-conversion/archive/v3.1.5.tar.gz"
sha256: "a63ecb93182134ba4293fd5f22d6e08ca417caafa244afaa751cbfddf6415b13"
"3.1.4":
url: "ssh://git@git.avroid.tech.:2222/Mirrors/double-conversion"
branch: "v3.1.4"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/google/double-conversion/archive/v3.1.4.tar.gz"
sha256: "95004b65e43fefc6100f337a25da27bb99b9ef8d4071a36a33b5e83eb1f82021"

View File

@@ -2,7 +2,6 @@ from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rmdir, rm
from conan.tools.microsoft import check_min_vs
from conan.tools.scm import Git
import os
required_conan_version = ">=1.54.0"
@@ -42,11 +41,7 @@ class DoubleConversionConan(ConanFile):
check_min_vs(self, "190")
def source(self):
#get(self, **self.conan_data["sources"][self.version], strip_root=True)
git = Git(self)
sources = self.conan_data["sources"][self.version]
clone_args = ['--depth', '1', '--branch', sources["branch"]]
git.clone(url=sources["url"], target=self.source_folder, args=clone_args)
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)

View File

@@ -21,6 +21,6 @@ class TestPackageConan(ConanFile):
cmake.build()
def test(self):
if can_run(self):
if can_run(self) and (self.settings.compiler != "gcc" or self.settings.os != "Windows"):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,31 @@
sources:
"2.6.4":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libexpat/libexpat/releases/download/R_2_6_4/expat-2.6.4.tar.xz"
sha256: "a695629dae047055b37d50a0ff4776d1d45d0a4c842cf4ccee158441f55ff7ee"
"2.6.3":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libexpat/libexpat/releases/download/R_2_6_3/expat-2.6.3.tar.xz"
sha256: "274db254a6979bde5aad404763a704956940e465843f2a9bd9ed7af22e2c0efc"
"2.6.2":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libexpat/libexpat/releases/download/R_2_6_2/expat-2.6.2.tar.xz"
sha256: "ee14b4c5d8908b1bec37ad937607eab183d4d9806a08adee472c3c3121d27364"
"2.6.0":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libexpat/libexpat/releases/download/R_2_6_0/expat-2.6.0.tar.xz"
sha256: "cb5f5a8ea211e1cabd59be0a933a52e3c02cc326e86a4d387d8d218e7ee47a3e"
"2.5.0":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.xz"
sha256: "ef2420f0232c087801abf705e89ae65f6257df6b7931d37846a193ef2e8cdcbe"
"2.4.9":
sha256: "6e8c0728fe5c7cd3f93a6acce43046c5e4736c7b4b68e032e9350daa0efc0354"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libexpat/libexpat/releases/download/R_2_4_9/expat-2.4.9.tar.xz"
"2.4.8":
sha256: "f79b8f904b749e3e0d20afeadecf8249c55b2e32d4ebb089ae378df479dcaf25"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.xz"
"2.3.0":
sha256: "89df123c62f2c2e2b235692d9fe76def6a9ab03dbe95835345bf412726eb1987"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libexpat/libexpat/releases/download/R_2_3_0/expat-2.3.0.tar.gz"
"2.2.10":
sha256: "bf42d1f52371d23684de36cc6d2f0f1acd02de264d1105bdc17792bbeb7e7ceb"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libexpat/libexpat/releases/download/R_2_2_10/expat-2.2.10.tar.gz"
patches:
"2.3.0":
- patch_file: "patches/0001-2.3.0-relax-vs-restriction.patch"

View File

@@ -0,0 +1,102 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rmdir
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
import os
required_conan_version = ">=1.53.0"
class ExpatConan(ConanFile):
name = "expat"
description = "Fast streaming XML parser written in C."
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/libexpat/libexpat"
topics = ("xml", "parsing")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"char_type": ["char", "wchar_t", "ushort"],
"large_size": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"char_type": "char",
"large_size": False,
}
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["EXPAT_BUILD_DOCS"] = False
tc.variables["EXPAT_BUILD_EXAMPLES"] = False
tc.variables["EXPAT_SHARED_LIBS"] = self.options.shared
tc.variables["EXPAT_BUILD_TESTS"] = False
tc.variables["EXPAT_BUILD_TOOLS"] = False
tc.variables["EXPAT_CHAR_TYPE"] = self.options.char_type
if is_msvc(self):
tc.variables["EXPAT_MSVC_STATIC_CRT"] = is_msvc_static_runtime(self)
tc.variables["EXPAT_BUILD_PKGCONFIG"] = False
tc.variables["EXPAT_LARGE_SIZE"] = self.options.large_size
tc.generate()
def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_module_file_name", "EXPAT")
self.cpp_info.set_property("cmake_module_target_name", "EXPAT::EXPAT")
self.cpp_info.set_property("cmake_file_name", "expat")
self.cpp_info.set_property("cmake_target_name", "expat::expat")
self.cpp_info.set_property("pkg_config_name", "expat")
self.cpp_info.libs = collect_libs(self)
if not self.options.shared:
self.cpp_info.defines = ["XML_STATIC"]
if self.options.get_safe("char_type") in ("wchar_t", "ushort"):
self.cpp_info.defines.append("XML_UNICODE")
elif self.options.get_safe("char_type") == "wchar_t":
self.cpp_info.defines.append("XML_UNICODE_WCHAR_T")
if self.options.large_size:
self.cpp_info.defines.append("XML_LARGE_SIZE")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
# TODO: to remove in conan v2
self.cpp_info.names["cmake_find_package"] = "EXPAT"
self.cpp_info.names["cmake_find_package_multi"] = "expat"

View File

@@ -0,0 +1,13 @@
diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt
index e3564691..0dc5cf80 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -133,7 +133,7 @@ if(MSVC)
# Minimum supported MSVC version is 1910 = Visual Studio 15.0/2017
# See also https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
if(MSVC_VERSION VERSION_LESS 1910)
- message(SEND_ERROR "MSVC_VERSION ${MSVC_VERSION} is not a supported Visual Studio compiler version. Please use Visual Studio 15.0/2017 or any later version.")
+ message(WARNING "MSVC_VERSION ${MSVC_VERSION} is not a supported Visual Studio compiler version. Please use Visual Studio 15.0/2017 or any later version.")
endif()
endif()

View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
find_package(expat REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE expat::expat)

View File

@@ -0,0 +1,26 @@
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", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,64 @@
/* This is simple demonstration of how to use expat. This program
reads an XML document from standard input and writes a line with
the name of each element to standard output indenting child
elements by one tab stop more than their parent element.
It must be used with Expat compiled for UTF-8 output.
*/
#include <stdio.h>
#include "expat.h"
#ifdef XML_UNICODE_WCHAR_T
#include <wchar.h>
#endif
#ifdef XML_LARGE_SIZE
#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
#define XML_FMT_INT_MOD "I64"
#else
#define XML_FMT_INT_MOD "ll"
#endif
#else
#define XML_FMT_INT_MOD "l"
#endif
static void XMLCALL
startElement(void *userData, const XML_Char *name, const XML_Char **atts)
{
int i;
int *depthPtr = (int *)userData;
(void)atts;
for (i = 0; i < *depthPtr; i++)
putchar('\t');
#ifdef XML_UNICODE_WCHAR_T
fputws(name, stdout);
#else
puts(name);
#endif
*depthPtr += 1;
}
static void XMLCALL
endElement(void *userData, const XML_Char *name)
{
int *depthPtr = (int *)userData;
(void)name;
*depthPtr -= 1;
}
int
main(int argc, char *argv[])
{
XML_Parser parser = XML_ParserCreate(NULL);
int depth = 0;
(void)argc;
(void)argv;
XML_SetUserData(parser, &depth);
XML_SetElementHandler(parser, startElement, endElement);
XML_ParserFree(parser);
printf("Test application successfully ran!\n");
return 0;
}

View File

@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10)
project(test_package LANGUAGES C)
find_package(EXPAT REQUIRED MODULE)
add_executable(${PROJECT_NAME} ../test_package/test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE EXPAT::EXPAT)
# Test whether variables from https://cmake.org/cmake/help/latest/module/FindEXPAT.html
# are properly defined in conan generators
set(_custom_vars
EXPAT_INCLUDE_DIRS
EXPAT_LIBRARIES
EXPAT_FOUND
)
foreach(_custom_var ${_custom_vars})
if(DEFINED ${_custom_var})
message(STATUS "${_custom_var}: ${${_custom_var}}")
else()
message(FATAL_ERROR "${_custom_var} not defined")
endif()
endforeach()

View File

@@ -0,0 +1,26 @@
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", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)

View File

@@ -0,0 +1,18 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
import os
class TestPackageV1Conan(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 cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package_module/
${CMAKE_CURRENT_BINARY_DIR}/test_package_module/)

View File

@@ -0,0 +1,18 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
import os
class TestPackageV1Conan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

19
recipes/expat/config.yml Normal file
View File

@@ -0,0 +1,19 @@
versions:
"2.6.4":
folder: all
"2.6.3":
folder: all
"2.6.2":
folder: all
"2.6.0":
folder: all
"2.5.0":
folder: all
"2.4.9":
folder: all
"2.4.8":
folder: all
"2.3.0":
folder: all
"2.2.10":
folder: all

View File

@@ -0,0 +1,62 @@
sources:
"7.0.1":
url: "https://ffmpeg.org//releases/ffmpeg-7.0.1.tar.bz2"
sha256: "5e77e84b6434d656106fafe3bceccc77176449014f3eba24d33db3fbd0939dc9"
"6.1.1":
url: "https://ffmpeg.org/releases/ffmpeg-6.1.1.tar.bz2"
sha256: "5e3133939a61ef64ac9b47ffd29a5ea6e337a4023ef0ad972094b4da844e3a20"
"6.1":
url: "https://ffmpeg.org/releases/ffmpeg-6.1.tar.bz2"
sha256: "eb7da3de7dd3ce48a9946ab447a7346bd11a3a85e6efb8f2c2ce637e7f547611"
"6.0.1":
url: "https://ffmpeg.org/releases/ffmpeg-6.0.1.tar.bz2"
sha256: "2c6e294569d1ba8e99cbf1acbe49e060a23454228a540a0f45d679d72ec69a06"
"5.1.3":
url: "https://ffmpeg.org/releases/ffmpeg-5.1.3.tar.bz2"
sha256: "5d5bef6a11f0c500588f9870ec965a30acc0d54d8b1e535da6554a32902d236d"
"5.0.3":
url: "https://ffmpeg.org/releases/ffmpeg-5.0.3.tar.bz2"
sha256: "664e8fa8ac4cc5dce03277f022798461998d9bb8d96b9e1859b24e74511229fd"
"4.4.4":
url: "https://ffmpeg.org/releases/ffmpeg-4.4.4.tar.bz2"
sha256: "47b1fbf70a2c090d9c0fae5910da11c6406ca92408bb69d8c935cd46c622c7ce"
patches:
"5.1.3":
- patch_file: "patches/5.1-0001-fix-libsvtav1-compressed_ten_bit_format.patch"
patch_description: "Compatibility with libsvtav1 > 1.2.0"
patch_type: "portability"
patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/031f1561cd286596cdb374da32f8aa816ce3b135"
- patch_file: "patches/5.1-0002-fix-libsvtav1-vbv_bufsize-1.patch"
patch_description: "Compatibility with libsvtav1 > 1.2.0"
patch_type: "portability"
patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/1c6fd7d756afe0f8b7df14dbf7a95df275f8f5ee"
- patch_file: "patches/5.1-0003-fix-libsvtav1-vbv_bufsize-2.patch"
patch_description: "Compatibility with libsvtav1 > 1.2.0"
patch_type: "portability"
patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/96748ac54f998ba6fe22802799c16b4eba8d4ccc"
- patch_file: "patches/5.0-0001-fix-hwcontext_vulkan.patch"
patch_description: "Compatibility with vulkan >= 1.3.239"
patch_type: "portability"
patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/eb0455d64690eed0068e5cb202f72ecdf899837c"
- patch_file: "patches/5.1-0004-fix-binutils.patch"
patch_description: "Compatibility with binutils >= 2.41"
patch_type: "portability"
patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/effadce6c756247ea8bae32dc13bb3e6f464f0eb"
"5.0.3":
- patch_file: "patches/5.0-0001-fix-hwcontext_vulkan.patch"
patch_description: "Compatibility with vulkan >= 1.3.239"
patch_type: "portability"
patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/eb0455d64690eed0068e5cb202f72ecdf899837c"
- patch_file: "patches/5.1-0004-fix-binutils.patch"
patch_description: "Compatibility with binutils >= 2.41"
patch_type: "portability"
patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/effadce6c756247ea8bae32dc13bb3e6f464f0eb"
"4.4.4":
- patch_file: "patches/4.4-0001-fix-aom_codec_av1_dx_algo.patch"
patch_description: "Compatibility with shared libaom"
patch_type: "portability"
patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/d92fdc714496d43234733c315894abe0beeb3529"
- patch_file: "patches/5.1-0004-fix-binutils.patch"
patch_description: "Compatibility with binutils >= 2.41"
patch_type: "portability"
patch_source: "https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/effadce6c756247ea8bae32dc13bb3e6f464f0eb"

View File

@@ -0,0 +1,938 @@
from conan import ConanFile, conan_version
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
from conan.tools.build import cross_building
from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import (
apply_conandata_patches, chdir, copy, export_conandata_patches, get, rename,
replace_in_file, rm, rmdir, save, load
)
from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain, PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.microsoft import check_min_vs, is_msvc, unix_path
from conan.tools.scm import Version
import os
import glob
import shutil
import re
required_conan_version = ">=1.57.0"
class FFMpegConan(ConanFile):
name = "ffmpeg"
url = "https://github.com/conan-io/conan-center-index"
description = "A complete, cross-platform solution to record, convert and stream audio and video"
# https://github.com/FFmpeg/FFmpeg/blob/master/LICENSE.md
license = ("LGPL-2.1-or-later", "GPL-2.0-or-later")
homepage = "https://ffmpeg.org"
topics = ("multimedia", "audio", "video", "encoder", "decoder", "encoding", "decoding",
"transcoding", "multiplexer", "demultiplexer", "streaming")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"avdevice": [True, False],
"avcodec": [True, False],
"avformat": [True, False],
"swresample": [True, False],
"swscale": [True, False],
"postproc": [True, False],
"avfilter": [True, False],
"with_asm": [True, False],
"with_zlib": [True, False],
"with_bzip2": [True, False],
"with_lzma": [True, False],
"with_libiconv": [True, False],
"with_freetype": [True, False],
"with_openjpeg": [True, False],
"with_openh264": [True, False],
"with_opus": [True, False],
"with_vorbis": [True, False],
"with_zeromq": [True, False],
"with_sdl": [True, False],
"with_libx264": [True, False],
"with_libx265": [True, False],
"with_libvpx": [True, False],
"with_libmp3lame": [True, False],
"with_libfdk_aac": [True, False],
"with_libwebp": [True, False],
"with_ssl": [False, "openssl", "securetransport"],
"with_libalsa": [True, False],
"with_pulse": [True, False],
"with_vaapi": [True, False],
"with_vdpau": [True, False],
"with_vulkan": [True, False],
"with_xcb": [True, False],
"with_appkit": [True, False],
"with_avfoundation": [True, False],
"with_coreimage": [True, False],
"with_audiotoolbox": [True, False],
"with_videotoolbox": [True, False],
"with_programs": [True, False],
"with_libsvtav1": [True, False],
"with_libaom": [True, False],
"with_libdav1d": [True, False],
"with_libdrm": [True, False],
"with_jni": [True, False],
"with_mediacodec": [True, False],
"with_xlib": [True, False],
"disable_everything": [True, False],
"disable_all_encoders": [True, False],
"disable_encoders": [None, "ANY"],
"enable_encoders": [None, "ANY"],
"disable_all_decoders": [True, False],
"disable_decoders": [None, "ANY"],
"enable_decoders": [None, "ANY"],
"disable_all_hardware_accelerators": [True, False],
"disable_hardware_accelerators": [None, "ANY"],
"enable_hardware_accelerators": [None, "ANY"],
"disable_all_muxers": [True, False],
"disable_muxers": [None, "ANY"],
"enable_muxers": [None, "ANY"],
"disable_all_demuxers": [True, False],
"disable_demuxers": [None, "ANY"],
"enable_demuxers": [None, "ANY"],
"disable_all_parsers": [True, False],
"disable_parsers": [None, "ANY"],
"enable_parsers": [None, "ANY"],
"disable_all_bitstream_filters": [True, False],
"disable_bitstream_filters": [None, "ANY"],
"enable_bitstream_filters": [None, "ANY"],
"disable_all_protocols": [True, False],
"disable_protocols": [None, "ANY"],
"enable_protocols": [None, "ANY"],
"disable_all_devices": [True, False],
"disable_all_input_devices": [True, False],
"disable_input_devices": [None, "ANY"],
"enable_input_devices": [None, "ANY"],
"disable_all_output_devices": [True, False],
"disable_output_devices": [None, "ANY"],
"enable_output_devices": [None, "ANY"],
"disable_all_filters": [True, False],
"disable_filters": [None, "ANY"],
"enable_filters": [None, "ANY"],
}
default_options = {
"shared": False,
"fPIC": True,
"avdevice": True,
"avcodec": True,
"avformat": True,
"swresample": True,
"swscale": True,
"postproc": True,
"avfilter": True,
"with_asm": True,
"with_zlib": True,
"with_bzip2": True,
"with_lzma": True,
"with_libiconv": True,
"with_freetype": True,
"with_openjpeg": True,
"with_openh264": True,
"with_opus": True,
"with_vorbis": True,
"with_zeromq": False,
"with_sdl": False,
"with_libx264": True,
"with_libx265": True,
"with_libvpx": True,
"with_libmp3lame": True,
"with_libfdk_aac": True,
"with_libwebp": True,
"with_ssl": "openssl",
"with_libalsa": True,
"with_pulse": True,
"with_vaapi": True,
"with_vdpau": True,
"with_vulkan": False,
"with_xcb": True,
"with_appkit": True,
"with_avfoundation": True,
"with_coreimage": True,
"with_audiotoolbox": True,
"with_videotoolbox": True,
"with_programs": True,
"with_libsvtav1": True,
"with_libaom": True,
"with_libdav1d": True,
"with_libdrm": False,
"with_jni": False,
"with_mediacodec": False,
"with_xlib": True,
"disable_everything": False,
"disable_all_encoders": False,
"disable_encoders": None,
"enable_encoders": None,
"disable_all_decoders": False,
"disable_decoders": None,
"enable_decoders": None,
"disable_all_hardware_accelerators": False,
"disable_hardware_accelerators": None,
"enable_hardware_accelerators": None,
"disable_all_muxers": False,
"disable_muxers": None,
"enable_muxers": None,
"disable_all_demuxers": False,
"disable_demuxers": None,
"enable_demuxers": None,
"disable_all_parsers": False,
"disable_parsers": None,
"enable_parsers": None,
"disable_all_bitstream_filters": False,
"disable_bitstream_filters": None,
"enable_bitstream_filters": None,
"disable_all_protocols": False,
"disable_protocols": None,
"enable_protocols": None,
"disable_all_devices": False,
"disable_all_input_devices": False,
"disable_input_devices": None,
"enable_input_devices": None,
"disable_all_output_devices": False,
"disable_output_devices": None,
"enable_output_devices": None,
"disable_all_filters": False,
"disable_filters": None,
"enable_filters": None,
}
@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)
@property
def _dependencies(self):
return {
"avformat": ["avcodec"],
"avdevice": ["avcodec", "avformat"],
"avfilter": ["avformat"],
"with_bzip2": ["avformat"],
"with_ssl": ["avformat"],
"with_zlib": ["avcodec"],
"with_lzma": ["avcodec"],
"with_libiconv": ["avcodec"],
"with_openjpeg": ["avcodec"],
"with_openh264": ["avcodec"],
"with_vorbis": ["avcodec"],
"with_opus": ["avcodec"],
"with_libx264": ["avcodec"],
"with_libx265": ["avcodec"],
"with_libvpx": ["avcodec"],
"with_libmp3lame": ["avcodec"],
"with_libfdk_aac": ["avcodec"],
"with_libwebp": ["avcodec"],
"with_freetype": ["avfilter"],
"with_zeromq": ["avfilter", "avformat"],
"with_libalsa": ["avdevice"],
"with_xcb": ["avdevice"],
"with_pulse": ["avdevice"],
"with_sdl": ["with_programs"],
"with_libsvtav1": ["avcodec"],
"with_libaom": ["avcodec"],
"with_libdav1d": ["avcodec"],
"with_mediacodec": ["with_jni"],
"with_xlib": ["avdevice"],
}
@property
def _version_supports_libsvtav1(self):
return Version(self.version) >= "5.1.0"
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if self.settings.os not in ["Linux", "FreeBSD"]:
del self.options.with_vaapi
del self.options.with_vdpau
del self.options.with_vulkan
del self.options.with_xcb
del self.options.with_libalsa
del self.options.with_pulse
del self.options.with_xlib
del self.options.with_libdrm
if self.settings.os != "Macos":
del self.options.with_appkit
if self.settings.os not in ["Macos", "iOS", "tvOS"]:
del self.options.with_coreimage
del self.options.with_audiotoolbox
del self.options.with_videotoolbox
if not is_apple_os(self):
del self.options.with_avfoundation
if not self.settings.os == "Android":
del self.options.with_jni
del self.options.with_mediacodec
if not self._version_supports_libsvtav1:
self.options.rm_safe("with_libsvtav1")
if self.settings.os == "Android":
del self.options.with_libfdk_aac
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
def layout(self):
basic_layout(self, src_folder="src")
def requirements(self):
if self.options.with_zlib:
self.requires("zlib/[>=1.2.11 <2]")
if self.options.with_bzip2:
self.requires("bzip2/1.0.8")
if self.options.with_lzma:
self.requires("xz_utils/5.4.5")
if self.options.with_libiconv:
self.requires("libiconv/1.17")
if self.options.with_freetype:
self.requires("freetype/2.13.2")
if self.options.with_openjpeg:
self.requires("openjpeg/2.5.2")
if self.options.with_openh264:
self.requires("openh264/2.4.1")
if self.options.with_vorbis:
self.requires("vorbis/1.3.7")
if self.options.with_opus:
self.requires("opus/1.4")
if self.options.with_zeromq:
self.requires("zeromq/4.3.5")
if self.options.with_sdl:
self.requires("sdl/2.28.5")
if self.options.with_libx264:
self.requires("libx264/cci.20240224")
if self.options.with_libx265:
self.requires("libx265/3.4")
if self.options.with_libvpx:
self.requires("libvpx/1.14.1")
if self.options.with_libmp3lame:
self.requires("libmp3lame/3.100")
if self.options.get_safe("with_libfdk_aac"):
self.requires("libfdk_aac/2.0.3")
if self.options.with_libwebp:
self.requires("libwebp/1.3.2")
if self.options.with_ssl == "openssl":
self.requires("openssl/[>=1.1 <4]")
if self.options.get_safe("with_libalsa"):
self.requires("libalsa/1.2.10")
if self.options.get_safe("with_xcb") or self.options.get_safe("with_xlib"):
self.requires("xorg/system")
if self.options.get_safe("with_pulse"):
self.requires("pulseaudio/14.2")
if self.options.get_safe("with_vaapi"):
self.requires("vaapi/system")
if self.options.get_safe("with_vdpau"):
self.requires("vdpau/system")
if self.options.get_safe("with_vulkan"):
self.requires("vulkan-loader/1.3.243.0")
if self.options.get_safe("with_libsvtav1"):
self.requires("libsvtav1/2.1.0")
if self.options.with_libaom:
self.requires("libaom-av1/3.6.1")
if self.options.get_safe("with_libdav1d"):
self.requires("dav1d/1.4.3")
if self.options.get_safe("with_libdrm"):
self.requires("libdrm/2.4.119")
def validate(self):
if self.options.with_ssl == "securetransport" and not is_apple_os(self):
raise ConanInvalidConfiguration(
"securetransport is only available on Apple")
for dependency, features in self._dependencies.items():
if not self.options.get_safe(dependency):
continue
used = False
for feature in features:
used = used or self.options.get_safe(feature)
if not used:
raise ConanInvalidConfiguration("FFmpeg '{}' option requires '{}' option to be enabled".format(
dependency, "' or '".join(features)))
if Version(self.version) >= "6.1" and conan_version.major == 1 and is_msvc(self) and self.options.shared:
# Linking fails with "Argument list too long" for some reason on Conan v1
raise ConanInvalidConfiguration("MSVC shared build is not supported for Conan v1")
if Version(self.version) == "7.0.1" and self.settings.build_type == "Debug":
# FIXME: FFMpeg fails to build in Debug mode with the following error:
# ld: libavcodec/libavcodec.a(vvcdsp_init.o): in function `ff_vvc_put_pixels2_8_sse4':
# src/libavcodec/x86/vvc/vvcdsp_init.c:69: undefined reference to `ff_h2656_put_pixels2_8_sse4'
# May be related https://github.com/ffvvc/FFmpeg/issues/234
raise ConanInvalidConfiguration(f"{self.ref} Conan recipe does not support build_type=Debug. Contributions are welcome to fix this issue.")
def build_requirements(self):
if self.settings.arch in ("x86", "x86_64"):
# if Version(self.version) >= "7.0":
# INFO: FFmpeg 7.0+ added avcodec vvc_mc.asm which fails to assemble with yasm 1.3.0
# src/libavcodec/x86/vvc/vvc_mc.asm:55: error: operand 1: expression is not simple or relocatable
self.tool_requires("nasm/[>=2.16.01]")
# else:
# self.tool_requires("yasm/1.3.0")
if self.settings.os != "Linux" and not self.conf.get("tools.gnu:pkg_config", check_type=str):
# See https://github.com/conan-io/conan-center-index/pull/26447#discussion_r1926682155
self.tool_requires("pkgconf/[>=2.1 <3]")
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)
@property
def _target_arch(self):
# Taken from acceptable values https://github.com/FFmpeg/FFmpeg/blob/0684e58886881a998f1a7b510d73600ff1df2b90/configure#L5010
if str(self.settings.arch).startswith("armv8"):
return "aarch64"
elif self.settings.arch == "x86":
return "i686"
return str(self.settings.arch)
@property
def _target_os(self):
if self.settings.os == "Windows":
return "mingw32" if self.settings.compiler == "gcc" else "win32"
elif is_apple_os(self):
return "darwin"
# Taken from https://github.com/FFmpeg/FFmpeg/blob/0684e58886881a998f1a7b510d73600ff1df2b90/configure#L5485
# This is the map of Conan OS settings to FFmpeg acceptable values
return {
"AIX": "aix",
"Android": "android",
"FreeBSD": "freebsd",
"Linux": "linux",
"Neutrino": "qnx",
"SunOS": "sunos",
}.get(str(self.settings.os), "none")
def _patch_sources(self):
apply_conandata_patches(self)
if Version(self.version) < "5.1":
# suppress MSVC linker warnings: https://trac.ffmpeg.org/ticket/7396
# warning LNK4049: locally defined symbol x264_levels imported
# warning LNK4049: locally defined symbol x264_bit_depth imported
replace_in_file(self, os.path.join(self.source_folder, "libavcodec", "libx264.c"),
"#define X264_API_IMPORTS 1", "")
if self.options.with_ssl == "openssl":
# https://trac.ffmpeg.org/ticket/5675
openssl_libs = load(self, os.path.join(self.build_folder, "openssl_libs.list"))
replace_in_file(self, os.path.join(self.source_folder, "configure"),
"check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||",
f"check_lib openssl openssl/ssl.h OPENSSL_init_ssl {openssl_libs} || ")
replace_in_file(self, os.path.join(self.source_folder, "configure"), "echo libx264.lib", "echo x264.lib")
@property
def _default_compilers(self):
if self.settings.compiler == "gcc":
return {"cc": "gcc", "cxx": "g++"}
elif self.settings.compiler in ["clang", "apple-clang"]:
return {"cc": "clang", "cxx": "clang++"}
elif is_msvc(self):
return {"cc": "cl.exe", "cxx": "cl.exe"}
return {}
def _create_toolchain(self):
tc = AutotoolsToolchain(self)
# Custom configure script of ffmpeg understands:
# --prefix, --bindir, --datadir, --docdir, --incdir, --libdir, --mandir
# Options --datadir, --docdir, --incdir, and --mandir are not injected by AutotoolsToolchain but their default value
# in ffmpeg script matches expected conan install layout.
# Several options injected by AutotoolsToolchain are unknown from this configure script and must be pruned.
# This must be done before modifying tc.configure_args, because update_configre_args currently removes
# duplicate configuration keys, even when they have different values, such as list of encoder flags.
# See https://github.com/conan-io/conan-center-index/issues/17140 for further information.
tc.update_configure_args({
"--sbindir": None,
"--includedir": None,
"--oldincludedir": None,
"--datarootdir": None,
"--build": None,
"--host": None,
"--target": None,
})
return tc
def generate(self):
env = VirtualBuildEnv(self)
env.generate()
if not cross_building(self):
env = VirtualRunEnv(self)
env.generate(scope="build")
def opt_enable_disable(what, v):
return "--{}-{}".format("enable" if v else "disable", what)
def opt_append_disable_if_set(args, what, v):
if v:
args.append(f"--disable-{what}")
tc = self._create_toolchain()
args = [
"--pkg-config-flags=--static",
"--disable-doc",
opt_enable_disable("cross-compile", cross_building(self)),
opt_enable_disable("asm", self.options.with_asm),
# Libraries
opt_enable_disable("shared", self.options.shared),
opt_enable_disable("static", not self.options.shared),
opt_enable_disable("pic", self.options.get_safe("fPIC", True)),
# Components
opt_enable_disable("avdevice", self.options.avdevice),
opt_enable_disable("avcodec", self.options.avcodec),
opt_enable_disable("avformat", self.options.avformat),
opt_enable_disable("swresample", self.options.swresample),
opt_enable_disable("swscale", self.options.swscale),
opt_enable_disable("postproc", self.options.postproc),
opt_enable_disable("avfilter", self.options.avfilter),
# Dependencies
opt_enable_disable("bzlib", self.options.with_bzip2),
opt_enable_disable("zlib", self.options.with_zlib),
opt_enable_disable("lzma", self.options.with_lzma),
opt_enable_disable("iconv", self.options.with_libiconv),
opt_enable_disable("libopenjpeg", self.options.with_openjpeg),
opt_enable_disable("libopenh264", self.options.with_openh264),
opt_enable_disable("libvorbis", self.options.with_vorbis),
opt_enable_disable("libopus", self.options.with_opus),
opt_enable_disable("libzmq", self.options.with_zeromq),
opt_enable_disable("sdl2", self.options.with_sdl),
opt_enable_disable("libx264", self.options.with_libx264),
opt_enable_disable("libx265", self.options.with_libx265),
opt_enable_disable("libvpx", self.options.with_libvpx),
opt_enable_disable("libmp3lame", self.options.with_libmp3lame),
opt_enable_disable("libfdk-aac", self.options.get_safe("with_libfdk_aac")),
opt_enable_disable("libwebp", self.options.with_libwebp),
opt_enable_disable("libaom", self.options.with_libaom),
opt_enable_disable("openssl", self.options.with_ssl == "openssl"),
opt_enable_disable("alsa", self.options.get_safe("with_libalsa")),
opt_enable_disable("libpulse", self.options.get_safe("with_pulse")),
opt_enable_disable("vaapi", self.options.get_safe("with_vaapi")),
opt_enable_disable("libdrm", self.options.get_safe("with_libdrm")),
opt_enable_disable("vdpau", self.options.get_safe("with_vdpau")),
opt_enable_disable("libxcb", self.options.get_safe("with_xcb")),
opt_enable_disable("libxcb-shm", self.options.get_safe("with_xcb")),
opt_enable_disable("libxcb-shape", self.options.get_safe("with_xcb")),
opt_enable_disable("libxcb-xfixes", self.options.get_safe("with_xcb")),
opt_enable_disable("appkit", self.options.get_safe("with_appkit")),
opt_enable_disable("avfoundation", self.options.get_safe("with_avfoundation")),
opt_enable_disable("coreimage", self.options.get_safe("with_coreimage")),
opt_enable_disable("audiotoolbox", self.options.get_safe("with_audiotoolbox")),
opt_enable_disable("videotoolbox", self.options.get_safe("with_videotoolbox")),
opt_enable_disable("securetransport", self.options.with_ssl == "securetransport"),
opt_enable_disable("vulkan", self.options.get_safe("with_vulkan")),
opt_enable_disable("libdav1d", self.options.get_safe("with_libdav1d")),
opt_enable_disable("jni", self.options.get_safe("with_jni")),
opt_enable_disable("mediacodec", self.options.get_safe("with_mediacodec")),
opt_enable_disable("xlib", self.options.get_safe("with_xlib")),
"--disable-cuda", # FIXME: CUDA support
"--disable-cuvid", # FIXME: CUVID support
# Licenses
opt_enable_disable("nonfree", self.options.get_safe("with_libfdk_aac") or (self.options.with_ssl and (
self.options.with_libx264 or self.options.with_libx265 or self.options.postproc))),
opt_enable_disable("gpl", self.options.with_libx264 or self.options.with_libx265 or self.options.postproc)
]
# Individual Component Options
opt_append_disable_if_set(args, "everything", self.options.disable_everything)
opt_append_disable_if_set(args, "encoders", self.options.disable_all_encoders)
opt_append_disable_if_set(args, "decoders", self.options.disable_all_decoders)
opt_append_disable_if_set(args, "hwaccels", self.options.disable_all_hardware_accelerators)
opt_append_disable_if_set(args, "muxers", self.options.disable_all_muxers)
opt_append_disable_if_set(args, "demuxers", self.options.disable_all_demuxers)
opt_append_disable_if_set(args, "parsers", self.options.disable_all_parsers)
opt_append_disable_if_set(args, "bsfs", self.options.disable_all_bitstream_filters)
opt_append_disable_if_set(args, "protocols", self.options.disable_all_protocols)
opt_append_disable_if_set(args, "devices", self.options.disable_all_devices)
opt_append_disable_if_set(args, "indevs", self.options.disable_all_input_devices)
opt_append_disable_if_set(args, "outdevs", self.options.disable_all_output_devices)
opt_append_disable_if_set(args, "filters", self.options.disable_all_filters)
args.extend(self._split_and_format_options_string(
"enable-encoder", self.options.enable_encoders))
args.extend(self._split_and_format_options_string(
"disable-encoder", self.options.disable_encoders))
args.extend(self._split_and_format_options_string(
"enable-decoder", self.options.enable_decoders))
args.extend(self._split_and_format_options_string(
"disable-decoder", self.options.disable_decoders))
args.extend(self._split_and_format_options_string(
"enable-hwaccel", self.options.enable_hardware_accelerators))
args.extend(self._split_and_format_options_string(
"disable-hwaccel", self.options.disable_hardware_accelerators))
args.extend(self._split_and_format_options_string(
"enable-muxer", self.options.enable_muxers))
args.extend(self._split_and_format_options_string(
"disable-muxer", self.options.disable_muxers))
args.extend(self._split_and_format_options_string(
"enable-demuxer", self.options.enable_demuxers))
args.extend(self._split_and_format_options_string(
"disable-demuxer", self.options.disable_demuxers))
args.extend(self._split_and_format_options_string(
"enable-parser", self.options.enable_parsers))
args.extend(self._split_and_format_options_string(
"disable-parser", self.options.disable_parsers))
args.extend(self._split_and_format_options_string(
"enable-bsf", self.options.enable_bitstream_filters))
args.extend(self._split_and_format_options_string(
"disable-bsf", self.options.disable_bitstream_filters))
args.extend(self._split_and_format_options_string(
"enable-protocol", self.options.enable_protocols))
args.extend(self._split_and_format_options_string(
"disable-protocol", self.options.disable_protocols))
args.extend(self._split_and_format_options_string(
"enable-indev", self.options.enable_input_devices))
args.extend(self._split_and_format_options_string(
"disable-indev", self.options.disable_input_devices))
args.extend(self._split_and_format_options_string(
"enable-outdev", self.options.enable_output_devices))
args.extend(self._split_and_format_options_string(
"disable-outdev", self.options.disable_output_devices))
args.extend(self._split_and_format_options_string(
"enable-filter", self.options.enable_filters))
args.extend(self._split_and_format_options_string(
"disable-filter", self.options.disable_filters))
if self._version_supports_libsvtav1:
args.append(opt_enable_disable("libsvtav1", self.options.get_safe("with_libsvtav1")))
if is_apple_os(self):
# relocatable shared libs
args.append("--install-name-dir=@rpath")
args.append(f"--arch={self._target_arch}")
if self.settings.build_type == "Debug":
args.extend([
"--disable-optimizations",
"--disable-mmx",
"--disable-stripping",
"--enable-debug",
])
if not self.options.with_programs:
args.append("--disable-programs")
# since ffmpeg"s build system ignores CC and CXX
compilers_from_conf = self.conf.get("tools.build:compiler_executables", default={}, check_type=dict)
buildenv_vars = VirtualBuildEnv(self).vars()
nm = buildenv_vars.get("NM")
if nm:
args.append(f"--nm={unix_path(self, nm)}")
ar = buildenv_vars.get("AR")
if ar:
args.append(f"--ar={unix_path(self, ar)}")
if self.options.with_asm:
asm = compilers_from_conf.get("asm", buildenv_vars.get("AS"))
if asm:
args.append(f"--as={unix_path(self, asm)}")
strip = buildenv_vars.get("STRIP")
if strip:
args.append(f"--strip={unix_path(self, strip)}")
cc = compilers_from_conf.get("c", buildenv_vars.get("CC", self._default_compilers.get("cc")))
if cc:
args.append(f"--cc={unix_path(self, cc)}")
cxx = compilers_from_conf.get("cpp", buildenv_vars.get("CXX", self._default_compilers.get("cxx")))
if cxx:
args.append(f"--cxx={unix_path(self, cxx)}")
ld = buildenv_vars.get("LD")
if ld:
args.append(f"--ld={unix_path(self, ld)}")
ranlib = buildenv_vars.get("RANLIB")
if ranlib:
args.append(f"--ranlib={unix_path(self, ranlib)}")
pkg_config = self.conf.get("tools.gnu:pkg_config", default=buildenv_vars.get("PKG_CONFIG"), check_type=str)
if pkg_config:
# the ffmpeg configure script hardcodes the name of the executable,
# unlike other tools that use the PKG_CONFIG environment variable
# if we are aware the user has requested a specific pkg-config, we pass it to the configure script
args.append(f"--pkg-config={unix_path(self, pkg_config)}")
if is_msvc(self):
args.append("--toolchain=msvc")
if not check_min_vs(self, "190", raise_invalid=False):
# Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++)
tc.extra_defines.append("inline=__inline")
if self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) >= "15":
# Workaround for link error "ld: building exports trie: duplicate symbol '_av_ac3_parse_header'"
tc.extra_ldflags.append("-Wl,-ld_classic")
if cross_building(self):
args.append(f"--target-os={self._target_os}")
if is_apple_os(self) and self.options.with_audiotoolbox:
args.append("--disable-outdev=audiotoolbox")
if tc.cflags:
args.append("--extra-cflags={}".format(" ".join(tc.cflags)))
if tc.ldflags:
args.append("--extra-ldflags={}".format(" ".join(tc.ldflags)))
tc.configure_args.extend(args)
tc.generate()
if is_msvc(self):
# Custom AutotoolsDeps for cl like compilers
# workaround for https://github.com/conan-io/conan/issues/12784
includedirs = []
defines = []
libs = []
libdirs = []
linkflags = []
cxxflags = []
cflags = []
for dependency in self.dependencies.values():
deps_cpp_info = dependency.cpp_info.aggregated_components()
includedirs.extend(deps_cpp_info.includedirs)
defines.extend(deps_cpp_info.defines)
libs.extend(deps_cpp_info.libs + deps_cpp_info.system_libs)
libdirs.extend(deps_cpp_info.libdirs)
linkflags.extend(deps_cpp_info.sharedlinkflags + deps_cpp_info.exelinkflags)
cxxflags.extend(deps_cpp_info.cxxflags)
cflags.extend(deps_cpp_info.cflags)
env = Environment()
env.append("CPPFLAGS", [f"-I{unix_path(self, p)}" for p in includedirs] + [f"-D{d}" for d in defines])
env.append("_LINK_", [lib if lib.endswith(".lib") else f"{lib}.lib" for lib in libs])
env.append("LDFLAGS", [f"-LIBPATH:{unix_path(self, p)}" for p in libdirs] + linkflags)
env.append("CXXFLAGS", cxxflags)
env.append("CFLAGS", cflags)
env.vars(self).save_script("conanautotoolsdeps_cl_workaround")
else:
deps = AutotoolsDeps(self)
deps.generate()
deps = PkgConfigDeps(self)
deps.generate()
if self.options.with_ssl == "openssl":
openssl_libs = " ".join([f"-l{lib}" for lib in self.dependencies["openssl"].cpp_info.aggregated_components().libs])
save(self, os.path.join(self.build_folder, "openssl_libs.list"), openssl_libs)
def _split_and_format_options_string(self, flag_name, options_list):
if not options_list:
return []
def _format_options_list_item(flag_name, options_item):
return f"--{flag_name}={options_item}"
def _split_options_string(options_string):
return list(filter(None, "".join(options_string.split()).split(",")))
options_string = str(options_list)
return [_format_options_list_item(flag_name, item) for item in _split_options_string(options_string)]
def build(self):
self._patch_sources()
if self.options.with_libx264:
# ffmepg expects libx264.pc instead of x264.pc
with chdir(self, self.generators_folder):
shutil.copy("x264.pc", "libx264.pc")
autotools = Autotools(self)
autotools.configure()
autotools.make()
def package(self):
copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
autotools.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))
if is_msvc(self):
if self.options.shared:
# ffmpeg created `.lib` files in the `/bin` folder
for fn in os.listdir(os.path.join(self.package_folder, "bin")):
if fn.endswith(".lib"):
rename(self, os.path.join(self.package_folder, "bin", fn),
os.path.join(self.package_folder, "lib", fn))
rm(self, "*.def", os.path.join(self.package_folder, "lib"))
else:
# ffmpeg produces `.a` files that are actually `.lib` files
with chdir(self, os.path.join(self.package_folder, "lib")):
for lib in glob.glob("*.a"):
rename(self, lib, lib[3:-2] + ".lib")
def _read_component_version(self, component_name):
# since 5.1, major version may be defined in version_major.h instead of version.h
component_folder = os.path.join(self.package_folder, "include", f"lib{component_name}")
version_file_name = os.path.join(component_folder, "version.h")
version_major_file_name = os.path.join(component_folder, "version_major.h")
pattern = f"define LIB{component_name.upper()}_VERSION_(MAJOR|MINOR|MICRO)[ \t]+(\\d+)"
version = dict()
for file in (version_file_name, version_major_file_name):
if os.path.isfile(file):
with open(file, "r", encoding="utf-8") as f:
for line in f:
match = re.search(pattern, line)
if match:
version[match[1]] = match[2]
if "MAJOR" in version and "MINOR" in version and "MICRO" in version:
return f"{version['MAJOR']}.{version['MINOR']}.{version['MICRO']}"
return None
def _set_component_version(self, component_name):
version = self._read_component_version(component_name)
if version is not None:
self.cpp_info.components[component_name].set_property("component_version", version)
# TODO: to remove once support of conan v1 dropped
self.cpp_info.components[component_name].version = version
else:
self.output.warning(f"cannot determine version of lib{component_name} packaged with ffmpeg!")
def package_info(self):
if self.options.with_programs:
if self.options.with_sdl:
self.cpp_info.components["programs"].requires = ["sdl::libsdl2"]
def _add_component(name, dependencies):
component = self.cpp_info.components[name]
component.set_property("pkg_config_name", f"lib{name}")
self._set_component_version(name)
component.libs = [name]
if name != "avutil":
component.requires = ["avutil"]
for dep in dependencies:
if self.options.get_safe(dep):
component.requires.append(dep)
if self.settings.os in ("FreeBSD", "Linux"):
component.system_libs.append("m")
return component
avutil = _add_component("avutil", [])
if self.options.avdevice:
avdevice = _add_component("avdevice", ["avfilter", "swscale", "avformat", "avcodec", "swresample", "postproc"])
if self.options.avfilter:
avfilter = _add_component("avfilter", ["swscale", "avformat", "avcodec", "swresample", "postproc"])
if self.options.avformat:
avformat = _add_component("avformat", ["avcodec", "swscale"])
if self.options.avcodec:
avcodec = _add_component("avcodec", ["swresample"])
if self.options.swscale:
_add_component("swscale", [])
if self.options.swresample:
_add_component("swresample", [])
if self.options.postproc:
_add_component("postproc", [])
if self.settings.os in ("FreeBSD", "Linux"):
avutil.system_libs.extend(["pthread", "dl"])
if self.options.get_safe("fPIC"):
if self.settings.compiler in ("gcc", "clang"):
# https://trac.ffmpeg.org/ticket/1713
# https://ffmpeg.org/platform.html#Advanced-linking-configuration
# https://ffmpeg.org/pipermail/libav-user/2014-December/007719.html
avcodec.exelinkflags.append("-Wl,-Bsymbolic")
avcodec.sharedlinkflags.append("-Wl,-Bsymbolic")
if self.options.avfilter:
avfilter.system_libs.append("pthread")
elif self.settings.os == "Windows":
if self.options.avcodec:
avcodec.system_libs = ["mfplat", "mfuuid", "strmiids"]
if self.options.avdevice:
avdevice.system_libs = ["ole32", "psapi", "strmiids", "uuid", "oleaut32", "shlwapi", "gdi32", "vfw32"]
avutil.system_libs = ["user32", "bcrypt"]
avformat.system_libs = ["secur32"]
elif is_apple_os(self):
if self.options.avdevice:
avdevice.frameworks = ["CoreFoundation", "Foundation", "CoreGraphics"]
if self.options.avfilter:
avfilter.frameworks = ["CoreGraphics"]
if self.options.avcodec:
avcodec.frameworks = ["CoreFoundation", "CoreVideo", "CoreMedia"]
if self.settings.os == "Macos":
if self.options.avdevice:
avdevice.frameworks.append("OpenGL")
if self.options.avfilter:
avfilter.frameworks.append("OpenGL")
if self.options.avdevice:
if self.options.get_safe("with_libalsa"):
avdevice.requires.append("libalsa::libalsa")
if self.options.get_safe("with_xcb"):
avdevice.requires.extend(["xorg::xcb", "xorg::xcb-shm", "xorg::xcb-xfixes", "xorg::xcb-shape", "xorg::xv", "xorg::xext"])
if self.options.get_safe("with_xlib"):
avdevice.requires.extend(["xorg::x11", "xorg::xext", "xorg::xv"])
if self.options.get_safe("with_pulse"):
avdevice.requires.append("pulseaudio::pulseaudio")
if self.options.get_safe("with_appkit"):
avdevice.frameworks.append("AppKit")
if self.options.get_safe("with_avfoundation"):
avdevice.frameworks.append("AVFoundation")
if self.options.get_safe("with_audiotoolbox"):
avdevice.frameworks.append("CoreAudio")
if self.settings.os == "Android" and not self.options.shared:
avdevice.system_libs.extend(["android", "camera2ndk", "mediandk"])
if self.options.avcodec:
if self.options.with_zlib:
avcodec.requires.append("zlib::zlib")
if self.options.with_lzma:
avcodec.requires.append("xz_utils::xz_utils")
if self.options.with_libiconv:
avcodec.requires.append("libiconv::libiconv")
if self.options.with_openjpeg:
avcodec.requires.append("openjpeg::openjpeg")
if self.options.with_openh264:
avcodec.requires.append("openh264::openh264")
if self.options.with_vorbis:
avcodec.requires.append("vorbis::vorbis")
if self.options.with_opus:
avcodec.requires.append("opus::opus")
if self.options.with_libx264:
avcodec.requires.append("libx264::libx264")
if self.options.with_libx265:
avcodec.requires.append("libx265::libx265")
if self.options.with_libvpx:
avcodec.requires.append("libvpx::libvpx")
if self.options.with_libmp3lame:
avcodec.requires.append("libmp3lame::libmp3lame")
if self.options.get_safe("with_libfdk_aac"):
avcodec.requires.append("libfdk_aac::libfdk_aac")
if self.options.with_libwebp:
avcodec.requires.append("libwebp::libwebp")
if self.options.get_safe("with_audiotoolbox"):
avcodec.frameworks.append("AudioToolbox")
if self.options.get_safe("with_videotoolbox"):
avcodec.frameworks.append("VideoToolbox")
if self.options.get_safe("with_libsvtav1"):
avcodec.requires.extend(["libsvtav1::decoder", "libsvtav1::encoder"])
if self.options.get_safe("with_libaom"):
avcodec.requires.append("libaom-av1::libaom-av1")
if self.options.get_safe("with_libdav1d"):
avcodec.requires.append("dav1d::dav1d")
if self.options.avformat:
if self.options.with_bzip2:
avformat.requires.append("bzip2::bzip2")
if self.options.with_zeromq:
avformat.requires.append("zeromq::libzmq")
if self.options.with_ssl == "openssl":
avformat.requires.append("openssl::ssl")
elif self.options.with_ssl == "securetransport":
avformat.frameworks.append("Security")
if self.options.avfilter:
if self.options.with_freetype:
avfilter.requires.append("freetype::freetype")
if self.options.with_zeromq:
avfilter.requires.append("zeromq::libzmq")
if self.options.get_safe("with_appkit"):
avfilter.frameworks.append("AppKit")
if self.options.get_safe("with_coreimage"):
avfilter.frameworks.append("CoreImage")
if Version(self.version) >= "5.0" and is_apple_os(self):
avfilter.frameworks.append("Metal")
if self.options.get_safe("with_libdrm"):
avutil.requires.append("libdrm::libdrm_libdrm")
if self.options.get_safe("with_vaapi"):
avutil.requires.append("vaapi::vaapi")
if self.options.get_safe("with_xcb"):
avutil.requires.append("xorg::x11")
if self.options.get_safe("with_vdpau"):
avutil.requires.append("vdpau::vdpau")
if self.options.with_ssl == "openssl":
avutil.requires.append("openssl::ssl")
if self.options.get_safe("with_vulkan"):
avutil.requires.append("vulkan-loader::vulkan-loader")

View File

@@ -0,0 +1,11 @@
--- a/libavcodec/libaomdec.c
+++ b/libavcodec/libaomdec.c
@@ -224,7 +224,7 @@ static av_cold int aom_free(AVCodecContext *avctx)
static av_cold int av1_init(AVCodecContext *avctx)
{
- return aom_init(avctx, &aom_codec_av1_dx_algo);
+ return aom_init(avctx, aom_codec_av1_dx());
}
AVCodec ff_libaom_av1_decoder = {

View File

@@ -0,0 +1,17 @@
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -354,14 +354,6 @@ static const VulkanOptExtension optional_device_exts[] = {
{ VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_WIN32_MEMORY },
{ VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, FF_VK_EXT_EXTERNAL_WIN32_SEM },
#endif
-
- /* Video encoding/decoding */
- { VK_KHR_VIDEO_QUEUE_EXTENSION_NAME, FF_VK_EXT_NO_FLAG },
- { VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME, FF_VK_EXT_NO_FLAG },
- { VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME, FF_VK_EXT_NO_FLAG },
- { VK_EXT_VIDEO_ENCODE_H264_EXTENSION_NAME, FF_VK_EXT_NO_FLAG },
- { VK_EXT_VIDEO_DECODE_H264_EXTENSION_NAME, FF_VK_EXT_NO_FLAG },
- { VK_EXT_VIDEO_DECODE_H265_EXTENSION_NAME, FF_VK_EXT_NO_FLAG },
};
/* Converts return values to strings */

View File

@@ -0,0 +1,22 @@
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
{
- const int pack_mode_10bit =
- (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
- const size_t luma_size_8bit =
- config->source_width * config->source_height * (1 << pack_mode_10bit);
- const size_t luma_size_10bit =
- (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
+ const size_t luma_size = config->source_width * config->source_height *
+ (config->encoder_bit_depth > 8 ? 2 : 1);
EbSvtIOFormat *in_data;
- svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
+ svt_enc->raw_size = luma_size * 3 / 2;
// allocate buffer for in and out
svt_enc->in_buf = av_mallocz(sizeof(*svt_enc->in_buf));

View File

@@ -0,0 +1,20 @@
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -179,7 +179,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
param->min_qp_allowed = avctx->qmin;
}
param->max_bit_rate = avctx->rc_max_rate;
- param->vbv_bufsize = avctx->rc_buffer_size;
+ param->maximum_buffer_size_ms = avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
if (svt_enc->crf > 0) {
param->qp = svt_enc->crf;
@@ -296,7 +296,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
avctx->bit_rate = param->rate_control_mode > 0 ?
param->target_bit_rate : 0;
avctx->rc_max_rate = param->max_bit_rate;
- avctx->rc_buffer_size = param->vbv_bufsize;
+ avctx->rc_buffer_size = param->maximum_buffer_size_ms * avctx->bit_rate / 1000LL;
if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) {
AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx);

View File

@@ -0,0 +1,12 @@
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -179,7 +179,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
param->min_qp_allowed = avctx->qmin;
}
param->max_bit_rate = avctx->rc_max_rate;
- param->maximum_buffer_size_ms = avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
+ if (avctx->bit_rate && avctx->rc_buffer_size)
+ param->maximum_buffer_size_ms = avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
if (svt_enc->crf > 0) {
param->qp = svt_enc->crf;

View File

@@ -0,0 +1,73 @@
From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
Date: Sun, 16 Jul 2023 18:18:02 +0300
Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
instructions within inline assembly
Fixes assembling with binutil as >= 2.41
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
index 6298f5ed1983b..ca7e2dffc1076 100644
--- a/libavcodec/x86/mathops.h
+++ b/libavcodec/x86/mathops.h
@@ -35,12 +35,20 @@
static av_always_inline av_const int MULL(int a, int b, unsigned shift)
{
int rt, dummy;
+ if (__builtin_constant_p(shift))
__asm__ (
"imull %3 \n\t"
"shrdl %4, %%edx, %%eax \n\t"
:"=a"(rt), "=d"(dummy)
- :"a"(a), "rm"(b), "ci"((uint8_t)shift)
+ :"a"(a), "rm"(b), "i"(shift & 0x1F)
);
+ else
+ __asm__ (
+ "imull %3 \n\t"
+ "shrdl %4, %%edx, %%eax \n\t"
+ :"=a"(rt), "=d"(dummy)
+ :"a"(a), "rm"(b), "c"((uint8_t)shift)
+ );
return rt;
}
@@ -113,19 +121,31 @@ __asm__ volatile(\
// avoid +32 for shift optimization (gcc should do that ...)
#define NEG_SSR32 NEG_SSR32
static inline int32_t NEG_SSR32( int32_t a, int8_t s){
+ if (__builtin_constant_p(s))
__asm__ ("sarl %1, %0\n\t"
: "+r" (a)
- : "ic" ((uint8_t)(-s))
+ : "i" (-s & 0x1F)
);
+ else
+ __asm__ ("sarl %1, %0\n\t"
+ : "+r" (a)
+ : "c" ((uint8_t)(-s))
+ );
return a;
}
#define NEG_USR32 NEG_USR32
static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
+ if (__builtin_constant_p(s))
__asm__ ("shrl %1, %0\n\t"
: "+r" (a)
- : "ic" ((uint8_t)(-s))
+ : "i" (-s & 0x1F)
);
+ else
+ __asm__ ("shrl %1, %0\n\t"
+ : "+r" (a)
+ : "c" ((uint8_t)(-s))
+ );
return a;
}

View File

@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
find_package(ffmpeg REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avutil)
if (TARGET ffmpeg::avdevice)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVDEVICE)
target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avdevice)
endif ()
if (TARGET ffmpeg::avfilter)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVFILTER)
target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avfilter)
endif ()
if (TARGET ffmpeg::avformat)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVFORMAT)
target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avformat)
endif ()
if (TARGET ffmpeg::avcodec)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVCODEC)
target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::avcodec)
endif ()
if (TARGET ffmpeg::swscale)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_SWSCALE)
target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::swscale)
endif ()
if (TARGET ffmpeg::swresample)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_SWRESAMPLE)
target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::swresample)
endif ()
if (TARGET ffmpeg::postproc)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_POSTPROC)
target_link_libraries(${PROJECT_NAME} PRIVATE ffmpeg::postproc)
endif ()

View File

@@ -0,0 +1,26 @@
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", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,55 @@
#ifdef HAVE_FFMPEG_AVCODEC
# include <libavcodec/avcodec.h>
#endif
#ifdef HAVE_FFMPEG_AVFORMAT
# include <libavformat/avformat.h>
#endif
#ifdef HAVE_FFMPEG_AVFILTER
# include <libavfilter/avfilter.h>
#endif
#ifdef HAVE_FFMPEG_AVDEVICE
# include <libavdevice/avdevice.h>
#endif
#ifdef HAVE_FFMPEG_SWRESAMPLE
# include <libswresample/swresample.h>
#endif
#ifdef HAVE_FFMPEG_SWSCALE
# include <libswscale/swscale.h>
#endif
#include <libavutil/hwcontext.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
#ifdef HAVE_FFMPEG_AVCODEC
printf("configuration: %s\n", avcodec_configuration());
printf("avcodec version: %d.%d.%d\n", AV_VERSION_MAJOR(avcodec_version()), AV_VERSION_MINOR(avcodec_version()), AV_VERSION_MICRO(avcodec_version()));
#else
printf("avcodec is disabled!\n");
#endif
#ifdef HAVE_FFMPEG_AVFILTER
printf("avfilter version: %d.%d.%d\n", AV_VERSION_MAJOR(avfilter_version()), AV_VERSION_MINOR(avfilter_version()), AV_VERSION_MICRO(avfilter_version()));
#else
printf("avfilter is disabled!\n");
#endif
#ifdef HAVE_FFMPEG_AVDEVICE
avdevice_register_all();
printf("avdevice version: %d.%d.%d\n", AV_VERSION_MAJOR(avdevice_version()), AV_VERSION_MINOR(avdevice_version()), AV_VERSION_MICRO(avdevice_version()));
#else
printf("avdevice is disabled!\n");
#endif
#ifdef HAVE_FFMPEG_SWRESAMPLE
printf("swresample version: %d.%d.%d\n", AV_VERSION_MAJOR(swresample_version()), AV_VERSION_MINOR(swresample_version()), AV_VERSION_MICRO(swresample_version()));
#else
printf("swresample is disabled!\n");
#endif
#ifdef HAVE_FFMPEG_SWSCALE
printf("swscale version: %d.%d.%d\n", AV_VERSION_MAJOR(swscale_version()), AV_VERSION_MINOR(swscale_version()), AV_VERSION_MICRO(swscale_version()));
#else
printf("swscale is disabled!\n");
#endif
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
${CMAKE_CURRENT_BINARY_DIR}/test_package)

View File

@@ -0,0 +1,20 @@
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):
if self.options["ffmpeg"].with_programs:
self.run("ffmpeg --help", run_environment=True)
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

15
recipes/ffmpeg/config.yml Normal file
View File

@@ -0,0 +1,15 @@
versions:
"7.0.1":
folder: "all"
"6.1.1":
folder: "all"
"6.1":
folder: "all"
"6.0.1":
folder: "all"
"5.1.3":
folder: "all"
"5.0.3":
folder: "all"
"4.4.4":
folder: "all"

View File

@@ -0,0 +1,23 @@
sources:
"1.4.3":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/xiph/flac/releases/download/1.4.3/flac-1.4.3.tar.xz"
sha256: "6c58e69cd22348f441b861092b825e591d0b822e106de6eb0ee4d05d27205b70"
"1.4.2":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/xiph/flac/releases/download/1.4.2/flac-1.4.2.tar.xz"
sha256: "e322d58a1f48d23d9dd38f432672865f6f79e73a6f9cc5a5f57fcaa83eb5a8e4"
"1.3.3":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/xiph/flac/archive/1.3.3.tar.gz"
sha256: "668cdeab898a7dd43cf84739f7e1f3ed6b35ece2ef9968a5c7079fe9adfe1689"
patches:
"1.4.3":
- patch_file: "patches/1.4.2-002-ignore-dll_export-define.patch"
patch_description: "Ignore autotools-specific DLL_EXPORT define in export.h"
patch_type: "conan"
"1.4.2":
- patch_file: "patches/1.4.2-002-ignore-dll_export-define.patch"
patch_description: "Ignore autotools-specific DLL_EXPORT define in export.h"
patch_type: "conan"
"1.3.3":
- patch_file: "patches/fix-cmake-1.3.3.patch"
patch_description: "Various adaptations in CMakeLists.txt files to improve compatibility with Conan."
patch_type: "conan"

View File

@@ -0,0 +1,121 @@
from conan import ConanFile
from conan.tools.apple import is_apple_os
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, rmdir, replace_in_file
from conan.tools.scm import Version
import os
required_conan_version = ">=1.54.0"
class FlacConan(ConanFile):
name = "flac"
description = "Free Lossless Audio Codec"
topics = ("flac", "codec", "audio", )
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/xiph/flac"
license = ("BSD-3-Clause", "GPL-2.0-or-later", "LPGL-2.1-or-later", "GFDL-1.2")
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def requirements(self):
self.requires("ogg/1.3.5")
def build_requirements(self):
if Version(self.version) < "1.4.2" and self.settings.arch in ["x86", "x86_64"]:
self.tool_requires("nasm/2.15.05")
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_EXAMPLES"] = False
tc.variables["BUILD_DOCS"] = False
tc.variables["BUILD_PROGRAMS"] = not is_apple_os(self) or self.settings.os == "Macos"
tc.variables["BUILD_TESTING"] = False
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.generate()
cd = CMakeDeps(self)
cd.generate()
if self.settings.arch in ["x86", "x86_64"]:
envbuild = VirtualBuildEnv(self)
envbuild.generate(scope="build")
def _patch_sources(self):
apply_conandata_patches(self)
replace_in_file(self, os.path.join(self.source_folder, "src", "share", "getopt", "CMakeLists.txt"),
"find_package(Intl)", "")
def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "COPYING.*", src=self.source_folder,
dst=os.path.join(self.package_folder, "licenses"), keep_path=False)
copy(self, "*.h", src=os.path.join(self.source_folder, "include", "share"),
dst=os.path.join(self.package_folder, "include", "share"), keep_path=False)
copy(self, "*.h", src=os.path.join(self.source_folder, "include", "share", "grabbag"),
dst=os.path.join(self.package_folder, "include", "share", "grabbag"), keep_path=False)
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "flac")
self.cpp_info.components["libflac"].set_property("cmake_target_name", "FLAC::FLAC")
self.cpp_info.components["libflac"].set_property("pkg_config_name", "flac")
self.cpp_info.components["libflac"].libs = ["FLAC"]
self.cpp_info.components["libflac"].requires = ["ogg::ogg"]
self.cpp_info.components["libflac++"].set_property("cmake_target_name", "FLAC::FLAC++")
self.cpp_info.components["libflac++"].set_property("pkg_config_name", "flac++")
self.cpp_info.components["libflac++"].libs = ["FLAC++"]
self.cpp_info.components["libflac++"].requires = ["libflac"]
if not self.options.shared:
self.cpp_info.components["libflac"].defines = ["FLAC__NO_DLL"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["libflac"].system_libs += ["m"]
bin_path = os.path.join(self.package_folder, "bin")
self.env_info.PATH.append(bin_path)
# TODO: to remove in conan v2
self.cpp_info.filenames["cmake_find_package"] = "flac"
self.cpp_info.filenames["cmake_find_package_multi"] = "flac"
self.cpp_info.names["cmake_find_package"] = "FLAC"
self.cpp_info.names["cmake_find_package_multi"] = "FLAC"
self.cpp_info.components["libflac"].names["cmake_find_package"] = "FLAC"
self.cpp_info.components["libflac"].names["cmake_find_package_multi"] = "FLAC"
self.cpp_info.components["libflac++"].names["cmake_find_package"] = "FLAC++"
self.cpp_info.components["libflac++"].names["cmake_find_package_multi"] = "FLAC++"

View File

@@ -0,0 +1,22 @@
--- include/FLAC/export.h
+++ include/FLAC/export.h
@@ -74,7 +74,7 @@
*/
#if defined(_WIN32)
-#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT))
+#if defined(FLAC__NO_DLL)
#define FLAC_API
#else
#ifdef FLAC_API_EXPORTS
--- include/FLAC++/export.h
+++ include/FLAC++/export.h
@@ -73,7 +73,7 @@
* by libtool, must override FLAC__NO_DLL on building shared components
*/
#if defined(_WIN32)
-#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT))
+#if defined(FLAC__NO_DLL)
#define FLACPP_API
#else
#ifdef FLACPP_API_EXPORTS

View File

@@ -0,0 +1,48 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,9 +25,6 @@ endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef")
endif()
-if(CMAKE_C_COMPILER_ID MATCHES "GNU")
- set(CMAKE_EXE_LINKER_FLAGS -no-pie)
-endif()
include(CMakePackageConfigHelpers)
include(CPack)
@@ -76,7 +73,7 @@ add_compile_options(
$<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${HAVE_DECL_AFTER_STMT_FLAG}>>:-Wdeclaration-after-statement>)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND HAVE_STACKREALIGN_FLAG)
- add_compile_options(-mstackrealign)
+ add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-mstackrealign>)
endif()
include_directories("include")
--- a/src/flac/CMakeLists.txt
+++ b/src/flac/CMakeLists.txt
@@ -21,4 +21,4 @@ if(TARGET win_utf8_io)
endif()
install(TARGETS flacapp EXPORT targets
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")
--- a/src/libFLAC/CMakeLists.txt
+++ b/src/libFLAC/CMakeLists.txt
@@ -102,7 +102,7 @@ target_compile_definitions(FLAC
target_include_directories(FLAC INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
-target_link_libraries(FLAC PRIVATE $<$<BOOL:${HAVE_LROUND}>:m>)
+target_link_libraries(FLAC PUBLIC $<$<BOOL:${HAVE_LROUND}>:m>)
if(TARGET Ogg::ogg)
target_link_libraries(FLAC PUBLIC Ogg::ogg)
endif()
--- a/src/metaflac/CMakeLists.txt
+++ b/src/metaflac/CMakeLists.txt
@@ -15,4 +15,4 @@ if(TARGET win_utf8_io)
endif()
install(TARGETS metaflac EXPORT targets
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")

View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)
find_package(flac REQUIRED FLAC++ CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE FLAC::FLAC++)

View File

@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import cross_building
from conan.tools.cmake import CMake, cmake_layout
import os
class TestPackageConan(ConanFile):
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 cross_building(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,21 @@
#include <cstdlib>
#include <iostream>
#include "FLAC++/encoder.h"
class OurEncoder: public FLAC::Encoder::File {
public:
OurEncoder(): FLAC::Encoder::File() {}
protected:
virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate)
{}
};
int main()
{
OurEncoder encoder;
if(!encoder) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

7
recipes/flac/config.yml Normal file
View File

@@ -0,0 +1,7 @@
versions:
"1.4.3":
folder: all
"1.4.2":
folder: all
"1.3.3":
folder: all

View File

@@ -0,0 +1,10 @@
sources:
"2.6.4":
sha256: "e87aae032bf07c26f85ac0ed3250998c37621d95f8bd748b31f15b33c45ee995"
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz"
patches:
"2.6.4":
- patch_file: patches/darwin-newer-versions.patch
patch_description: "missing linker flags skipped due to a problem in configure."
patch_source: "https://github.com/westes/flex/issues/509"
patch_type: "portability"

View File

@@ -0,0 +1,99 @@
import os
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.build import cross_building
from conan.tools.files import get, rmdir, copy, rm, export_conandata_patches, apply_conandata_patches
from conan.tools.gnu import AutotoolsToolchain, Autotools
required_conan_version = ">=1.53.0"
class FlexConan(ConanFile):
name = "flex"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/westes/flex"
description = "Flex, the fast lexical analyzer generator"
topics = ("lex", "lexer", "lexical analyzer generator")
license = "BSD-2-Clause"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def export_sources(self):
export_conandata_patches(self)
def requirements(self):
# Flex requires M4 to be compiled. If consumer does not have M4
# installed, Conan will need to know that Flex requires it.
self.requires("m4/1.4.19")
def build_requirements(self):
self.tool_requires("m4/1.4.19")
if hasattr(self, "settings_build") and cross_building(self):
self.tool_requires(f"{self.name}/{self.version}")
def validate(self):
if self.settings.os == "Windows":
raise ConanInvalidConfiguration("Flex package is not compatible with Windows. "
"Consider using winflexbison instead.")
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")
def generate(self):
at = AutotoolsToolchain(self)
at.configure_args.extend([
"--disable-nls",
"--disable-bootstrap",
"HELP2MAN=/bin/true",
"M4=m4",
# https://github.com/westes/flex/issues/247
"ac_cv_func_malloc_0_nonnull=yes", "ac_cv_func_realloc_0_nonnull=yes",
# https://github.com/easybuilders/easybuild-easyconfigs/pull/5792
"ac_cv_func_reallocarray=no",
])
at.generate()
def build(self):
apply_conandata_patches(self)
autotools = Autotools(self)
autotools.configure()
autotools.make()
def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
autotools.install()
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
fix_apple_shared_install_name(self)
def package_info(self):
self.cpp_info.libs = ["fl"]
self.cpp_info.system_libs = ["m"]
# Avoid CMakeDeps messing with Conan targets
self.cpp_info.set_property("cmake_find_mode", "none")
bindir = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bindir))
self.env_info.PATH.append(bindir)
lex_path = os.path.join(bindir, "flex").replace("\\", "/")
self.output.info("Setting LEX environment variable: {}".format(lex_path))
self.env_info.LEX = lex_path

View File

@@ -0,0 +1,13 @@
diff --git a/configure b/configure
index d88c47c..827c01a 100755
--- a/configure
+++ b/configure
@@ -6842,7 +6842,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
10.[012][,.]*)
_lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
- 10.*)
+ *)
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
esac
;;

View File

@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)
find_package(FLEX REQUIRED)
flex_target(flex_scanner basic_nr.l ${PROJECT_BINARY_DIR}/basic_nr.cpp)
add_executable(${PROJECT_NAME} basic_nr.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE ${FLEX_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${FLEX_LIBRARIES})

View File

@@ -0,0 +1,89 @@
/*
* This file is part of flex.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
%option C++ noyywrap
%{
int mylineno = 0;
%}
string \"[^\n"]+\"
ws [ \t]+
alpha [A-Za-z]
dig [0-9]
name ({alpha}|{dig}|\$)({alpha}|{dig}|\_|\.|\-|\/|\$)*
num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)?
num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)?
number {num1}|{num2}
%%
{ws} /* skip blanks and tabs */
"/*" {
int c;
while((c = yyinput()) != 0)
{
if(c == '\n')
++mylineno;
else if(c == '*')
{
if((c = yyinput()) == '/')
break;
else
unput(c);
}
}
}
{number} std::cout << "number " << YYText() << '\n';
\n mylineno++;
{name} std::cout << "name " << YYText() << '\n';
{string} std::cout << "string " << YYText() << '\n';
%%
extern "C" {
int yylex() {return 0;}
}
#include <fstream>
int main( int argc, const char *argv[]) {
if (argc < 2) {
fprintf(stderr, "Need an argument\n");
return 1;
}
std::ifstream ifs(argv[1]);
FlexLexer *lexer = new yyFlexLexer(ifs, std::cout);
while(lexer->yylex() != 0)
;
return 0;
}

View File

@@ -0,0 +1,6 @@
/* this is a multi line comment
still in the comment
and done */
foo = "bar"
num = 43
setting = false

View File

@@ -0,0 +1,50 @@
import os
import re
from io import StringIO
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "VirtualBuildEnv", "VirtualRunEnv", "CMakeDeps"
test_type = "explicit"
def requirements(self):
self.requires(self.tested_reference_str)
def build_requirements(self):
self.tool_requires(self.tested_reference_str)
def layout(self):
cmake_layout(self)
def _assert_expected_version(self):
def tested_reference_version():
tokens = re.split('[@#]', self.tested_reference_str)
return tokens[0].split("/", 1)[1]
output = StringIO()
self.run("flex --version", output)
output_str = str(output.getvalue())
self.output.info("Installed version: {}".format(output_str))
expected_version = tested_reference_version()
self.output.info("Expected version: {}".format(expected_version))
assert_flex_version = "flex {}".format(expected_version)
assert(assert_flex_version in output_str)
def build(self):
# Let's check flex version installed
self._assert_expected_version()
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
txt_file = os.path.join(self.source_folder, "basic_nr.txt")
self.run(f"{bin_path} {txt_file}", env="conanrun")

3
recipes/flex/config.yml Normal file
View File

@@ -0,0 +1,3 @@
versions:
"2.6.4":
folder: all

View File

@@ -0,0 +1,16 @@
sources:
"2.15.0":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-freedesktop_org/software/fontconfig/release/fontconfig-2.15.0.tar.xz"
sha256: "63a0658d0e06e0fa886106452b58ef04f21f58202ea02a94c39de0d3335d7c0e"
"2.14.2":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-freedesktop_org/software/fontconfig/release/fontconfig-2.14.2.tar.xz"
sha256: "dba695b57bce15023d2ceedef82062c2b925e51f5d4cc4aef736cf13f60a468b"
"2.13.93":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-freedesktop_org/software/fontconfig/release/fontconfig-2.13.93.tar.gz"
sha256: "0f302a18ee52dde0793fe38b266bf269dfe6e0c0ae140e30d72c6cca5dc08db5"
patches:
"2.13.93":
- patch_file: "patches/0001-meson-win32.patch"
patch_type: "portability"
patch_source: "https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/7bfbaecf819a8b1630dfc8f56126e31f985d5fb3"
patch_description: "Windows: Fix symlink privilege error detection"

View File

@@ -0,0 +1,132 @@
from conan import ConanFile
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import (
apply_conandata_patches, copy, export_conandata_patches, get,
rm, rmdir
)
from conan.tools.gnu import PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson, MesonToolchain
import os
required_conan_version = ">=1.64.0 <2 || >=2.2.0"
class FontconfigConan(ConanFile):
name = "fontconfig"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
description = "Fontconfig is a library for configuring and customizing font access"
homepage = "https://gitlab.freedesktop.org/fontconfig/fontconfig"
topics = ("fonts", "freedesktop")
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")
def layout(self):
basic_layout(self, src_folder="src")
def requirements(self):
self.requires("freetype/2.13.2")
self.requires("expat/[>=2.6.2 <3]")
def build_requirements(self):
self.tool_requires("gperf/3.1")
# self.tool_requires("meson/1.4.0")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/[>=2.1.0]")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
env = VirtualBuildEnv(self)
env.generate()
deps = PkgConfigDeps(self)
deps.generate()
tc = MesonToolchain(self)
tc.project_options.update({
"doc": "disabled",
"nls": "disabled",
"tests": "disabled",
"tools": "disabled",
"sysconfdir": os.path.join("res", "etc"),
"datadir": os.path.join("res", "share"),
})
tc.generate()
def _patch_files(self):
apply_conandata_patches(self)
def build(self):
self._patch_files()
meson = Meson(self)
meson.configure()
meson.build()
def package(self):
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses"))
meson = Meson(self)
meson.install()
rm(self, "*.pdb", self.package_folder, recursive=True)
rm(self, "*.conf", os.path.join(self.package_folder, "res", "etc", "fonts", "conf.d"))
rm(self, "*.def", os.path.join(self.package_folder, "lib"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
fix_apple_shared_install_name(self)
fix_msvc_libname(self)
def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", "Fontconfig")
self.cpp_info.set_property("cmake_target_name", "Fontconfig::Fontconfig")
self.cpp_info.set_property("pkg_config_name", "fontconfig")
self.cpp_info.libs = ["fontconfig"]
if self.settings.os in ("Linux", "FreeBSD"):
self.cpp_info.system_libs.extend(["m", "pthread"])
fontconfig_path = os.path.join(self.package_folder, "res", "etc", "fonts")
self.runenv_info.append_path("FONTCONFIG_PATH", fontconfig_path)
# TODO: to remove in conan v2
self.cpp_info.names["cmake_find_package"] = "Fontconfig"
self.cpp_info.names["cmake_find_package_multi"] = "Fontconfig"
self.env_info.FONTCONFIG_PATH = fontconfig_path
def fix_msvc_libname(conanfile, remove_lib_prefix=True):
"""remove lib prefix & change extension to .lib in case of cl like compiler"""
if not conanfile.settings.get_safe("compiler.runtime"):
return
from conan.tools.files import rename
import glob
libdirs = getattr(conanfile.cpp.package, "libdirs")
for libdir in libdirs:
for ext in [".dll.a", ".dll.lib", ".a"]:
full_folder = os.path.join(conanfile.package_folder, libdir)
for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")):
libname = os.path.basename(filepath)[0:-len(ext)]
if remove_lib_prefix and libname[0:3] == "lib":
libname = libname[3:]
rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib"))

View File

@@ -0,0 +1,19 @@
--- conf.d/link_confs.py
+++ conf.d/link_confs.py
@@ -3,6 +3,7 @@
import os
import sys
import argparse
+import platform
if __name__=='__main__':
parser = argparse.ArgumentParser()
@@ -26,7 +27,7 @@ if __name__=='__main__':
break
except OSError as e:
# Symlink privileges are not available
- if len(e.args) == 1 and 'privilege' in e.args[0]:
+ if platform.system().lower() == 'windows' and e.winerror == 1314:
break
raise
except FileExistsError:

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.14)
project(test_package LANGUAGES C)
find_package(Fontconfig REQUIRED)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE Fontconfig::Fontconfig)
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99)

View File

@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,24 @@
#include <fontconfig/fontconfig.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
FcConfig* config = FcInitLoadConfigAndFonts();
FcPattern* pat = FcNameParse((const FcChar8*)"Arial");
FcConfigSubstitute(config, pat, FcMatchPattern);
FcDefaultSubstitute(pat);
char* fontFile;
FcResult result;
FcPattern* font = FcFontMatch(config, pat, &result);
if (font) {
FcChar8* file = NULL;
if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
fontFile = (char*)file;
printf("%s\n",fontFile);
}
} else {
printf("Ops! I can't find any font!\n");
}
FcPatternDestroy(pat);
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/
)

View File

@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

View File

@@ -0,0 +1,7 @@
versions:
"2.15.0":
folder: all
"2.14.2":
folder: all
"2.13.93":
folder: all

View File

@@ -1,4 +1,8 @@
sources:
"2.13.2":
url:
- "https://nexus.avroid.tech/repository/all-raw-proxy-download_savannah_gnu_org/releases/freetype/freetype-2.13.2.tar.xz"
- "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/freetype/files/freetype2/2.13.2/freetype-2.13.2.tar.xz"
"2.12.1":
url:
- "https://nexus.avroid.tech/repository/all-raw-proxy-download_savannah_gnu_org/releases/freetype/freetype-2.12.1.tar.xz"

View File

@@ -58,11 +58,9 @@ class FreetypeConan(ConanFile):
def requirements(self):
if self.options.with_png:
# self.requires("libpng/[>=1.6 <2]")
self.requires("libpng/1.6.43")
self.requires("libpng/[>=1.6 <2]")
if self.options.with_zlib:
#self.requires("zlib/[>=1.2.10 <2]")
self.requires("zlib/1.3.1")
self.requires("zlib/[>=1.2.10 <2]")
if self.options.with_bzip2:
self.requires("bzip2/1.0.8")
if self.options.with_brotli:

View File

@@ -0,0 +1,33 @@
sources:
"2.81.0":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/glib/2.81/glib-2.81.0.tar.xz"
sha256: "1665188ed9cc941c0a189dc6295e6859872523d1bfc84a5a84732a7ae87b02e4"
"2.78.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/glib/2.78/glib-2.78.3.tar.xz"
sha256: "609801dd373796e515972bf95fc0b2daa44545481ee2f465c4f204d224b2bc21"
"2.77.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/glib/2.77/glib-2.77.3.tar.xz"
sha256: "1753f963bb680b28a83d6e2095f63d0d4b94244675bcd2603850b2ebc1ac6a61"
"2.76.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-download_gnome_org/sources/glib/2.76/glib-2.76.3.tar.xz"
sha256: "c0be444e403d7c3184d1f394f89f0b644710b5e9331b54fa4e8b5037813ad32a"
patches:
"2.81.0":
- patch_file: "patches/dont-use-python-packaging-2.81.0.patch"
patch_type: bugfix
patch_description: replace package.version.Version by internal code
patch_source: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3352
"2.78.3":
- patch_file: "patches/remove-distutils-2.77.0.patch"
patch_type: bugfix
patch_description: remove distutils
patch_source: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4133
"2.76.3":
- patch_file: "patches/libintl-discovery.patch"
patch_type: bugfix
patch_description: fix libintl discovery
patch_source: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3352
- patch_file: "patches/remove-distutils.patch"
patch_type: bugfix
patch_description: remove distutils
patch_source: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4133

View File

@@ -0,0 +1,299 @@
from conan import ConanFile
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir
from conan.tools.gnu import PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson, MesonToolchain
from conan.tools.microsoft import is_msvc
import os
import shutil
required_conan_version = ">=2.0"
class GLibConan(ConanFile):
name = "glib"
description = (
"Low-level core library that forms the basis for projects such as GTK+ and GNOME. "
"It provides data structure handling for C, portability wrappers, and interfaces "
"for such runtime functionality as an event loop, threads, dynamic loading, and an object system."
)
topics = "gio", "gmodule", "gnome", "gobject", "gtk"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://gitlab.gnome.org/GNOME/glib"
license = "LGPL-2.1-or-later"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_elf": [True, False],
"with_selinux": [True, False],
"with_mount": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_elf": True,
"with_mount": True,
"with_selinux": True,
}
short_paths = True
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if self.settings.os != "Linux":
del self.options.with_mount
del self.options.with_selinux
if is_msvc(self):
del self.options.with_elf
if self.settings.os == "Neutrino":
del self.options.with_elf
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
def layout(self):
basic_layout(self, src_folder="src")
def requirements(self):
self.requires("zlib/[>=1.2.11 <2]")
self.requires("libffi/3.4.4")
self.requires("pcre2/[>=10.42]")
if self.options.get_safe("with_elf"):
self.requires("libelf/0.8.13")
if self.options.get_safe("with_mount"):
self.requires("libmount/2.39.2")
if self.options.get_safe("with_selinux"):
self.requires("libselinux/3.6")
if self.settings.os != "Linux":
# for Linux, gettext is provided by libc
self.requires("libgettext/0.22", transitive_headers=True, transitive_libs=True)
if is_apple_os(self):
self.requires("libiconv/1.17")
def build_requirements(self):
self.tool_requires("meson/[>=1.2.3 <2]")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/[>=2.2 <3]")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
virtual_build_env = VirtualBuildEnv(self)
virtual_build_env.generate()
tc = PkgConfigDeps(self)
tc.generate()
tc = MesonToolchain(self)
tc.project_options["selinux"] = "enabled" if self.options.get_safe("with_selinux") else "disabled"
tc.project_options["libmount"] = "enabled" if self.options.get_safe("with_mount") else "disabled"
if self.settings.os == "FreeBSD" or self.settings.os == "Neutrino":
tc.project_options["xattr"] = "false"
tc.project_options["tests"] = "false"
tc.project_options["libelf"] = "enabled" if self.options.get_safe("with_elf") else "disabled"
if self.settings.os == "Neutrino":
tc.cross_build["host"]["system"] = "qnx"
tc.c_link_args.append("-lm")
tc.c_link_args.append("-lsocket")
tc.generate()
def _patch_sources(self):
apply_conandata_patches(self)
replace_in_file(self,
os.path.join(self.source_folder, "meson.build"),
"subdir('fuzzing')",
"#subdir('fuzzing')",
) # https://gitlab.gnome.org/GNOME/glib/-/issues/2152
if self.settings.os != "Linux" and self.settings.os != "Neutrino":
# allow to find gettext
replace_in_file(self,
os.path.join(self.source_folder, "meson.build"),
"libintl = dependency('intl', required: false",
"libintl = dependency('libgettext', method : 'pkg-config', required : false",
)
replace_in_file(self,
os.path.join(
self.source_folder,
"gio",
"gdbus-2.0",
"codegen",
"gdbus-codegen.in",
),
"'share'",
"'res'",
)
def build(self):
self._patch_sources()
meson = Meson(self)
meson.configure()
meson.build()
def package(self):
copy(self, pattern="LGPL-2.1-or-later.txt", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "LICENSES"))
meson = Meson(self)
meson.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "libexec"))
shutil.move(
os.path.join(self.package_folder, "share"),
os.path.join(self.package_folder, "res"),
)
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
fix_apple_shared_install_name(self)
fix_msvc_libname(self)
def package_info(self):
self.cpp_info.components["glib-2.0"].set_property("pkg_config_name", "glib-2.0")
self.cpp_info.components["glib-2.0"].libs = ["glib-2.0"]
self.cpp_info.components["glib-2.0"].includedirs += [
os.path.join("include", "glib-2.0"),
os.path.join("lib", "glib-2.0", "include")
]
self.cpp_info.components["glib-2.0"].resdirs = ["res"]
self.cpp_info.components["gmodule-no-export-2.0"].set_property("pkg_config_name", "gmodule-no-export-2.0")
self.cpp_info.components["gmodule-no-export-2.0"].libs = ["gmodule-2.0"]
self.cpp_info.components["gmodule-no-export-2.0"].resdirs = ["res"]
self.cpp_info.components["gmodule-no-export-2.0"].requires.append("glib-2.0")
self.cpp_info.components["gmodule-export-2.0"].set_property("pkg_config_name", "gmodule-export-2.0")
self.cpp_info.components["gmodule-export-2.0"].requires += ["gmodule-no-export-2.0", "glib-2.0"]
self.cpp_info.components["gmodule-2.0"].set_property("pkg_config_name", "gmodule-2.0")
self.cpp_info.components["gmodule-2.0"].requires += ["gmodule-no-export-2.0", "glib-2.0"]
self.cpp_info.components["gobject-2.0"].set_property("pkg_config_name", "gobject-2.0")
self.cpp_info.components["gobject-2.0"].libs = ["gobject-2.0"]
self.cpp_info.components["gobject-2.0"].resdirs = ["res"]
self.cpp_info.components["gobject-2.0"].requires += ["glib-2.0", "libffi::libffi"]
self.cpp_info.components["gthread-2.0"].set_property("pkg_config_name", "gthread-2.0")
self.cpp_info.components["gthread-2.0"].libs = ["gthread-2.0"]
self.cpp_info.components["gthread-2.0"].resdirs = ["res"]
self.cpp_info.components["gthread-2.0"].requires.append("glib-2.0")
self.cpp_info.components["gio-2.0"].set_property("pkg_config_name", "gio-2.0")
self.cpp_info.components["gio-2.0"].libs = ["gio-2.0"]
self.cpp_info.components["gio-2.0"].resdirs = ["res"]
self.cpp_info.components["gio-2.0"].requires += ["glib-2.0", "gobject-2.0", "gmodule-2.0", "zlib::zlib"]
self.cpp_info.components["gresource"].set_property("pkg_config_name", "gresource")
self.cpp_info.components["gresource"].libs = [] # this is actually an executable
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["glib-2.0"].system_libs.append("pthread")
self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("pthread")
self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("dl")
self.cpp_info.components["gmodule-export-2.0"].sharedlinkflags.append("-Wl,--export-dynamic")
self.cpp_info.components["gmodule-2.0"].sharedlinkflags.append("-Wl,--export-dynamic")
self.cpp_info.components["gthread-2.0"].system_libs.append("pthread")
self.cpp_info.components["gio-2.0"].system_libs.append("dl")
if self.settings.os == "Neutrino":
self.cpp_info.components["gmodule-export-2.0"].sharedlinkflags.append("-Wl,--export-dynamic")
self.cpp_info.components["gmodule-2.0"].sharedlinkflags.append("-Wl,--export-dynamic")
self.cpp_info.components["glib-2.0"].system_libs.append("m")
self.cpp_info.components["glib-2.0"].system_libs.append("socket")
self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("c")
self.cpp_info.components["gio-2.0"].system_libs.append("c")
self.cpp_info.components["gio-2.0"].system_libs.append("socket")
if self.settings.os == "Windows":
self.cpp_info.components["glib-2.0"].system_libs += ["ws2_32", "ole32", "shell32", "user32", "advapi32"]
self.cpp_info.components["gio-2.0"].system_libs.extend(["iphlpapi", "dnsapi", "shlwapi"])
self.cpp_info.components["gio-windows-2.0"].set_property("pkg_config_name", "gio-windows-2.0")
self.cpp_info.components["gio-windows-2.0"].requires = ["gobject-2.0", "gmodule-no-export-2.0", "gio-2.0"]
self.cpp_info.components["gio-windows-2.0"].includedirs = [os.path.join("include", "gio-win32-2.0")]
else:
self.cpp_info.components["gio-unix-2.0"].set_property("pkg_config_name", "gio-unix-2.0")
self.cpp_info.components["gio-unix-2.0"].requires += ["gobject-2.0", "gio-2.0"]
self.cpp_info.components["gio-unix-2.0"].includedirs = [os.path.join("include", "gio-unix-2.0")]
if self.settings.os == "Macos":
self.cpp_info.components["glib-2.0"].system_libs.append("resolv")
self.cpp_info.components["glib-2.0"].frameworks += ["Foundation", "CoreServices", "CoreFoundation"]
self.cpp_info.components["gio-2.0"].frameworks.append("AppKit")
if is_apple_os(self):
self.cpp_info.components["glib-2.0"].requires.append("libiconv::libiconv")
self.cpp_info.components["glib-2.0"].requires.append("pcre2::pcre2")
if self.settings.os == "Linux":
self.cpp_info.components["gio-2.0"].system_libs.append("resolv")
else:
self.cpp_info.components["glib-2.0"].requires.append("libgettext::libgettext")
if self.options.get_safe("with_mount"):
self.cpp_info.components["gio-2.0"].requires.append("libmount::libmount")
if self.options.get_safe("with_selinux"):
self.cpp_info.components["gio-2.0"].requires.append("libselinux::libselinux")
if self.options.get_safe("with_elf"):
self.cpp_info.components["gresource"].requires.append("libelf::libelf") # this is actually an executable
self.env_info.GLIB_COMPILE_SCHEMAS = os.path.join(self.package_folder, "bin", "glib-compile-schemas")
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
pkgconfig_variables = {
'datadir': '${prefix}/res',
'schemasdir': '${datadir}/glib-2.0/schemas',
'bindir': '${prefix}/bin',
# Can't use libdir here as it is libdir1 when using the PkgConfigDeps generator.
'giomoduledir': '${prefix}/lib/gio/modules',
'gio': '${bindir}/gio',
'gio_querymodules': '${bindir}/gio-querymodules',
'glib_compile_schemas': '${bindir}/glib-compile-schemas',
'glib_compile_resources': '${bindir}/glib-compile-resources',
'gdbus': '${bindir}/gdbus',
'gdbus_codegen': '${bindir}/gdbus-codegen',
'gresource': '${bindir}/gresource',
'gsettings': '${bindir}/gsettings'
}
self.cpp_info.components["gio-2.0"].set_property(
"pkg_config_custom_content",
"\n".join(f"{key}={value}" for key,value in pkgconfig_variables.items()))
pkgconfig_variables = {
'bindir': '${prefix}/bin',
'glib_genmarshal': '${bindir}/glib-genmarshal',
'gobject_query': '${bindir}/gobject-query',
'glib_mkenums': '${bindir}/glib-mkenums'
}
self.cpp_info.components["glib-2.0"].set_property(
"pkg_config_custom_content",
"\n".join(f"{key}={value}" for key, value in pkgconfig_variables.items()))
def fix_msvc_libname(conanfile, remove_lib_prefix=True):
"""remove lib prefix & change extension to .lib in case of cl like compiler"""
from conan.tools.files import rename
import glob
if not conanfile.settings.get_safe("compiler.runtime"):
return
libdirs = getattr(conanfile.cpp.package, "libdirs")
for libdir in libdirs:
for ext in [".dll.a", ".dll.lib", ".a"]:
full_folder = os.path.join(conanfile.package_folder, libdir)
for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")):
libname = os.path.basename(filepath)[0:-len(ext)]
if remove_lib_prefix and libname[0:3] == "lib":
libname = libname[3:]
rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib"))

View File

@@ -0,0 +1,148 @@
diff --git a/gio/gdbus-2.0/codegen/gdbus-codegen.in b/gio/gdbus-2.0/codegen/gdbus-codegen.in
index 9c409e6..1913b6d 100755
--- a/gio/gdbus-2.0/codegen/gdbus-codegen.in
+++ b/gio/gdbus-2.0/codegen/gdbus-codegen.in
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!/usr/bin/env @PYTHON@
# GDBus - GLib D-Bus Library
#
diff --git a/gio/gdbus-2.0/codegen/meson.build b/gio/gdbus-2.0/codegen/meson.build
index 67ea9f2..2ee1fc8 100644
--- a/gio/gdbus-2.0/codegen/meson.build
+++ b/gio/gdbus-2.0/codegen/meson.build
@@ -31,7 +31,7 @@ gdbus_codegen_conf = configuration_data()
gdbus_codegen_conf.set('VERSION', glib_version)
gdbus_codegen_conf.set('MAJOR_VERSION', major_version)
gdbus_codegen_conf.set('MINOR_VERSION', minor_version)
-gdbus_codegen_conf.set('PYTHON', python.full_path())
+gdbus_codegen_conf.set('PYTHON', python_name)
gdbus_codegen_conf.set('DATADIR', glib_datadir)
# Install gdbus-codegen executable
diff --git a/gio/gdbus-2.0/codegen/utils.py b/gio/gdbus-2.0/codegen/utils.py
index 6399945..86024d7 100644
--- a/gio/gdbus-2.0/codegen/utils.py
+++ b/gio/gdbus-2.0/codegen/utils.py
@@ -21,10 +21,9 @@
#
# Author: David Zeuthen <davidz@redhat.com>
-import packaging.version
import os
import sys
-
+import re
# pylint: disable=too-few-public-methods
class Color:
@@ -161,11 +160,35 @@ def lookup_brief_docs(annotations):
def version_cmp_key(key):
# If the 'since' version is 'UNRELEASED', compare higher than anything else
# If it is empty put a 0 in its place as this will
- # allow LooseVersion to work and will always compare lower.
+ # allow _parse_version() to work and will always compare lower.
if key[0] == "UNRELEASED":
v = "9999"
elif key[0]:
v = str(key[0])
else:
v = "0"
- return (packaging.version.Version(v), key[1])
+ return (_parse_version(v), key[1])
+
+
+def _parse_version(version):
+ """
+ Parse a version string into a list of integers and strings.
+
+ This function takes a version string and breaks it down into its component parts.
+ It separates numeric and non-numeric segments, converting numeric segments to integers.
+
+ Args:
+ version (str): The version string to parse.
+
+ Returns:
+ list: A list where each element is either an integer (for numeric parts)
+ or a string (for non-numeric parts).
+
+ Example:
+ >>> parseversion("1.2.3a")
+ [1, 2, 3, 'a']
+ >>> parseversion("2.0.0-rc1")
+ [2, 0, 0, 'rc1']
+ """
+ blocks = re.findall(r"(\d+|\w+)", version)
+ return [int(b) if b.isdigit() else b for b in blocks]
diff --git a/glib/gtester-report.in b/glib/gtester-report.in
index 0745d53..b8291d2 100644
--- a/glib/gtester-report.in
+++ b/glib/gtester-report.in
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#! /usr/bin/env @PYTHON@
# GLib Testing Framework Utility -*- Mode: python; -*-
# Copyright (C) 2007 Imendio AB
# Authors: Tim Janik
diff --git a/glib/meson.build b/glib/meson.build
index b2dd569..5c29bb7 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -502,7 +502,7 @@ endif
report_conf = configuration_data()
report_conf.set('GLIB_VERSION', glib_version)
-report_conf.set('PYTHON', python.full_path())
+report_conf.set('PYTHON', python_name)
configure_file(
input: 'gtester-report.in',
output: 'gtester-report',
diff --git a/gobject/glib-genmarshal.in b/gobject/glib-genmarshal.in
index 0578b74..aa5af43 100755
--- a/gobject/glib-genmarshal.in
+++ b/gobject/glib-genmarshal.in
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!/usr/bin/env @PYTHON@
# pylint: disable=too-many-lines, missing-docstring, invalid-name
diff --git a/gobject/glib-mkenums.in b/gobject/glib-mkenums.in
index 7e794e9..e10b910 100755
--- a/gobject/glib-mkenums.in
+++ b/gobject/glib-mkenums.in
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!/usr/bin/env @PYTHON@
# If the code below looks horrible and unpythonic, do not panic.
#
diff --git a/gobject/meson.build b/gobject/meson.build
index 78b732b..2129aaf 100644
--- a/gobject/meson.build
+++ b/gobject/meson.build
@@ -87,7 +87,7 @@ python_tools = [
python_tools_conf = configuration_data()
python_tools_conf.set('VERSION', glib_version)
-python_tools_conf.set('PYTHON', python.full_path())
+python_tools_conf.set('PYTHON', python_name)
foreach tool: python_tools
tool_bin = configure_file(
diff --git a/meson.build b/meson.build
index bcc2887..6cca73d 100644
--- a/meson.build
+++ b/meson.build
@@ -2457,7 +2457,9 @@ endif
glib_conf.set('HAVE_PROC_SELF_CMDLINE', have_proc_self_cmdline)
-python = import('python').find_installation(modules: ['packaging'])
+python = import('python').find_installation()
+# used for '#!/usr/bin/env <name>'
+python_name = 'python3'
python_version = python.language_version()
python_version_req = '>=3.7'

Some files were not shown because too many files have changed in this diff Show More