From a83e233deaee706fb20c4866d21a1a05fbe0a871 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 1 Nov 2019 14:16:58 +0300 Subject: [PATCH] building modules can now be done from any directory --- vlib/compiler/cc.v | 8 +++----- vlib/compiler/main.v | 6 ++++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vlib/compiler/cc.v b/vlib/compiler/cc.v index 2bf840ee63..4885d38b5f 100644 --- a/vlib/compiler/cc.v +++ b/vlib/compiler/cc.v @@ -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 + diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index 2659370df1..1c46d7d41a 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -764,6 +764,9 @@ pub fn new_v(args[]string) &V { os.mkdir(v_modules_path) 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') {