make V compilable on Windows with mingw-w64
parent
d8caa6431f
commit
1bcccf0d1e
|
@ -523,7 +523,7 @@ mut args := ''
|
||||||
}
|
}
|
||||||
println('linux cross compilation done. resulting binary: "$c.out_name"')
|
println('linux cross compilation done. resulting binary: "$c.out_name"')
|
||||||
}
|
}
|
||||||
// print_time('after gcc')
|
//os.rm('$TmpPath/$c.out_name_c')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (c &V) v_files_from_dir(dir string) []string {
|
fn (c &V) v_files_from_dir(dir string) []string {
|
||||||
|
@ -851,6 +851,10 @@ fn new_v(args[]string) *V {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_repl() []string {
|
fn run_repl() []string {
|
||||||
|
if $windows {
|
||||||
|
println('REPL does not work on Windows yet, sorry!')
|
||||||
|
exit1()
|
||||||
|
}
|
||||||
println('V $Version')
|
println('V $Version')
|
||||||
println('Use Ctrl-D to exit')
|
println('Use Ctrl-D to exit')
|
||||||
println('For now you have to use println() to print values, this will be fixed soon\n')
|
println('For now you have to use println() to print values, this will be fixed soon\n')
|
||||||
|
@ -900,6 +904,7 @@ Options:
|
||||||
-obf Obfuscate the resulting binary.
|
-obf Obfuscate the resulting binary.
|
||||||
run Build and execute a V program.
|
run Build and execute a V program.
|
||||||
You can add arguments after file name.
|
You can add arguments after file name.
|
||||||
|
|
||||||
Files:
|
Files:
|
||||||
<file>_test.v Test file.
|
<file>_test.v Test file.
|
||||||
'
|
'
|
||||||
|
|
24
os/os.v
24
os/os.v
|
@ -271,12 +271,22 @@ pub fn getenv(key string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setenv(name string, value string, overwrite bool) int {
|
pub fn setenv(name string, value string, overwrite bool) int {
|
||||||
|
$if windows {
|
||||||
|
|
||||||
|
}
|
||||||
|
$else {
|
||||||
return C.setenv(name.cstr(), value.cstr(), overwrite)
|
return C.setenv(name.cstr(), value.cstr(), overwrite)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn unsetenv(name string) int {
|
pub fn unsetenv(name string) int {
|
||||||
|
$if windows {
|
||||||
|
|
||||||
|
}
|
||||||
|
$else {
|
||||||
return C.unsetenv(name.cstr())
|
return C.unsetenv(name.cstr())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// `file_exists` returns true if `path` exists.
|
// `file_exists` returns true if `path` exists.
|
||||||
pub fn file_exists(path string) bool {
|
pub fn file_exists(path string) bool {
|
||||||
|
@ -370,21 +380,30 @@ pub fn filename(path string) string {
|
||||||
//Otherwise, it would cause a valgrind warning and may be dangerous
|
//Otherwise, it would cause a valgrind warning and may be dangerous
|
||||||
//Malloc takes an int as argument so a cast has to be made
|
//Malloc takes an int as argument so a cast has to be made
|
||||||
pub fn get_line() string {
|
pub fn get_line() string {
|
||||||
|
$if windows {
|
||||||
|
panic('get_line() not implemented on Windows yet, sorry!')
|
||||||
|
}
|
||||||
|
$else {
|
||||||
max := u64(256)
|
max := u64(256)
|
||||||
buf := malloc(int(max))
|
buf := malloc(int(max))
|
||||||
nr_chars := C.getline(&buf, &max, stdin)
|
nr_chars := C.getline(&buf, &max, stdin)
|
||||||
if nr_chars == 0 {
|
if nr_chars == 0 {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
if buf[nr_chars - 1] == `\n` /* newline */ {
|
if buf[nr_chars - 1] == `\n` { // newline
|
||||||
return tos(buf, nr_chars - 1)
|
return tos(buf, nr_chars - 1)
|
||||||
}
|
}
|
||||||
/* To prevent cutting end of line if no newline */
|
// To prevent cutting end of line if no newline
|
||||||
return tos(buf, nr_chars)
|
return tos(buf, nr_chars)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_raw_line returns a one-line string from stdin along with '\n' if there is any
|
// get_raw_line returns a one-line string from stdin along with '\n' if there is any
|
||||||
pub fn get_raw_line() string {
|
pub fn get_raw_line() string {
|
||||||
|
$if windows {
|
||||||
|
panic('get_raw_line() not implemented on Windows yet, sorry!')
|
||||||
|
}
|
||||||
|
$else {
|
||||||
max := u64(256)
|
max := u64(256)
|
||||||
buf := malloc(int(max))
|
buf := malloc(int(max))
|
||||||
nr_chars := C.getline(&buf, &max, stdin)
|
nr_chars := C.getline(&buf, &max, stdin)
|
||||||
|
@ -392,6 +411,7 @@ pub fn get_raw_line() string {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
return tos(buf, nr_chars)
|
return tos(buf, nr_chars)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn user_os() string {
|
pub fn user_os() string {
|
||||||
|
|
Loading…
Reference in New Issue