builder: rename `a` to `args`
parent
7ac457f1db
commit
280afb2282
|
@ -148,15 +148,15 @@ fn (mut v Builder) cc() {
|
||||||
// '-Werror',
|
// '-Werror',
|
||||||
// TODO : try and remove the below workaround options when the corresponding
|
// TODO : try and remove the below workaround options when the corresponding
|
||||||
// warnings are totally fixed/removed
|
// warnings are totally fixed/removed
|
||||||
mut a := [v.pref.cflags, '-std=gnu11', '-Wall', '-Wextra', '-Wno-unused-variable', '-Wno-unused-parameter',
|
mut args := [v.pref.cflags, '-std=gnu11', '-Wall', '-Wextra', '-Wno-unused-variable', '-Wno-unused-parameter',
|
||||||
'-Wno-unused-result', '-Wno-unused-function', '-Wno-missing-braces', '-Wno-unused-label']
|
'-Wno-unused-result', '-Wno-unused-function', '-Wno-missing-braces', '-Wno-unused-label']
|
||||||
if v.pref.os == .ios {
|
if v.pref.os == .ios {
|
||||||
a << '-framework Foundation'
|
args << '-framework Foundation'
|
||||||
a << '-framework UIKit'
|
args << '-framework UIKit'
|
||||||
a << '-framework Metal'
|
args << '-framework Metal'
|
||||||
a << '-framework MetalKit'
|
args << '-framework MetalKit'
|
||||||
a << '-DSOKOL_METAL'
|
args << '-DSOKOL_METAL'
|
||||||
a << '-fobjc-arc'
|
args << '-fobjc-arc'
|
||||||
}
|
}
|
||||||
mut linker_flags := []string{}
|
mut linker_flags := []string{}
|
||||||
// TCC on Linux by default, unless -cc was provided
|
// TCC on Linux by default, unless -cc was provided
|
||||||
|
@ -181,7 +181,7 @@ fn (mut v Builder) cc() {
|
||||||
// os.mkdir('/var/tmp/tcc/lib/tcc/') or { panic(err) }
|
// os.mkdir('/var/tmp/tcc/lib/tcc/') or { panic(err) }
|
||||||
// os.create('/var/tmp/tcc/lib/tcc/libtcc1.a')
|
// os.create('/var/tmp/tcc/lib/tcc/libtcc1.a')
|
||||||
v.pref.ccompiler = tcc_path
|
v.pref.ccompiler = tcc_path
|
||||||
a << '-m64'
|
args << '-m64'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} $else {
|
} $else {
|
||||||
|
@ -196,7 +196,7 @@ fn (mut v Builder) cc() {
|
||||||
v.log('cc() isprod=$v.pref.is_prod outname=$v.pref.out_name')
|
v.log('cc() isprod=$v.pref.is_prod outname=$v.pref.out_name')
|
||||||
if v.pref.is_shared {
|
if v.pref.is_shared {
|
||||||
linker_flags << '-shared'
|
linker_flags << '-shared'
|
||||||
a << '-fPIC' // -Wl,-z,defs'
|
args << '-fPIC' // -Wl,-z,defs'
|
||||||
$if macos {
|
$if macos {
|
||||||
v.pref.out_name += '.dylib'
|
v.pref.out_name += '.dylib'
|
||||||
} $else {
|
} $else {
|
||||||
|
@ -204,8 +204,8 @@ fn (mut v Builder) cc() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v.pref.is_bare {
|
if v.pref.is_bare {
|
||||||
a << '-fno-stack-protector'
|
args << '-fno-stack-protector'
|
||||||
a << '-ffreestanding'
|
args << '-ffreestanding'
|
||||||
linker_flags << '-static'
|
linker_flags << '-static'
|
||||||
linker_flags << '-nostdlib'
|
linker_flags << '-nostdlib'
|
||||||
}
|
}
|
||||||
|
@ -266,36 +266,36 @@ fn (mut v Builder) cc() {
|
||||||
optimization_options = '-O3 -fno-strict-aliasing -flto'
|
optimization_options = '-O3 -fno-strict-aliasing -flto'
|
||||||
}
|
}
|
||||||
if debug_mode {
|
if debug_mode {
|
||||||
a << debug_options
|
args << debug_options
|
||||||
$if macos {
|
$if macos {
|
||||||
a << ' -ferror-limit=5000 '
|
args << ' -ferror-limit=5000 '
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v.pref.is_prod {
|
if v.pref.is_prod {
|
||||||
a << optimization_options
|
args << optimization_options
|
||||||
}
|
}
|
||||||
if debug_mode && os.user_os() != 'windows' {
|
if debug_mode && os.user_os() != 'windows' {
|
||||||
linker_flags << ' -rdynamic ' // needed for nicer symbolic backtraces
|
linker_flags << ' -rdynamic ' // needed for nicer symbolic backtraces
|
||||||
}
|
}
|
||||||
if ccompiler != 'msvc' && v.pref.os != .freebsd {
|
if ccompiler != 'msvc' && v.pref.os != .freebsd {
|
||||||
a << '-Werror=implicit-function-declaration'
|
args << '-Werror=implicit-function-declaration'
|
||||||
}
|
}
|
||||||
if v.pref.is_liveshared || v.pref.is_livemain {
|
if v.pref.is_liveshared || v.pref.is_livemain {
|
||||||
if v.pref.os == .linux || os.user_os() == 'linux' {
|
if v.pref.os == .linux || os.user_os() == 'linux' {
|
||||||
linker_flags << '-rdynamic'
|
linker_flags << '-rdynamic'
|
||||||
}
|
}
|
||||||
if v.pref.os == .mac || os.user_os() == 'mac' {
|
if v.pref.os == .mac || os.user_os() == 'mac' {
|
||||||
a << '-flat_namespace'
|
args << '-flat_namespace'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mut libs := '' // builtin.o os.o http.o etc
|
mut libs := '' // builtin.o os.o http.o etc
|
||||||
if v.pref.build_mode == .build_module {
|
if v.pref.build_mode == .build_module {
|
||||||
a << '-c'
|
args << '-c'
|
||||||
} else if v.pref.use_cache {
|
} else if v.pref.use_cache {
|
||||||
/*
|
/*
|
||||||
QTODO
|
QTODO
|
||||||
builtin_o_path := os.join_path(pref.default_module_path, 'cache', 'vlib', 'builtin.o')
|
builtin_o_path := os.join_path(pref.default_module_path, 'cache', 'vlib', 'builtin.o')
|
||||||
a << builtin_o_path.replace('builtin.o', 'strconv.o') // TODO hack no idea why this is needed
|
args << builtin_o_path.replace('builtin.o', 'strconv.o') // TODO hack no idea why this is needed
|
||||||
if os.exists(builtin_o_path) {
|
if os.exists(builtin_o_path) {
|
||||||
libs = builtin_o_path
|
libs = builtin_o_path
|
||||||
}
|
}
|
||||||
|
@ -330,12 +330,12 @@ fn (mut v Builder) cc() {
|
||||||
os.system('$vexe build-module vlib$os.path_separator$imp_path')
|
os.system('$vexe build-module vlib$os.path_separator$imp_path')
|
||||||
}
|
}
|
||||||
if path.ends_with('vlib/ui.o') {
|
if path.ends_with('vlib/ui.o') {
|
||||||
a << '-framework Cocoa -framework Carbon'
|
args << '-framework Cocoa -framework Carbon'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v.pref.sanitize {
|
if v.pref.sanitize {
|
||||||
a << '-fsanitize=leak'
|
args << '-fsanitize=leak'
|
||||||
}
|
}
|
||||||
// Cross compiling for linux
|
// Cross compiling for linux
|
||||||
if v.pref.os == .linux {
|
if v.pref.os == .linux {
|
||||||
|
@ -349,42 +349,42 @@ fn (mut v Builder) cc() {
|
||||||
// Output executable name
|
// Output executable name
|
||||||
if v.pref.os == .ios {
|
if v.pref.os == .ios {
|
||||||
bundle_name := v.pref.out_name.split('/').last()
|
bundle_name := v.pref.out_name.split('/').last()
|
||||||
a << '-o "$v.pref.out_name\.app/$bundle_name"'
|
args << '-o "$v.pref.out_name\.app/$bundle_name"'
|
||||||
} else {
|
} else {
|
||||||
a << '-o "$v.pref.out_name"'
|
args << '-o "$v.pref.out_name"'
|
||||||
}
|
}
|
||||||
if os.is_dir(v.pref.out_name) {
|
if os.is_dir(v.pref.out_name) {
|
||||||
verror("'$v.pref.out_name' is a directory")
|
verror("'$v.pref.out_name' is a directory")
|
||||||
}
|
}
|
||||||
// macOS code can include objective C TODO remove once objective C is replaced with C
|
// macOS code can include objective C TODO remove once objective C is replaced with C
|
||||||
if v.pref.os == .mac || v.pref.os == .ios {
|
if v.pref.os == .mac || v.pref.os == .ios {
|
||||||
a << '-x objective-c'
|
args << '-x objective-c'
|
||||||
}
|
}
|
||||||
// The C file we are compiling
|
// The C file we are compiling
|
||||||
a << '"$v.out_name_c"'
|
args << '"$v.out_name_c"'
|
||||||
if v.pref.os == .mac {
|
if v.pref.os == .mac {
|
||||||
a << '-x none'
|
args << '-x none'
|
||||||
}
|
}
|
||||||
// Min macos version is mandatory I think?
|
// Min macos version is mandatory I think?
|
||||||
if v.pref.os == .mac {
|
if v.pref.os == .mac {
|
||||||
a << '-mmacosx-version-min=10.7'
|
args << '-mmacosx-version-min=10.7'
|
||||||
}
|
}
|
||||||
if v.pref.os == .ios {
|
if v.pref.os == .ios {
|
||||||
a << '-miphoneos-version-min=10.0'
|
args << '-miphoneos-version-min=10.0'
|
||||||
}
|
}
|
||||||
if v.pref.os == .windows {
|
if v.pref.os == .windows {
|
||||||
a << '-municode'
|
args << '-municode'
|
||||||
}
|
}
|
||||||
cflags := v.get_os_cflags()
|
cflags := v.get_os_cflags()
|
||||||
// add .o files
|
// add .o files
|
||||||
a << cflags.c_options_only_object_files()
|
args << cflags.c_options_only_object_files()
|
||||||
// add all flags (-I -l -L etc) not .o files
|
// add all flags (-I -l -L etc) not .o files
|
||||||
a << cflags.c_options_without_object_files()
|
args << cflags.c_options_without_object_files()
|
||||||
a << libs
|
args << libs
|
||||||
// For C++ we must be very tolerant
|
// For C++ we must be very tolerant
|
||||||
if guessed_compiler.contains('++') {
|
if guessed_compiler.contains('++') {
|
||||||
a << '-fpermissive'
|
args << '-fpermissive'
|
||||||
a << '-w'
|
args << '-w'
|
||||||
}
|
}
|
||||||
if v.pref.use_cache {
|
if v.pref.use_cache {
|
||||||
// vexe := pref.vexe_path()
|
// vexe := pref.vexe_path()
|
||||||
|
@ -397,7 +397,7 @@ fn (mut v Builder) cc() {
|
||||||
println('$vexe build-module vlib/$cfile')
|
println('$vexe build-module vlib/$cfile')
|
||||||
os.system('$vexe build-module vlib/$cfile')
|
os.system('$vexe build-module vlib/$cfile')
|
||||||
}
|
}
|
||||||
a << ofile
|
args << ofile
|
||||||
}
|
}
|
||||||
if !is_cc_tcc {
|
if !is_cc_tcc {
|
||||||
$if linux {
|
$if linux {
|
||||||
|
@ -407,7 +407,7 @@ fn (mut v Builder) cc() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if is_cc_tcc {
|
if is_cc_tcc {
|
||||||
a << '-bt10'
|
args << '-bt10'
|
||||||
}
|
}
|
||||||
// Without these libs compilation will fail on Linux
|
// Without these libs compilation will fail on Linux
|
||||||
// || os.user_os() == 'linux'
|
// || os.user_os() == 'linux'
|
||||||
|
@ -427,14 +427,14 @@ fn (mut v Builder) cc() {
|
||||||
if !v.pref.is_bare && v.pref.os == .js && os.user_os() == 'linux' {
|
if !v.pref.is_bare && v.pref.os == .js && os.user_os() == 'linux' {
|
||||||
linker_flags << '-lm'
|
linker_flags << '-lm'
|
||||||
}
|
}
|
||||||
args := a.join(' ') + ' ' + linker_flags.join(' ')
|
str_args := args.join(' ') + ' ' + linker_flags.join(' ')
|
||||||
if v.pref.is_verbose {
|
if v.pref.is_verbose {
|
||||||
println('cc args=$args')
|
println('cc args=$str_args')
|
||||||
println(a)
|
println(args)
|
||||||
}
|
}
|
||||||
// write args to response file
|
// write args to response file
|
||||||
response_file := '${v.out_name_c}.rsp'
|
response_file := '${v.out_name_c}.rsp'
|
||||||
response_file_content := args.replace('\\', '\\\\')
|
response_file_content := str_args.replace('\\', '\\\\')
|
||||||
os.write_file(response_file, response_file_content) or {
|
os.write_file(response_file, response_file_content) or {
|
||||||
verror('Unable to write response file "$response_file"')
|
verror('Unable to write response file "$response_file"')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue