You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:23:46 UTC

[buildstream] 03/25: win32: _platform/win32: add support for win32

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch aevri/win32_minimal
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 5a132531f14e449d2183952adcdc2d81fd135bdd
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Tue Jul 16 14:17:54 2019 +0100

    win32: _platform/win32: add support for win32
    
    Copy the approach of 'Darwin' and provide a SandboxDummy.
    
    This enables us to run 'bst workspace list' on Windows.
---
 src/buildstream/_platform/platform.py |  4 +++
 src/buildstream/_platform/win32.py    | 56 +++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py
index 11c9217..af49b9e 100644
--- a/src/buildstream/_platform/platform.py
+++ b/src/buildstream/_platform/platform.py
@@ -98,6 +98,8 @@ class Platform():
             backend = 'darwin'
         elif sys.platform.startswith('linux'):
             backend = 'linux'
+        elif sys.platform == 'win32':
+            backend = 'win32'
         else:
             backend = 'fallback'
 
@@ -105,6 +107,8 @@ class Platform():
             from .linux import Linux as PlatformImpl  # pylint: disable=cyclic-import
         elif backend == 'darwin':
             from .darwin import Darwin as PlatformImpl  # pylint: disable=cyclic-import
+        elif backend == 'win32':
+            from .win32 import Win32 as PlatformImpl  # pylint: disable=cyclic-import
         elif backend == 'fallback':
             from .fallback import Fallback as PlatformImpl  # pylint: disable=cyclic-import
         else:
diff --git a/src/buildstream/_platform/win32.py b/src/buildstream/_platform/win32.py
new file mode 100644
index 0000000..bb763cd
--- /dev/null
+++ b/src/buildstream/_platform/win32.py
@@ -0,0 +1,56 @@
+#
+#  Copyright (C) 2019 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/>.
+
+from ..sandbox import SandboxDummy
+
+from .platform import Platform
+
+
+class Win32(Platform):
+
+    def maximize_open_file_limit(self):
+        # Note that on Windows, we don't have the 'resource' module to help us
+        # configure open file limits. By default we are allowed 512 open files,
+        # the `_setmaxstdio` C api may be used to increase this up to 8192.
+        #
+        # A grep for '_setmaxstdio' in the C python code base as at Python 3.8
+        # comes up empty, perhaps it will be added in later versions.
+        #
+        # 'psutil' provides an rlimit implementation that is only available on
+        # Linux, as of version 5.3. A grep of the psutil source for
+        # '_setmaxstdio' also comes up empty.
+        #
+        # To increase beyond the 512 limit on Windows, we will likely need to
+        # use Cython.
+        #
+        # For more information:
+        # https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio
+        #
+        pass
+
+    @staticmethod
+    def _check_dummy_sandbox_config(config):
+        return True
+
+    @staticmethod
+    def _create_dummy_sandbox(*args, **kwargs):
+        kwargs['dummy_reason'] = "There are no supported sandbox technologies for Win32 at this time."
+        return SandboxDummy(*args, **kwargs)
+
+    def _setup_dummy_sandbox(self):
+        self.check_sandbox_config = Win32._check_dummy_sandbox_config
+        self.create_sandbox = Win32._create_dummy_sandbox
+        return True
\ No newline at end of file