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 build-vbinaries
echo "DONE"

View File

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

View File

@ -62,7 +62,7 @@ pub fn (ts mut TestSession) test() {
ts.benchmark.step()
if show_stats {
println('-------------------------------------------------')
eprintln('-------------------------------------------------')
status := os.system(cmd)
if status == 0 {
ts.benchmark.ok()
@ -75,16 +75,16 @@ pub fn (ts mut TestSession) test() {
r := os.exec(cmd) or {
ts.benchmark.fail()
ts.failed = true
println(ts.benchmark.step_message('$relative_file ${ts.fail}'))
eprintln(ts.benchmark.step_message('$relative_file ${ts.fail}'))
continue
}
if r.exit_code != 0 {
ts.benchmark.fail()
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 {
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 )
@ -95,7 +95,7 @@ pub fn (ts mut TestSession) test() {
pub fn vlib_should_be_present( parent_dir string ) {
vlib_dir := filepath.join( parent_dir, 'vlib' )
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)
}
}
@ -107,7 +107,7 @@ pub fn v_build_failing(vargs string, folder string) bool {
parent_dir := os.dir(vexe)
vlib_should_be_present( parent_dir )
println(main_label)
eprintln(main_label)
mut session := new_test_sesion( vargs )
files := os.walk_ext(filepath.join(parent_dir, folder),'.v')
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.test()
println( session.benchmark.total_message( finish_label ) )
eprintln( session.benchmark.total_message( finish_label ) )
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') {
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)
}
*/
@ -37,38 +37,37 @@ fn v_test_compiler(vargs string){
if os.file_exists('/v.v') {
os.system('$vexe -o v.c v.v')
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)
}
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')
println('\nTesting all _test.v files...')
eprintln('\nTesting all _test.v files...')
mut compiler_test_session := testing.new_test_sesion( vargs )
compiler_test_session.files << os.walk_ext(parent_dir, '_test.v')
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')
eprintln('')
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()
ret := os.system(v_module_install_cmd)
if ret != 0 {
println('failed to run v install')
exit(1)
eprintln('failed to run v install')
}
if !os.file_exists(v_modules_path + '/nedpals/args') {
println('v failed to install a test module')
exit(1)
eprintln('v failed to install a test module')
}
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 {
exit(1)

2
v.v
View File

@ -25,7 +25,7 @@ fn main() {
stuff_after_executable := os.args[1..]
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 {
if tool in commands {
compiler.launch_tool('v$tool')