mirror of
https://github.com/vlang/v.git
synced 2025-09-08 14:51:53 -04:00
v.pref: add get_build_facts_and_defines/0 and set_build_flags_and_defines/2
This commit is contained in:
parent
ed84fb9ce8
commit
469e268c79
@ -885,8 +885,7 @@ pub const is_started_mysqld = find_started_process('mysqld') or { '' }
|
||||
pub const is_started_postgres = find_started_process('postgres') or { '' }
|
||||
|
||||
pub fn (mut ts TestSession) setup_build_environment() {
|
||||
facts := os.getenv('VBUILD_FACTS').split_any(',')
|
||||
mut defines := os.getenv('VBUILD_DEFINES').split_any(',')
|
||||
facts, mut defines := pref.get_build_facts_and_defines()
|
||||
// add the runtime information, that the test runner has already determined by checking once:
|
||||
if is_started_mysqld != '' {
|
||||
defines << 'started_mysqld'
|
||||
|
13
cmd/v/v.v
13
cmd/v/v.v
@ -241,18 +241,7 @@ fn setup_vbuild_env_vars(prefs &pref.Preferences) {
|
||||
if github_job != '' {
|
||||
facts << github_job
|
||||
}
|
||||
sfacts := facts.join(',')
|
||||
os.setenv('VBUILD_FACTS', sfacts, true)
|
||||
|
||||
sdefines := prefs.compile_defines_all.join(',')
|
||||
os.setenv('VBUILD_DEFINES', sdefines, true)
|
||||
|
||||
$if trace_vbuild ? {
|
||||
eprintln('> VBUILD_FACTS: ${sfacts}')
|
||||
eprintln('> VBUILD_DEFINES: ${sdefines}')
|
||||
}
|
||||
unsafe { sdefines.free() }
|
||||
unsafe { sfacts.free() }
|
||||
pref.set_build_flags_and_defines(facts, prefs.compile_defines_all)
|
||||
unsafe { github_job.free() }
|
||||
unsafe { facts.free() }
|
||||
}
|
||||
|
23
vlib/v/pref/build_flags.v
Normal file
23
vlib/v/pref/build_flags.v
Normal file
@ -0,0 +1,23 @@
|
||||
module pref
|
||||
|
||||
import os
|
||||
|
||||
pub fn get_build_facts_and_defines() ([]string, []string) {
|
||||
facts := os.getenv('VBUILD_FACTS').split_any(',')
|
||||
defines := os.getenv('VBUILD_DEFINES').split_any(',')
|
||||
return facts, defines
|
||||
}
|
||||
|
||||
@[manualfree]
|
||||
pub fn set_build_flags_and_defines(facts []string, defines []string) {
|
||||
sfacts := facts.join(',')
|
||||
sdefines := defines.join(',')
|
||||
os.setenv('VBUILD_FACTS', sfacts, true)
|
||||
os.setenv('VBUILD_DEFINES', sdefines, true)
|
||||
$if trace_vbuild ? {
|
||||
eprintln('> VBUILD_FACTS: ${sfacts}')
|
||||
eprintln('> VBUILD_DEFINES: ${sdefines}')
|
||||
}
|
||||
unsafe { sdefines.free() }
|
||||
unsafe { sfacts.free() }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user