@@ -11,7 +11,12 @@ fn sdk_path(target: &str) -> Result<String, std::io::Error> {
11
11
12
12
let sdk = if target. contains ( "apple-darwin" ) {
13
13
"macosx"
14
- } else if target. contains ( "apple-ios" ) {
14
+ } else if target == "x86_64-apple-ios" || target == "i386-apple-ios" {
15
+ "iphonesimulator"
16
+ } else if target == "aarch64-apple-ios"
17
+ || target == "armv7-apple-ios"
18
+ || target == "armv7s-apple-ios"
19
+ {
15
20
"iphoneos"
16
21
} else {
17
22
unreachable ! ( ) ;
@@ -47,14 +52,19 @@ fn build(sdk_path: Option<&str>, target: &str) {
47
52
48
53
#[ cfg( feature = "audio_unit" ) ]
49
54
{
50
- println ! ( "cargo:rustc-link-lib=framework=AudioUnit " ) ;
55
+ println ! ( "cargo:rustc-link-lib=framework=AudioToolbox " ) ;
51
56
headers. push ( "AudioUnit/AudioUnit.h" ) ;
52
57
}
53
58
54
59
#[ cfg( feature = "core_audio" ) ]
55
60
{
56
61
println ! ( "cargo:rustc-link-lib=framework=CoreAudio" ) ;
57
- headers. push ( "CoreAudio/CoreAudio.h" ) ;
62
+
63
+ if target. contains ( "apple-ios" ) {
64
+ headers. push ( "CoreAudio/CoreAudioTypes.h" ) ;
65
+ } else {
66
+ headers. push ( "CoreAudio/CoreAudio.h" ) ;
67
+ }
58
68
}
59
69
60
70
#[ cfg( feature = "open_al" ) ]
@@ -79,13 +89,27 @@ fn build(sdk_path: Option<&str>, target: &str) {
79
89
// Begin building the bindgen params.
80
90
let mut builder = bindgen:: Builder :: default ( ) ;
81
91
92
+ // See https://github.com/rust-lang/rust-bindgen/issues/1211
93
+ // Technically according to the llvm mailing list, the argument to clang here should be
94
+ // -arch arm64 but it looks cleaner to just change the target.
95
+ let target = if target == "aarch64-apple-ios" {
96
+ "arm64-apple-ios"
97
+ } else {
98
+ target
99
+ } ;
82
100
builder = builder. size_t_is_usize ( true ) ;
83
101
84
102
builder = builder. clang_args ( & [ & format ! ( "--target={}" , target) ] ) ;
85
103
86
104
if let Some ( sdk_path) = sdk_path {
87
105
builder = builder. clang_args ( & [ "-isysroot" , sdk_path] ) ;
88
106
}
107
+ if target. contains ( "apple-ios" ) {
108
+ // time.h as has a variable called timezone that conflicts with some of the objective-c
109
+ // calls from NSCalendar.h in the Foundation framework. This removes that one variable.
110
+ builder = builder. blacklist_item ( "timezone" ) ;
111
+ builder = builder. blacklist_item ( "objc_object" ) ;
112
+ }
89
113
90
114
let meta_header: Vec < _ > = headers
91
115
. iter ( )
@@ -95,9 +119,7 @@ fn build(sdk_path: Option<&str>, target: &str) {
95
119
builder = builder. header_contents ( "coreaudio.h" , & meta_header. concat ( ) ) ;
96
120
97
121
// Generate the bindings.
98
- builder = builder
99
- . trust_clang_mangling ( false )
100
- . derive_default ( true ) ;
122
+ builder = builder. trust_clang_mangling ( false ) . derive_default ( true ) ;
101
123
102
124
let bindings = builder. generate ( ) . expect ( "unable to generate bindings" ) ;
103
125
0 commit comments