ci: fix -usecache for programs using thirdparty C libs
parent
9f31829e0c
commit
8398e2f448
|
@ -5,10 +5,10 @@ import term
|
||||||
import time
|
import time
|
||||||
|
|
||||||
const (
|
const (
|
||||||
vexe = os.getenv('VEXE')
|
vexe = os.getenv('VEXE')
|
||||||
vroot = os.dir(vexe)
|
vroot = os.dir(vexe)
|
||||||
args_string = os.args[1..].join(' ')
|
args_string = os.args[1..].join(' ')
|
||||||
vargs = args_string.all_before('test-all')
|
vargs = args_string.all_before('test-all')
|
||||||
)
|
)
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -49,6 +49,14 @@ mut:
|
||||||
|
|
||||||
fn get_all_commands() []Command {
|
fn get_all_commands() []Command {
|
||||||
mut res := []Command{}
|
mut res := []Command{}
|
||||||
|
res << Command{
|
||||||
|
line: '$vexe examples/hello_world.v'
|
||||||
|
okmsg: 'V can compile hello world.'
|
||||||
|
}
|
||||||
|
res << Command{
|
||||||
|
line: '$vexe -o vtmp cmd/v'
|
||||||
|
okmsg: 'V can compile itself.'
|
||||||
|
}
|
||||||
res << Command{
|
res << Command{
|
||||||
line: '$vexe $vargs -progress test-cleancode'
|
line: '$vexe $vargs -progress test-cleancode'
|
||||||
okmsg: 'All important .v files are invariant when processed with `v fmt`'
|
okmsg: 'All important .v files are invariant when processed with `v fmt`'
|
||||||
|
@ -78,6 +86,13 @@ fn get_all_commands() []Command {
|
||||||
line: '$vexe install nedpals.args'
|
line: '$vexe install nedpals.args'
|
||||||
okmsg: '`v install` works.'
|
okmsg: '`v install` works.'
|
||||||
}
|
}
|
||||||
|
// NB: test that a program that depends on thirdparty libraries with its
|
||||||
|
// own #flags (tetris depends on gg, which uses sokol) can be compiled
|
||||||
|
// with -usecache:
|
||||||
|
res << Command{
|
||||||
|
line: '$vexe -usecache examples/tetris/tetris.v'
|
||||||
|
okmsg: '`v -usecache` works.'
|
||||||
|
}
|
||||||
$if macos {
|
$if macos {
|
||||||
res << Command{
|
res << Command{
|
||||||
line: '$vexe -o v.c cmd/v && cc -Werror v.c && rm -rf v.c'
|
line: '$vexe -o v.c cmd/v && cc -Werror v.c && rm -rf v.c'
|
||||||
|
|
|
@ -174,6 +174,7 @@ mut:
|
||||||
//
|
//
|
||||||
args []string // ordinary C options like `-O2`
|
args []string // ordinary C options like `-O2`
|
||||||
wargs []string // for `-Wxyz` *exclusively*
|
wargs []string // for `-Wxyz` *exclusively*
|
||||||
|
pre_args []string // options that should go before .o_args
|
||||||
o_args []string // for `-o target`
|
o_args []string // for `-o target`
|
||||||
source_args []string // for `x.tmp.c`
|
source_args []string // for `x.tmp.c`
|
||||||
post_args []string // options that should go after .o_args
|
post_args []string // options that should go after .o_args
|
||||||
|
@ -321,8 +322,8 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
|
||||||
cflags := v.get_os_cflags()
|
cflags := v.get_os_cflags()
|
||||||
ccoptions.o_args << cflags.c_options_only_object_files()
|
ccoptions.o_args << cflags.c_options_only_object_files()
|
||||||
defines, others, libs := cflags.defines_others_libs()
|
defines, others, libs := cflags.defines_others_libs()
|
||||||
ccoptions.args << defines
|
ccoptions.pre_args << defines
|
||||||
ccoptions.args << others
|
ccoptions.pre_args << others
|
||||||
ccoptions.linker_flags << libs
|
ccoptions.linker_flags << libs
|
||||||
// TODO: why is this duplicated from above?
|
// TODO: why is this duplicated from above?
|
||||||
if v.pref.use_cache && v.pref.build_mode != .build_module {
|
if v.pref.use_cache && v.pref.build_mode != .build_module {
|
||||||
|
@ -382,6 +383,7 @@ fn (ccoptions CcompilerOptions) all_args() []string {
|
||||||
all << ccoptions.env_cflags
|
all << ccoptions.env_cflags
|
||||||
all << ccoptions.args
|
all << ccoptions.args
|
||||||
all << ccoptions.o_args
|
all << ccoptions.o_args
|
||||||
|
all << ccoptions.pre_args
|
||||||
all << ccoptions.source_args
|
all << ccoptions.source_args
|
||||||
all << ccoptions.post_args
|
all << ccoptions.post_args
|
||||||
all << ccoptions.linker_flags
|
all << ccoptions.linker_flags
|
||||||
|
@ -537,7 +539,7 @@ fn (mut v Builder) cc() {
|
||||||
//
|
//
|
||||||
mut libs := []string{} // builtin.o os.o http.o etc
|
mut libs := []string{} // builtin.o os.o http.o etc
|
||||||
if v.pref.build_mode == .build_module {
|
if v.pref.build_mode == .build_module {
|
||||||
v.ccoptions.args << '-c'
|
v.ccoptions.pre_args << '-c'
|
||||||
} else if v.pref.use_cache {
|
} else if v.pref.use_cache {
|
||||||
mut built_modules := []string{}
|
mut built_modules := []string{}
|
||||||
builtin_obj_path := v.rebuild_cached_module(vexe, 'vlib/builtin')
|
builtin_obj_path := v.rebuild_cached_module(vexe, 'vlib/builtin')
|
||||||
|
|
Loading…
Reference in New Issue