-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"1.3.9": | ||
sha256: 42b1006f998adb189b1f316bf1a60e3171da047a85c4aaded2d0d26c1476c9f6 | ||
url: https://downloads.sourceforge.net/project/rhash/rhash/1.3.9/rhash-1.3.9-src.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import os | ||
from conans import AutoToolsBuildEnvironment, ConanFile, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
|
||
|
||
class LibRHashConan(ConanFile): | ||
name = "librhash" | ||
description = "Great utility for computing hash sums" | ||
topics = ("conan", "rhash", "hash", "checksum") | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "http://rhash.sourceforge.net/" | ||
license = "MIT" | ||
exports_sources = "CMakeLists.txt", | ||
generators = "cmake", | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"with_openssl": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_openssl": True, | ||
} | ||
|
||
_autotools = None | ||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.settings.compiler == "Visual Studio": | ||
raise ConanInvalidConfiguration("Visual Studio is not supported") | ||
del self.settings.compiler.cppstd | ||
del self.settings.compiler.libcxx | ||
if self.options.shared: | ||
del self.options.fPIC | ||
|
||
def build_requirements(self): | ||
if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ: | ||
self.build_requires("msys2/20190524") | ||
|
||
def requirements(self): | ||
if self.options.with_openssl: | ||
self.requires("openssl/1.1.1d") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
extracted_folder = "RHash-{}".format(self.version) | ||
os.rename(extracted_folder, self._source_subfolder) | ||
|
||
def _configure_autotools(self): | ||
if self._autotools: | ||
return self._autotools | ||
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) | ||
conf_args = [ | ||
"--enable-openssl" if self.options.with_openssl else "--disable-openssl", | ||
"--disable-gettext", | ||
# librhash's configure script is custom and does not understand "--bindir=${prefix}/bin" arguments | ||
"--prefix={}".format(tools.unix_path(self.package_folder)), | ||
"--bindir={}".format(tools.unix_path(os.path.join(self.package_folder, "bin"))), | ||
"--libdir={}".format(tools.unix_path(os.path.join(self.package_folder, "lib"))), | ||
"--extra-cflags={}".format(self._autotools.vars["CPPFLAGS"]), | ||
"--extra-ldflags={}".format(self._autotools.vars["LDFLAGS"]), | ||
] | ||
if self.options.shared: | ||
conf_args.extend(["--enable-lib-shared", "--disable-lib-static"]) | ||
else: | ||
conf_args.extend(["--disable-lib-shared", "--enable-lib-static"]) | ||
|
||
self._autotools.configure(args=conf_args, use_default_install_dirs=False) | ||
return self._autotools | ||
|
||
def build(self): | ||
with tools.chdir(self._source_subfolder): | ||
autotools = self._configure_autotools() | ||
autotools.make() | ||
|
||
def package(self): | ||
self.copy("COPYING", src=self._source_subfolder, dst="licenses") | ||
with tools.chdir(self._source_subfolder): | ||
autotools = self._configure_autotools() | ||
autotools.install() | ||
autotools.make(target="install-lib-headers") | ||
with tools.chdir("librhash"): | ||
if self.options.shared: | ||
autotools.make(target="install-so-link") | ||
tools.rmdir(os.path.join(self.package_folder, "bin")) | ||
tools.rmdir(os.path.join(self.package_folder, "etc")) | ||
tools.rmdir(os.path.join(self.package_folder, "share")) | ||
|
||
def package_info(self): | ||
self.cpp_info.names["cmake_find_package"] = "LibRHash" | ||
self.cpp_info.names["cmake_find_package_multi"] = "LibRHash" | ||
self.cpp_info.libs = tools.collect_libs(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.3) | ||
project(test_package CXX) | ||
|
||
set(CMAKE_VERBOSE_MAKEFILE ON) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
add_executable(${PROJECT_NAME} example.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class SolaceTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
self.run(os.path.join("bin", "test_package"), run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "rhash.h" | ||
|
||
#include <cstdio> | ||
#include <cstring> | ||
|
||
#define MSG "hello world" | ||
#define SHA256_REF "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" | ||
|
||
int main() { | ||
rhash_library_init(); | ||
unsigned char rhash_bin_buffer[128]; | ||
char rhash_char_buffer[128]; | ||
rhash_msg(RHASH_SHA256, MSG, strlen(MSG), rhash_bin_buffer); | ||
int nb = rhash_print_bytes(rhash_char_buffer, rhash_bin_buffer, rhash_get_hash_length(RHASH_SHA256), RHPR_HEX); | ||
rhash_char_buffer[rhash_get_hash_length(RHASH_SHA256)] = '\0'; | ||
printf("calculated SHA256 hash= %s\n", rhash_char_buffer); | ||
|
||
printf("reference SHA256 hash= %s\n", SHA256_REF); | ||
return strcmp(rhash_char_buffer, SHA256_REF); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
1.3.9: | ||
folder: all |