Repository navigation
Expand file tree
/
Copy pathpatch.dart
More file actions
65 lines (59 loc) · 2.18 KB
/
Copy pathpatch.dart
File metadata and controls
65 lines (59 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
part of 'main.dart';
// to use correct cmake target for boringssl
// the logic in build.rs doesn't account for aarch64 simulators
Future<void> patchQuiche() async {
File("quiche/quiche/src/build.rs").writeAsStringSync(
File("quiche/quiche/src/build.rs").readAsStringSync().replaceAll(
"""// Hack for Xcode 10.1.
let target_cflag = if arch == "x86_64" {
"-target x86_64-apple-ios-simulator"
} else {
""
};""",
"""// Hack for Xcode 10.1.
let target_cflag = if target == "aarch64-apple-ios-sim" {
"-target aarch64-apple-ios-simulator"
} else if target == "x86_64-apple-ios" {
"-target x86_64-apple-ios-simulator"
} else {
""
};""",
).replaceAll("""let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();""",
"""let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let target = std::env::var("TARGET").unwrap();
let os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();"""),
);
}
// dart ffi doesn't work nicely with varargs in C. so adding these additional
// helper functions to get explicit function params.
Future<void> patchCurl() async {
File('curl/configure.ac').writeAsStringSync(
File('curl/configure.ac').readAsStringSync().replaceAll(
'LIB_BROTLI="-lbrotlidec"',
'LIB_BROTLI="-lbrotlidec -lbrotlicommon"',
),
);
File("curl/lib/setopt.c").writeAsStringSync(
File("curl/lib/setopt.c").readAsStringSync() +
"""
// EXTRAS FOR LIBCURL
CURL_EXTERN CURLcode curl_easy_setopt_string(struct Curl_easy *data, CURLoption tag, char* val)
{
return curl_easy_setopt(data, tag, val);
}
CURL_EXTERN CURLcode curl_easy_setopt_int(struct Curl_easy *data, CURLoption tag, int val)
{
return curl_easy_setopt(data, tag, val);
}
CURL_EXTERN CURLcode curl_easy_setopt_ptr(struct Curl_easy *data, CURLoption tag, void* val)
{
return curl_easy_setopt(data, tag, val);
}
CURL_EXTERN CURLcode curl_easy_getinfo_long(CURL *curl, CURLINFO info, long* val)
{
return curl_easy_getinfo(curl, info, val);
}
""",
);
}