Skip to content

Commit

Permalink
Feature: conan2 (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
liss-h authored Nov 14, 2023
1 parent 744dca0 commit dc7fa17
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish-conan-branch-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ concurrency:
cancel-in-progress: true

jobs:
publish-release:
publish-conan-branch-package:
uses: dice-group/cpp-conan-release-reusable-workflow/.github/workflows/publish-conan-branch-package.yml@main
with:
public_artifactory: true
os: ubuntu-22.04
compiler: clang-14
compiler: clang-15
cmake-version: 3.22.6
conan-version: 1.59
conan-version: 2.0.13
secrets:
CONAN_USER: ${{ secrets.CONAN_USER }}
CONAN_PW: ${{ secrets.CONAN_PW }}
6 changes: 3 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ concurrency:
group: publish-release-${{ github.workflow }}-${{ github.ref }}

jobs:
publish-conan-branch-package:
publish-release:
uses: dice-group/cpp-conan-release-reusable-workflow/.github/workflows/publish-release.yml@main
with:
public_artifactory: true
os: ubuntu-22.04
compiler: clang-14
compiler: clang-15
cmake-version: 3.22.6
conan-version: 1.59
conan-version: 2.0.13
secrets:
CONAN_USER: ${{ secrets.CONAN_USER }}
CONAN_PW: ${{ secrets.CONAN_PW }}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(SPARQL_VERSION "1.1" CACHE STRING "SPARQL version" FORCE)
mark_as_advanced(SPARQL_VERSION)


set(ANTLR4_TAG "4.10.1" CACHE STRING "Antlr4 version" FORCE)
set(ANTLR4_TAG "4.13.1" CACHE STRING "Antlr4 version" FORCE)
mark_as_advanced(ANTLR4_TAG)
set(ANTLR4_JAR_LOCATION "${PROJECT_BINARY_DIR}/antlr-${ANTLR4_TAG}-complete.jar")
if (NOT EXISTS "${ANTLR4_JAR_LOCATION}")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ make -j sparql-parser-base

`-DSPARQL_VERSION="1.0"/"1.1" [default: "1.1"]`: SPARQL version of the generated parser.

`-DANTLR4_TAG=... [default: "4.10.1"]`: ANTLR4 version to be used.
`-DANTLR4_TAG=... [default: "4.13.1"]`: ANTLR4 version to be used.

`-DCONAN_CMAKE=ON/OFF [default: ON]`: If available, use Conan to retrieve dependencies.
37 changes: 13 additions & 24 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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
from conan.tools.files import load, rmdir, copy
from conan.tools.microsoft import is_msvc
from conan.tools.files import load, rmdir
from conan import ConanFile, Version
from conan.errors import ConanInvalidConfiguration


class Recipe(ConanFile):
Expand All @@ -28,23 +28,18 @@ class Recipe(ConanFile):
"fPIC": True,
'sparql_version': '1.1',
}
requires = "antlr4-cppruntime/4.10.1",
settings = "os", "compiler", "build_type", "arch"
generators = ("CMakeDeps", "CMakeToolchain")
exports_sources = "CMakeLists.txt", "antlr4cmake/antlr4-generator.cmake.in", "cmake/*", "SparqlLexer_1.1.g4", "SparqlParser_1.0.g4", "SparqlParser_1.1.g4"

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)

compiler_required_cpp17 = {
"Visual Studio": "16",
"gcc": "7",
"clang": "5",
"apple-clang": "9.1"
}

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand All @@ -55,23 +50,13 @@ def validate(self):
# Need to deal with missing libuuid on Arm.
# So far ANTLR delivers macOS binary package.

compiler_version = Version(self.settings.compiler.version)
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")

minimum_version = self.compiler_required_cpp17.get(str(self.settings.compiler), False)

if minimum_version:
if compiler_version < minimum_version:
raise ConanInvalidConfiguration(
"{} requires C++17, which your compiler does not support.".format(self.name))
else:
self.output.warn(
"{} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name))

_cmake = None

def _configure_cmake(self):
Expand All @@ -81,7 +66,7 @@ def _configure_cmake(self):
self._cmake.configure(
variables=
{"USE_CONAN": False,
"ANTLR4_TAG": self.requires['antlr4-cppruntime'].ref.version}
"ANTLR4_TAG": self.dependencies['antlr4-cppruntime'].ref.version}
)
self._cmake.configure()
return self._cmake
Expand All @@ -93,9 +78,13 @@ def build(self):
def package(self):
cmake = self._configure_cmake()
cmake.install()
self.copy("LICENSE", src=self.folders.base_source, dst="licenses")
copy(self, "LICENSE", src=self.folders.base_source, dst="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")

0 comments on commit dc7fa17

Please sign in to comment.