@@ -177,28 +177,39 @@ pub fn compile_v_to_c(opt CompileOptions) !VMetaInfo {
177
177
return v_meta_dump
178
178
}
179
179
180
- fn build_raylib (opt CompileOptions,raylib_path string , arch string ) ? {
181
- build_path := os.join_path (raylib_path,'build' )
182
- // check if the library already exists or compile it
183
- if os.exists (os.join_path (build_path,arch,'libraylib.a' )){
180
+ fn build_raylib (opt CompileOptions, raylib_path string , arch string ) ? {
181
+ build_path := os.join_path (raylib_path, 'build' )
182
+ // check if the library already exists or compile it
183
+ if os.exists (os.join_path (build_path, arch, 'libraylib.a' )) {
184
184
return
185
- }
186
- else {
187
- src_path := os.join_path (raylib_path,'src' )
185
+ } else {
186
+ src_path := os.join_path (raylib_path, 'src' )
188
187
ndk_path := ndk.root ()
189
- os.execute ('make -C $src_path clean' )
190
- arch_name := if arch == 'arm64-v8a' {'arm64' } else if arch == 'armeabi-v7a' {'arm' } else if arch in ['x86' ,'x86_64' ] {arch} else {'' }
191
- if arch_name ! in ['arm64' ,'arm' ,'x86' ,'x86_64' ]{return error ('$arch_name is now a known architecture' )}
192
- os.execute ('make -C $src_path PLATFORM=PLATFORM_ANDROID ANDROID_NDK=$ndk_path ANDROID_ARCH=$arch_name ANDROID_API_VERSION=$opt.api_level ' )
193
- taget_path := os.join_path (build_path,arch)
194
- os.mkdir_all (taget_path) or {return error ('failed making directory "$taget_path "' )}
195
- os.mv (os.join_path (src_path,'libraylib.a' ),taget_path) or {return error ('failed to move .a file from $src_path to $taget_path ' )}
188
+ os.execute ('make -C ${src_path} clean' )
189
+ arch_name := if arch == 'arm64-v8a' {
190
+ 'arm64'
191
+ } else if arch == 'armeabi-v7a' {
192
+ 'arm'
193
+ } else if arch in ['x86' , 'x86_64' ] {
194
+ arch
195
+ } else {
196
+ ''
197
+ }
198
+ if arch_name ! in ['arm64' , 'arm' , 'x86' , 'x86_64' ] {
199
+ return error ('${arch_name} is now a known architecture' )
200
+ }
201
+ os.execute ('make -C ${src_path} PLATFORM=PLATFORM_ANDROID ANDROID_NDK=${ndk_path} ANDROID_ARCH=${arch_name} ANDROID_API_VERSION=${opt.api_level} ' )
202
+ taget_path := os.join_path (build_path, arch)
203
+ os.mkdir_all (taget_path) or { return error ('failed making directory "${taget_path} "' ) }
204
+ os.mv (os.join_path (src_path, 'libraylib.a' ), taget_path) or {
205
+ return error ('failed to move .a file from ${src_path} to ${taget_path} ' )
196
206
}
197
207
}
208
+ }
198
209
199
- fn download_raylib (raylib_path string ){
200
- // clone raylib from github
201
- os.execute ('git clone https://github.com/raysan5/raylib.git $raylib_path ' )
210
+ fn download_raylib (raylib_path string ) {
211
+ // clone raylib from github
212
+ os.execute ('git clone https://github.com/raysan5/raylib.git ${ raylib_path} ' )
202
213
}
203
214
204
215
pub fn compile (opt CompileOptions) ! {
@@ -207,32 +218,36 @@ pub fn compile(opt CompileOptions) ! {
207
218
return error ('${err_sig} : failed making directory "${opt.work_dir} ". ${err} ' )
208
219
}
209
220
build_dir := opt.build_directory ()!
210
-
221
+
211
222
v_meta_dump := compile_v_to_c (opt) or {
212
223
return IError (CompileError{
213
224
kind: .v_to_c
214
225
err: err.msg ()
215
226
})
216
227
}
217
-
218
- is_raylib := 'mohamedlt.vraylib' in v_meta_dump.imports
219
-
220
- // check if raylib floder is found else clone it
221
- if is_raylib{
222
- raylib_path := os.join_path (vxt.vmodules ()or {return error ('$err_sig :vmodules folder not found' )},'vab' ,'raylib' )
223
- if os.exists (raylib_path){
224
- for arch in opt.archs{
225
- build_raylib (opt,raylib_path,arch)or { return error ('cant build raylib ERROR: $err ' )}
226
- }
227
- }
228
- else {
228
+
229
+ is_raylib := 'mohamedlt.vraylib' in v_meta_dump.imports
230
+
231
+ // check if raylib floder is found else clone it
232
+ if is_raylib {
233
+ raylib_path := os.join_path (vxt.vmodules () or {
234
+ return error ('${err_sig} :vmodules folder not found' )
235
+ }, 'vab' , 'raylib' )
236
+ if os.exists (raylib_path) {
237
+ for arch in opt.archs {
238
+ build_raylib (opt, raylib_path, arch) or {
239
+ return error ('cant build raylib ERROR: ${err} ' )
240
+ }
241
+ }
242
+ } else {
229
243
download_raylib (raylib_path)
230
- for arch in opt.archs{
231
- build_raylib (opt,raylib_path,arch)or { return error ('cant build raylib ERROR: $err ' )}
244
+ for arch in opt.archs {
245
+ build_raylib (opt, raylib_path, arch) or {
246
+ return error ('cant build raylib ERROR: ${err} ' )
232
247
}
233
248
}
234
-
235
249
}
250
+ }
236
251
237
252
v_cflags := v_meta_dump.c_flags
238
253
imported_modules := v_meta_dump.imports
@@ -369,15 +384,13 @@ pub fn compile(opt CompileOptions) ! {
369
384
370
385
is_debug_build := opt.is_debug_build ()
371
386
372
-
373
387
// add needed flags for raylib
374
- if is_raylib{
388
+ if is_raylib {
375
389
ldflags << '-lEGL'
376
390
ldflags << '-lGLESv2'
377
391
ldflags << '-u ANativeActivity_onCreate'
378
- ldflags<< '-lOpenSLES'
379
-
380
- }
392
+ ldflags << '-lOpenSLES'
393
+ }
381
394
382
395
// Sokol sapp
383
396
if 'sokol.sapp' in imported_modules {
@@ -517,8 +530,10 @@ pub fn compile(opt CompileOptions) ! {
517
530
]
518
531
// add the compiled raylib libraries for each arch
519
532
if is_raylib {
520
- build_cmd<< '-L ${os.join_path(vxt.vmodules()or{return error('$err_sig:vmodules folder not found')} ,' vab',' raylib',' build',arch)}'
521
- }
533
+ build_cmd << '-L ${os.join_path(vxt.vmodules() or {
534
+ return error(' ${err_sig}:vmodules folder not found')
535
+ }, ' vab', ' raylib', ' build', arch)}'
536
+ }
522
537
523
538
jobs << job_util.ShellJob{
524
539
cmd: build_cmd
0 commit comments