Skip to content
Snippets Groups Projects
Commit 0199524c authored by knownexus's avatar knownexus
Browse files

Adding darwin.py platform

Adding functionality to recognise Darwin as a platform in plaform.py
parent b6de9265
No related branches found
No related tags found
No related merge requests found
#
# Copyright (C) 2017 Codethink Limited
# Copyright (C) 2018 Bloomberg Finance LP
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
import os
import resource
from .._exceptions import PlatformError
from ..sandbox import SandboxChroot
from . import Platform
class Darwin(Platform):
def __init__(self, context):
# This value comes from OPEN_MAX in syslimits.h
OPEN_MAX = 10240
super().__init__(context)
@property
def artifactcache(self):
return self._artifact_cache
def create_sandbox(self, *args, **kwargs):
return SandboxChroot(*args, **kwargs)
def get_cpu_count(self, cap=None):
if cap < os.cpu_count():
return cap
else:
return os.cpu_count()
def set_resources(self, soft_limit=OPEN_MAX, hard_limit=None):
super().set_resources(soft_limit)
......@@ -44,19 +44,23 @@ class Platform():
@classmethod
def create_instance(cls, *args, **kwargs):
if sys.platform.startswith('linux'):
backend = 'linux'
else:
backend = 'unix'
# Meant for testing purposes and therefore hidden in the
# deepest corners of the source code. Try not to abuse this,
# please?
if os.getenv('BST_FORCE_BACKEND'):
backend = os.getenv('BST_FORCE_BACKEND')
elif sys.platform.startswith('linux'):
backend = 'linux'
elif sys.platform.startswith('darwin'):
backend = 'darwin'
else:
backend = 'unix'
if backend == 'linux':
from .linux import Linux as PlatformImpl
elif backend == 'darwin':
from .darwin import Darwin as PlatformImpl
elif backend == 'unix':
from .unix import Unix as PlatformImpl
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment