Skip to content

Commit

Permalink
Build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
muit committed Jan 3, 2023
1 parent 5660b55 commit 2109c13
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 35 deletions.
36 changes: 21 additions & 15 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import sys, getopt
import subprocess
import sys
import shutil
import time
import argparse


def install_dependencies():
if sys.platform == "linux" or sys.platform == "linux2":
if sys.platform == "linux":
print(">> Install dependencies")
try:
os.system('sudo apt -qq install -y libedit-dev')
Expand All @@ -19,36 +20,38 @@ def configure(root, path, build_path, config):
cache_file = os.path.join(root, 'cache.cmake')

command = 'cmake -S "{}" -B "{}" -C "{}" -DCMAKE_BUILD_TYPE={}'.format(path, build_path, cache_file, config)

print('Command: {}'.format(command))
os.system(command)
subprocess.run(command, check=True)
print('\n')

def build(build_path, config):
print('>> Build ({})'.format(config))
targets = ["libclang", "install"]
command = 'cmake --build "{}" --config {} --target {}'.format(build_path, config, ' '.join(targets))
command = 'cmake --build "{}" --config {} --target install'.format(build_path, config)
print('Command: {}'.format(command))
os.system(command)
print('\n')
subprocess.run(command, check=False)

# Extra targets
#command = 'cmake --build "{}" --config {} --target libclang'.format(build_path, config)
#print('Command: {}'.format(command))
#subprocess.run(command, check=False)
print('\n')

def install(root, build_path, install_path, config):
def install(install_path, build_path, config):
print(">> Install LLVM")
if not os.path.isabs(install_path):
install_path = os.path.join(root, install_path)
install_path = os.path.join(install_path, config)
os.system('cmake -DCMAKE_INSTALL_PREFIX={} -DBUILD_TYPE={} -P {}/cmake_install.cmake'.format(install_path, config, build_path))
command = 'cmake --install {} --config {} --prefix {}'.format(build_path, config, install_path)
print('Command: {}'.format(command))
subprocess.run(command, check=True)
print('\n')


def main(argv):
root = os.path.dirname(__file__)

parser = argparse.ArgumentParser(description = "Build LLVM for Rift", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--config", "-c", default="Release", help="Configuration to build LLVM in. Debug, Release, MinSizeRel or RelWithDebInfo")
parser.add_argument("--build", "-b", default="build", help="Path where to build LLVM")
parser.add_argument("--no-build", action='store_true', help="Should build be skipped?")
parser.add_argument("--install", "-i", default=None, help="Path where to install build LLVM files. If none provided, install won't be run")
parser.add_argument("--install", "-i", default=None, help="Should llvm build be installed in install directory?")
parser.add_argument("--clean-build", action='store_true', help="Should build files be cleaned after LLVM is build and/or installed? Keeping build uses disk space but speeds up rebuilds of LLVM")
args = parser.parse_args()

Expand All @@ -71,7 +74,10 @@ def main(argv):
build(args.build, args.config)

if args.install:
install(root, args.build, args.install, args.config)
if not os.path.isabs(args.install):
args.install = os.path.join(root, args.install)
args.install = os.path.join(args.install, args.config)
install(args.install, args.build, args.config)

if args.clean_build:
shutil.rmtree(args.build)
Expand Down
27 changes: 7 additions & 20 deletions cache.cmake
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
# This file sets up a CMakeCache for the llvm build for rift

set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
set(LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
set(LLVM_TARGETS_TO_BUILD "X86;ARM;AArch64;RISCV" CACHE STRING "")

set(LLVM_INSTALL_TOOLCHAIN_ONLY OFF CACHE BOOL "")

#set(LLVM_DISTRIBUTION_COMPONENTS
# clang
# builtins
# runtimes
# CACHE STRING "")
set(LLVM_ENABLE_PROJECTS clang lld CACHE STRING "")
# set(LLVM_ENABLE_RUNTIMES libc CACHE STRING "")
set(LLVM_TARGETS_TO_BUILD X86 ARM AArch64 RISCV CACHE STRING "")

# https://www.llvm.org/docs/CMake.html#llvm-related-variables
set(LLVM_BUILD_TOOLS OFF CACHE BOOL "")
set(LLVM_ENABLE_BINDINGS OFF CACHE BOOL "")
set(LLVM_ENABLE_OCAMLDOC OFF CACHE BOOL "")
set(LLVM_ENABLE_LIBXML2 OFF CACHE BOOL "")
if (NOT APPLE)
set(LLVM_ENABLE_LLD ON CACHE BOOL "")
endif()
set(LLVM_ENABLE_LLD OFF CACHE BOOL "")
set(LLVM_ENABLE_WARNINGS OFF CACHE BOOL "")
set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
set(LLVM_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
set(LLVM_INCLUDE_TOOLS ON CACHE BOOL "")
set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
set(CLANG_BUILD_TOOLS OFF CACHE BOOL "")


# -DLLVM_INCLUDE_TOOLS=ON \
# -DLLVM_BUILD_TOOLS=ON \
# -DLLVM_USE_CRT_RELEASE=MD \
# -DLLVM_USE_CRT_DEBUG=MDd
set(CLANG_BUILD_DOCS OFF CACHE BOOL "")

0 comments on commit 2109c13

Please sign in to comment.