Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

noodling with libzmq linking #824

Merged
merged 61 commits into from
Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a8ae07c
noodling with libzmq linking
thedavidmeister Jan 7, 2019
0a29bef
use zmq-sys from upstream
thedavidmeister Jan 8, 2019
c509f3d
try dropping LIBZMQ_PREFIX from travis
thedavidmeister Jan 8, 2019
53cc2b9
lint
thedavidmeister Jan 8, 2019
1da024a
Merge branch 'develop' into 2019-01-07-static-libzmq
thedavidmeister Jan 8, 2019
0b1c87f
better path handling for zmq
thedavidmeister Jan 8, 2019
508be35
Merge branch '2019-01-07-static-libzmq' of github.com:holochain/holoc…
thedavidmeister Jan 8, 2019
5bad844
debug windows zmq
thedavidmeister Jan 8, 2019
b0a2d38
remove old zmq path from path
thedavidmeister Jan 8, 2019
0c8dc22
put correct zmq path back in path for windows
thedavidmeister Jan 8, 2019
9b0a1d1
add bin to search directory in zmq-sys
thedavidmeister Jan 8, 2019
cbd0992
remove zmq path again for windows
thedavidmeister Jan 8, 2019
43ea1ca
debug windows paths for zmq
thedavidmeister Jan 8, 2019
af3748d
set environment path for windows for zmq
thedavidmeister Jan 8, 2019
1e9dca9
remove zmq from makefile
thedavidmeister Jan 9, 2019
494a116
Merge branch 'develop' of github.com:holochain/holochain-rust into 20…
thedavidmeister Jan 9, 2019
fc90f19
remove LIBZMQ_PREFIX keep PATH for zmq
thedavidmeister Jan 9, 2019
fac20ab
lint zmq-sys .gitignore
thedavidmeister Jan 9, 2019
7f309be
cleanup zmq-sys libs
thedavidmeister Jan 9, 2019
d315d0c
cleanup zmq-sys build.rs
thedavidmeister Jan 9, 2019
81df5f1
add windows installation instructions to readme
thedavidmeister Jan 9, 2019
d2bc2e0
updated readme instructions
thedavidmeister Jan 9, 2019
2c1f70a
make working
thedavidmeister Jan 9, 2019
0cd62de
messing with ubuntu install to try and get a full build
thedavidmeister Jan 9, 2019
39f1081
testing 0.0.3 install instructions
thedavidmeister Jan 9, 2019
ea79db4
Merge branch 'release-0.0.3' of github.com:holochain/holochain-rust i…
thedavidmeister Jan 9, 2019
07b01b6
install node in ubuntu
thedavidmeister Jan 9, 2019
ff5d891
add cold ubuntu on circle
thedavidmeister Jan 9, 2019
94788af
run cold.ubuntu on circle
thedavidmeister Jan 9, 2019
6191029
fix circle yml
thedavidmeister Jan 9, 2019
c096bfa
fix circle yml
thedavidmeister Jan 9, 2019
094e610
add cold nixos to circle
thedavidmeister Jan 9, 2019
78b3027
set NIX_PATH for cold nixos run
thedavidmeister Jan 9, 2019
15b816d
remove libzmq from nix shell
thedavidmeister Jan 9, 2019
f417c39
bump node in nix
thedavidmeister Jan 9, 2019
fb638cc
updating shell.nix for new node js
thedavidmeister Jan 9, 2019
247ee23
tweak circle for nix cold
thedavidmeister Jan 9, 2019
a16199b
rollback to node 8 on nix
thedavidmeister Jan 9, 2019
9177bd0
drop cold ubuntu job
thedavidmeister Jan 9, 2019
b2b1be4
don't add PATH in travis for zmq
thedavidmeister Jan 9, 2019
f6cddfa
write zmq dll to cargo dir
thedavidmeister Jan 9, 2019
8300161
better cargo dll copying logic
thedavidmeister Jan 9, 2019
3e0ed2a
debug dll copying
thedavidmeister Jan 9, 2019
461177c
only copy dll on windows
thedavidmeister Jan 9, 2019
93c8c52
better windows handling for dll copying for zmq
thedavidmeister Jan 9, 2019
c996d15
move test cmd to circle
thedavidmeister Jan 9, 2019
45e4599
remove PATH instructions for windows
thedavidmeister Jan 9, 2019
1da2657
create path to libzmq bin on windows
thedavidmeister Jan 9, 2019
b37e3c3
lint
thedavidmeister Jan 9, 2019
eb5d1c7
lint
thedavidmeister Jan 9, 2019
1319cf5
fix zmq copying on windows
thedavidmeister Jan 9, 2019
56aec14
use --release to try and shrink cache size on travis
thedavidmeister Jan 9, 2019
8f030fa
lint
thedavidmeister Jan 9, 2019
82fbdec
Merge branch 'develop' into 2019-01-07-static-libzmq
thedavidmeister Jan 9, 2019
6146f96
Merge branch '2019-01-07-static-libzmq' of github.com:holochain/holoc…
thedavidmeister Jan 9, 2019
76df8bc
add cargo rerun logic for minifest and cargo dirs in zmq
thedavidmeister Jan 10, 2019
30e4877
Merge branch 'develop' into 2019-01-07-static-libzmq
thedavidmeister Jan 10, 2019
f64c5ca
cold ubuntu on develop only
thedavidmeister Jan 10, 2019
8f6e752
lint readme
thedavidmeister Jan 10, 2019
a84fb63
lint shell nix
thedavidmeister Jan 10, 2019
bb45e09
Merge branch 'develop' into 2019-01-07-static-libzmq
thedavidmeister Jan 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
name: install cmd
command: nix-shell --run hc-install-cmd

- run:
name: test cmd
command: nix-shell --run hc-test-cmd

- run:
name: install node container
command: nix-shell --run hc-install-node-container
Expand Down Expand Up @@ -67,12 +71,29 @@ jobs:
- run: docker build -f .circleci/Dockerfile.zz.end -t holochain/holochain-rust:circle.zz.end .
- run: docker push holochain/holochain-rust:circle.zz.end

cold.ubuntu:
docker:
- image: ubuntu
steps:
- checkout
- run: . ./scripts/install/ubuntu.sh
- run: make test

workflows:
version: 2
tests:
jobs:
- build
- integration-tests

cold:
jobs:
- cold.ubuntu:
filters:
branches:
only:
- develop

dockers:
# https://circleci.com/docs/2.0/workflows/#scheduling-a-workflow
triggers:
Expand Down
25 changes: 2 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ _windows_template: &_windows_template
- nodist add $TRAVIS_NODE_VERSION
- nodist $TRAVIS_NODE_VERSION
- NODE_PATH="/c/Program Files (x86)\Nodist\bin\node_modules;$NODE_PATH"
- PATH=$PATH:/c/Users/travis/build/holochain/holochain-rust/vendor/zmq/bin
- PATH="$PATH:/c/Program Files (x86)/Nodist/bin"

_unix_nodejs_container_template: &_unix_nodejs_container_template
Expand Down Expand Up @@ -133,7 +132,7 @@ _cmd_deploy_template: &_cmd_deploy_template
rust: nightly-2018-12-26
if: tag =~ /^holochain-cmd-v\d+\.\d+\.\d+/
before_script:
- make install_system_libzmq
- . ./scripts/install/ubuntu.sh
script:
- cargo rustc --manifest-path cmd/Cargo.toml --target $TARGET --release -- -C lto
- mkdir $TRAVIS_TAG-$TARGET
Expand All @@ -150,16 +149,11 @@ _cmd_deploy_template: &_cmd_deploy_template
tags: true
name: $TRAVIS_TAG

env:
global:
- LIBZMQ_PREFIX=C:\\Users\\travis\\build\\holochain\\holochain-rust\\vendor\\zmq

_windows_template_lite: &_windows_template_lite
os: windows
language: rust
rust: nightly-2018-12-26-x86_64-pc-windows-msvc
before_install:
- PATH=$PATH:$TRAVIS_BUILD_DIR/vendor/zmq/bin
- CARGO_INCREMENTAL=1
- RUSTFLAGS="-Z thinlto -C codegen-units=16"
cache:
Expand All @@ -184,7 +178,7 @@ _windows_template_lite: &_windows_template_lite
- if [ ! -z "$WASM_PATH_2" ]; then cargo build --manifest-path ${TEST_PATH}${WASM_PATH_2}Cargo.toml --release --target wasm32-unknown-unknown --target-dir ${HC_TARGET_PREFIX}${TEST_PATH}${WASM_PATH_2}target; fi;

script:
- cargo test -p $TEST_P --target-dir ${HC_TARGET_PREFIX}${TEST_PATH}target
- cargo test -p $TEST_P --release --target-dir ${HC_TARGET_PREFIX}${TEST_PATH}target

jobs:
# test builds are ordered from slowest to quickest
Expand Down Expand Up @@ -287,12 +281,6 @@ jobs:
before_cache:
- rm -rf $HOME/.cargo/registry/index

- name: "Command-line tools"
<<: *_trusty_nodejs
<<: *_cargo_cache_template
script:
- make test_cmd

# holochain-cmd releases section
- name: "CMD DEPLOY - 64 bit Linux"
<<: *_cmd_deploy_template
Expand All @@ -314,9 +302,6 @@ jobs:
env:
- TARGET=x86_64-pc-windows-msvc
- CRATE_NAME=hc
- LIBZMQ_PREFIX=C:\\Users\\travis\\build\\holochain\\holochain-rust\\vendor\\zmq
before_script:
- PATH=$PATH:/c/Users/travis/build/holochain/holochain-rust/vendor/zmq/bin

- name: "CMD DEPLOY - 64 bit Windows GNU"
<<: *_cmd_deploy_template
Expand All @@ -325,9 +310,6 @@ jobs:
env:
- TARGET=x86_64-pc-windows-gnu
- CRATE_NAME=hc
- LIBZMQ_PREFIX=C:\\Users\\travis\\build\\holochain\\holochain-rust\\vendor\\zmq
before_script:
- PATH=$PATH:/c/Users/travis/build/holochain/holochain-rust/vendor/zmq/bin

# holochain-nodejs releases section
- name: "Linux - Node 8"
Expand Down Expand Up @@ -378,7 +360,6 @@ jobs:
- NODIST_X64=1
- TRAVIS_NODE_VERSION="8"
- PERFORM_NODE_DEPLOY=1
- LIBZMQ_PREFIX=C:\\Users\\travis\\build\\holochain\\holochain-rust\\vendor\\zmq
- name: "Windows - Node 10"
<<: *_windows_template
<<: *_to_deploy_template
Expand All @@ -389,7 +370,6 @@ jobs:
- NODIST_X64=1
- TRAVIS_NODE_VERSION="10"
- PERFORM_NODE_DEPLOY=1
- LIBZMQ_PREFIX=C:\\Users\\travis\\build\\holochain\\holochain-rust\\vendor\\zmq
- name: "Windows - Node 11"
<<: *_windows_template
<<: *_to_deploy_template
Expand All @@ -400,4 +380,3 @@ jobs:
- NODIST_X64=1
- TRAVIS_NODE_VERSION="11"
- PERFORM_NODE_DEPLOY=1
- LIBZMQ_PREFIX=C:\\Users\\travis\\build\\holochain\\holochain-rust\\vendor\\zmq
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ exclude = [
"app_spec",
"nodejs_container/native",
"rust_sodium-sys",
"zmq-sys",
]

[patch.crates-io]
rust_sodium-sys = { path = "./rust_sodium-sys" }
zmq-sys = { path = "./zmq-sys" }
36 changes: 2 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,47 +90,15 @@ install_rustup: version_rustup curl_rustup
install_rustup_tools: RUST_VERSION = $(TOOLS_RUST_VERSION)
install_rustup_tools: version_rustup curl_rustup


# idempotent installation of libzmq system library
# note, this is complicated by our use of travis-ci ubuntu trusty
# we need to install a newer version than is otherwise available
.PHONY: install_system_libzmq
install_system_libzmq:
@if ! (pkg-config libzmq --libs >/dev/null) ; then \
if ! which apt-get ; then \
if which brew ; then \
echo -e "\033[0;93m## Attempting to install zmq using homebrew ##\033[0m"; \
brew install zmq; \
else \
echo -e "\033[0;93m## libzmq couldn't be installed, build probably won't work ##\033[0m"; \
fi; \
else \
if [ "x${TRAVIS}" = "x" ]; then \
echo -e "\033[0;93m## Attempting to install libzmq3-dev with apt-get ##\033[0m"; \
sudo apt-get install -y libzmq3-dev; \
else \
echo -e "\033[0;93m## Attempting to install libzmq3-dev on UBUNTU TRUSTY ##\033[0m"; \
echo "deb http://download.opensuse.org/repositories/network:/messaging:/zeromq:/release-stable/xUbuntu_14.04/ ./" >> /etc/apt/sources.list; \
wget https://download.opensuse.org/repositories/network:/messaging:/zeromq:/release-stable/xUbuntu_14.04/Release.key -O- | sudo apt-key add; \
sudo apt-get update -qq; \
sudo apt-get install libzmq3-dev; \
fi; \
fi; \
fi; \

# idempotent install of any required system libraries
.PHONY: install_system_libs
install_system_libs: install_system_libzmq

# idempotent installation of core toolchain. Changes default toolchain to CORE_RUST_VERSION.
.PHONY: core_toolchain
core_toolchain: RUST_VERSION=$(CORE_RUST_VERSION)
core_toolchain: version_rustup install_rustup install_system_libs
core_toolchain: version_rustup install_rustup

# idempotent installation of tools toolchain. Changes default toolchain to TOOLS_RUST_VERSION.
.PHONY: tools_toolchain
tools_toolchain: RUST_VERSION=$(TOOLS_RUST_VERSION)
tools_toolchain: version_rustup install_rustup_tools install_system_libs
tools_toolchain: version_rustup install_rustup_tools

# idempotent addition of wasm target in current (default: CORE_RUST_VERSION) toolchain
.PHONY: ensure_wasm_target
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ There are three approaches to building and testing Holochain: using `make`, `doc
For Ubuntu you can install the prerequisites with :

``` shell
sudo apt-get install git build-essential libssl-dev curl
. ./scripts/install/ubuntu.sh
```

If you are running on ubuntu or macOS, and you have `make` installed, you can do local development by simply typing:
Expand All @@ -104,6 +104,22 @@ If you are running on ubuntu or macOS, and you have `make` installed, you can do

We also use [docker](https://www.docker.com/). The `docker` folder contains scripts to build and run docker images.

### Windows

You will need to install rust manually.

Rustup `https://rustup.rs/#` is likely the best option.

The rust language moves very fast on the nightly channel.

It is very important to be using the correct nightly version.

Currently this is:

`nightly-2018-12-26-x86_64-pc-windows-msvc`

The nightly version we test/develop against can always be found in the .travis.yml file.

### NixOS

If you have `nix-shell` then feel free to use our `.nix` files.
Expand Down
2 changes: 1 addition & 1 deletion core_types/src/dna/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl CapabilityCall {
CapabilityCall {
cap_name: name,
cap_token: token,
caller: caller,
caller,
signature: CallSignature {}, // FIXME
}
}
Expand Down
2 changes: 1 addition & 1 deletion core_types/src/dna/entry_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum Sharing {
}

impl Sharing {
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
pub fn can_publish(self) -> bool {
match self {
Sharing::Public => true,
Expand Down
4 changes: 1 addition & 3 deletions core_types/src/entry/cap_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ pub struct CapTokenGrant {

impl CapTokenGrant {
fn new(assignees: Option<Vec<Address>>) -> Self {
CapTokenGrant {
assignees: assignees,
}
CapTokenGrant { assignees }
}

pub fn create(
Expand Down
4 changes: 2 additions & 2 deletions core_types/src/error/ribosome_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl RibosomeReturnCode {
/// Enum of all possible ERROR codes that a Zome API Function could return.
#[repr(u32)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, DefaultJson)]
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
pub enum RibosomeErrorCode {
Unspecified = 1 << 16,
ArgumentDeserializationFailed = 2 << 16,
Expand All @@ -95,7 +95,7 @@ pub enum RibosomeErrorCode {
UnknownEntryType = 10 << 16,
}

#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
impl RibosomeErrorCode {
pub fn as_str(&self) -> &str {
match self {
Expand Down
2 changes: 1 addition & 1 deletion rust_sodium-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
missing_docs, non_upper_case_globals, trivial_casts, trivial_numeric_casts, unsafe_code,
variant_size_differences
)]
#![cfg_attr(feature = "cargo-clippy", allow(decimal_literal_representation, unreadable_literal))]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::decimal_literal_representation, unreadable_literal))]

#[macro_use]
extern crate lazy_static;
Expand Down
24 changes: 24 additions & 0 deletions scripts/install/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# basics
apt-get update
apt-get install -y cmake curl sudo

# sodium deps
apt-get install -y \
libssl-dev \
pkg-config \
python2.7

# libzmq
apt-get install -y \
libzmq3-dev

# hc deps
apt-get install -y qt5-default;

# nodejs_container deps
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
curl -sL https://deb.nodesource.com/setup_11.x | bash
apt-get update && apt-get install -y nodejs yarn
2 changes: 0 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ stdenv.mkDerivation rec {

# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md
binutils gcc gnumake openssl pkgconfig coreutils
# carnix

cmake
python
Expand Down Expand Up @@ -127,7 +126,6 @@ stdenv.mkDerivation rec {

# curl needed to push to codecov
curl
docker
circleci-cli
hc-codecov
ci
Expand Down
1 change: 1 addition & 0 deletions zmq-sys/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
22 changes: 22 additions & 0 deletions zmq-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "zmq-sys"
version = "0.9.0"
authors = [
"a.rottmann@gmx.at",
"erick.tryzelaar@gmail.com",
]
license = "MIT/Apache-2.0"
description = "Low-level bindings to the zeromq library"
keywords = ["ffi", "bindings"]
repository = "https://github.com/erickt/rust-zmq"
build = "build.rs"
links = "zmq"

[dependencies]
libc = "0.2.15"

[build-dependencies]
metadeps = "1"

[package.metadata.pkg-config]
libzmq = "4.1"
1 change: 1 addition & 0 deletions zmq-sys/LICENSE-APACHE
1 change: 1 addition & 0 deletions zmq-sys/LICENSE-MIT
34 changes: 34 additions & 0 deletions zmq-sys/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
extern crate metadeps;

use std::env;
#[cfg(windows)]
use std::fs;
use std::path::Path;

fn prefix_dir(dir: &str) -> Option<String> {
env::var("CARGO_MANIFEST_DIR").ok()
.map(|prefix| Path::new(&prefix).join("vendor").join("zmq").join(dir))
.and_then(|path| path.to_str().map(|p| p.to_owned()))
}

fn main() {
println!("cargo:rerun-if-env-changed=CARGO_MANIFEST_DIR");

#[cfg(windows)]
// hack to get the libzmq dll on the PATH
// copies it next to cargo
// kind of messy, is less than 1MB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I like this as an interim solution until we get static linking working... since this is where cargo install will put the binaries in any case.

{
println!("cargo:rerun-if-env-changed=CARGO");
let dll_name = "libzmq-v140-mt-4_2_0.dll";
let cargo_path = &env::var("CARGO").unwrap();
let path_on_path = Path::new(cargo_path).parent().unwrap();
fs::copy(
Path::new(&prefix_dir("bin").unwrap()).join(dll_name),
path_on_path.join(dll_name),
).unwrap();
}

println!("cargo:rustc-link-search=native={}", &prefix_dir("lib").unwrap());
println!("cargo:include={}", &prefix_dir("include").unwrap());
}
Loading