1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
import os
import subprocess
import sys
#### UTILITIES ####
def enum(*sequential, **named):
enums = dict(zip(sequential, range(len(sequential))), **named)
return type('Enum', (), enums)
#### SETTINGS ####
#### INTERFACE TO THE XCODEPROJ ####
def lldb_source_path():
path = os.environ.get('SRCROOT')
if path:
return path
else:
return "./"
def expected_llvm_build_path():
if build_type() == BuildType.Xcode:
return package_build_path()
else:
return os.path.join(
os.environ.get('LLDB_PATH_TO_LLVM_BUILD'),
package_build_dir_name("llvm"))
def archives_txt():
return os.path.join(expected_package_build_path(), "archives.txt")
def expected_package_build_path():
return os.path.abspath(os.path.join(expected_llvm_build_path(), ".."))
def is_host_build():
rc_project_name = os.environ.get('RC_ProjectName')
if rc_project_name:
if rc_project_name == 'lldb_host': return True
return False
def rc_release_target():
return os.environ.get('RC_RELEASE', '')
def rc_platform_name():
return os.environ.get('RC_PLATFORM_NAME', 'macOS')
def architecture():
if is_host_build(): return 'macosx'
platform_name = os.environ.get('RC_PLATFORM_NAME')
if not platform_name:
platform_name = os.environ.get('PLATFORM_NAME')
platform_arch = os.environ.get('ARCHS').split()[-1]
return platform_name + "-" + platform_arch
def lldb_configuration():
return os.environ.get('CONFIGURATION')
def llvm_configuration():
return os.environ.get('LLVM_CONFIGURATION')
def llvm_build_dirtree():
return os.environ.get('LLVM_BUILD_DIRTREE')
# Edit the code below when adding build styles.
BuildType = enum('Xcode') # (Debug,DebugClang,Release)
def build_type():
return BuildType.Xcode
#### VCS UTILITIES ####
VCS = enum('git',
'svn')
def run_in_directory(args, path):
return subprocess.check_output([str(arg) for arg in args], cwd=path)
class Git:
def __init__(self, spec):
self.spec = spec
def status(self):
return run_in_directory(["git", "branch", "-v"], self.spec['root'])
def diff(self):
return run_in_directory(["git", "diff"], self.spec['root'])
def check_out(self):
run_in_directory(["git",
"clone",
"--depth=1",
self.spec['url'],
self.spec['root']],
lldb_source_path())
run_in_directory(["git", "fetch", "--all"], self.spec['root'])
run_in_directory(["git", "checkout", self.spec[
'ref']], self.spec['root'])
class SVN:
def __init__(self, spec):
self.spec = spec
def status(self):
return run_in_directory(["svn", "info"], self.spec['root'])
def diff(self):
return run_in_directory(["svn", "diff"], self.spec['root'])
# TODO implement check_out
def vcs(spec):
if spec['vcs'] == VCS.git:
return Git(spec)
elif spec['vcs'] == VCS.svn:
return SVN(spec)
else:
return None
#### SOURCE PATHS ####
def llvm_source_path():
if build_type() == BuildType.Xcode:
return os.path.join(lldb_source_path(), "llvm")
def clang_source_path():
if build_type() == BuildType.Xcode:
return os.path.join(llvm_source_path(), "tools", "clang")
def ninja_source_path():
if build_type() == BuildType.Xcode:
return os.path.join(lldb_source_path(), "ninja")
#### BUILD PATHS ####
def packages():
return ["llvm"]
def package_build_dir_name(package):
return package + "-" + architecture()
def expected_package_build_path_for(package):
if build_type() == BuildType.Xcode:
if package != "llvm":
raise "On Xcode build, we only support the llvm package: requested {}"
return package_build_path()
return os.path.join(
expected_package_build_path(),
package_build_dir_name(package))
def expected_package_build_paths():
return [expected_package_build_path_for(package) for package in packages()]
def library_path(build_path):
return build_path + "/lib"
def library_paths():
if build_type() == BuildType.Xcode:
package_build_paths = [package_build_path()]
else:
package_build_paths = expected_package_build_paths()
return [library_path(build_path) for build_path in package_build_paths]
def package_build_path():
return os.path.join(
llvm_build_dirtree(),
os.environ["LLVM_CONFIGURATION"],
os.environ["CURRENT_ARCH"])
|