[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
This commit is contained in:
Aleksandr Vodyanov
2024-12-26 12:02:17 +03:00
parent 39afe6a1dd
commit c807f2514e
126 changed files with 6604 additions and 0 deletions

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,9 @@
{
"version": 4,
"vendor": {
"conan": {}
},
"include": [
"build/gcc-12-x86_64-gnu17-release/generators/CMakePresets.json"
]
}

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")