Skip to content

Commit f1bce35

Browse files
committed
Make script-merge-tool more generic to be reused in other scripts
1 parent decdde0 commit f1bce35

File tree

8 files changed

+311
-147
lines changed

8 files changed

+311
-147
lines changed

Cargo.lock

Lines changed: 15 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "2"
33

44
members = [
55
"build-tools/build-params-finder",
6-
"build-tools/patch-root-binary",
6+
"build-tools/script-merge-tool",
77
]
88

99
[profile.release]

build-tools/build-params-finder/src/main.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,9 @@ fn main() {
2727
println!(
2828
r#"#include <stdint.h>
2929
#include "aggregated-params.h"
30-
"#
30+
#include "leaf-vars.h""#
3131
);
3232

33-
for (params_id, _params_name) in &params {
34-
println!(
35-
r#"__attribute__ ((visibility ("default"))) const uint32_t param{params_id}_binary_offset = 0xFFFFFFFF;
36-
__attribute__ ((visibility ("default"))) const uint32_t param{params_id}_binary_length = 1;"#
37-
);
38-
}
39-
4033
println!(
4134
r#"
4235
typedef struct {{
@@ -51,12 +44,15 @@ CkbSphincsParams ckb_sphincs_supported_params[] = {{"#
5144
);
5245

5346
for (params_id, params_name) in &params {
47+
let name = format!("CKB_{}", params_name)
48+
.replace("-", "_")
49+
.to_uppercase();
5450
println!(
5551
r#" {{
5652
.pk_bytes = PARAM{params_id}_PK_BYTES,
5753
.sign_bytes = PARAM{params_id}_SIGN_BYTES,
58-
.offset_ptr = &param{params_id}_binary_offset,
59-
.length_ptr = &param{params_id}_binary_length,
54+
.offset_ptr = &{name}_BINARY_OFFSET,
55+
.length_ptr = &{name}_BINARY_LENGTH,
6056
.name = "{params_name}",
6157
}},"#
6258
);

build-tools/patch-root-binary/src/main.rs

Lines changed: 0 additions & 113 deletions
This file was deleted.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
[package]
2-
name = "patch-root-binary"
2+
name = "script-merge-tool"
33
version = "0.1.0"
4+
description = "A helper tool to aid merging multiple binaries together for CKB usage"
45
edition = "2021"
56

67
[dependencies]
78
clap = { version = "4.5.28", features = ["cargo", "derive"] }
9+
glob = "0.3.2"
810
goblin = "0.9.3"

0 commit comments

Comments
 (0)