From 2d87fea074fee75ab016b270a29b1ede530f400d Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 27 Aug 2019 21:08:54 +0300 Subject: [PATCH] compiler: allow passing options to v run --- .travis.yml | 9 +++++---- compiler/main.v | 23 ++++++++++++++--------- make.bat | 1 + make_msvc.bat | 3 ++- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 527ae7ee1b..f299d1a246 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,14 +39,15 @@ script: - | if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries thirdparty/freetype/ - ##echo "Just running ./make.bat to produce v.exe" - ##./make.bat + echo "Just running ./make.bat to produce v.exe" + ./make.bat + ls -la v.exe + echo "Running v test v..." + ./v.exe test v ##echo "Running only the repl tests directly" ##./v.exe ./compiler/tests/repl/repl_test.v echo "Testing msvc bootstrapping" ./make_msvc.bat - echo "Running v test v..." - v.exe test v fi - | if [[ "${TRAVIS_OS_NAME}" != "windows" ]]; then diff --git a/compiler/main.v b/compiler/main.v index 19c8a540f3..400e2c537f 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -616,7 +616,11 @@ fn (v mut V) add_v_files_to_compile() { } fn get_arg(joined_args, arg, def string) string { - key := '-$arg ' + return get_all_after(joined_args, '-$arg', def) +} + +fn get_all_after(joined_args, arg, def string) string { + key := '$arg ' mut pos := joined_args.index(key) if pos == -1 { return def @@ -648,17 +652,18 @@ fn (v &V) log(s string) { } fn new_v(args[]string) *V { - mut dir := args.last() - if args.contains('run') { - dir = args[2] - } - // println('new compiler "$dir"') - if args.len < 2 { - dir = '' - } joined_args := args.join(' ') target_os := get_arg(joined_args, 'os', '') mut out_name := get_arg(joined_args, 'o', 'a.out') + + mut dir := args.last() + if args.contains('run') { + dir = get_all_after(joined_args, 'run', '') + } + if args.len < 2 { + dir = '' + } + // println('new compiler "$dir"') // build mode mut build_mode := BuildMode.default_mode mut mod := '' diff --git a/make.bat b/make.bat index 3fcb9bfc22..43eeea5307 100644 --- a/make.bat +++ b/make.bat @@ -1,4 +1,5 @@ rd /s /q vc +git version git clone --depth 1 --quiet https://github.com/vlang/vc gcc -std=gnu11 -DUNICODE -D_UNICODE -w -o v2.exe vc/v_win.c v2.exe -o v.exe compiler diff --git a/make_msvc.bat b/make_msvc.bat index ef235c6914..1482d3740f 100644 --- a/make_msvc.bat +++ b/make_msvc.bat @@ -28,11 +28,12 @@ if %ERRORLEVEL% GEQ 1 ( echo rebuild from source v2.exe -os msvc -o v.exe compiler - if %ERRORLEVEL% GEQ 1 ( goto :compileerror ) +dir v_win.c v2.exe v.exe + del .v_win.c.obj del v_win.c del v2.exe