mirror of
https://git.rtems.org/rtems-tools/
synced 2025-07-25 07:23:11 +08:00
rtemstoolkit: Move host support access into a separate module.
Moving the host support into a module lets it get used where options is not being used.
This commit is contained in:
parent
15a3e06518
commit
7d3350d0bb
@ -51,12 +51,14 @@ import sys
|
|||||||
try:
|
try:
|
||||||
from . import error
|
from . import error
|
||||||
from . import execute
|
from . import execute
|
||||||
|
from . import host
|
||||||
from . import log
|
from . import log
|
||||||
from . import options
|
from . import options
|
||||||
from . import path
|
from . import path
|
||||||
except (ValueError, SystemError):
|
except (ValueError, SystemError):
|
||||||
import error
|
import error
|
||||||
import execute
|
import execute
|
||||||
|
import host
|
||||||
import log
|
import log
|
||||||
import options
|
import options
|
||||||
import path
|
import path
|
||||||
@ -211,7 +213,7 @@ class file(object):
|
|||||||
if len(sl):
|
if len(sl):
|
||||||
e = execute.capture_execution()
|
e = execute.capture_execution()
|
||||||
for s in sl:
|
for s in sl:
|
||||||
if options.host_windows:
|
if host.is_windows:
|
||||||
cmd = '%s -c "%s"' % (self.macros.expand('%{__sh}'), s[2:-1])
|
cmd = '%s -c "%s"' % (self.macros.expand('%{__sh}'), s[2:-1])
|
||||||
else:
|
else:
|
||||||
cmd = s[2:-1]
|
cmd = s[2:-1]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# RTEMS Tools Project (http://www.rtems.org/)
|
# RTEMS Tools Project (http://www.rtems.org/)
|
||||||
# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
|
# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
||||||
@ -44,15 +44,19 @@ try:
|
|||||||
except (ValueError, SystemError):
|
except (ValueError, SystemError):
|
||||||
import execute
|
import execute
|
||||||
|
|
||||||
def load():
|
def cpus():
|
||||||
uname = os.uname()
|
|
||||||
sysctl = '/usr/sbin/sysctl '
|
sysctl = '/usr/sbin/sysctl '
|
||||||
e = execute.capture_execution()
|
e = execute.capture_execution()
|
||||||
exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
|
exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
|
||||||
if exit_code == 0:
|
if exit_code == 0:
|
||||||
ncpus = output.split(' ')[1].strip()
|
ncpus = int(output.split(' ')[1].strip())
|
||||||
else:
|
else:
|
||||||
ncpus = '1'
|
ncpus = 1
|
||||||
|
return ncpus
|
||||||
|
|
||||||
|
def overrides():
|
||||||
|
uname = os.uname()
|
||||||
|
ncpus = '%d' % (cores())
|
||||||
defines = {
|
defines = {
|
||||||
'_ncpus': ('none', 'none', ncpus),
|
'_ncpus': ('none', 'none', ncpus),
|
||||||
'_os': ('none', 'none', 'darwin'),
|
'_os': ('none', 'none', 'darwin'),
|
||||||
@ -83,4 +87,5 @@ def load():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import pprint
|
import pprint
|
||||||
pprint.pprint(load())
|
pprint.pprint(cpus())
|
||||||
|
pprint.pprint(overrides())
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# RTEMS Tools Project (http://www.rtems.org/)
|
# RTEMS Tools Project (http://www.rtems.org/)
|
||||||
# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
|
# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
||||||
@ -33,7 +33,6 @@
|
|||||||
# RTEMS project's spec files.
|
# RTEMS project's spec files.
|
||||||
#
|
#
|
||||||
|
|
||||||
import pprint
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -47,15 +46,19 @@ except (ValueError, SystemError):
|
|||||||
import check
|
import check
|
||||||
import execute
|
import execute
|
||||||
|
|
||||||
def load():
|
def cpus():
|
||||||
uname = os.uname()
|
|
||||||
sysctl = '/sbin/sysctl '
|
sysctl = '/sbin/sysctl '
|
||||||
e = execute.capture_execution()
|
e = execute.capture_execution()
|
||||||
exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
|
exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
|
||||||
if exit_code == 0:
|
if exit_code == 0:
|
||||||
ncpus = output.split(' ')[1].strip()
|
ncpus = int(output.split(' ')[1].strip())
|
||||||
else:
|
else:
|
||||||
ncpus = '1'
|
ncpus = 1
|
||||||
|
return ncpus
|
||||||
|
|
||||||
|
def overrides():
|
||||||
|
uname = os.uname()
|
||||||
|
ncpus = '%d' % (cpus())
|
||||||
if uname[4] == 'amd64':
|
if uname[4] == 'amd64':
|
||||||
cpu = 'x86_64'
|
cpu = 'x86_64'
|
||||||
else:
|
else:
|
||||||
@ -104,4 +107,6 @@ def load():
|
|||||||
return defines
|
return defines
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pprint.pprint(load())
|
import pprint
|
||||||
|
pprint.pprint(cpus())
|
||||||
|
pprint.pprint(overrides())
|
||||||
|
111
rtemstoolkit/host.py
Normal file
111
rtemstoolkit/host.py
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
#
|
||||||
|
# RTEMS Tools Project (http://www.rtems.org/)
|
||||||
|
# Copyright 2017 Chris Johns (chrisj@rtems.org)
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Host specifics.
|
||||||
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
#
|
||||||
|
# Support to handle use in a package and as a unit test.
|
||||||
|
# If there is a better way to let us know.
|
||||||
|
#
|
||||||
|
try:
|
||||||
|
from . import error
|
||||||
|
except (ValueError, SystemError):
|
||||||
|
import error
|
||||||
|
|
||||||
|
is_windows = False
|
||||||
|
platform = None
|
||||||
|
name = None
|
||||||
|
|
||||||
|
def _load():
|
||||||
|
|
||||||
|
global is_windows
|
||||||
|
global platform
|
||||||
|
global name
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
name = 'windows'
|
||||||
|
is_windows = True
|
||||||
|
elif os.name == 'posix':
|
||||||
|
uname = os.uname()
|
||||||
|
if uname[0].startswith('CYGWIN_NT'):
|
||||||
|
name = 'windows'
|
||||||
|
elif uname[0] == 'Darwin':
|
||||||
|
name = darwin
|
||||||
|
elif uname[0] == 'FreeBSD':
|
||||||
|
name = 'freebsd'
|
||||||
|
elif uname[0] == 'NetBSD':
|
||||||
|
name = netbsd
|
||||||
|
elif uname[0] == 'Linux':
|
||||||
|
name = 'linux'
|
||||||
|
elif uname[0] == 'SunOS':
|
||||||
|
name = 'solaris'
|
||||||
|
|
||||||
|
if name is None:
|
||||||
|
raise error.general('unsupported host type; please add')
|
||||||
|
|
||||||
|
#try:
|
||||||
|
# try:
|
||||||
|
# platform = __import__(name, globals(), locals(), ['.'])
|
||||||
|
# except:
|
||||||
|
# platform = __import__(name, globals(), locals())
|
||||||
|
#except:
|
||||||
|
# raise error.general('failed to load %s host support' % (name))
|
||||||
|
|
||||||
|
platform = __import__(name, globals(), locals(), ['.', ''])
|
||||||
|
|
||||||
|
if platform is None:
|
||||||
|
raise error.general('failed to load %s host support' % (name))
|
||||||
|
|
||||||
|
def cpus():
|
||||||
|
_load()
|
||||||
|
return platform.cpus()
|
||||||
|
|
||||||
|
def overrides():
|
||||||
|
_load()
|
||||||
|
return platform.overrides()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import pprint
|
||||||
|
_load()
|
||||||
|
print('Name : %s' % (name))
|
||||||
|
if is_windows:
|
||||||
|
status = 'Yes'
|
||||||
|
else:
|
||||||
|
status = 'No'
|
||||||
|
print('Windows : %s' % (status))
|
||||||
|
print('CPUs : %d' % (cpus()))
|
||||||
|
print('Overrides :')
|
||||||
|
pprint.pprint(overrides())
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# RTEMS Tools Project (http://www.rtems.org/)
|
# RTEMS Tools Project (http://www.rtems.org/)
|
||||||
# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
|
# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
||||||
@ -33,7 +33,6 @@
|
|||||||
# RTEMS project's spec files.
|
# RTEMS project's spec files.
|
||||||
#
|
#
|
||||||
|
|
||||||
import pprint
|
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
@ -48,9 +47,7 @@ except (ValueError, SystemError):
|
|||||||
import execute
|
import execute
|
||||||
import path
|
import path
|
||||||
|
|
||||||
def load():
|
def cpus():
|
||||||
uname = os.uname()
|
|
||||||
smp_mflags = ''
|
|
||||||
processors = '/bin/grep processor /proc/cpuinfo'
|
processors = '/bin/grep processor /proc/cpuinfo'
|
||||||
e = execute.capture_execution()
|
e = execute.capture_execution()
|
||||||
exit_code, proc, output = e.shell(processors)
|
exit_code, proc, output = e.shell(processors)
|
||||||
@ -63,7 +60,12 @@ def load():
|
|||||||
ncpus = int(count)
|
ncpus = int(count)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
ncpus = str(ncpus + 1)
|
return ncpus + 1
|
||||||
|
|
||||||
|
def overrides():
|
||||||
|
uname = os.uname()
|
||||||
|
smp_mflags = ''
|
||||||
|
ncpus = '%d' % cpus()
|
||||||
if uname[4].startswith('arm'):
|
if uname[4].startswith('arm'):
|
||||||
cpu = 'arm'
|
cpu = 'arm'
|
||||||
else:
|
else:
|
||||||
@ -153,4 +155,6 @@ def load():
|
|||||||
return defines
|
return defines
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pprint.pprint(load())
|
import pprint
|
||||||
|
pprint.pprint(cpus())
|
||||||
|
pprint.pprint(overrides())
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# RTEMS Tools Project (http://www.rtems.org/)
|
# RTEMS Tools Project (http://www.rtems.org/)
|
||||||
# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
|
# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
||||||
@ -24,7 +24,6 @@
|
|||||||
# RTEMS project's spec files.
|
# RTEMS project's spec files.
|
||||||
#
|
#
|
||||||
|
|
||||||
import pprint
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -34,15 +33,19 @@ except (ValueError, SystemError):
|
|||||||
import check
|
import check
|
||||||
import execute
|
import execute
|
||||||
|
|
||||||
def load():
|
def cpus():
|
||||||
uname = os.uname()
|
|
||||||
sysctl = '/sbin/sysctl '
|
sysctl = '/sbin/sysctl '
|
||||||
e = execute.capture_execution()
|
e = execute.capture_execution()
|
||||||
exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
|
exit_code, proc, output = e.shell(sysctl + 'hw.ncpu')
|
||||||
if exit_code == 0:
|
if exit_code == 0:
|
||||||
ncpus = output.split(' ')[1].strip()
|
ncpus = int(output.split(' ')[1].strip())
|
||||||
else:
|
else:
|
||||||
ncpus = '1'
|
ncpus = 1
|
||||||
|
return ncpus
|
||||||
|
|
||||||
|
def overrides():
|
||||||
|
uname = os.uname()
|
||||||
|
ncpus = '%d' % (cpus())
|
||||||
if uname[4] == 'amd64':
|
if uname[4] == 'amd64':
|
||||||
cpu = 'x86_64'
|
cpu = 'x86_64'
|
||||||
else:
|
else:
|
||||||
@ -93,4 +96,6 @@ def load():
|
|||||||
return defines
|
return defines
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pprint.pprint(load())
|
import pprint
|
||||||
|
pprint.pprint(cpus())
|
||||||
|
pprint.pprint(overrides())
|
||||||
|
@ -50,6 +50,7 @@ try:
|
|||||||
from . import error
|
from . import error
|
||||||
from . import execute
|
from . import execute
|
||||||
from . import git
|
from . import git
|
||||||
|
from . import host
|
||||||
from . import log
|
from . import log
|
||||||
from . import macros
|
from . import macros
|
||||||
from . import path
|
from . import path
|
||||||
@ -58,6 +59,7 @@ except (ValueError, SystemError):
|
|||||||
import error
|
import error
|
||||||
import execute
|
import execute
|
||||||
import git
|
import git
|
||||||
|
import host
|
||||||
import log
|
import log
|
||||||
import macros
|
import macros
|
||||||
import path
|
import path
|
||||||
@ -65,11 +67,6 @@ except (ValueError, SystemError):
|
|||||||
|
|
||||||
basepath = 'tb'
|
basepath = 'tb'
|
||||||
|
|
||||||
#
|
|
||||||
# Save the host state.
|
|
||||||
#
|
|
||||||
host_windows = False
|
|
||||||
|
|
||||||
class command_line(object):
|
class command_line(object):
|
||||||
"""Process the command line in a common way for all Tool Builder commands."""
|
"""Process the command line in a common way for all Tool Builder commands."""
|
||||||
|
|
||||||
@ -539,61 +536,7 @@ def load(opts):
|
|||||||
if not isinstance(opts, command_line):
|
if not isinstance(opts, command_line):
|
||||||
raise error.general('invalid options type passed to options loader')
|
raise error.general('invalid options type passed to options loader')
|
||||||
|
|
||||||
global host_windows
|
overrides = host.overrides()
|
||||||
|
|
||||||
overrides = None
|
|
||||||
if os.name == 'nt':
|
|
||||||
try:
|
|
||||||
import windows
|
|
||||||
overrides = windows.load()
|
|
||||||
host_windows = True
|
|
||||||
except:
|
|
||||||
raise error.general('failed to load Windows host support')
|
|
||||||
elif os.name == 'posix':
|
|
||||||
uname = os.uname()
|
|
||||||
try:
|
|
||||||
if uname[0].startswith('CYGWIN_NT'):
|
|
||||||
try:
|
|
||||||
from . import windows
|
|
||||||
except:
|
|
||||||
import windows
|
|
||||||
overrides = windows.load()
|
|
||||||
elif uname[0] == 'Darwin':
|
|
||||||
try:
|
|
||||||
from . import darwin
|
|
||||||
except:
|
|
||||||
import darwin
|
|
||||||
overrides = darwin.load()
|
|
||||||
elif uname[0] == 'FreeBSD':
|
|
||||||
try:
|
|
||||||
from . import freebsd
|
|
||||||
except:
|
|
||||||
import freebsd
|
|
||||||
overrides = freebsd.load()
|
|
||||||
elif uname[0] == 'NetBSD':
|
|
||||||
try:
|
|
||||||
from . import netbsd
|
|
||||||
except:
|
|
||||||
import netbsd
|
|
||||||
overrides = netbsd.load()
|
|
||||||
elif uname[0] == 'Linux':
|
|
||||||
try:
|
|
||||||
from . import linux
|
|
||||||
except:
|
|
||||||
import linux
|
|
||||||
overrides = linux.load()
|
|
||||||
elif uname[0] == 'SunOS':
|
|
||||||
try:
|
|
||||||
from . import solaris
|
|
||||||
except:
|
|
||||||
import solaris
|
|
||||||
overrides = solaris.load()
|
|
||||||
except:
|
|
||||||
raise error.general('failed to load %s host support' % (uname[0]))
|
|
||||||
else:
|
|
||||||
raise error.general('unsupported host type; please add')
|
|
||||||
if overrides is None:
|
|
||||||
raise error.general('no hosts defaults found; please add')
|
|
||||||
for k in overrides:
|
for k in overrides:
|
||||||
opts.defaults[k] = overrides[k]
|
opts.defaults[k] = overrides[k]
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# RTEMS Tools Project (http://www.rtems.org/)
|
# RTEMS Tools Project (http://www.rtems.org/)
|
||||||
# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
|
# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
||||||
@ -22,7 +22,6 @@
|
|||||||
# RTEMS project's spec files.
|
# RTEMS project's spec files.
|
||||||
#
|
#
|
||||||
|
|
||||||
import pprint
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -34,15 +33,19 @@ except (ValueError, SystemError):
|
|||||||
import error
|
import error
|
||||||
import execute
|
import execute
|
||||||
|
|
||||||
def load():
|
def cpus():
|
||||||
uname = os.uname()
|
|
||||||
psrinfo = '/sbin/psrinfo|wc -l'
|
psrinfo = '/sbin/psrinfo|wc -l'
|
||||||
e = execute.capture_execution()
|
e = execute.capture_execution()
|
||||||
exit_code, proc, output = e.shell(psrinfo)
|
exit_code, proc, output = e.shell(psrinfo)
|
||||||
if exit_code == 0:
|
if exit_code == 0:
|
||||||
ncpus = output
|
ncpus = int(output)
|
||||||
else:
|
else:
|
||||||
ncpus = '1'
|
ncpus = 1
|
||||||
|
return ncpus
|
||||||
|
|
||||||
|
def overrides():
|
||||||
|
uname = os.uname()
|
||||||
|
ncpus = '%d' % (cpus())
|
||||||
if uname[4] == 'i86pc':
|
if uname[4] == 'i86pc':
|
||||||
cpu = 'i386'
|
cpu = 'i386'
|
||||||
else:
|
else:
|
||||||
@ -87,4 +90,6 @@ def load():
|
|||||||
return defines
|
return defines
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pprint.pprint(load())
|
import pprint
|
||||||
|
pprint.pprint(cpus())
|
||||||
|
pprint.pprint(overrides())
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# RTEMS Tools Project (http://www.rtems.org/)
|
# RTEMS Tools Project (http://www.rtems.org/)
|
||||||
# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
|
# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
||||||
@ -32,7 +32,6 @@
|
|||||||
# Windows specific support and overrides.
|
# Windows specific support and overrides.
|
||||||
#
|
#
|
||||||
|
|
||||||
import pprint
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -46,7 +45,14 @@ except (ValueError, SystemError):
|
|||||||
import error
|
import error
|
||||||
import execute
|
import execute
|
||||||
|
|
||||||
def load():
|
def cpus():
|
||||||
|
if os.environ.has_key('NUMBER_OF_PROCESSORS'):
|
||||||
|
ncpus = int(os.environ['NUMBER_OF_PROCESSORS'])
|
||||||
|
else:
|
||||||
|
ncpus = 1
|
||||||
|
return ncpus
|
||||||
|
|
||||||
|
def overrides():
|
||||||
# Default to the native Windows Python.
|
# Default to the native Windows Python.
|
||||||
uname = 'win32'
|
uname = 'win32'
|
||||||
system = 'mingw32'
|
system = 'mingw32'
|
||||||
@ -76,10 +82,7 @@ def load():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if os.environ.has_key('NUMBER_OF_PROCESSORS'):
|
ncpus = '%d' % (cpus())
|
||||||
ncpus = os.environ['NUMBER_OF_PROCESSORS']
|
|
||||||
else:
|
|
||||||
ncpus = '1'
|
|
||||||
|
|
||||||
defines = {
|
defines = {
|
||||||
'_ncpus': ('none', 'none', ncpus),
|
'_ncpus': ('none', 'none', ncpus),
|
||||||
@ -140,4 +143,6 @@ def load():
|
|||||||
return defines
|
return defines
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pprint.pprint(load())
|
import pprint
|
||||||
|
pprint.pprint(cpus())
|
||||||
|
pprint.pprint(overrides())
|
||||||
|
@ -37,11 +37,11 @@ import sys
|
|||||||
import termios
|
import termios
|
||||||
|
|
||||||
from rtemstoolkit import error
|
from rtemstoolkit import error
|
||||||
from rtemstoolkit import options
|
from rtemstoolkit import host
|
||||||
from rtemstoolkit import path
|
from rtemstoolkit import path
|
||||||
|
|
||||||
def save():
|
def save():
|
||||||
if not options.host_windows:
|
if not host.is_windows:
|
||||||
try:
|
try:
|
||||||
sin = termios.tcgetattr(sys.stdin)
|
sin = termios.tcgetattr(sys.stdin)
|
||||||
sout = termios.tcgetattr(sys.stdout)
|
sout = termios.tcgetattr(sys.stdout)
|
||||||
@ -60,13 +60,13 @@ def restore(attributes):
|
|||||||
class tty:
|
class tty:
|
||||||
|
|
||||||
def __init__(self, dev):
|
def __init__(self, dev):
|
||||||
if options.host_windows:
|
if host.is_windows:
|
||||||
raise error.general('termios not support on host')
|
raise error.general('termios not support on host')
|
||||||
self.dev = dev
|
self.dev = dev
|
||||||
self.default_attr = None
|
self.default_attr = None
|
||||||
self.fd = None
|
self.fd = None
|
||||||
self.if_on = False
|
self.if_on = False
|
||||||
if options.host_windows:
|
if host.is_windows:
|
||||||
raise error.general('TTY consoles not supported on Windows.')
|
raise error.general('TTY consoles not supported on Windows.')
|
||||||
if not path.exists(dev):
|
if not path.exists(dev):
|
||||||
raise error.general('dev not found: %s' % (dev))
|
raise error.general('dev not found: %s' % (dev))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user