diff --git a/.travis.yml b/.travis.yml index eb86ecf..ec048da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,6 @@ matrix: - rust: nightly install: - - git clone https://github.com/bitcoin/secp256k1.git - - cd secp256k1 - - ./autogen.sh && ./configure --enable-module-ecdh --enable-module-recovery && make && sudo make install - - sudo ldconfig /usr/local/lib - - cd .. - | pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH diff --git a/Cargo.toml b/Cargo.toml index a7aef3b..eb031f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,10 @@ description = "Rust bindings for Pieter Wuille's `libsecp256k1` library. Impleme keywords = [ "crypto", "ECDSA", "secp256k1", "libsecp256k1", "bitcoin" ] readme = "README.md" +build = "build.rs" +[build-dependencies] +gcc = "0.3" + [lib] name = "secp256k1" path = "src/lib.rs" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..fc6da49 --- /dev/null +++ b/build.rs @@ -0,0 +1,44 @@ +// Bitcoin secp256k1 bindings +// Written in 2015 by +// Andrew Poelstra +// +// To the extent possible under law, the author(s) have dedicated all +// copyright and related and neighboring rights to this software to +// the public domain worldwide. This software is distributed without +// any warranty. +// +// You should have received a copy of the CC0 Public Domain Dedication +// along with this software. +// If not, see . +// + +//! # Build script + +// Coding conventions +#![deny(non_upper_case_globals)] +#![deny(non_camel_case_types)] +#![deny(non_snake_case)] +#![deny(unused_mut)] +#![warn(missing_docs)] + +extern crate gcc; + +fn main() { + gcc::Config::new() + .file("depend/secp256k1/src/secp256k1.c") + .include("depend/secp256k1/") + .include("depend/secp256k1/src") + // TODO these three should be changed to use libgmp, at least until secp PR 290 is merged + .define("USE_NUM_NONE", Some("1")) + .define("USE_FIELD_INV_BUILTIN", Some("1")) + .define("USE_SCALAR_INV_BUILTIN", Some("1")) + // TODO these should use 64-bit variants on 64-bit systems + .define("USE_FIELD_10X26", Some("1")) + .define("USE_SCALAR_8X32", Some("1")) + .define("USE_ENDOMORPHISM", Some("1")) + // These all are OK. + .define("ENABLE_MODULE_ECDH", Some("1")) + .define("ENABLE_MODULE_RECOVERY", Some("1")) + .compile("libsecp256k1.a"); +} + diff --git a/src/ffi.rs b/src/ffi.rs index bd7ed4d..4016342 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -116,7 +116,6 @@ impl SharedSecret { unsafe impl Send for Context {} unsafe impl Sync for Context {} -#[link(name = "secp256k1")] extern "C" { pub static secp256k1_nonce_function_rfc6979: NonceFn;