summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-07-16 14:17:54 +0100
committerAngelos Evripiotis <jevripiotis@bloomberg.net>2019-10-10 15:57:42 +0100
commit3d0676ffe249891f3889014c791702bfddc31cd4 (patch)
tree7eaa7094a46ee0e41a224144b6c02cc2341962a8
parent1db77530d1b14fe8d3ceab9952ab6c75f85a6dea (diff)
downloadbuildstream-aevri/platform_win32.tar.gz
win32: _platform/win32: add support for win32aevri/platform_win32
Copy the approach of 'Darwin' and provide a SandboxDummy. This enables us to run 'bst workspace list' on Windows.
-rw-r--r--src/buildstream/_platform/platform.py4
-rw-r--r--src/buildstream/_platform/win32.py59
2 files changed, 63 insertions, 0 deletions
diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py
index 11c9217be..af49b9e82 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 000000000..36680019d
--- /dev/null
+++ b/src/buildstream/_platform/win32.py
@@ -0,0 +1,59 @@
+#
+# 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.
+ #
+ # 'psutil' provides an rlimit implementation that is only available on
+ # Linux, as of version 5.3.
+ #
+ # Given that this limit is only important for SafeHardLinks FUSE, and
+ # we don't have FUSE on Windows, this won't be an obstacle for now.
+ #
+ # If it does turn out to be an obstacle, beware that the Windows API
+ # `_setmaxstdio` for increasing the open file limit only applies to the
+ # 'stream I/O level', i.e. `fopen()` and friends. CPython opens files
+ # using `_wopen()`, which is at the 'low I/O level'.
+ #
+ # You can see this in the function `os_open_impl` in `posixmodule.c` in
+ # CPython version 3.9.
+ #
+ # 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