Relocate native programs to deps/ subdirectory of the current executable

This layout is `cargo build` compatible, no post-build file moves
required.
This commit is contained in:
Michael Vines 2018-12-08 10:43:02 -08:00
parent 3a13ecba1f
commit f5569e76db
6 changed files with 18 additions and 14 deletions

View File

@ -45,7 +45,7 @@ echo --- Creating tarball
cargo install --path drone --root solana-release cargo install --path drone --root solana-release
cargo install --path . --root solana-release cargo install --path . --root solana-release
./scripts/install-native-programs.sh solana-release/bin release ./scripts/install-native-programs.sh solana-release/bin/deps/ release
./fetch-perf-libs.sh ./fetch-perf-libs.sh
# shellcheck source=/dev/null # shellcheck source=/dev/null

View File

@ -50,7 +50,5 @@ echo --- ci/localnet-sanity.sh
set -x set -x
# Assume |cargo build| has populated target/debug/ successfully. # Assume |cargo build| has populated target/debug/ successfully.
export PATH=$PWD/target/debug:$PATH export PATH=$PWD/target/debug:$PATH
# Move programs into the executable location so native_loader can find them
scripts/install-native-programs.sh "$PWD"/target/debug debug
USE_INSTALL=1 ci/localnet-sanity.sh USE_INSTALL=1 ci/localnet-sanity.sh
) )

View File

@ -141,7 +141,7 @@ build() {
export NDEBUG=1 export NDEBUG=1
cargo install --path drone --features=$cargoFeatures --root farf cargo install --path drone --features=$cargoFeatures --root farf
cargo install --path . --features=$cargoFeatures --root farf cargo install --path . --features=$cargoFeatures --root farf
./scripts/install-native-programs.sh farf/ release ./scripts/install-native-programs.sh farf/bin/deps/ release
" "
) )
echo "Build took $SECONDS seconds" echo "Build took $SECONDS seconds"

View File

@ -38,15 +38,20 @@ const PLATFORM_FILE_EXTENSION_NATIVE: &str = "so";
const PLATFORM_FILE_EXTENSION_NATIVE: &str = "dll"; const PLATFORM_FILE_EXTENSION_NATIVE: &str = "dll";
fn create_path(name: &str) -> PathBuf { fn create_path(name: &str) -> PathBuf {
let pathbuf = {
let current_exe = env::current_exe().unwrap(); let current_exe = env::current_exe().unwrap();
PathBuf::from(current_exe.parent().unwrap()) let current_exe_directory = PathBuf::from(current_exe.parent().unwrap());
}; let library_file_name = PathBuf::from(PLATFORM_FILE_PREFIX_NATIVE.to_string() + name)
.with_extension(PLATFORM_FILE_EXTENSION_NATIVE);
pathbuf.join( // Check the current_exe directory for the library as `cargo tests` are run
PathBuf::from(PLATFORM_FILE_PREFIX_NATIVE.to_string() + name) // from the deps/ subdirectory
.with_extension(PLATFORM_FILE_EXTENSION_NATIVE), let file_path = current_exe_directory.join(&library_file_name);
) if file_path.exists() {
file_path
} else {
// `cargo build` places dependent libraries in the deps/ subdirectory
current_exe_directory.join("deps").join(library_file_name)
}
} }
pub fn check_id(program_id: &Pubkey) -> bool { pub fn check_id(program_id: &Pubkey) -> bool {

View File

@ -24,7 +24,7 @@ rm -rf usr/
cargo install --path . --root sdk/docker-solana/usr cargo install --path . --root sdk/docker-solana/usr
" "
cp -f entrypoint.sh usr/bin/solana-entrypoint.sh cp -f entrypoint.sh usr/bin/solana-entrypoint.sh
../../scripts/install-native-programs.sh usr/bin/ release ../../scripts/install-native-programs.sh usr/bin/deps/ release
docker build -t solanalabs/solana:$CHANNEL . docker build -t solanalabs/solana:$CHANNEL .

View File

@ -95,7 +95,8 @@ parts:
cargo install --path . --root $SNAPCRAFT_PART_INSTALL --bins cargo install --path . --root $SNAPCRAFT_PART_INSTALL --bins
# Install native programs # Install native programs
./scripts/install-native-programs.sh $SNAPCRAFT_PART_INSTALL/bin/ release mkdir -p $SNAPCRAFT_PART_INSTALL/bin/deps/
./scripts/install-native-programs.sh $SNAPCRAFT_PART_INSTALL/bin/deps/ release
# Install multinode-demo/ # Install multinode-demo/
mkdir -p $SNAPCRAFT_PART_INSTALL/multinode-demo/ mkdir -p $SNAPCRAFT_PART_INSTALL/multinode-demo/