From 2af18deca00d05738c535a8aa9b37b8e81c2d26f Mon Sep 17 00:00:00 2001 From: Kimihiro Nonaka Date: Mon, 19 Dec 2016 17:09:03 +0900 Subject: [PATCH] fix build on NetBSD/amd64. --- mbuild/base.py | 3 +++ mbuild/env.py | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mbuild/base.py b/mbuild/base.py index 32fff28..8d03003 100755 --- a/mbuild/base.py +++ b/mbuild/base.py @@ -158,6 +158,7 @@ _on_windows = False # cygwin or native windows _on_cygwin = False _on_linux = False _on_freebsd = False +_on_netbsd = False _operating_system_name = platform.system() if _operating_system_name.find('CYGWIN') != -1: _on_cygwin = True @@ -169,6 +170,8 @@ elif _operating_system_name == 'Linux': _on_linux = True elif _operating_system_name == 'FreeBSD': _on_freebsd = True +elif _operating_system_name == 'NetBSD': + _on_netbsd = True elif _operating_system_name == 'Darwin': _on_mac = True else: diff --git a/mbuild/env.py b/mbuild/env.py index 85baa37..984e1a0 100755 --- a/mbuild/env.py +++ b/mbuild/env.py @@ -143,7 +143,7 @@ class env_t(object): - System valuesE{:} - uname standard python tuple of values from uname. - - system standard valuesE{:} 'Linux', 'Windows', 'Darwin', 'Microsoft', 'FreeBSD' + - system standard valuesE{:} 'Linux', 'Windows', 'Darwin', 'Microsoft', 'FreeBSD', 'NetBSD' - hostname - build_os standard valuesE{:} 'lin', 'win', 'mac', 'bsd' - host_os standard valuesE{:} 'lin', 'win', 'mac', 'bsd' @@ -463,7 +463,7 @@ class env_t(object): #uses continue to work. self.env['target_cpu']=None - if self.env['system'] in [ 'Linux', 'FreeBSD']: + if self.env['system'] in [ 'Linux', 'FreeBSD', 'NetBSD']: uname = platform.uname() self.env['build_os'] = self._normalize_os_name(uname[0]) @@ -798,6 +798,13 @@ class env_t(object): (retval, output, error_output) = util.run_command(cmd) if retval == 0 and len(output)>0: n = int(output[0]) + elif self.on_netbsd(): + sysctl = "/sbin/sysctl" + if os.path.exists(sysctl): + cmd = "%s -n hw.ncpuonline" % (sysctl) + (retval, output, error_output) = util.run_command(cmd) + if retval == 0 and len(output)>0: + n = int(output[0]) else: f = '/proc/cpuinfo' proc_pat= re.compile(r'proces') @@ -1115,6 +1122,13 @@ class env_t(object): return True return False + def on_netbsd(self): + """@rtype: bool + @return: True iff on netbsd""" + if self.env['system'] == 'NetBSD': + return True + return False + def on_linux(self): """@rtype: bool @return: True iff on linux""" @@ -1199,7 +1213,7 @@ class env_t(object): return 'lin' elif name in ['mac', 'Darwin']: return 'mac' - elif name in ['bsd', 'FreeBSD']: + elif name in ['bsd', 'FreeBSD', 'NetBSD']: return 'bsd' elif name[0:6] == 'CYGWIN': return 'win' @@ -1315,7 +1329,7 @@ class env_t(object): def path_search(self,exe): path = os.environ['PATH'] - if self.on_freebsd() or self.on_linux() or self.on_cygwin(): + if self.on_freebsd() or self.on_linux() or self.on_cygwin() or self.on_netbsd(): sep = ':' else: sep = ';'