Skip to content

Commit ff7a607

Browse files
committed
remove build from cargo.toml and use python for updating lib
1 parent 548061a commit ff7a607

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

lazer/publisher_sdk/rust/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2021"
55
description = "Pyth Lazer Publisher SDK types."
66
license = "Apache-2.0"
77
repository = "https://github.com/pyth-network/pyth-crosschain"
8-
build = "build.rs"
98

109
[dependencies]
1110
protobuf = "3.7.2"

lazer/publisher_sdk/rust/publish.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ echo "deleting build.rs file"
1515
rm -f "${PACKAGE_DIR}/build.rs"
1616

1717
echo "updating lib.rs to export local protobuf files"
18-
cat > "${PACKAGE_DIR}/src/lib.rs" << EOF
19-
pub mod transaction {
20-
pub use crate::protobuf::pyth_lazer_transaction::*;
21-
}
22-
pub mod publisher_update {
23-
pub use crate::protobuf::publisher_update::*;
24-
}
25-
mod protobuf;
26-
EOF
27-
28-
echo "removing build spec from Cargo.toml"
29-
# MacOS sed command is slightly different
30-
# This script shouldn't be run locally anyway, but I may as well make sure it works
31-
if [[ "$OSTYPE" == "darwin"* ]]; then
32-
sed -i '' '/build.*build\.rs/d' Cargo.toml
33-
else
34-
sed -i '/build.*build\.rs/d' Cargo.toml
35-
fi
18+
python3 -c "
19+
import re
20+
21+
def replace_mod_protobuf(file_path):
22+
with open(file_path, 'r') as f:
23+
content = f.read()
24+
25+
pattern = re.compile(r'mod\s+protobuf\s*\{.*?\}', re.DOTALL)
26+
27+
replacement = 'mod protobuf;'
28+
29+
new_content = pattern.sub(replacement, content)
30+
31+
with open(file_path, 'w') as f:
32+
f.write(new_content)
33+
34+
replace_mod_protobuf('${PACKAGE_DIR}/src/lib.rs')
35+
"
3636

3737
echo "publishing package"
3838
cargo publish --token ${CARGO_REGISTRY_TOKEN}

0 commit comments

Comments
 (0)