MCPcopy Create free account
hub / github.com/apache/arrow / CMakeBuild

Class CMakeBuild

dev/archery/archery/utils/cmake.py:121–208  ·  view source on GitHub ↗

CMakeBuild represents a build directory initialized by cmake. The build instance can be used to build/test/install. It alleviates the user to know which generator is used.

Source from the content-addressed store, hash-verified

119
120
121class CMakeBuild(CMake):
122 """ CMakeBuild represents a build directory initialized by cmake.
123
124 The build instance can be used to build/test/install. It alleviates the
125 user to know which generator is used.
126 """
127
128 def __init__(self, build_dir, build_type, definition=None):
129 """ Initialize a CMakeBuild.
130
131 The caller must ensure that cmake was invoked in the build directory.
132
133 Parameters
134 ----------
135 definition : CMakeDefinition
136 The definition to build from.
137 build_dir : str
138 The build directory to setup into.
139 """
140 assert CMakeBuild.is_build_dir(build_dir)
141 super().__init__()
142 self.build_dir = os.path.abspath(build_dir)
143 self.build_type = build_type
144 self.definition = definition
145
146 @property
147 def binaries_dir(self):
148 return os.path.join(self.build_dir, self.build_type)
149
150 def run(self, *argv, verbose=False, **kwargs):
151 cmake_args = ["--build", self.build_dir, "--"]
152 extra = []
153 if verbose:
154 extra.append("-v" if self.bin.endswith("ninja") else "VERBOSE=1")
155 # Commands must be ran under the build directory
156 return super().run(*cmake_args, *extra,
157 *argv, **kwargs, cwd=self.build_dir)
158
159 def all(self):
160 return self.run("all")
161
162 def clean(self):
163 return self.run("clean")
164
165 def install(self):
166 return self.run("install")
167
168 def test(self):
169 return self.run("test")
170
171 @staticmethod
172 def is_build_dir(path):
173 """ Indicate if a path is CMake build directory.
174
175 This method only checks for the existence of paths and does not do any
176 validation whatsoever.
177 """
178 cmake_cache = os.path.join(path, "CMakeCache.txt")

Callers 2

buildMethod · 0.85
from_pathMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected