mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[cmake] Canonicalize CMake booleans to 0/1 for lit interop
Canonicalize all CMake booleans to 0/1 before passing them to lit, to ensure that the Python side handles all of them consistently and correctly. 0/1 is a safe choice of values that trigger the same boolean interpretation in CMake, Python and C++. Furthermore, using them without quotes improves the chance Python will explicitly fail when an incorrect value (such as ON/OFF, TRUE/FALSE, YES/NO) is accidentally passed, rather than silently misinterpreting the value. This replaces a lot of different logics spread around lit site files, attempting to partially reproduce the boolean logic used in CMake and usually silently failing when an uncommon value was used instead. In fact, some of them were never working correctly since different values were assigned in CMake and checked in Python. The alternative solution could be to create a common parser for CMake booleans in lit and use it consistently throughout the site files. However, it does not seem like the best idea to create redundant implementation of the same logic and have to follow upstream if it ever is extended to handle more values. Differential Revision: https://reviews.llvm.org/D28294 llvm-svn: 291284
This commit is contained in:
parent
564c4f1d2a
commit
a44b476fd0
@ -462,13 +462,6 @@ if( MSVC )
|
||||
if(LLVM_ENABLE_DIA_SDK AND NOT HAVE_DIA_SDK)
|
||||
message(FATAL_ERROR "DIA SDK not found. If you have both VS 2012 and 2013 installed, you may need to uninstall the former and re-install the latter afterwards.")
|
||||
endif()
|
||||
|
||||
# Normalize to 0/1 for lit.site.cfg
|
||||
if(LLVM_ENABLE_DIA_SDK)
|
||||
set(LLVM_ENABLE_DIA_SDK 1)
|
||||
else()
|
||||
set(LLVM_ENABLE_DIA_SDK 0)
|
||||
endif()
|
||||
else()
|
||||
set(LLVM_ENABLE_DIA_SDK 0)
|
||||
endif( MSVC )
|
||||
|
@ -1067,6 +1067,19 @@ function(llvm_add_go_executable binary pkgpath)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# This function canonicalize the CMake variables passed by names
|
||||
# from CMake boolean to 0/1 suitable for passing into Python or C++,
|
||||
# in place.
|
||||
function(llvm_canonicalize_cmake_booleans)
|
||||
foreach(var ${ARGN})
|
||||
if(${var})
|
||||
set(${var} 1 PARENT_SCOPE)
|
||||
else()
|
||||
set(${var} 0 PARENT_SCOPE)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction(llvm_canonicalize_cmake_booleans)
|
||||
|
||||
# This function provides an automatic way to 'configure'-like generate a file
|
||||
# based on a set of common and custom variables, specifically targeting the
|
||||
# variables needed for the 'lit.site.cfg' files. This function bundles the
|
||||
|
@ -6,7 +6,7 @@ import sys
|
||||
if not 'go' in config.root.llvm_bindings:
|
||||
config.unsupported = True
|
||||
|
||||
if config.root.include_go_tests != 'ON':
|
||||
if not config.root.include_go_tests:
|
||||
config.unsupported = True
|
||||
|
||||
def find_executable(executable, path=None):
|
||||
|
@ -3,5 +3,5 @@ config.suffixes = ['.ml']
|
||||
if not 'ocaml' in config.root.llvm_bindings:
|
||||
config.unsupported = True
|
||||
|
||||
if config.root.have_ocaml_ounit not in ('1', 'TRUE'):
|
||||
if not config.root.have_ocaml_ounit:
|
||||
config.unsupported = True
|
||||
|
@ -1,3 +1,14 @@
|
||||
llvm_canonicalize_cmake_booleans(
|
||||
LLVM_TOOL_LTO_BUILD
|
||||
HAVE_OCAMLOPT
|
||||
HAVE_OCAML_OUNIT
|
||||
LLVM_INCLUDE_GO_TESTS
|
||||
LLVM_USE_INTEL_JITEVENTS
|
||||
HAVE_LIBZ
|
||||
HAVE_LIBXAR
|
||||
LLVM_ENABLE_DIA_SDK
|
||||
LLVM_ENABLE_FFI)
|
||||
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
||||
|
@ -1,3 +1,3 @@
|
||||
# These tests require foreign function calls
|
||||
if config.enable_ffi != "ON":
|
||||
if not config.enable_ffi:
|
||||
config.unsupported = True
|
||||
|
@ -1,3 +1,3 @@
|
||||
if not config.root.llvm_use_intel_jitevents == "true":
|
||||
if not config.root.llvm_use_intel_jitevents:
|
||||
config.unsupported = True
|
||||
|
||||
|
@ -231,7 +231,7 @@ config.substitutions.append( ('%ld64', ld64_cmd) )
|
||||
config.substitutions.append( ('%ocamlc',
|
||||
"%s ocamlc -cclib -L%s %s" %
|
||||
(config.ocamlfind_executable, llvm_lib_dir, config.ocaml_flags)) )
|
||||
if config.have_ocamlopt in ('1', 'TRUE'):
|
||||
if config.have_ocamlopt:
|
||||
config.substitutions.append( ('%ocamlopt',
|
||||
"%s ocamlopt -cclib -L%s -cclib -Wl,-rpath,%s %s" %
|
||||
(config.ocamlfind_executable, llvm_lib_dir, llvm_lib_dir, config.ocaml_flags)) )
|
||||
@ -399,7 +399,7 @@ if lit_config.params.get("run_long_tests", None) == "true":
|
||||
if not 'hexagon' in config.target_triple:
|
||||
config.available_features.add("object-emission")
|
||||
|
||||
if config.have_zlib == "1":
|
||||
if config.have_zlib:
|
||||
config.available_features.add("zlib")
|
||||
else:
|
||||
config.available_features.add("nozlib")
|
||||
@ -455,7 +455,7 @@ if have_ld_plugin_support():
|
||||
config.available_features.add('ld_plugin')
|
||||
|
||||
def have_ld64_plugin_support():
|
||||
if (config.llvm_tool_lto_build == 'OFF' or config.ld64_executable == ''):
|
||||
if not config.llvm_tool_lto_build or config.ld64_executable == '':
|
||||
return False
|
||||
|
||||
ld_cmd = subprocess.Popen([config.ld64_executable, '-v'], stderr = subprocess.PIPE)
|
||||
|
@ -15,12 +15,12 @@ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
|
||||
config.python_executable = "@PYTHON_EXECUTABLE@"
|
||||
config.gold_executable = "@GOLD_EXECUTABLE@"
|
||||
config.ld64_executable = "@LD64_EXECUTABLE@"
|
||||
config.llvm_tool_lto_build = "@LLVM_TOOL_LTO_BUILD@"
|
||||
config.llvm_tool_lto_build = @LLVM_TOOL_LTO_BUILD@
|
||||
config.ocamlfind_executable = "@OCAMLFIND@"
|
||||
config.have_ocamlopt = "@HAVE_OCAMLOPT@"
|
||||
config.have_ocaml_ounit = "@HAVE_OCAML_OUNIT@"
|
||||
config.have_ocamlopt = @HAVE_OCAMLOPT@
|
||||
config.have_ocaml_ounit = @HAVE_OCAML_OUNIT@
|
||||
config.ocaml_flags = "@OCAMLFLAGS@"
|
||||
config.include_go_tests = "@LLVM_INCLUDE_GO_TESTS@"
|
||||
config.include_go_tests = @LLVM_INCLUDE_GO_TESTS@
|
||||
config.go_executable = "@GO_EXECUTABLE@"
|
||||
config.enable_shared = @ENABLE_SHARED@
|
||||
config.enable_assertions = @ENABLE_ASSERTIONS@
|
||||
@ -32,12 +32,12 @@ config.host_arch = "@HOST_ARCH@"
|
||||
config.host_cc = "@HOST_CC@"
|
||||
config.host_cxx = "@HOST_CXX@"
|
||||
config.host_ldflags = "@HOST_LDFLAGS@"
|
||||
config.llvm_use_intel_jitevents = "@LLVM_USE_INTEL_JITEVENTS@"
|
||||
config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
|
||||
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
|
||||
config.have_zlib = "@HAVE_LIBZ@"
|
||||
config.have_libxar = "@HAVE_LIBXAR@"
|
||||
config.have_zlib = @HAVE_LIBZ@
|
||||
config.have_libxar = @HAVE_LIBXAR@
|
||||
config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
|
||||
config.enable_ffi = "@LLVM_ENABLE_FFI@"
|
||||
config.enable_ffi = @LLVM_ENABLE_FFI@
|
||||
|
||||
# Support substitution of the tools_dir with user parameters. This is
|
||||
# used when we can't determine the tool dir at configuration time.
|
||||
|
Loading…
x
Reference in New Issue
Block a user