mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
building modules can now be done from any directory
This commit is contained in:
parent
15d4f68af6
commit
a83e233dea
@ -16,6 +16,7 @@ fn todo() {
|
||||
fn (v mut V) cc() {
|
||||
v.build_thirdparty_obj_files()
|
||||
vexe := vexe_path()
|
||||
vdir := os.dir(vexe)
|
||||
// Just create a C/JavaScript file and exit
|
||||
// for example: `v -o v.c compiler`
|
||||
if v.out_name.ends_with('.c') || v.out_name.ends_with('.js') {
|
||||
@ -25,12 +26,11 @@ fn (v mut V) cc() {
|
||||
$if !js {
|
||||
if v.out_name.ends_with('.js') {
|
||||
vjs_path := vexe + 'js'
|
||||
dir := os.dir(vexe)
|
||||
if !os.file_exists(vjs_path) {
|
||||
println('V.js compiler not found, building...')
|
||||
// Build V.js. Specifying `-os js` makes V include
|
||||
// only _js.v files and ignore _c.v files.
|
||||
ret := os.system('$vexe -o $vjs_path -os js $dir/v.v')
|
||||
ret := os.system('$vexe -o $vjs_path -os js $vdir/v.v')
|
||||
if ret == 0 {
|
||||
println('Done.')
|
||||
} else {
|
||||
@ -67,7 +67,6 @@ fn (v mut V) cc() {
|
||||
if v.pref.fast {
|
||||
$if linux {
|
||||
$if !android {
|
||||
vdir := os.dir(vexe)
|
||||
tcc_3rd := '$vdir/thirdparty/tcc/bin/tcc'
|
||||
//println('tcc third "$tcc_3rd"')
|
||||
tcc_path := '/var/tmp/tcc/bin/tcc'
|
||||
@ -141,7 +140,7 @@ fn (v mut V) cc() {
|
||||
}
|
||||
|
||||
if v.pref.ccompiler != 'msvc' && v.os != .freebsd {
|
||||
//a << '-Werror=implicit-function-declaration'
|
||||
a << '-Werror=implicit-function-declaration'
|
||||
}
|
||||
|
||||
for f in v.generate_hotcode_reloading_compiler_flags() {
|
||||
@ -173,7 +172,6 @@ fn (v mut V) cc() {
|
||||
} else {
|
||||
println('$path not found... building module $imp')
|
||||
if path.ends_with('vlib/ui.o') {
|
||||
vdir := os.dir(vexe)
|
||||
println('copying ui...')
|
||||
os.cp('$vdir/thirdparty/ui/ui.o', path)
|
||||
os.cp('$vdir/thirdparty/ui/ui.vh', v_modules_path +
|
||||
|
@ -765,6 +765,9 @@ pub fn new_v(args[]string) &V {
|
||||
os.mkdir('$v_modules_path${os.path_separator}cache')
|
||||
}
|
||||
|
||||
// Location of all vlib files
|
||||
vroot := os.dir(vexe_path())
|
||||
|
||||
mut vgen_buf := strings.new_builder(1000)
|
||||
vgen_buf.writeln('module main\nimport strings')
|
||||
|
||||
@ -791,6 +794,7 @@ pub fn new_v(args[]string) &V {
|
||||
mut mod := ''
|
||||
if joined_args.contains('build module ') {
|
||||
build_mode = .build_module
|
||||
os.chdir(vroot)
|
||||
// v build module ~/v/os => os.o
|
||||
mod_path := if dir.contains('vlib') {
|
||||
dir.all_after('vlib'+os.path_separator)
|
||||
@ -880,8 +884,6 @@ pub fn new_v(args[]string) &V {
|
||||
else {
|
||||
_os = os_from_string(target_os)
|
||||
}
|
||||
// Location of all vlib files
|
||||
vroot := os.dir(vexe_path())
|
||||
//println('VROOT=$vroot')
|
||||
// v.exe's parent directory should contain vlib
|
||||
if !os.dir_exists(vroot) || !os.dir_exists(vroot + '/vlib/builtin') {
|
||||
|
Loading…
Reference in New Issue
Block a user