mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tools: make v self
compile with tcc on Apple M1, since it is faster, and tcc now can handle it (#17409)
This commit is contained in:
parent
4c13a4c22c
commit
00aecf92e7
@ -2,11 +2,15 @@ module main
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import os.cmdline
|
import os.cmdline
|
||||||
import v.pref
|
|
||||||
import v.util.recompilation
|
import v.util.recompilation
|
||||||
|
|
||||||
const is_debug = os.args.contains('-debug')
|
const is_debug = os.args.contains('-debug')
|
||||||
|
|
||||||
|
// support a renamed `v` executable too:
|
||||||
|
const vexe = os.getenv_opt('VEXE') or { @VEXE }
|
||||||
|
|
||||||
|
const vroot = os.dir(vexe)
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// make testing `v up` easier, by providing a way to force `v self` to fail,
|
// make testing `v up` easier, by providing a way to force `v self` to fail,
|
||||||
// to test the fallback logic:
|
// to test the fallback logic:
|
||||||
@ -14,16 +18,24 @@ fn main() {
|
|||||||
eprintln('v self failed')
|
eprintln('v self failed')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
// support a renamed `v` executable too:
|
|
||||||
vexe := pref.vexe_path()
|
|
||||||
vroot := os.dir(vexe)
|
|
||||||
vexe_name := os.file_name(vexe)
|
vexe_name := os.file_name(vexe)
|
||||||
short_v_name := vexe_name.all_before('.')
|
short_v_name := vexe_name.all_before('.')
|
||||||
//
|
//
|
||||||
recompilation.must_be_enabled(vroot, 'Please install V from source, to use `${vexe_name} self` .')
|
recompilation.must_be_enabled(vroot, 'Please install V from source, to use `${vexe_name} self` .')
|
||||||
os.chdir(vroot)!
|
os.chdir(vroot)!
|
||||||
os.setenv('VCOLORS', 'always', true)
|
os.setenv('VCOLORS', 'always', true)
|
||||||
args := os.args[1..].filter(it != 'self')
|
mut args := os.args[1..].filter(it != 'self')
|
||||||
|
if args.len == 0 || ('-cc' !in args && '-prod' !in args) {
|
||||||
|
// compiling by default, i.e. `v self`:
|
||||||
|
uos := os.user_os()
|
||||||
|
uname := os.uname()
|
||||||
|
if uos == 'macos' && uname.machine == 'arm64' {
|
||||||
|
// Apple silicon, like m1, m2 etc
|
||||||
|
// Use tcc by default for V, since tinycc is much faster and also
|
||||||
|
// it already supports compiling many programs like V itself, that do not depend on inlined objective-C code
|
||||||
|
args << '-cc tcc'
|
||||||
|
}
|
||||||
|
}
|
||||||
jargs := args.join(' ')
|
jargs := args.join(' ')
|
||||||
obinary := cmdline.option(args, '-o', '')
|
obinary := cmdline.option(args, '-o', '')
|
||||||
sargs := if obinary != '' { jargs } else { '${jargs} -o v2' }
|
sargs := if obinary != '' { jargs } else { '${jargs} -o v2' }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user