mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: support for custom flags
[if custom]fn..{} , #flag custom, $if custom {}
This commit is contained in:

committed by
Alexander Medvednikov

parent
42b1660c7e
commit
6e130cd446
@ -486,24 +486,47 @@ fn find_c_compiler_default() string {
|
||||
|
||||
fn find_c_compiler_thirdparty_options() string {
|
||||
fullargs := env_vflags_and_os_args()
|
||||
mut cflags := get_cmdline_cflags(fullargs)
|
||||
mut cflags := get_cmdline_multiple_values(fullargs,'-cflags')
|
||||
$if !windows {
|
||||
cflags += ' -fPIC'
|
||||
cflags << '-fPIC'
|
||||
}
|
||||
if '-m32' in fullargs {
|
||||
cflags += ' -m32'
|
||||
cflags << '-m32'
|
||||
}
|
||||
return cflags
|
||||
return cflags.join(' ')
|
||||
}
|
||||
|
||||
fn get_cmdline_cflags(args []string) string {
|
||||
mut cflags := ''
|
||||
fn get_cmdline_multiple_values(args []string, optname string) []string {
|
||||
mut flags := []string
|
||||
for ci, cv in args {
|
||||
if cv == '-cflags' {
|
||||
cflags += args[ci + 1] + ' '
|
||||
if cv == optname {
|
||||
flags << args[ci + 1]
|
||||
}
|
||||
}
|
||||
return cflags
|
||||
return flags
|
||||
}
|
||||
|
||||
fn parse_defines(defines []string) ([]string,[]string) {
|
||||
// '-d abc -d xyz=1 -d qwe=0' should produce:
|
||||
// compile_defines: ['abc','xyz']
|
||||
// compile_defines_all ['abc','xyz','qwe']
|
||||
mut compile_defines := []string
|
||||
mut compile_defines_all := []string
|
||||
for dfn in defines {
|
||||
dfn_parts := dfn.split('=')
|
||||
if dfn_parts.len == 1 {
|
||||
compile_defines << dfn
|
||||
compile_defines_all << dfn
|
||||
continue
|
||||
}
|
||||
if dfn_parts.len == 2 {
|
||||
compile_defines_all << dfn_parts[0]
|
||||
if dfn_parts[1] == '1' {
|
||||
compile_defines << dfn_parts[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
return compile_defines, compile_defines_all
|
||||
}
|
||||
|
||||
fn missing_compiler_info() string {
|
||||
|
Reference in New Issue
Block a user