diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f03f2c7dd..0d345236d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,22 @@ +# +# Copyright (c) 2017 Bitprim developers (see AUTHORS) +# +# This file is part of Bitprim. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + cmake_minimum_required(VERSION 3.4) # secp256k1 @@ -6,9 +25,13 @@ project(secp256k1 VERSION 0.1 LANGUAGES C) +if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup() +else() + message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first") +endif() -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -24,6 +47,7 @@ option(ENABLE_MODULE_ECDH "Enable ECDH shared secret computation (experimental). option(ENABLE_MODULE_SCHNORR "Enable Schnorr signature module (experimental)." OFF) option(ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." ON) +#TODO(fernando): Implement the following with_... as options set(WITH_ASM "auto" CACHE STRING "Specify assembly optimizations to use (x86_64|arm|no|auto).") set(WITH_FIELD "auto" CACHE STRING "Specify Field Implementation (64bit|32bit|auto).") set(WITH_SCALAR "auto" CACHE STRING "Specify scalar implementation (64bit|32bit|auto).") @@ -132,6 +156,9 @@ elseif (WITH_SCALAR STREQUAL "32bit") target_compile_definitions(secp256k1 PUBLIC -DUSE_SCALAR_8X32=1) endif() +message("fer WITH_BIGNUM: ") +message(WITH_BIGNUM) + if (WITH_BIGNUM STREQUAL "gmp") target_compile_definitions(secp256k1 PUBLIC -DHAVE_LIBGMP=1) diff --git a/build.py b/build.py index a1c6702d57..da5ef5a746 100644 --- a/build.py +++ b/build.py @@ -6,7 +6,7 @@ remotes="https://api.bintray.com/conan/bitprim/bitprim") builder.add_common_builds(shared_option_name="secp256k1:shared") - builder.password = os.getenv("CONAN_PASSWORD") + # builder.password = os.getenv("CONAN_PASSWORD") filtered_builds = [] for settings, options, env_vars, build_requires in builder.builds: diff --git a/conanfile.py b/conanfile.py index ec0e391356..39ff358d0a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,27 @@ -from conans import ConanFile, CMake +# +# Copyright (c) 2017 Bitprim developers (see AUTHORS) +# +# This file is part of Bitprim. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + import os +from conans import ConanFile, CMake + +def option_on_off(option): + return "ON" if option else "OFF" class Secp256k1Conan(ConanFile): name = "secp256k1" @@ -7,9 +29,48 @@ class Secp256k1Conan(ConanFile): license = "http://www.boost.org/users/license.html" url = "https://github.com/bitprim/secp256k1" description = "Optimized C library for EC operations on curve secp256k1" + settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False]} - default_options = "shared=False" + + # options = {"shared": [True, False]} + # default_options = "shared=False" + + #TODO(fernando): See what to do with shared/static option... (not supported yet in Cmake) + # "shared": [True, False], + options = {"fPIC": [True, False], + "enable_benchmark": [True, False], + "enable_tests": [True, False], + "enable_openssl_tests": [True, False], + "enable_experimental": [True, False], + "enable_endomorphism": [True, False], + "enable_ecmult_static_precomputation": [True, False], + "enable_module_ecdh": [True, False], + "enable_module_schnorr": [True, False], + "enable_module_recovery": [True, False], + + # "with_asm": ['x86_64', 'arm', 'no', 'auto'], + # "with_field": ['64bit', '32bit', 'auto'], + # "with_scalar": ['64bit', '32bit', 'auto'], + # "with_bignum": ['gmp', 'no', 'auto'], + } + + # "shared=False", \ + default_options = "fPIC=True", \ + "enable_benchmark=False", \ + "enable_tests=True", \ + "enable_openssl_tests=False", \ + "enable_experimental=False", \ + "enable_endomorphism=False", \ + "enable_ecmult_static_precomputation=True", \ + "enable_module_ecdh='False'", \ + "enable_module_schnorr=False", \ + "enable_module_recovery=True" + + # "with_asm='auto'", \ + # "with_field='auto'", \ + # "with_scalar='auto'" + # "with_bignum='auto'" + generators = "cmake" build_policy = "missing" exports_sources = "src/*", "include/*", "CMakeLists.txt", "cmake/*", "secp256k1Config.cmake.in", "contrib/*", "test/*" @@ -20,12 +81,31 @@ def requirements(self): def build(self): cmake = CMake(self) + + cmake.definitions["USE_CONAN"] = "ON" + cmake.definitions["CMAKE_VERBOSE_MAKEFILE"] = "ON" + cmake.definitions["ENABLE_POSITION_INDEPENDENT_CODE"] = option_on_off(self.options.fPIC) + cmake.definitions["ENABLE_BENCHMARK"] = option_on_off(self.options.enable_benchmark) + cmake.definitions["ENABLE_TESTS"] = option_on_off(self.options.enable_tests) + cmake.definitions["ENABLE_OPENSSL_TESTS"] = option_on_off(self.options.enable_openssl_tests) + cmake.definitions["ENABLE_EXPERIMENTAL"] = option_on_off(self.options.enable_experimental) + cmake.definitions["ENABLE_ENDOMORPHISM"] = option_on_off(self.options.enable_endomorphism) + cmake.definitions["ENABLE_ECMULT_STATIC_PRECOMPUTATION"] = option_on_off(self.options.enable_ecmult_static_precomputation) + cmake.definitions["ENABLE_MODULE_ECDH"] = option_on_off(self.options.enable_module_ecdh) + cmake.definitions["ENABLE_MODULE_SCHNORR"] = option_on_off(self.options.enable_module_schnorr) + cmake.definitions["ENABLE_MODULE_RECOVERY"] = option_on_off(self.options.enable_module_recovery) + + # cmake.definitions["WITH_ASM"] = option_on_off(self.options.with_asm) + # cmake.definitions["WITH_FIELD"] = option_on_off(self.options.with_field) + # cmake.definitions["WITH_SCALAR"] = option_on_off(self.options.with_scalar) + if self.settings.os == "Windows": - cmake.definitions["WITH_BIGNUM"]="no" + cmake.definitions["WITH_BIGNUM"] = "no" if self.settings.compiler == "Visual Studio" and (self.settings.compiler.version != 12): cmake.definitions["ENABLE_TESTS"] = "OFF" else: - cmake.definitions["WITH_BIGNUM"]="gmp" + cmake.definitions["WITH_BIGNUM"] = "gmp" + cmake.configure(source_dir=self.conanfile_directory) cmake.build()