From 374781da1a0dfabfcb876c7701598618245f1b11 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 15 Jul 2019 20:18:05 +0200 Subject: [PATCH] OpenBSD, NetBSD, DragonFly support --- compiler/main.v | 21 +++++++++++++++++++-- compiler/parser.v | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index 0a99aec2a3..c1007c7f4a 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -29,7 +29,7 @@ fn vtmp_path() string { } const ( - SupportedPlatforms = ['windows', 'mac', 'linux', 'freebsd'] + SupportedPlatforms = ['windows', 'mac', 'linux', 'freebsd', 'openbsd', 'netbsd', 'dragonfly'] TmpPath = vtmp_path() ) @@ -38,6 +38,9 @@ enum OS { linux windows freebsd + openbsd + netbsd + dragonfly } enum Pass { @@ -607,7 +610,9 @@ mut args := '' a << '-x objective-c' } // Without these libs compilation will fail on Linux - if (v.os == .linux || os.user_os() == 'linux' || v.os == .freebsd) && v.pref.build_mode != .build { + // || os.user_os() == 'linux' + if v.pref.build_mode != .build && (v.os == .linux || v.os == .freebsd || v.os == .openbsd || + v.os == .netbsd || v.os == .dragonfly) { a << '-lm -ldl -lpthread' } // Find clang executable @@ -894,6 +899,15 @@ fn new_v(args[]string) *V { $if freebsd { _os = .freebsd } + $if openbsd { + _os = .openbsd + } + $if netbsd { + _os = .netbsd + } + $if dragonfly { + _os = .dragonfly + } } else { switch target_os { @@ -901,6 +915,9 @@ fn new_v(args[]string) *V { case 'windows': _os = .windows case 'mac': _os = .mac case 'freebsd': _os = .freebsd + case 'openbsd': _os = .openbsd + case 'netbsd': _os = .netbsd + case 'dragonfly': _os = .dragonfly } } builtins := [ diff --git a/compiler/parser.v b/compiler/parser.v index 744f80404b..56ff18ec78 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -2617,6 +2617,9 @@ fn os_name_to_ifdef(name string) string { case 'mac': return '__APPLE__' case 'linux': return '__linux__' case 'freebsd': return '__FreeBSD__' + case 'openbsd': return '__OpenBSD__' + case 'netbsd': return '__NetBSD__' + case 'dragonfly': return '__DragonFly__' } panic('bad os ifdef name "$name"') return ''