Skip to content

Commit 2a88d5c

Browse files
kaadambryanpkc
authored andcommitted
script: update llvm build script
* Native Ninja is already available for Windows on ARM, so we can use it on both Windows platform. * Introduced a new '-i' build option to trigger whether the user wants to install LLVM or not. Previously the script relies on install_prefix option which was wrong approach. In this case we still could not defer the install for a later time if install directory was set. With this change the python build script will be consistent with official bash script.
1 parent fabcee4 commit 2a88d5c

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

scripts/build_llvm_project.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,29 @@ def get_arguments():
2626
buildopt.add_argument('-t', '--target', metavar='ARCH', choices=['X86', 'AArch64', 'PowerPC'], default='X86',
2727
help='Control which targets are enabled (%(choices)s) (default: %(default)s)')
2828
buildopt.add_argument('-p', '--install-prefix', metavar='PATH', nargs='?', default=None, const=False,
29-
help='Install directory (default: do not install)')
29+
help='Specify installation directory (default: platform-specific location)')
30+
buildopt.add_argument('-i', '--install', action='store_true', default=False,
31+
help='Install LLVM (default: do not install)')
3032
buildopt.add_argument('-j', '--jobs', metavar='N', type=int, default=os.cpu_count(),
31-
help='number of parallel build jobs (default: %(default)s)')
33+
help='Number of parallel build jobs (default: %(default)s)')
3234
buildopt.add_argument('--toolchain', metavar='FILE', default=default_toolchain().as_posix(),
33-
help='specify toolchain file (default: %(default)s)')
35+
help='Specify toolchain file (default: %(default)s)')
3436
buildopt.add_argument('-d', '--builddir', metavar='DIR', default='build',
35-
help=f'specify build directory (default: {settings.LLVM_DIR}/%(default)s)')
37+
help=f'Specify build directory (default: {settings.LLVM_DIR}/%(default)s)')
3638
buildopt.add_argument('--clean', action='store_true', default=False,
37-
help='clean build')
39+
help='Clean build')
3840
buildopt.add_argument('-b', '--build-type', metavar='TYPE', default='Release',
39-
help='set build type (default: %(default)s)')
41+
help='Set build type (default: %(default)s)')
4042
buildopt.add_argument('-x', '--cmake-param', metavar='OPT', action='append', default=[],
41-
help='add custom argument to CMake')
43+
help='Add custom argument to CMake')
4244
buildopt.add_argument('-e', '--llvm-enable-projects', metavar='OPT', action='append', default=['clang'] if sys.platform == 'win32' else ['clang', 'openmp'],
43-
help='enable llvm projects to build (in quotation marks separated by semicolons e.g.: "clang;openmp")')
45+
help='Enable LLVM projects to build (in quotation marks separated by semicolons e.g.: "clang;openmp")')
4446
buildopt.add_argument('-c', '--use-ccache', action="store_true", default=False,
4547
help='Using ccache during the build (default: %(default)s)')
4648
buildopt.add_argument('--cc', metavar='OPT', default=None,
47-
help='use specific C compiler')
49+
help='Use specific C compiler')
4850
buildopt.add_argument('--cxx', metavar='OPT', default=None,
49-
help='use specific C++ compiler')
51+
help='Use specific C++ compiler')
5052
buildopt.add_argument('-v', '--verbose', action='store_true', default=False,
5153
help='Verbose build (default: %(default)s')
5254
arguments = parser.parse_args()
@@ -58,11 +60,8 @@ def generate_buildoptions(arguments):
5860
f'-DCMAKE_TOOLCHAIN_FILE={arguments.toolchain}'
5961
]
6062

61-
if sys.platform == 'win32' and platform.uname()[4].lower() == 'arm64':
62-
base_cmake_args.append('-GNMake Makefiles')
63-
else:
64-
generator = 'Ninja' if sys.platform == 'win32' else 'Unix Makefiles'
65-
base_cmake_args.append(f'-G{generator}')
63+
generator = 'Ninja' if sys.platform == 'win32' else 'Unix Makefiles'
64+
base_cmake_args.append(f'-G{generator}')
6665

6766
if arguments.install_prefix:
6867
install_root = Path(arguments.install_prefix)
@@ -143,10 +142,10 @@ def print_header(title):
143142
def main():
144143
arguments = get_arguments()
145144

146-
print_header('Building classic llvm')
145+
print_header('Building classic LLVM')
147146
build_path = configure_llvm(arguments)
148147
build_project(build_path, arguments)
149-
if arguments.install_prefix is not None:
148+
if arguments.install:
150149
install_project(build_path, arguments)
151150

152151
if __name__ == "__main__":

0 commit comments

Comments
 (0)