v.pref: add get_build_facts_and_defines/0 and set_build_flags_and_defines/2

This commit is contained in:
Delyan Angelov 2025-05-10 11:26:04 +03:00
parent ed84fb9ce8
commit 469e268c79
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 25 additions and 14 deletions

View File

@ -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'

View File

@ -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
View 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() }
}