Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ root@pyth-dev# usermod -u 1002 -g 1004 -s /bin/bash pyth

Finally, in docker extension inside VS Code click right and choose "Attach VS Code". If you're using a remote host in VS Code make sure to let this connection be open.

To get best experience from C++ IntelliSense, open entire `/home/pyth` in VS Code to include `solana` directory in home for lookup directories.

### pre-commit hooks
pre-commit is a tool that checks and fixes simple issues (formatting, ...) before each commit. You can install it by following [their website](https://pre-commit.com/). In order to enable checks for this repo run `pre-commit install` from command-line in the root of this repo.

Expand Down
6 changes: 2 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RUN useradd -m pyth
# Fixes a bug in the solana docker image
# https://github.com/solana-labs/solana/issues/20577
RUN mkdir /usr/bin/sdk/bpf/dependencies \
&& chmod 777 /usr/bin/sdk/bpf/dependencies
&& chmod -R 777 /usr/bin/sdk/bpf


USER pyth
Expand All @@ -61,9 +61,7 @@ COPY --chown=pyth:pyth . pyth-client/
RUN cd pyth-client && ./scripts/build.sh

RUN ./pyth-client/scripts/get-bpf-tools.sh
# Copy solana sdk and apply patch.
RUN mkdir solana
RUN cp -a /usr/bin/sdk solana
# Apply patch to solana
RUN ./pyth-client/scripts/patch-solana.sh

# Build and test the oracle program.
Expand Down
3 changes: 2 additions & 1 deletion pctest/setup_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

PYTH=./pyth
PYTH_ADMIN=./pyth_admin
SOLANA=../../solana/target/release/solana
SOLANA_DIR="$(dirname $(which cargo-build-bpf))"
SOLANA="$SOLANA_DIR/solana"
SOL_OPT="-u localhost --commitment finalized"
RPC="-r localhost"
FINAL="-c finalized"
Expand Down
6 changes: 4 additions & 2 deletions pctest/setup_pub.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

PYTH=./pyth
SOLANA=../../solana/target/release/solana
SOLANA_KEYGEN=../../solana/target/release/solana-keygen
SOLANA_DIR="$(dirname $(which cargo-build-bpf))"
SOLANA="$SOLANA_DIR/solana"
SOLANA_KEYGEN="$SOLANA_DIR/solana-keygen"

SOL_OPT="-u localhost --commitment finalized"
RPC="-r localhost"
FINAL="-c finalized"
Expand Down
2 changes: 1 addition & 1 deletion program/c/makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OUT_DIR := ./target
SOLANA := ../../../solana
SOLANA := $(shell dirname $(shell which cargo-build-bpf))
include $(SOLANA)/sdk/bpf/c/bpf.mk

cpyth-bpf:
Expand Down
24 changes: 22 additions & 2 deletions program/rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use bindgen::Builder;
use {
bindgen::Builder,
std::{
path::PathBuf,
process::Command,
},
};

fn main() {
println!("cargo:rustc-link-search=./program/c/target");

// Generate and write bindings
let bindings = Builder::default()
.clang_arg("-I../../../solana/sdk/bpf/c/inc/")
.clang_arg(format!("-I{:}", get_solana_inc_path().display()))
.header("./src/bindings.h")
.rustfmt_bindings(true)
.generate()
Expand All @@ -14,3 +20,17 @@ fn main() {
.write_to_file("./bindings.rs")
.expect("Couldn't write bindings!");
}

/// Find the Solana C header bindgen
fn get_solana_inc_path() -> PathBuf {
let which_stdout = Command::new("which")
.args(["cargo-build-bpf"])
.output()
.unwrap()
.stdout;
let mut path = PathBuf::new();
path.push(std::str::from_utf8(&which_stdout).unwrap());
path.pop(); //
path.push("sdk/bpf/c/inc/");
path
}
3 changes: 1 addition & 2 deletions scripts/patch-solana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ set -eu

THIS_DIR="$( dirname "${BASH_SOURCE[0]}" )"
THIS_DIR="$( cd "${THIS_DIR}" && pwd )"
SOLANA="${SOLANA:-$THIS_DIR/../../solana}"
SOLANA="$( cd "${SOLANA}" && pwd )"
SOLANA="$(dirname $(which cargo-build-bpf))"

set -x
cd "${SOLANA}"
Expand Down