1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

FreeBSD support

This commit is contained in:
Alexander Medvednikov 2019-07-15 17:24:40 +02:00
parent 92fb9c8b94
commit 7c6f59afa6
3 changed files with 11 additions and 2 deletions

View File

@ -29,7 +29,7 @@ fn vtmp_path() string {
}
const (
SupportedPlatforms = ['windows', 'mac', 'linux']
SupportedPlatforms = ['windows', 'mac', 'linux', 'freebsd']
TmpPath = vtmp_path()
)
@ -37,6 +37,7 @@ enum OS {
mac
linux
windows
freebsd
}
enum Pass {
@ -597,7 +598,7 @@ mut args := ''
a << '-x objective-c'
}
// Without these libs compilation will fail on Linux
if (v.os == .linux || os.user_os() == 'linux') && v.pref.build_mode != .build {
if (v.os == .linux || os.user_os() == 'linux' || v.os == .freebsd) && v.pref.build_mode != .build {
a << '-lm -ldl -lpthread'
}
// Find clang executable
@ -892,12 +893,16 @@ fn new_v(args[]string) *V {
$if windows {
_os = .windows
}
$if freebsd {
_os = .freebsd
}
}
else {
switch target_os {
case 'linux': _os = .linux
case 'windows': _os = .windows
case 'mac': _os = .mac
case 'freebsd': _os = .freebsd
}
}
builtins := [

View File

@ -2616,6 +2616,7 @@ fn os_name_to_ifdef(name string) string {
case 'windows': return '_WIN32'
case 'mac': return '__APPLE__'
case 'linux': return '__linux__'
case 'freebsd': return '__FreeBSD__'
}
panic('bad os ifdef name "$name"')
return ''

View File

@ -455,6 +455,9 @@ pub fn user_os() string {
$if windows {
return 'windows'
}
$if freebsd {
return 'freebsd'
}
return 'unknown'
}