Skip to content

Commit 765f192

Browse files
authored
Fix solana dir (#318)
* Fix solana dir * Fix permisions * Fix CI * Comment * Revert build-bpf * Better comment * Update other files
1 parent 8442f2f commit 765f192

File tree

7 files changed

+32
-14
lines changed

7 files changed

+32
-14
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ root@pyth-dev# usermod -u 1002 -g 1004 -s /bin/bash pyth
106106

107107
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.
108108

109-
To get best experience from C++ IntelliSense, open entire `/home/pyth` in VS Code to include `solana` directory in home for lookup directories.
110-
111109
### pre-commit hooks
112110
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.
113111

docker/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ RUN useradd -m pyth
4040
# Fixes a bug in the solana docker image
4141
# https://github.com/solana-labs/solana/issues/20577
4242
RUN mkdir /usr/bin/sdk/bpf/dependencies \
43-
&& chmod 777 /usr/bin/sdk/bpf/dependencies
43+
&& chmod -R 777 /usr/bin/sdk/bpf
4444

4545

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

6363
RUN ./pyth-client/scripts/get-bpf-tools.sh
64-
# Copy solana sdk and apply patch.
65-
RUN mkdir solana
66-
RUN cp -a /usr/bin/sdk solana
64+
# Apply patch to solana
6765
RUN ./pyth-client/scripts/patch-solana.sh
6866

6967
# Build and test the oracle program.

pctest/setup_local.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
PYTH=./pyth
44
PYTH_ADMIN=./pyth_admin
5-
SOLANA=../../solana/target/release/solana
5+
SOLANA_DIR="$(dirname $(which cargo-build-bpf))"
6+
SOLANA="$SOLANA_DIR/solana"
67
SOL_OPT="-u localhost --commitment finalized"
78
RPC="-r localhost"
89
FINAL="-c finalized"

pctest/setup_pub.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash
22

33
PYTH=./pyth
4-
SOLANA=../../solana/target/release/solana
5-
SOLANA_KEYGEN=../../solana/target/release/solana-keygen
4+
SOLANA_DIR="$(dirname $(which cargo-build-bpf))"
5+
SOLANA="$SOLANA_DIR/solana"
6+
SOLANA_KEYGEN="$SOLANA_DIR/solana-keygen"
7+
68
SOL_OPT="-u localhost --commitment finalized"
79
RPC="-r localhost"
810
FINAL="-c finalized"

program/c/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
OUT_DIR := ./target
2-
SOLANA := ../../../solana
2+
SOLANA := $(shell dirname $(shell which cargo-build-bpf))
33
include $(SOLANA)/sdk/bpf/c/bpf.mk
44

55
cpyth-bpf:

program/rust/build.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
use bindgen::Builder;
1+
use {
2+
bindgen::Builder,
3+
std::{
4+
path::PathBuf,
5+
process::Command,
6+
},
7+
};
28

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

612
// Generate and write bindings
713
let bindings = Builder::default()
8-
.clang_arg("-I../../../solana/sdk/bpf/c/inc/")
14+
.clang_arg(format!("-I{:}", get_solana_inc_path().display()))
915
.header("./src/bindings.h")
1016
.rustfmt_bindings(true)
1117
.generate()
@@ -14,3 +20,17 @@ fn main() {
1420
.write_to_file("./bindings.rs")
1521
.expect("Couldn't write bindings!");
1622
}
23+
24+
/// Find the Solana C header bindgen
25+
fn get_solana_inc_path() -> PathBuf {
26+
let which_stdout = Command::new("which")
27+
.args(["cargo-build-bpf"])
28+
.output()
29+
.unwrap()
30+
.stdout;
31+
let mut path = PathBuf::new();
32+
path.push(std::str::from_utf8(&which_stdout).unwrap());
33+
path.pop(); //
34+
path.push("sdk/bpf/c/inc/");
35+
path
36+
}

scripts/patch-solana.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ set -eu
1010

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

1615
set -x
1716
cd "${SOLANA}"

0 commit comments

Comments
 (0)