@@ -100,7 +100,7 @@ pub fn (cflags []CFlag) c_options_before_target() []string {
100
100
mut args := []string {cap: defines.len + others.len}
101
101
args << defines
102
102
args << others
103
- return args
103
+ return uniq_non_empty ( args)
104
104
}
105
105
106
106
pub fn (cflags []CFlag) c_options_after_target () []string {
@@ -116,7 +116,7 @@ pub fn (cflags []CFlag) c_options_without_object_files() []string {
116
116
}
117
117
args << flag.format () or { continue }
118
118
}
119
- return args
119
+ return uniq_non_empty ( args)
120
120
}
121
121
122
122
pub fn (cflags []CFlag) c_options_only_object_files () []string {
@@ -128,7 +128,7 @@ pub fn (cflags []CFlag) c_options_only_object_files() []string {
128
128
args << flag.format () or { continue }
129
129
}
130
130
}
131
- return args. filter ( it != '' )
131
+ return uniq_non_empty (args )
132
132
}
133
133
134
134
pub fn (cflags []CFlag) defines_others_libs () ([]string , []string , []string ) {
@@ -137,6 +137,10 @@ pub fn (cflags []CFlag) defines_others_libs() ([]string, []string, []string) {
137
137
mut others := []string {}
138
138
mut libs := []string {}
139
139
for copt in copts_without_obj_files {
140
+ if copt.ends_with ('@START_LIBS' ) {
141
+ libs.insert (0 , copt.all_before ('@START_LIBS' ))
142
+ continue
143
+ }
140
144
if copt.starts_with ('-l' ) {
141
145
libs << copt
142
146
continue
@@ -145,11 +149,34 @@ pub fn (cflags []CFlag) defines_others_libs() ([]string, []string, []string) {
145
149
libs << '"${copt} "'
146
150
continue
147
151
}
152
+
153
+ if copt.ends_with ('@START_DEFINES' ) {
154
+ defines.insert (0 , copt.all_before ('@START_DEFINES' ))
155
+ continue
156
+ }
148
157
if copt.starts_with ('-D' ) {
149
158
defines << copt
150
159
continue
151
160
}
161
+
162
+ if copt.ends_with ('@START_OTHERS' ) {
163
+ others.insert (0 , copt.all_before ('@START_OTHERS' ))
164
+ continue
165
+ }
152
166
others << copt
153
167
}
154
- return defines, others, libs
168
+ return uniq_non_empty (defines), uniq_non_empty (others), uniq_non_empty (libs)
169
+ }
170
+
171
+ fn uniq_non_empty (args []string ) []string {
172
+ mut uniq_args := []string {}
173
+ for a in args {
174
+ if a == '' {
175
+ continue
176
+ }
177
+ if a ! in uniq_args {
178
+ uniq_args << a
179
+ }
180
+ }
181
+ return uniq_args
155
182
}
0 commit comments