Skip to content

Commit c65e2e6

Browse files
authored
(#5769) add cityhash/cci.20130801
* add cityhash/cci.20130801 * fix msvc build
1 parent bd78cf7 commit c65e2e6

File tree

6 files changed

+141
-0
lines changed

6 files changed

+141
-0
lines changed

recipes/cityhash/all/conandata.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"cci.20130801":
3+
url: "https://github.com/google/cityhash/archive/8af9b8c2b889d80c22d6bc26ba0df1afb79a30db.zip"
4+
sha256: "3524f5ed43143974a29fddeeece29c8b6348f05db08dd180452da01a2837ddce"

recipes/cityhash/all/conanfile.py

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
from conans import ConanFile, AutoToolsBuildEnvironment, tools
2+
from conans.errors import ConanInvalidConfiguration
3+
from contextlib import contextmanager
4+
import os
5+
6+
required_conan_version = ">=1.33.0"
7+
8+
9+
class CityhashConan(ConanFile):
10+
name = "cityhash"
11+
description = "CityHash, a family of hash functions for strings."
12+
license = "MIT"
13+
topics = ("conan", "cityhash", "hash")
14+
homepage = "https://github.com/google/cityhash"
15+
url = "https://github.com/conan-io/conan-center-index"
16+
17+
settings = "os", "arch", "compiler", "build_type"
18+
options = {
19+
"shared": [True, False],
20+
"fPIC": [True, False],
21+
}
22+
default_options = {
23+
"shared": False,
24+
"fPIC": True,
25+
}
26+
27+
_autotools = None
28+
29+
@property
30+
def _source_subfolder(self):
31+
return "source_subfolder"
32+
33+
def config_options(self):
34+
if self.settings.os == "Windows":
35+
del self.options.fPIC
36+
37+
def configure(self):
38+
if self.options.shared:
39+
del self.options.fPIC
40+
41+
def validate(self):
42+
if self.settings.compiler == "Visual Studio" and self.options.shared:
43+
raise ConanInvalidConfiguration("cityhash does not support shared builds with Visual Studio")
44+
45+
def build_requirements(self):
46+
self.build_requires("libtool/2.4.6")
47+
if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"):
48+
self.build_requires("msys2/cci.latest")
49+
50+
def source(self):
51+
tools.get(**self.conan_data["sources"][self.version],
52+
destination=self._source_subfolder, strip_root=True)
53+
54+
@contextmanager
55+
def _build_context(self):
56+
if self.settings.compiler == "Visual Studio":
57+
with tools.vcvars(self.settings):
58+
env = {
59+
"CC": "cl -nologo",
60+
"CXX": "cl -nologo",
61+
"LD": "link -nologo",
62+
"AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)),
63+
}
64+
with tools.environment_append(env):
65+
yield
66+
else:
67+
yield
68+
69+
def _configure_autotools(self):
70+
if self._autotools:
71+
return self._autotools
72+
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
73+
self._autotools.libs = []
74+
yes_no = lambda v: "yes" if v else "no"
75+
args = [
76+
"--enable-static={}".format(yes_no(not self.options.shared)),
77+
"--enable-shared={}".format(yes_no(self.options.shared)),
78+
]
79+
if self.settings.compiler == "Visual Studio":
80+
self._autotools.cxx_flags.append("-EHsc")
81+
self._autotools.flags.append("-FS")
82+
self._autotools.configure(configure_dir=self._source_subfolder, args=args)
83+
return self._autotools
84+
85+
def build(self):
86+
with tools.chdir(self._source_subfolder):
87+
self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows)
88+
with self._build_context():
89+
autotools = self._configure_autotools()
90+
autotools.make()
91+
92+
def package(self):
93+
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
94+
with self._build_context():
95+
autotools = self._configure_autotools()
96+
autotools.install()
97+
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la")
98+
tools.rmdir(os.path.join(self.package_folder, "share"))
99+
100+
def package_info(self):
101+
self.cpp_info.libs = ["cityhash"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(test_package)
3+
4+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
add_executable(${PROJECT_NAME} test_package.cpp)
8+
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
5+
class TestPackageConan(ConanFile):
6+
settings = "os", "arch", "compiler", "build_type"
7+
generators = "cmake"
8+
9+
def build(self):
10+
cmake = CMake(self)
11+
cmake.configure()
12+
cmake.build()
13+
14+
def test(self):
15+
if not tools.cross_building(self.settings):
16+
bin_path = os.path.join("bin", "test_package")
17+
self.run(bin_path, run_environment=True)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <city.h>
2+
3+
#include <iostream>
4+
5+
int main() {
6+
std::cout << CityHash64("conan-center-index", 18) << std::endl;
7+
return 0;
8+
}

recipes/cityhash/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"cci.20130801":
3+
folder: all

0 commit comments

Comments
 (0)