MCPcopy Create free account
hub / github.com/apache/kvrocks / build

Function build

x.py:117–162  ·  view source on GitHub ↗
(dir: str, jobs: Optional[int] = None, ninja: bool = False, unittest: bool = False,
          compiler: str = 'auto', cmake_path: str = 'cmake', D: List[str] = [], skip_build: bool = False,
          dep_dir: Optional[str] = None, toolchain: Optional[str] = None)

Source from the content-addressed store, hash-verified

115 print(f"{hook.name} installed at {dst}.")
116
117def build(dir: str, jobs: Optional[int] = None, ninja: bool = False, unittest: bool = False,
118 compiler: str = 'auto', cmake_path: str = 'cmake', D: List[str] = [], skip_build: bool = False,
119 dep_dir: Optional[str] = None, toolchain: Optional[str] = None) -> None:
120 basedir = Path(__file__).parent.absolute()
121
122 find_command("autoconf", msg="autoconf is required to build jemalloc")
123 cmake = find_command(cmake_path, msg="CMake is required")
124
125 output = run_pipe(cmake, "-version")
126 output = run_pipe("head", "-n", "1", stdin=output)
127 output = run_pipe("awk", "{print $(NF)}", stdin=output)
128 cmake_version = output.read().strip()
129 check_version(cmake_version, CMAKE_REQUIRE_VERSION, "CMake")
130
131 os.makedirs(dir, exist_ok=True)
132
133 cmake_options = ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"]
134 if toolchain:
135 cmake_options.append(f"-DCMAKE_TOOLCHAIN_FILE={toolchain}")
136 if ninja:
137 cmake_options.append("-G Ninja")
138 if compiler == 'gcc':
139 cmake_options += ["-DCMAKE_C_COMPILER=gcc", "-DCMAKE_CXX_COMPILER=g++"]
140 elif compiler == 'clang':
141 cmake_options += ["-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++"]
142 if D:
143 cmake_options += [f"-D{o}" for o in D]
144 if dep_dir:
145 dep_dir = os.path.abspath(dep_dir)
146 cmake_options += [f"-DDEPS_FETCH_DIR={dep_dir}"]
147
148 run(cmake, str(basedir), *cmake_options, verbose=True, cwd=dir)
149
150 if skip_build:
151 return
152
153 target = ["kvrocks", "kvrocks2redis"]
154 if unittest:
155 target.append("unittest")
156
157 options = ["--build", "."]
158 if jobs:
159 options.append(f"-j{jobs}")
160 options += ["-t", *target]
161
162 run(cmake, *options, verbose=True, cwd=dir)
163
164
165def fetch_deps(dir: str, D: List[str] = []) -> None:

Callers 1

fetch_depsFunction · 0.85

Calls 5

find_commandFunction · 0.85
run_pipeFunction · 0.85
check_versionFunction · 0.85
runFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected