1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: fix -usecache for programs using thirdparty C libs

This commit is contained in:
Delyan Angelov 2021-01-29 19:40:39 +02:00
parent 9f31829e0c
commit 8398e2f448
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 23 additions and 6 deletions

View File

@ -49,6 +49,14 @@ mut:
fn get_all_commands() []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{
line: '$vexe $vargs -progress test-cleancode'
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'
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 {
res << Command{
line: '$vexe -o v.c cmd/v && cc -Werror v.c && rm -rf v.c'

View File

@ -174,6 +174,7 @@ mut:
//
args []string // ordinary C options like `-O2`
wargs []string // for `-Wxyz` *exclusively*
pre_args []string // options that should go before .o_args
o_args []string // for `-o target`
source_args []string // for `x.tmp.c`
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()
ccoptions.o_args << cflags.c_options_only_object_files()
defines, others, libs := cflags.defines_others_libs()
ccoptions.args << defines
ccoptions.args << others
ccoptions.pre_args << defines
ccoptions.pre_args << others
ccoptions.linker_flags << libs
// TODO: why is this duplicated from above?
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.args
all << ccoptions.o_args
all << ccoptions.pre_args
all << ccoptions.source_args
all << ccoptions.post_args
all << ccoptions.linker_flags
@ -537,7 +539,7 @@ fn (mut v Builder) cc() {
//
mut libs := []string{} // builtin.o os.o http.o etc
if v.pref.build_mode == .build_module {
v.ccoptions.args << '-c'
v.ccoptions.pre_args << '-c'
} else if v.pref.use_cache {
mut built_modules := []string{}
builtin_obj_path := v.rebuild_cached_module(vexe, 'vlib/builtin')