more windows fixes + bring back windows ci

pull/4195/head
Alexander Medvednikov 2020-04-02 13:44:46 +02:00
parent 1178bfa578
commit 5b835d294c
6 changed files with 28 additions and 30 deletions

View File

@ -257,10 +257,10 @@ jobs:
run: | run: |
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/
.\.github\workflows\windows-install-sdl.bat .\.github\workflows\windows-install-sdl.bat
# - name: Build - name: Build
# run: | run: |
# gcc --version gcc --version
# .\make.bat -gcc .\make.bat -gcc
# - name: Test # - name: Test
# run: | # run: |
# .\v.exe -silent test-compiler # .\v.exe -silent test-compiler

View File

@ -52,7 +52,8 @@ fn find_windows_kit_internal(key RegKey, versions []string) ?string {
if value[length - 1] != u16(0) { if value[length - 1] != u16(0) {
value[length] = u16(0) value[length] = u16(0)
} }
return string_from_wide(value) res := string_from_wide(value)
return res
} }
} }
} }

View File

@ -2,7 +2,7 @@ module os
// Ref - winnt.h // Ref - winnt.h
const ( const (
SUCCESS = 0 // ERROR_SUCCESS success = 0 // ERROR_SUCCESS
ERROR_INSUFFICIENT_BUFFER = 130 ERROR_INSUFFICIENT_BUFFER = 130
) )
@ -77,7 +77,7 @@ const (
ENABLE_INSERT_MODE = 0x0020 ENABLE_INSERT_MODE = 0x0020
ENABLE_LINE_INPUT = 0x0002 ENABLE_LINE_INPUT = 0x0002
ENABLE_MOUSE_INPUT = 0x0010 ENABLE_MOUSE_INPUT = 0x0010
ENABLE_PROCESSED_INPUT = 0x0001 ENABLE_PROCESSED_INPUT = 0x0001
ENABLE_QUICK_EDIT_MODE = 0x0040 ENABLE_QUICK_EDIT_MODE = 0x0040
ENABLE_WINDOW_INPUT = 0x0008 ENABLE_WINDOW_INPUT = 0x0008
ENABLE_VIRTUAL_TERMINAL_INPUT = 0x0200 ENABLE_VIRTUAL_TERMINAL_INPUT = 0x0200

View File

@ -198,14 +198,13 @@ pub fn get_file_handle(path string) HANDLE {
// get_module_filename retrieves the fully qualified path for the file that contains the specified module. // get_module_filename retrieves the fully qualified path for the file that contains the specified module.
// The module must have been loaded by the current process. // The module must have been loaded by the current process.
pub fn get_module_filename(handle HANDLE) ?string { pub fn get_module_filename(handle HANDLE) ?string {
success := C.SUCCESS
unsafe { unsafe {
mut sz := 4096 // Optimized length mut sz := 4096 // Optimized length
mut buf := &u16(malloc(4096)) mut buf := &u16(malloc(4096))
for { for {
status := int(C.GetModuleFileNameW(handle, voidptr(&buf), sz)) status := int(C.GetModuleFileNameW(handle, voidptr(&buf), sz))
match status { match status {
success { os.success {
_filename := string_from_wide2(buf, sz) _filename := string_from_wide2(buf, sz)
return _filename return _filename
} }

View File

@ -7,7 +7,6 @@ import (
v.depgraph v.depgraph
v.token v.token
v.pref v.pref
v.util
term term
) )
@ -99,13 +98,7 @@ pub fn cgen(files []ast.File, table &table.Table, pref &pref.Preferences) string
if g.is_test { if g.is_test {
g.write_tests_main() g.write_tests_main()
} }
return g.hashes() + g.typedefs.str() + g.definitions.str() + g.out.str() return c_commit_hash_default + g.typedefs.str() + g.definitions.str() + g.out.str()
}
pub fn (g &Gen) hashes() string {
mut res := c_commit_hash_default.replace('@@@', util.vhash() )
res += c_current_commit_hash_default.replace('@@@', util.githash( g.pref.building_v ) )
return res
} }
pub fn (g mut Gen) init() { pub fn (g mut Gen) init() {
@ -1103,8 +1096,12 @@ fn (g mut Gen) expr(node ast.Expr) {
*/ */
ast.SizeOf { ast.SizeOf {
styp := g.typ(it.typ) if it.type_name != '' {
g.write('sizeof($styp)') g.write('sizeof($it.type_name)')
} else {
styp := g.typ(it.typ)
g.write('sizeof($styp)')
}
} }
ast.StringLiteral { ast.StringLiteral {
if it.is_raw { if it.is_raw {

View File

@ -776,21 +776,22 @@ pub fn (p mut Parser) expr(precedence int) ast.Expr {
.key_sizeof { .key_sizeof {
p.next() // sizeof p.next() // sizeof
p.check(.lpar) p.check(.lpar)
if p.tok.lit == 'C' {
p.next()
p.check(.dot)
}
if p.tok.kind == .amp { if p.tok.kind == .amp {
p.next() p.next()
} }
// type_name := p.check_name() if p.tok.lit == 'C' {
sizeof_type := p.parse_type() p.next()
p.check(.rpar) p.check(.dot)
node = ast.SizeOf{ node = ast.SizeOf{
typ: sizeof_type type_name: p.check_name()
// type_name: type_name }
} else {
sizeof_type := p.parse_type()
node = ast.SizeOf{
typ: sizeof_type
}
} }
p.check(.rpar)
} }
.key_typeof { .key_typeof {
p.next() p.next()