ios: move `sokol` declarations out of builder, and support non-sokol apps too (#9703)

pull/9724/head
Leah Lundqvist 2021-04-12 18:35:06 +02:00 committed by GitHub
parent 07a6f4e445
commit cfaba49683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 8 deletions

View File

@ -12,8 +12,14 @@ pub const (
#flag freebsd -L/usr/local/lib -lX11 -lGL -lXcursor -lXi #flag freebsd -L/usr/local/lib -lX11 -lGL -lXcursor -lXi
#flag windows -lgdi32 #flag windows -lgdi32
// METAL // METAL
#flag darwin -DSOKOL_METAL $if darwin {
#flag darwin -framework Metal -framework Cocoa -framework MetalKit -framework QuartzCore #flag -DSOKOL_METAL
#flag -framework Metal -framework Cocoa -framework MetalKit -framework QuartzCore
}
$if ios {
#flag -DSOKOL_METAL
#flag -framework Foundation -framework Metal -framework MetalKit -framework UIKit
}
// OPENGL // OPENGL
#flag linux -DSOKOL_GLCORE33 #flag linux -DSOKOL_GLCORE33
#flag freebsd -DSOKOL_GLCORE33 #flag freebsd -DSOKOL_GLCORE33

View File

@ -202,11 +202,6 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
'-Wno-format-nonliteral', '-Wno-format-nonliteral',
] ]
if v.pref.os == .ios { if v.pref.os == .ios {
ccoptions.args << '-framework Foundation'
ccoptions.args << '-framework UIKit'
ccoptions.args << '-framework Metal'
ccoptions.args << '-framework MetalKit'
ccoptions.args << '-DSOKOL_METAL'
ccoptions.args << '-fobjc-arc' ccoptions.args << '-fobjc-arc'
} }
ccoptions.debug_mode = v.pref.is_debug ccoptions.debug_mode = v.pref.is_debug

View File

@ -12,7 +12,10 @@ pub fn (mut g Gen) gen_c_main() {
} }
g.out.writeln('') g.out.writeln('')
main_fn_start_pos := g.out.len main_fn_start_pos := g.out.len
if (g.pref.os == .android && g.pref.is_apk) || g.pref.os == .ios {
is_sokol := 'sokol' in g.table.imports
if (g.pref.os == .android && g.pref.is_apk) || (g.pref.os == .ios && is_sokol) {
g.gen_c_android_sokol_main() g.gen_c_android_sokol_main()
} else { } else {
g.gen_c_main_header() g.gen_c_main_header()