mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
pref: fix cross-compiling graphical apps to Windows (#7449)
This commit is contained in:
@@ -703,6 +703,9 @@ fn (mut v Builder) cc() {
|
||||
}
|
||||
|
||||
fn (mut b Builder) cc_linux_cross() {
|
||||
b.setup_ccompiler_options(b.pref.ccompiler)
|
||||
b.build_thirdparty_obj_files()
|
||||
b.setup_output_name()
|
||||
parent_dir := os.vmodules_dir()
|
||||
if !os.exists(parent_dir) {
|
||||
os.mkdir(parent_dir)
|
||||
@@ -763,6 +766,9 @@ fn (mut b Builder) cc_linux_cross() {
|
||||
|
||||
fn (mut c Builder) cc_windows_cross() {
|
||||
println('Cross compiling for Windows...')
|
||||
c.setup_ccompiler_options(c.pref.ccompiler)
|
||||
c.build_thirdparty_obj_files()
|
||||
c.setup_output_name()
|
||||
if !c.pref.out_name.ends_with('.exe') {
|
||||
c.pref.out_name += '.exe'
|
||||
}
|
||||
@@ -865,12 +871,6 @@ fn (mut v Builder) build_thirdparty_obj_files() {
|
||||
|
||||
fn (mut v Builder) build_thirdparty_obj_file(path string, moduleflags []cflag.CFlag) {
|
||||
obj_path := os.real_path(path)
|
||||
if v.pref.os == .windows {
|
||||
// Cross compiling for Windows
|
||||
$if !windows {
|
||||
v.pref.ccompiler = mingw_cc
|
||||
}
|
||||
}
|
||||
cfile := '${obj_path[..obj_path.len - 2]}.c'
|
||||
btarget := moduleflags.c_options_before_target()
|
||||
atarget := moduleflags.c_options_after_target()
|
||||
|
@@ -10,13 +10,6 @@ import v.table
|
||||
import v.token
|
||||
import vweb.tmpl
|
||||
|
||||
// #flag darwin -I.
|
||||
const (
|
||||
supported_platforms = ['windows', 'macos', 'darwin', 'linux', 'freebsd', 'openbsd', 'netbsd',
|
||||
'dragonfly', 'android', 'js', 'solaris', 'haiku', 'linux_or_macos']
|
||||
supported_ccompilers = ['tinyc', 'clang', 'mingw', 'msvc', 'gcc']
|
||||
)
|
||||
|
||||
// // #include, #flag, #v
|
||||
fn (mut p Parser) hash() ast.HashStmt {
|
||||
mut pos := p.prev_tok.position()
|
||||
|
@@ -68,6 +68,7 @@ pub fn (mut p Preferences) fill_with_defaults() {
|
||||
if p.ccompiler == '' {
|
||||
p.ccompiler = default_c_compiler()
|
||||
}
|
||||
p.find_cc_if_cross_compiling()
|
||||
p.ccompiler_type = cc_from_string(p.ccompiler)
|
||||
p.is_test = p.path.ends_with('_test.v')
|
||||
p.is_vsh = p.path.ends_with('.vsh')
|
||||
@@ -98,6 +99,21 @@ pub fn (mut p Preferences) fill_with_defaults() {
|
||||
// p.use_cache = os.user_os() != 'windows'
|
||||
}
|
||||
|
||||
fn (mut p Preferences) find_cc_if_cross_compiling() {
|
||||
if p.os == .windows {
|
||||
$if !windows {
|
||||
// Cross compiling to Windows
|
||||
p.ccompiler = 'x86_64-w64-mingw32-gcc'
|
||||
}
|
||||
}
|
||||
if p.os == .linux {
|
||||
$if !linux {
|
||||
// Cross compiling to Linux
|
||||
p.ccompiler = 'clang'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn (mut p Preferences) try_to_use_tcc_by_default() {
|
||||
if p.ccompiler == 'tcc' {
|
||||
p.ccompiler = default_tcc_compiler()
|
||||
|
Reference in New Issue
Block a user