From 71144d1922fd853fd6085dec58483e2995e4229c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=BChnel?= Date: Thu, 23 Apr 2020 11:22:24 +0200 Subject: [PATCH] By default: building all enabled projects. This is the fallback solution in case the project detection fails for whatever reason. This is also used for building the master branches. --- scripts/choose_projects.py | 14 +++++++++++--- scripts/run_cmake.py | 15 ++++++++++++--- scripts/run_cmake_config.yaml | 6 ------ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/scripts/choose_projects.py b/scripts/choose_projects.py index 13ab529..eb628cf 100755 --- a/scripts/choose_projects.py +++ b/scripts/choose_projects.py @@ -25,7 +25,7 @@ import logging import os import platform import sys -from typing import Dict, List, Set, Tuple +from typing import Dict, List, Set, Tuple, Optional from unidiff import PatchSet import yaml @@ -43,8 +43,8 @@ class ChooseProjects: # projects used if anything goes wrong FALLBACK_PROJECTS = ['all'] - def __init__(self, llvm_dir: str): - self.llvm_dir = llvm_dir + def __init__(self, llvm_dir: Optional[str]): + self.llvm_dir = llvm_dir # type: Optional[str] self.defaultProjects = dict() # type: Dict[str, Dict[str, str]] self.dependencies = dict() # type: Dict[str,List[str]] self.usages = dict() # type: Dict[str,List[str]] @@ -72,6 +72,9 @@ class ChooseProjects: return 'linux' def choose_projects(self, patch: str = None) -> List[str]: + if self.llvm_dir is None: + raise ValueError('path to llvm folder must be set in ChooseProject.') + llvm_dir = os.path.abspath(os.path.expanduser(self.llvm_dir)) logging.info('Scanning LLVM in {}'.format(llvm_dir)) if not self.match_projects_dirs(): @@ -165,6 +168,11 @@ class ChooseProjects: result.update(changes) return result + def get_all_enabled_projects(self) -> List[str]: + """Get list of all not-excluded projects for current platform.""" + result = set(self.all_projects) - self.excluded_projects + return sorted(list(result)) + if __name__ == "__main__": logging.basicConfig(filename='choose_projects.log', level=logging.INFO) diff --git a/scripts/run_cmake.py b/scripts/run_cmake.py index e22256f..fe3ef17 100755 --- a/scripts/run_cmake.py +++ b/scripts/run_cmake.py @@ -17,7 +17,6 @@ import argparse from enum import Enum from git import Repo import os -from pathlib import Path import platform import shutil import subprocess @@ -34,6 +33,11 @@ class OperatingSystem(Enum): class Configuration: + """Configuration for running cmake. + + The data is mostly read from the file `run_cmake_config.yaml` + residing in the same folder as this script. + """ def __init__(self, config_file_path: str): with open(config_file_path) as config_file: @@ -41,7 +45,6 @@ class Configuration: self._environment = config['environment'] # type: Dict[OperatingSystem, Dict[str, str]] self.general_cmake_arguments = config['arguments']['general'] # type: List[str] self._specific_cmake_arguments = config['arguments'] # type: Dict[OperatingSystem, List[str]] - self._default_projects = config['default_projects'] # type: Dict[OperatingSystem, str] self.operating_system = self._detect_os() # type: OperatingSystem @property @@ -54,7 +57,13 @@ class Configuration: @property def default_projects(self) -> str: - return self._default_projects[self.operating_system.value] + """Get string of projects enabled by default. + + This returns all projects in the mono repo minus the project that were + excluded for the current platform. + """ + cp = ChooseProjects(None) + return ';'.join(cp.get_all_enabled_projects()) @staticmethod def _detect_os() -> OperatingSystem: diff --git a/scripts/run_cmake_config.yaml b/scripts/run_cmake_config.yaml index 627c80a..7b7efb8 100644 --- a/scripts/run_cmake_config.yaml +++ b/scripts/run_cmake_config.yaml @@ -28,9 +28,3 @@ arguments: - '-DCMAKE_CXX_FLAGS=-gmlt' windows: - '-D LLVM_ENABLE_DIA_SDK=OFF' - -# if the automatic project detection fails or is not used, these projects are -# enabled -default_projects: - windows: 'clang;clang-tools-extra;libcxx;libc;lld;mlir;libcxxabi' - linux: 'clang;clang-tools-extra;libc;libcxx;libcxxabi;lld;libunwind;mlir;flang'