-
Notifications
You must be signed in to change notification settings - Fork 1
/
conanfile.py
88 lines (71 loc) · 3.33 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import os
import re
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import cmake_layout, CMake
from conan.tools.files import load, rmdir, copy
from conan.tools.microsoft import is_msvc
class Recipe(ConanFile):
name = "sparql-parser-base"
author = "DICE Group <info@dice-research.org>"
description = "This repository generates a [ANTLR-v4](https://github.com/antlr/antlr4) -based [SPARQL 1.1](https://www.w3.org/TR/sparql11-overview/) parser in C++. The ANTLR v4 code generator is called by CMake."
homepage = "https://github.com/dice-group/sparql-parser"
url = homepage
license = "BSD-3-Clause", "Apache-2.0"
topics = "SPARQL", "parser", "semantic web", "antlr4"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
settings = "os", "compiler", "build_type", "arch"
generators = ("CMakeDeps", "CMakeToolchain")
exports_sources = ("CMakeLists.txt", "antlr4cmake/antlr4-generator.cmake.in", "cmake/*", "SparqlLexer.g4", "SparqlParser.g4", "LICENSE-GRAMMAR", "LICENSE-APACHE", "LICENSE-MIT")
def requirements(self):
self.requires("antlr4-cppruntime/4.13.1", transitive_headers=True)
def set_version(self):
if not hasattr(self, 'version') or self.version is None:
cmake_file = load(self, os.path.join(self.recipe_folder, "CMakeLists.txt"))
self.version = re.search(r"project\([^)]*VERSION\s+(\d+\.\d+.\d+)[^)]*\)", cmake_file).group(1)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def validate(self):
if str(self.settings.arch).startswith("arm"):
raise ConanInvalidConfiguration("arm architectures are not supported")
# Need to deal with missing libuuid on Arm.
# So far ANTLR delivers macOS binary package.
compiler_version = self.settings.compiler.version
if is_msvc(self) and compiler_version < "16":
raise ConanInvalidConfiguration("library claims C2668 'Ambiguous call to overloaded function'")
if self.settings.get_safe("compiler.cppstd"):
check_min_cppstd(self, "17")
def layout(self):
cmake_layout(self)
_cmake = None
def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure(
variables={"ANTLR4_TAG": self.dependencies['antlr4-cppruntime'].ref.version}
)
return self._cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
cmake = self._configure_cmake()
cmake.install()
copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
rmdir(self, os.path.join(self.package_folder, "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
def package_info(self):
self.cpp_info.libs = ["sparql-parser-base"]
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_target_name", "sparql-parser-base::sparql-parser-base")
self.cpp_info.set_property("cmake_file_name", "sparql-parser-base")