Skip to content

Commit a8c4ee7

Browse files
[Codegen]: Add stdout logs, fix codegen-v1
1 parent 6ef3eb5 commit a8c4ee7

17 files changed

+62
-25
lines changed

codegen-v2/src/codegen/cpp/blockchain_dispatcher_generator.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ pub struct BlockchainDispatcherGenerator;
2424

2525
impl BlockchainDispatcherGenerator {
2626
pub fn generate_new_blockchain_type_dispatching(coin: &CoinItem) -> Result<()> {
27-
let mut file_content = FileContent::read(dispatcher_coin_cpp_path())?;
27+
let dispatcher_path = dispatcher_coin_cpp_path();
28+
println!("[EDIT] {dispatcher_path:?}");
29+
let mut file_content = FileContent::read(dispatcher_path)?;
2830

2931
Self::generate_include_of_blockchain_entry(coin, &mut file_content)?;
3032
Self::generate_blockchain_entry_constant(coin, &mut file_content)?;

codegen-v2/src/codegen/cpp/entry_generator.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ impl EntryGenerator {
2525
let entry_header_path = blockchain_dir.join("Entry.h");
2626

2727
if blockchain_dir.exists() {
28-
return Err(Error::IoError(io::Error::new(
29-
io::ErrorKind::AlreadyExists,
30-
"blockchain already exists",
31-
)));
28+
println!("[SKIP] Entry file already exists: {blockchain_dir:?}");
29+
return Ok(blockchain_dir);
3230
}
3331

34-
fs::create_dir(&blockchain_dir)?;
32+
fs::create_dir_all(&blockchain_dir)?;
3533

34+
println!("[ADD] {entry_header_path:?}");
3635
TemplateGenerator::new(ENTRY_HEADER_TEMPLATE)
3736
.write_to(entry_header_path.clone())
3837
.with_default_patterns(coin)

codegen-v2/src/codegen/cpp/tw_any_address_tests_generator.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ impl TWAnyAddressTestsGenerator {
2626

2727
fs::create_dir_all(coin_tests_dir)?;
2828
if tw_any_address_tests_path.exists() {
29+
println!("[SKIP] {tw_any_address_tests_path:?} already exists");
2930
return Ok(());
3031
}
3132

33+
println!("[ADD] {tw_any_address_tests_path:?}");
3234
TemplateGenerator::new(TW_ANY_ADDRESS_TESTS_TEMPLATE)
3335
.write_to(tw_any_address_tests_path)
3436
.with_default_patterns(coin)

codegen-v2/src/codegen/cpp/tw_any_signer_tests_generator.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ impl TWAnySignerTestsGenerator {
2626

2727
fs::create_dir_all(coin_tests_dir)?;
2828
if tw_any_signer_tests_path.exists() {
29+
println!("[SKIP] {tw_any_signer_tests_path:?} already exists");
2930
return Ok(());
3031
}
3132

33+
println!("[ADD] {tw_any_signer_tests_path:?}");
3234
TemplateGenerator::new(TW_ANY_SIGNER_TESTS_TEMPLATE)
3335
.write_to(tw_any_signer_tests_path)
3436
.with_default_patterns(coin)

codegen-v2/src/codegen/cpp/tw_blockchain.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ pub struct TWBlockchainGenerator;
2323
impl TWBlockchainGenerator {
2424
pub fn generate_blockchain_type_variant(coin: &CoinItem) -> Result<()> {
2525
let coin_type = coin.blockchain_type();
26+
let tw_blockchain_type_path = tw_blockchain_path();
2627

27-
let mut tw_blockchain_type_rs = FileContent::read(tw_blockchain_path())?;
28+
println!("[EDIT] {tw_blockchain_type_path:?}");
29+
let mut tw_blockchain_type_rs = FileContent::read(tw_blockchain_type_path)?;
2830

2931
{
3032
let mut enum_region =

codegen-v2/src/codegen/cpp/tw_coin_address_derivation_tests_generator.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ pub struct CoinAddressDerivationTestsGenerator;
2727
impl CoinAddressDerivationTestsGenerator {
2828
pub fn generate_new_coin_type_case(coin: &CoinItem) -> Result<()> {
2929
let coin_type = coin.coin_type();
30+
let test_path = coin_address_derivation_tests_path();
31+
println!("[EDIT] {test_path:?}");
3032

31-
let mut coin_address_derivation_test_rs =
32-
FileContent::read(coin_address_derivation_tests_path())?;
33+
let mut coin_address_derivation_test_rs = FileContent::read(test_path)?;
3334

3435
{
3536
let mut switch_case_region = coin_address_derivation_test_rs
@@ -50,9 +51,10 @@ r#" case TWCoinType{coin_type}:
5051

5152
pub fn generate_new_evm_coin_type_case(coin: &CoinItem) -> Result<()> {
5253
let coin_type = coin.coin_type();
54+
let test_path = coin_address_derivation_tests_path();
55+
println!("[EDIT] {test_path:?}");
5356

54-
let mut evm_address_derivation_test_rs =
55-
FileContent::read(coin_address_derivation_tests_path())?;
57+
let mut evm_address_derivation_test_rs = FileContent::read(test_path)?;
5658

5759
{
5860
let mut switch_case_region = evm_address_derivation_test_rs

codegen-v2/src/codegen/cpp/tw_coin_type_generator.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ impl TWCoinTypeGenerator {
2323
pub fn generate_coin_type_variant(coin: &CoinItem) -> Result<()> {
2424
let coin_type = coin.coin_type();
2525
let coin_id_number = coin.coin_id_number;
26+
let tw_coin_type_file_path = tw_coin_type_path();
2627

27-
let mut tw_coin_type_rs = FileContent::read(tw_coin_type_path())?;
28+
println!("[EDIT] {tw_coin_type_file_path:?}");
29+
let mut tw_coin_type_rs = FileContent::read(tw_coin_type_file_path)?;
2830

2931
{
3032
let mut enum_region =

codegen-v2/src/codegen/cpp/tw_coin_type_tests_generator.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ impl TWCoinTypeTestsGenerator {
2626

2727
fs::create_dir(coin_tests_dir)?;
2828
if tw_coin_type_tests_path.exists() {
29+
println!("[SKIP] {tw_coin_type_tests_path:?} already exists");
2930
return Ok(());
3031
}
3132

33+
println!("[ADD] {tw_coin_type_tests_path:?}");
3234
TemplateGenerator::new(TW_COIN_TYPE_TESTS_TEMPLATE)
3335
.write_to(tw_coin_type_tests_path)
3436
.with_default_patterns(coin)

codegen-v2/src/codegen/proto/proto_generator.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ impl ProtoGenerator {
2424
let proto_path = blockchain_proto_path(coin);
2525

2626
if proto_path.exists() {
27+
println!("[SKIP] Protobuf interface already exists: {proto_path:?}");
2728
return Ok(());
2829
}
2930

31+
println!("[ADD] {proto_path:?}");
3032
TemplateGenerator::new(PROTO_TEMPLATE)
3133
.write_to(proto_path)
3234
.with_default_patterns(coin)

codegen-v2/src/codegen/rust/blockchain_dispatcher_generator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub struct BlockchainDispatcherGenerator;
2424
impl BlockchainDispatcherGenerator {
2525
pub fn generate_new_blockchain_type_dispatching(coin: &CoinItem) -> Result<()> {
2626
let dispatcher_rs_path = dispatcher_path();
27+
println!("[EDIT] {dispatcher_rs_path:?}");
2728
let mut dispatcher_rs = FileContent::read(dispatcher_rs_path)?;
2829

2930
Self::generate_use_of_blockchain_entry(coin, &mut dispatcher_rs)?;

0 commit comments

Comments
 (0)