FreeBSD support

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

View File

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

View File

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