Simplified LLVMConfig.

llvm-svn: 114998
This commit is contained in:
Oscar Fuentes 2010-09-28 22:38:39 +00:00
parent d848beb1e5
commit 18811d503d
1 changed files with 43 additions and 32 deletions

View File

@ -59,6 +59,8 @@ endfunction(llvm_map_components_to_libraries)
function(explicit_map_components_to_libraries out_libs)
set( link_components ${ARGN} )
string(TOUPPER "${llvm_libs}" capitalized_libs)
# Translate symbolic component names to real libraries:
foreach(c ${link_components})
# add codegen, asmprinter, asmparser, disassembler
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
@ -102,39 +104,48 @@ function(explicit_map_components_to_libraries out_libs)
elseif( c STREQUAL "all" )
list(APPEND expanded_components ${llvm_libs})
else( NOT idx LESS 0 )
list(APPEND expanded_components LLVM${c})
# Canonize the component name:
string(TOUPPER "${c}" capitalized)
list(FIND capitalized_libs LLVM${capitalized} lib_idx)
if( lib_idx LESS 0 )
# The component is unkown. Maybe is an ommitted target?
is_llvm_target_library(${c} iltl_result)
if( NOT iltl_result )
message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
endif()
else( lib_idx LESS 0 )
list(GET llvm_libs ${lib_idx} canonical_lib)
list(APPEND expanded_components ${canonical_lib})
endif( lib_idx LESS 0 )
endif( NOT idx LESS 0 )
endforeach(c)
# We must match capitalization.
string(TOUPPER "${llvm_libs}" capitalized_libs)
list(REMOVE_DUPLICATES expanded_components)
# Expand dependencies while topologically sorting the list of libraries:
list(LENGTH expanded_components lst_size)
set(result "")
while( 0 LESS ${lst_size} )
list(GET expanded_components 0 c)
string(TOUPPER "${c}" capitalized)
list(FIND capitalized_libs ${capitalized} idx)
set(add_it ON)
if( idx LESS 0 )
# The library is unkown. Maybe is an ommitted target?
is_llvm_target_library(${c} iltl_result)
if( NOT iltl_result )
message(FATAL_ERROR "Library ${c} not found in list of llvm libraries.")
endif()
set(add_it OFF)
endif( idx LESS 0 )
list(GET llvm_libs ${idx} canonical_lib)
list(REMOVE_ITEM result ${canonical_lib})
foreach(c ${MSVC_LIB_DEPS_${canonical_lib}})
list(REMOVE_ITEM expanded_components ${c})
endforeach()
if( add_it )
list(APPEND result ${canonical_lib})
list(APPEND expanded_components ${MSVC_LIB_DEPS_${canonical_lib}})
endif()
list(REMOVE_AT expanded_components 0)
set(cursor 0)
set(processed)
while( cursor LESS lst_size )
list(GET expanded_components ${cursor} lib)
list(APPEND expanded_components ${MSVC_LIB_DEPS_${lib}})
# Remove duplicates at the front:
list(REVERSE expanded_components)
list(REMOVE_DUPLICATES expanded_components)
list(REVERSE expanded_components)
list(APPEND processed ${lib})
# Find the maximum index that doesn't have to be re-processed:
while(NOT "${expanded_components}" MATCHES "^${processed}.*" )
list(REMOVE_AT processed -1)
endwhile()
list(LENGTH processed cursor)
list(LENGTH expanded_components lst_size)
endwhile( 0 LESS ${lst_size} )
endwhile( cursor LESS lst_size )
# Return just the libraries included in this build:
set(result)
foreach(c ${expanded_components})
list(FIND llvm_libs ${c} lib_idx)
if( NOT lib_idx LESS 0 )
set(result ${result} ${c})
endif()
endforeach(c)
set(${out_libs} ${result} PARENT_SCOPE)
endfunction(explicit_map_components_to_libraries)
@ -151,13 +162,13 @@ endfunction(explicit_map_components_to_libraries)
# The format generated by GenLibDeps.pl
# libLLVMARMAsmPrinter.a: libLLVMMC.a libLLVMSupport.a
# LLVMARMAsmPrinter.o: LLVMARMCodeGen.o libLLVMAsmPrinter.a libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMTarget.a
# is translated to:
# set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMMC LLVMSupport)
# set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget)
# It is necessary to remove the `lib' prefix and the `.a' suffix.
# It is necessary to remove the `lib' prefix and the `.a'.
# This 'sed' script should do the trick:
# sed -e s'#\.a##g' -e 's#libLLVM#LLVM#g' -e 's#: # #' -e 's#\(.*\)#set(MSVC_LIB_DEPS_\1)#' ~/llvm/tools/llvm-config/LibDeps.txt