[PATCH] D26365: Add experimental support for unofficial monorepo-like directory layout

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 7 14:17:17 PST 2016


Mehdi AMINI <mehdi.amini at apple.com> writes:
> mehdi_amini created this revision.
> mehdi_amini added reviewers: bogner, beanz, jlebar.
> mehdi_amini added a subscriber: llvm-commits.
> Herald added a subscriber: mgorny.
>
> This allows to have clang and llvm and the other subprojects
> side-by-side instead of nested. This can be used with the monorepo or
> multiple repos.
>
> It will help having a single set of sources checked out but allows to
> have a build directory with llvm and another one with llvm+clang.
> Basically it abstracts LLVM_EXTERNAL_xxxx_SOURCE_DIR making it more
> convenient by adopting a convention.

As discussed in person, this LGTM as long as you add a comment
explaining what's going on with the automatically including
clang-tools-extra bit.

> mehdi_amini updated this revision to Diff 77084.
> mehdi_amini added a comment.
>
> Update the comment in CMake
>
>
> https://reviews.llvm.org/D26365
>
> Files:
>   llvm/CMakeLists.txt
>   llvm/docs/CMake.rst
>
>
> Index: llvm/docs/CMake.rst
> ===================================================================
> --- llvm/docs/CMake.rst
> +++ llvm/docs/CMake.rst
> @@ -336,6 +336,14 @@
>    will not be used.  If the variable for an external project does not point
>    to a valid path, then that project will not be built.
>  
> +**LLVM_ENABLE_PROJECTS**:STRING
> +  Semicolon-separated list of projects to build, or *all* for building all
> +  (clang, libcxx, libcxxabi, lldb, compiler-rt, lld, polly) projects.
> +  This flag assumes that projects are checked out side-by-side and not nested,
> +  i.e. clang needs to be in parallel of llvm instead of nested in `llvm/tools`.
> +  This feature allows to have one build for only LLVM and another for clang+llvm
> +  using the same source checkout.
> +
>  **LLVM_EXTERNAL_PROJECTS**:STRING
>    Semicolon-separated list of additional external projects to build as part of
>    llvm. For each project LLVM_EXTERNAL_<NAME>_SOURCE_DIR have to be specified
> Index: llvm/CMakeLists.txt
> ===================================================================
> --- llvm/CMakeLists.txt
> +++ llvm/CMakeLists.txt
> @@ -93,6 +93,28 @@
>    endif()
>  endif()
>  
> +# Side-by-side subprojects layout: automatically set the
> +# LLVM_EXTERNAL_${project}_SOURCE_DIR using LLVM_ALL_PROJECTS
> +# This allows an easy way of setting up a build directory for llvm and another
> +# one for llvm+clang+... using the same sources.
> +set(LLVM_ALL_PROJECTS "clang;libcxx;libcxxabi;lldb;compiler-rt;lld;polly")
> +set(LLVM_ENABLE_PROJECTS "" CACHE STRING
> +	"Semicolon-separated list of projects to build (${LLVM_ALL_PROJECTS}), or \"all\".")
> +if( LLVM_ENABLE_PROJECTS STREQUAL "all" )
> +  set( LLVM_ENABLE_PROJECTS ${LLVM_ALL_PROJECTS})
> +endif()
> +foreach(proj ${LLVM_ENABLE_PROJECTS})
> +  set(PROJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
> +  if(NOT EXISTS "${PROJ_DIR}" OR NOT IS_DIRECTORY "${PROJ_DIR}")
> +    message(FATAL_ERROR "LLVM_ENABLE_PROJECTS requests ${proj} but directory not found: ${PROJ_DIR}")
> +  endif()
> +  string(TOUPPER "${proj}" upper_proj)
> +  set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR   "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
> +  if (proj STREQUAL "clang")
> +    set(LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../clang-tools-extra")
> +  endif()
> +endforeach()
> +
>  # The following only works with the Ninja generator in CMake >= 3.0.
>  set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING
>    "Define the maximum number of concurrent compilation jobs.")
>
>
> Index: llvm/docs/CMake.rst
> ===================================================================
> --- llvm/docs/CMake.rst
> +++ llvm/docs/CMake.rst
> @@ -336,6 +336,14 @@
>    will not be used.  If the variable for an external project does not point
>    to a valid path, then that project will not be built.
>  
> +**LLVM_ENABLE_PROJECTS**:STRING
> +  Semicolon-separated list of projects to build, or *all* for building all
> +  (clang, libcxx, libcxxabi, lldb, compiler-rt, lld, polly) projects.
> +  This flag assumes that projects are checked out side-by-side and not nested,
> +  i.e. clang needs to be in parallel of llvm instead of nested in `llvm/tools`.
> +  This feature allows to have one build for only LLVM and another for clang+llvm
> +  using the same source checkout.
> +
>  **LLVM_EXTERNAL_PROJECTS**:STRING
>    Semicolon-separated list of additional external projects to build as part of
>    llvm. For each project LLVM_EXTERNAL_<NAME>_SOURCE_DIR have to be specified
> Index: llvm/CMakeLists.txt
> ===================================================================
> --- llvm/CMakeLists.txt
> +++ llvm/CMakeLists.txt
> @@ -93,6 +93,28 @@
>    endif()
>  endif()
>  
> +# Side-by-side subprojects layout: automatically set the
> +# LLVM_EXTERNAL_${project}_SOURCE_DIR using LLVM_ALL_PROJECTS
> +# This allows an easy way of setting up a build directory for llvm and another
> +# one for llvm+clang+... using the same sources.
> +set(LLVM_ALL_PROJECTS "clang;libcxx;libcxxabi;lldb;compiler-rt;lld;polly")
> +set(LLVM_ENABLE_PROJECTS "" CACHE STRING
> +	"Semicolon-separated list of projects to build (${LLVM_ALL_PROJECTS}), or \"all\".")
> +if( LLVM_ENABLE_PROJECTS STREQUAL "all" )
> +  set( LLVM_ENABLE_PROJECTS ${LLVM_ALL_PROJECTS})
> +endif()
> +foreach(proj ${LLVM_ENABLE_PROJECTS})
> +  set(PROJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
> +  if(NOT EXISTS "${PROJ_DIR}" OR NOT IS_DIRECTORY "${PROJ_DIR}")
> +    message(FATAL_ERROR "LLVM_ENABLE_PROJECTS requests ${proj} but directory not found: ${PROJ_DIR}")
> +  endif()
> +  string(TOUPPER "${proj}" upper_proj)
> +  set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR   "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
> +  if (proj STREQUAL "clang")
> +    set(LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../clang-tools-extra")
> +  endif()
> +endforeach()
> +
>  # The following only works with the Ninja generator in CMake >= 3.0.
>  set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING
>    "Define the maximum number of concurrent compilation jobs.")


More information about the llvm-commits mailing list