Skip to content

Commit bf388a7

Browse files
committed
rebase and run v fmt -w .
1 parent f5a1fa6 commit bf388a7

File tree

1 file changed

+55
-40
lines changed

1 file changed

+55
-40
lines changed

android/compile.v

+55-40
Original file line numberDiff line numberDiff line change
@@ -177,28 +177,39 @@ pub fn compile_v_to_c(opt CompileOptions) !VMetaInfo {
177177
return v_meta_dump
178178
}
179179

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')) {
184184
return
185-
}
186-
else {
187-
src_path := os.join_path(raylib_path,'src')
185+
} else {
186+
src_path := os.join_path(raylib_path, 'src')
188187
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}')
196206
}
197207
}
208+
}
198209

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}')
202213
}
203214

204215
pub fn compile(opt CompileOptions) ! {
@@ -207,32 +218,36 @@ pub fn compile(opt CompileOptions) ! {
207218
return error('${err_sig}: failed making directory "${opt.work_dir}". ${err}')
208219
}
209220
build_dir := opt.build_directory()!
210-
221+
211222
v_meta_dump := compile_v_to_c(opt) or {
212223
return IError(CompileError{
213224
kind: .v_to_c
214225
err: err.msg()
215226
})
216227
}
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 {
229243
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}')
232247
}
233248
}
234-
235249
}
250+
}
236251

237252
v_cflags := v_meta_dump.c_flags
238253
imported_modules := v_meta_dump.imports
@@ -369,15 +384,13 @@ pub fn compile(opt CompileOptions) ! {
369384

370385
is_debug_build := opt.is_debug_build()
371386

372-
373387
// add needed flags for raylib
374-
if is_raylib{
388+
if is_raylib {
375389
ldflags << '-lEGL'
376390
ldflags << '-lGLESv2'
377391
ldflags << '-u ANativeActivity_onCreate'
378-
ldflags<< '-lOpenSLES'
379-
380-
}
392+
ldflags << '-lOpenSLES'
393+
}
381394

382395
// Sokol sapp
383396
if 'sokol.sapp' in imported_modules {
@@ -517,8 +530,10 @@ pub fn compile(opt CompileOptions) ! {
517530
]
518531
// add the compiled raylib libraries for each arch
519532
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+
}
522537

523538
jobs << job_util.ShellJob{
524539
cmd: build_cmd

0 commit comments

Comments
 (0)