Skip to content

Commit cd67eca

Browse files
committed
refactor: deduplicate SOURCES/HEADERS constants
1 parent ad6e3ec commit cd67eca

File tree

1 file changed

+61
-90
lines changed

1 file changed

+61
-90
lines changed

build.rs

Lines changed: 61 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,64 @@ use std::env;
22
use std::fs;
33
use std::path::{Path, PathBuf};
44

5+
const SOURCES: &[&str] = &[
6+
"nghttp2/lib/sfparse.c",
7+
"nghttp2/lib/nghttp2_alpn.c",
8+
"nghttp2/lib/nghttp2_buf.c",
9+
"nghttp2/lib/nghttp2_callbacks.c",
10+
"nghttp2/lib/nghttp2_debug.c",
11+
"nghttp2/lib/nghttp2_extpri.c",
12+
"nghttp2/lib/nghttp2_frame.c",
13+
"nghttp2/lib/nghttp2_hd.c",
14+
"nghttp2/lib/nghttp2_hd_huffman.c",
15+
"nghttp2/lib/nghttp2_hd_huffman_data.c",
16+
"nghttp2/lib/nghttp2_helper.c",
17+
"nghttp2/lib/nghttp2_http.c",
18+
"nghttp2/lib/nghttp2_map.c",
19+
"nghttp2/lib/nghttp2_mem.c",
20+
"nghttp2/lib/nghttp2_option.c",
21+
"nghttp2/lib/nghttp2_outbound_item.c",
22+
"nghttp2/lib/nghttp2_pq.c",
23+
"nghttp2/lib/nghttp2_priority_spec.c",
24+
"nghttp2/lib/nghttp2_queue.c",
25+
"nghttp2/lib/nghttp2_rcbuf.c",
26+
"nghttp2/lib/nghttp2_session.c",
27+
"nghttp2/lib/nghttp2_stream.c",
28+
"nghttp2/lib/nghttp2_submit.c",
29+
"nghttp2/lib/nghttp2_version.c",
30+
"nghttp2/lib/nghttp2_ratelim.c",
31+
"nghttp2/lib/nghttp2_time.c",
32+
];
33+
34+
const HEADERS: &[&str] = &[
35+
"nghttp2/lib/sfparse.h",
36+
"nghttp2/lib/nghttp2_alpn.h",
37+
"nghttp2/lib/nghttp2_buf.h",
38+
"nghttp2/lib/nghttp2_callbacks.h",
39+
"nghttp2/lib/nghttp2_debug.h",
40+
"nghttp2/lib/nghttp2_extpri.h",
41+
"nghttp2/lib/nghttp2_frame.h",
42+
"nghttp2/lib/nghttp2_hd.h",
43+
"nghttp2/lib/nghttp2_hd_huffman.h",
44+
"nghttp2/lib/nghttp2_helper.h",
45+
"nghttp2/lib/nghttp2_http.h",
46+
"nghttp2/lib/nghttp2_int.h",
47+
"nghttp2/lib/nghttp2_map.h",
48+
"nghttp2/lib/nghttp2_mem.h",
49+
"nghttp2/lib/nghttp2_net.h",
50+
"nghttp2/lib/nghttp2_option.h",
51+
"nghttp2/lib/nghttp2_outbound_item.h",
52+
"nghttp2/lib/nghttp2_pq.h",
53+
"nghttp2/lib/nghttp2_priority_spec.h",
54+
"nghttp2/lib/nghttp2_queue.h",
55+
"nghttp2/lib/nghttp2_ratelim.h",
56+
"nghttp2/lib/nghttp2_rcbuf.h",
57+
"nghttp2/lib/nghttp2_session.h",
58+
"nghttp2/lib/nghttp2_stream.h",
59+
"nghttp2/lib/nghttp2_submit.h",
60+
"nghttp2/lib/nghttp2_time.h",
61+
];
62+
563
fn main() {
664
let out_dir = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR not set"));
765
let target = env::var("TARGET").expect("TARGET not set");
@@ -35,73 +93,15 @@ fn emit_rerun_if_changed() {
3593
println!("cargo:rerun-if-changed=nghttp2/lib/includes/nghttp2/nghttp2ver.h.in");
3694
println!("cargo:rerun-if-changed=nghttp2/lib/libnghttp2.pc.in");
3795

38-
// Header files
96+
// Header files (public)
3997
println!("cargo:rerun-if-changed=nghttp2/lib/includes/nghttp2/nghttp2.h");
4098

41-
// All source files
42-
const SOURCES: &[&str] = &[
43-
"nghttp2/lib/sfparse.c",
44-
"nghttp2/lib/nghttp2_alpn.c",
45-
"nghttp2/lib/nghttp2_buf.c",
46-
"nghttp2/lib/nghttp2_callbacks.c",
47-
"nghttp2/lib/nghttp2_debug.c",
48-
"nghttp2/lib/nghttp2_extpri.c",
49-
"nghttp2/lib/nghttp2_frame.c",
50-
"nghttp2/lib/nghttp2_hd.c",
51-
"nghttp2/lib/nghttp2_hd_huffman.c",
52-
"nghttp2/lib/nghttp2_hd_huffman_data.c",
53-
"nghttp2/lib/nghttp2_helper.c",
54-
"nghttp2/lib/nghttp2_http.c",
55-
"nghttp2/lib/nghttp2_map.c",
56-
"nghttp2/lib/nghttp2_mem.c",
57-
"nghttp2/lib/nghttp2_option.c",
58-
"nghttp2/lib/nghttp2_outbound_item.c",
59-
"nghttp2/lib/nghttp2_pq.c",
60-
"nghttp2/lib/nghttp2_priority_spec.c",
61-
"nghttp2/lib/nghttp2_queue.c",
62-
"nghttp2/lib/nghttp2_rcbuf.c",
63-
"nghttp2/lib/nghttp2_session.c",
64-
"nghttp2/lib/nghttp2_stream.c",
65-
"nghttp2/lib/nghttp2_submit.c",
66-
"nghttp2/lib/nghttp2_version.c",
67-
"nghttp2/lib/nghttp2_ratelim.c",
68-
"nghttp2/lib/nghttp2_time.c",
69-
];
70-
99+
// Source files
71100
for source in SOURCES {
72101
println!("cargo:rerun-if-changed={}", source);
73102
}
74103

75-
// Header dependencies
76-
const HEADERS: &[&str] = &[
77-
"nghttp2/lib/sfparse.h",
78-
"nghttp2/lib/nghttp2_alpn.h",
79-
"nghttp2/lib/nghttp2_buf.h",
80-
"nghttp2/lib/nghttp2_callbacks.h",
81-
"nghttp2/lib/nghttp2_debug.h",
82-
"nghttp2/lib/nghttp2_extpri.h",
83-
"nghttp2/lib/nghttp2_frame.h",
84-
"nghttp2/lib/nghttp2_hd.h",
85-
"nghttp2/lib/nghttp2_hd_huffman.h",
86-
"nghttp2/lib/nghttp2_helper.h",
87-
"nghttp2/lib/nghttp2_http.h",
88-
"nghttp2/lib/nghttp2_int.h",
89-
"nghttp2/lib/nghttp2_map.h",
90-
"nghttp2/lib/nghttp2_mem.h",
91-
"nghttp2/lib/nghttp2_net.h",
92-
"nghttp2/lib/nghttp2_option.h",
93-
"nghttp2/lib/nghttp2_outbound_item.h",
94-
"nghttp2/lib/nghttp2_pq.h",
95-
"nghttp2/lib/nghttp2_priority_spec.h",
96-
"nghttp2/lib/nghttp2_queue.h",
97-
"nghttp2/lib/nghttp2_ratelim.h",
98-
"nghttp2/lib/nghttp2_rcbuf.h",
99-
"nghttp2/lib/nghttp2_session.h",
100-
"nghttp2/lib/nghttp2_stream.h",
101-
"nghttp2/lib/nghttp2_submit.h",
102-
"nghttp2/lib/nghttp2_time.h",
103-
];
104-
104+
// Header dependencies (internal)
105105
for header in HEADERS {
106106
println!("cargo:rerun-if-changed={}", header);
107107
}
@@ -189,35 +189,6 @@ fn build_nghttp2(target: &str, include_dir: &Path, lib_dir: &Path) {
189189
}
190190

191191
fn add_source_files(build: &mut cc::Build) {
192-
const SOURCES: &[&str] = &[
193-
"nghttp2/lib/sfparse.c",
194-
"nghttp2/lib/nghttp2_alpn.c",
195-
"nghttp2/lib/nghttp2_buf.c",
196-
"nghttp2/lib/nghttp2_callbacks.c",
197-
"nghttp2/lib/nghttp2_debug.c",
198-
"nghttp2/lib/nghttp2_extpri.c",
199-
"nghttp2/lib/nghttp2_frame.c",
200-
"nghttp2/lib/nghttp2_hd.c",
201-
"nghttp2/lib/nghttp2_hd_huffman.c",
202-
"nghttp2/lib/nghttp2_hd_huffman_data.c",
203-
"nghttp2/lib/nghttp2_helper.c",
204-
"nghttp2/lib/nghttp2_http.c",
205-
"nghttp2/lib/nghttp2_map.c",
206-
"nghttp2/lib/nghttp2_mem.c",
207-
"nghttp2/lib/nghttp2_option.c",
208-
"nghttp2/lib/nghttp2_outbound_item.c",
209-
"nghttp2/lib/nghttp2_pq.c",
210-
"nghttp2/lib/nghttp2_priority_spec.c",
211-
"nghttp2/lib/nghttp2_queue.c",
212-
"nghttp2/lib/nghttp2_rcbuf.c",
213-
"nghttp2/lib/nghttp2_session.c",
214-
"nghttp2/lib/nghttp2_stream.c",
215-
"nghttp2/lib/nghttp2_submit.c",
216-
"nghttp2/lib/nghttp2_version.c",
217-
"nghttp2/lib/nghttp2_ratelim.c",
218-
"nghttp2/lib/nghttp2_time.c",
219-
];
220-
221192
for source in SOURCES {
222193
build.file(source);
223194
}

0 commit comments

Comments
 (0)