implement 'v build-vbinaries' tooling

pull/2951/head
Delyan Angelov 2019-12-01 15:12:51 +02:00 committed by Alexander Medvednikov
parent 5ff387bbe4
commit ee1edab2a9
7 changed files with 115 additions and 41 deletions

View File

@ -12,4 +12,6 @@ ls -lat
./v test-compiler ./v test-compiler
./v build-vbinaries
echo "DONE" echo "DONE"

View File

@ -37,6 +37,8 @@ jobs:
run: ./v -o v2 v.v && ./v2 -o v3 v.v run: ./v -o v2 v.v && ./v2 -o v3 v.v
- name: Test v->c - name: Test v->c
run: ./v test-compiler run: ./v test-compiler
- name: Test v binaries
run: ./v build-vbinaries
# - name: Test v->js # - name: Test v->js
# run: ./v -o hi.js examples/hello_v_js.v && node hi.js # run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test symlink - name: Test symlink
@ -59,6 +61,8 @@ jobs:
run: make && ./v -cc gcc -o v v.v run: make && ./v -cc gcc -o v v.v
- name: Test V - name: Test V
run: ./v test-compiler run: ./v test-compiler
- name: Test v binaries
run: ./v build-vbinaries
# - name: Test v->js # - name: Test v->js
# run: ./v -o hi.js examples/hello_v_js.v && node hi.js # run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Build Vorum - name: Build Vorum
@ -97,23 +101,27 @@ jobs:
ubuntu-tcc: ubuntu-tcc:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
env:
VFLAGS: -cc tcc
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Install dependencies - name: Install dependencies
run: sudo apt-get update; sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev run: sudo apt-get update; sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libssl-dev sqlite3 libsqlite3-dev
- name: Build v - name: Build v
run: make && ./v -o v v.v run: echo $VFLAGS && make && ./v -o v v.v
- name: Test v->c with tcc - name: Test v->c
env:
VFLAGS: -cc tcc
run: | run: |
sudo ln -s /var/tmp/tcc/bin/tcc /usr/local/bin/tcc sudo ln -s /var/tmp/tcc/bin/tcc /usr/local/bin/tcc
tcc -version tcc -version
./v -o v2 v.v # Make sure vtcc can build itself ./v -o v2 v.v # Make sure vtcc can build itself
./v test-compiler ./v test-compiler
- name: Test v binaries
run: ./v build-vbinaries
ubuntu-musl: ubuntu-musl:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
env:
VFLAGS: -cc musl-gcc
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
@ -122,14 +130,16 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: sudo apt-get update; sudo apt-get install --quiet -y musl musl-tools run: sudo apt-get update; sudo apt-get install --quiet -y musl musl-tools
- name: Build v - name: Build v
run: make && ./v -cc musl-gcc -o v v.v run: echo $VFLAGS && make && ./v -o v v.v
# - name: Test v->c - name: Test v binaries
# run: ./v test-compiler run: ./v build-vbinaries
# - name: Test v->js # - name: Test v->js
# run: ./v -o hi.js examples/hello_v_js.v && node hi.js # run: ./v -o hi.js examples/hello_v_js.v && node hi.js
windows-gcc: windows-gcc:
runs-on: windows-2019 runs-on: windows-2019
env:
VFLAGS: -cc gcc
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
#- uses: actions/setup-node@v1 #- uses: actions/setup-node@v1
@ -146,26 +156,30 @@ jobs:
## v.js dosent work on windows ## v.js dosent work on windows
#.\v.exe -o hi.js examples/hello_v_js.v #.\v.exe -o hi.js examples/hello_v_js.v
#node hi.js #node hi.js
- name: Test v binaries
run: ./v build-vbinaries
windows-msvc: windows-msvc:
runs-on: windows-2019 runs-on: windows-2019
env:
VFLAGS: -cc msvc
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
#- uses: actions/setup-node@v1 #- uses: actions/setup-node@v1
# with: # with:
# node-version: 12.x # node-version: 12.x
- name: Build - name: Build
env:
VFLAGS: -cc msvc
run: | run: |
echo %VFLAGS%
echo $VFLAGS
git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries.git thirdparty/freetype/ git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries.git thirdparty/freetype/
.\make.bat -msvc .\make.bat -msvc
- name: Test - name: Test
env:
VFLAGS: -cc msvc
run: | run: |
.\v.exe test-compiler .\v.exe test-compiler
## v.js dosent work on windows ## v.js dosent work on windows
#.\v.exe -o hi.js examples/hello_v_js.v #.\v.exe -o hi.js examples/hello_v_js.v
#node hi.js #node hi.js
- name: Test v binaries
run: ./v build-vbinaries

15
.gitignore vendored
View File

@ -6,25 +6,22 @@ fns.txt
/v.c /v.c
/v.*.c /v.*.c
/v.c.out /v.c.out
/v.exe
/tools/performance_compare /tools/performance_compare
/tools/performance_compare.exe /tools/performance_compare.exe
/tools/vrepl /tools/vrepl
/tools/vrepl.exe
/tools/vtest /tools/vtest
/tools/vtest.exe
/tools/vtest-compiler /tools/vtest-compiler
/tools/vtest-compiler.exe
/tools/vup /tools/vup
/tools/vup.exe
/tools/vpm /tools/vpm
/tools/vpm.exe
/tools/vcreate /tools/vcreate
/tools/vcreate.exe
/tools/vbuild-examples /tools/vbuild-examples
/tools/vbuild-examples.exe
/tools/vbuild-tools /tools/vbuild-tools
/tools/vbuild-tools.exe /tools/vbuild-vbinaries
/v_g
/v_cg
/v_prod
/v_prod_cg
/v_prod_g
*.exe *.exe
*.o *.o
.*.c .*.c

View File

@ -62,7 +62,7 @@ pub fn (ts mut TestSession) test() {
ts.benchmark.step() ts.benchmark.step()
if show_stats { if show_stats {
println('-------------------------------------------------') eprintln('-------------------------------------------------')
status := os.system(cmd) status := os.system(cmd)
if status == 0 { if status == 0 {
ts.benchmark.ok() ts.benchmark.ok()
@ -75,16 +75,16 @@ pub fn (ts mut TestSession) test() {
r := os.exec(cmd) or { r := os.exec(cmd) or {
ts.benchmark.fail() ts.benchmark.fail()
ts.failed = true ts.failed = true
println(ts.benchmark.step_message('$relative_file ${ts.fail}')) eprintln(ts.benchmark.step_message('$relative_file ${ts.fail}'))
continue continue
} }
if r.exit_code != 0 { if r.exit_code != 0 {
ts.benchmark.fail() ts.benchmark.fail()
ts.failed = true ts.failed = true
println(ts.benchmark.step_message('$relative_file ${ts.fail}\n`$file`\n (\n$r.output\n)')) eprintln(ts.benchmark.step_message('$relative_file ${ts.fail}\n`$file`\n (\n$r.output\n)'))
} else { } else {
ts.benchmark.ok() ts.benchmark.ok()
println(ts.benchmark.step_message('$relative_file ${ts.ok}')) eprintln(ts.benchmark.step_message('$relative_file ${ts.ok}'))
} }
} }
os.rm( tmpc_filepath ) os.rm( tmpc_filepath )
@ -95,7 +95,7 @@ pub fn (ts mut TestSession) test() {
pub fn vlib_should_be_present( parent_dir string ) { pub fn vlib_should_be_present( parent_dir string ) {
vlib_dir := filepath.join( parent_dir, 'vlib' ) vlib_dir := filepath.join( parent_dir, 'vlib' )
if !os.dir_exists( vlib_dir ){ if !os.dir_exists( vlib_dir ){
println('$vlib_dir is missing, it must be next to the V executable') eprintln('$vlib_dir is missing, it must be next to the V executable')
exit(1) exit(1)
} }
} }
@ -107,7 +107,7 @@ pub fn v_build_failing(vargs string, folder string) bool {
parent_dir := os.dir(vexe) parent_dir := os.dir(vexe)
vlib_should_be_present( parent_dir ) vlib_should_be_present( parent_dir )
println(main_label) eprintln(main_label)
mut session := new_test_sesion( vargs ) mut session := new_test_sesion( vargs )
files := os.walk_ext(filepath.join(parent_dir, folder),'.v') files := os.walk_ext(filepath.join(parent_dir, folder),'.v')
mains := files.filter(!it.contains('modules')) mains := files.filter(!it.contains('modules'))
@ -120,7 +120,60 @@ pub fn v_build_failing(vargs string, folder string) bool {
} }
session.files << rebuildable_mains session.files << rebuildable_mains
session.test() session.test()
println( session.benchmark.total_message( finish_label ) ) eprintln( session.benchmark.total_message( finish_label ) )
return session.failed return session.failed
} }
pub fn build_v_cmd_failed (cmd string) bool {
res := os.exec(cmd) or {
return true
}
if res.exit_code != 0 {
eprintln('')
eprintln( res.output )
return true
}
return false
}
pub fn building_any_v_binaries_failed() bool {
eprintln('Building V binaries...')
eprintln('VFLAGS is: "' + os.getenv('VFLAGS') + '"')
vexe := testing.vexe_path()
parent_dir := os.dir(vexe)
testing.vlib_should_be_present( parent_dir )
os.chdir( parent_dir )
mut failed := false
v_build_commands := [
// '$vexe -o v_g -g v.v',
// '$vexe -o v_prod_g -prod -g v.v',
'$vexe -o v_cg -cg v.v',
'$vexe -o v_prod_cg -prod -cg v.v',
'$vexe -o v_prod -prod v.v',
]
mut bmark := benchmark.new_benchmark()
bok := term.ok_message('OK')
bfail := term.fail_message('FAIL')
for cmd in v_build_commands {
bmark.step()
if build_v_cmd_failed(cmd) {
bmark.fail()
failed = true
eprintln(bmark.step_message('$cmd => ${bfail} . See details above ^^^^^^^'))
eprintln('')
continue
}
bmark.ok()
eprintln(bmark.step_message('$cmd => ${bok}'))
}
bmark.stop()
eprintln( bmark.total_message( 'building v binaries' ) )
return failed
}

View File

@ -0,0 +1,9 @@
module main
import testing
fn main() {
if testing.building_any_v_binaries_failed() {
exit(1)
}
}

View File

@ -27,7 +27,7 @@ fn v_test_compiler(vargs string){
/* /*
if !os.file_exists(parent_dir + '/v.v') { if !os.file_exists(parent_dir + '/v.v') {
println('v.v is missing, it must be next to the V executable') eprintln('v.v is missing, it must be next to the V executable')
exit(1) exit(1)
} }
*/ */
@ -37,38 +37,37 @@ fn v_test_compiler(vargs string){
if os.file_exists('/v.v') { if os.file_exists('/v.v') {
os.system('$vexe -o v.c v.v') os.system('$vexe -o v.c v.v')
if os.system('cc -Werror v.c') != 0 { if os.system('cc -Werror v.c') != 0 {
println('cc failed to build v.c without warnings') eprintln('cc failed to build v.c without warnings')
exit(1) exit(1)
} }
println('v.c can be compiled without warnings. This is good :)') eprintln('v.c can be compiled without warnings. This is good :)')
} }
} }
building_tools_failed := testing.v_build_failing(vargs, 'tools') building_tools_failed := testing.v_build_failing(vargs, 'tools')
println('\nTesting all _test.v files...') eprintln('\nTesting all _test.v files...')
mut compiler_test_session := testing.new_test_sesion( vargs ) mut compiler_test_session := testing.new_test_sesion( vargs )
compiler_test_session.files << os.walk_ext(parent_dir, '_test.v') compiler_test_session.files << os.walk_ext(parent_dir, '_test.v')
compiler_test_session.test() compiler_test_session.test()
println( compiler_test_session.benchmark.total_message('running V tests') ) eprintln( compiler_test_session.benchmark.total_message('running V tests') )
println('') eprintln('')
building_examples_failed := testing.v_build_failing(vargs, 'examples') building_examples_failed := testing.v_build_failing(vargs, 'examples')
eprintln('')
v_module_install_cmd := '$vexe install nedpals.args' v_module_install_cmd := '$vexe install nedpals.args'
println('\nInstalling a v module with: $v_module_install_cmd ') eprintln('\nInstalling a v module with: $v_module_install_cmd ')
mut vmark := benchmark.new_benchmark() mut vmark := benchmark.new_benchmark()
ret := os.system(v_module_install_cmd) ret := os.system(v_module_install_cmd)
if ret != 0 { if ret != 0 {
println('failed to run v install') eprintln('failed to run v install')
exit(1)
} }
if !os.file_exists(v_modules_path + '/nedpals/args') { if !os.file_exists(v_modules_path + '/nedpals/args') {
println('v failed to install a test module') eprintln('v failed to install a test module')
exit(1)
} }
vmark.stop() vmark.stop()
println( 'Installing a v module took: ' + vmark.total_duration().str() + 'ms') eprintln( 'Installing a v module took: ' + vmark.total_duration().str() + 'ms')
if building_tools_failed || compiler_test_session.failed || building_examples_failed { if building_tools_failed || compiler_test_session.failed || building_examples_failed {
exit(1) exit(1)

2
v.v
View File

@ -25,7 +25,7 @@ fn main() {
stuff_after_executable := os.args[1..] stuff_after_executable := os.args[1..]
commands := stuff_after_executable.filter(!it.starts_with('-')) commands := stuff_after_executable.filter(!it.starts_with('-'))
simple_tools := ['up', 'create', 'test', 'test-compiler', 'build-tools', 'build-examples'] simple_tools := ['up', 'create', 'test', 'test-compiler', 'build-tools', 'build-examples', 'build-vbinaries']
for tool in simple_tools { for tool in simple_tools {
if tool in commands { if tool in commands {
compiler.launch_tool('v$tool') compiler.launch_tool('v$tool')