def __init__(self, tk = None, path = None, root = None, os = None, arch = None, cxx_toolkit = drake.cxx.Toolkit()): """ Create a toolkit or clone an existing one. :param tk: The toolkit to clone. If specified, other arguments must be None :type tk: Toolkit :param path: The home of your go environment (override GOPATH). :type path: str :param root: The root of your go installation (override GOROOT). :type root: str :param os: The target os for cross-compilation (override GOOS). :type os: str :param arch: The target arch for cross-compilation (override GOARCH). :type arch: str Example: t = Toolkit(os = "windows", arch = "amd64") print(t.os) > "windows" print(t.env) {"GOOS": "windows", "GOARCH": "amd64"} t2 = Toolkit(t) print(t2.arch) > "amd64" """ if isinstance(tk, Toolkit): assert all(a is None for a in [path, root, os, arch]) return super().__init__(path = tk.path, root = tk.root, os = tk.os, arch = tk.arch) else: self.__arch = arch self.__go = tk or which('go') self.__path = path self.__os = os self.__root = root self.__version = None self.__env = False self.__cxx_toolkit = cxx_toolkit if self.go is None: raise Exception('go executable is undefined. Check its installation') try: self.run(['help']) except FileNotFoundError: raise Exception('go executable not found')
def _default_make_binary(): from drake.which import which to_try = [ 'make', 'gmake', 'mingw32-make', 'mingw64-make', ] for binary in to_try: path = which(binary) if path is not None: return path