Skip to content

Commit

Permalink
get rid of ./cargo when building downstream projects (solana-labs#29372)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillLykov authored and nickfrosty committed Jan 4, 2023
1 parent 30657ba commit 6d75899
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
19 changes: 12 additions & 7 deletions scripts/build-downstream-anchor-projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ source scripts/read-cargo-variable.sh

solana_ver=$(readCargoVariable version sdk/Cargo.toml)
solana_dir=$PWD
cargo="$solana_dir"/cargo
cargo_build_sbf="$solana_dir"/cargo-build-sbf
cargo_test_sbf="$solana_dir"/cargo-test-sbf

Expand Down Expand Up @@ -44,13 +43,15 @@ anchor() {
set -x
rm -rf anchor
git clone https://github.com/coral-xyz/anchor.git
# copy toolchain file to use solana's rust version
cp "$solana_dir"/rust-toolchain.toml anchor/
cd anchor

update_solana_dependencies . "$solana_ver"
patch_crates_io_solana Cargo.toml "$solana_dir"

$cargo build
$cargo test
cargo build
cargo test

anchor_dir=$PWD
anchor_ver=$(readCargoVariable version "$anchor_dir"/lang/Cargo.toml)
Expand All @@ -63,15 +64,17 @@ mango() {
set -x
rm -rf mango-v3
git clone https://github.com/blockworks-foundation/mango-v3
# copy toolchain file to use solana's rust version
cp "$solana_dir"/rust-toolchain.toml mango-v3/
cd mango-v3

update_solana_dependencies . "$solana_ver"
update_anchor_dependencies . "$anchor_ver"
patch_crates_io_solana Cargo.toml "$solana_dir"
patch_crates_io_anchor Cargo.toml "$anchor_dir"

$cargo build
$cargo test
cargo build
cargo test
$cargo_build_sbf
$cargo_test_sbf
)
Expand All @@ -82,15 +85,17 @@ metaplex() {
set -x
rm -rf metaplex-program-library
git clone https://github.com/metaplex-foundation/metaplex-program-library
# copy toolchain file to use solana's rust version
cp "$solana_dir"/rust-toolchain.toml metaplex-program-library/
cd metaplex-program-library

update_solana_dependencies . "$solana_ver"
update_anchor_dependencies . "$anchor_ver"
patch_crates_io_solana Cargo.toml "$solana_dir"
patch_crates_io_anchor Cargo.toml "$anchor_dir"

$cargo build
$cargo test
cargo build
cargo test
$cargo_build_sbf
$cargo_test_sbf
)
Expand Down
15 changes: 10 additions & 5 deletions scripts/build-downstream-projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ source scripts/read-cargo-variable.sh

solana_ver=$(readCargoVariable version sdk/Cargo.toml)
solana_dir=$PWD
cargo="$solana_dir"/cargo
cargo_build_sbf="$solana_dir"/cargo-build-sbf
cargo_test_sbf="$solana_dir"/cargo-test-sbf

Expand All @@ -24,6 +23,8 @@ example_helloworld() {
set -x
rm -rf example-helloworld
git clone https://github.com/solana-labs/example-helloworld.git
# copy toolchain file to use solana's rust version
cp "$solana_dir"/rust-toolchain.toml example-helloworld/
cd example-helloworld

update_solana_dependencies src/program-rust "$solana_ver"
Expand Down Expand Up @@ -57,6 +58,8 @@ spl() {
set -x
rm -rf spl
git clone https://github.com/solana-labs/solana-program-library.git spl
# copy toolchain file to use solana's rust version
cp "$solana_dir"/rust-toolchain.toml spl/
cd spl

project_used_solana_version=$(sed -nE 's/solana-sdk = \"[>=<~]*(.*)\"/\1/p' <"token/program/Cargo.toml")
Expand All @@ -75,8 +78,8 @@ spl() {
# TODO better: `build.rs` for spl-token-cli doesn't seem to properly build
# the required programs to run the tests, so instead we run the tests
# after we know programs have been built
$cargo build
$cargo test
cargo build
cargo test
)
}

Expand All @@ -85,6 +88,8 @@ openbook_dex() {
set -x
rm -rf openbook-dex
git clone https://github.com/openbook-dex/program.git openbook-dex
# copy toolchain file to use solana's rust version
cp "$solana_dir"/rust-toolchain.toml openbook-dex/
cd openbook-dex

update_solana_dependencies . "$solana_ver"
Expand All @@ -101,12 +106,12 @@ exclude = [
"permissioned",
]
EOF
$cargo build
cargo build

$cargo_build_sbf \
--manifest-path dex/Cargo.toml --no-default-features --features program

$cargo test \
cargo test \
--manifest-path dex/Cargo.toml --no-default-features --features program
)
}
Expand Down

0 comments on commit 6d75899

Please sign in to comment.