Skip to content

Commit 0181241

Browse files
committed
use add_custom_target
1 parent d153c85 commit 0181241

File tree

7 files changed

+55
-45
lines changed

7 files changed

+55
-45
lines changed

mlir/examples/standalone/test/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
tool_dirs = [config.standalone_tools_dir, config.llvm_tools_dir]
5555
tools = [
56-
ToolSubst("mlir-opt", post=";", unresolved="fatal"),
56+
"mlir-opt",
5757
"standalone-capi-test",
5858
"standalone-opt",
5959
"standalone-translate",

mlir/test/CMakeLists.txt

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ if (MLIR_INCLUDE_INTEGRATION_TESTS)
6565

6666
endif()
6767

68-
option(MLIR_RUN_STANDALONE_INSTALL_TESTS "Run Standalone example install tests." ON)
69-
if(MLIR_RUN_STANDALONE_INSTALL_TESTS AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
70-
message(WARNING "Standalone example install tests will install into root!\
71-
If you want to disable this behavior pass -DMLIR_RUN_STANDALONE_INSTALL_TESTS=OFF")
72-
endif()
73-
7468
llvm_canonicalize_cmake_booleans(
7569
LLVM_BUILD_EXAMPLES
7670
LLVM_HAS_NVPTX_TARGET
@@ -82,7 +76,6 @@ llvm_canonicalize_cmake_booleans(
8276
MLIR_ENABLE_SPIRV_CPU_RUNNER
8377
MLIR_ENABLE_VULKAN_RUNNER
8478
MLIR_INCLUDE_INTEGRATION_TESTS
85-
MLIR_RUN_STANDALONE_INSTALL_TESTS
8679
MLIR_RUN_AMX_TESTS
8780
MLIR_RUN_CUDA_TENSOR_CORE_TESTS
8881
MLIR_RUN_X86VECTOR_TESTS
@@ -132,6 +125,50 @@ set(MLIR_TEST_DEPENDS
132125
if(NOT MLIR_STANDALONE_BUILD)
133126
list(APPEND MLIR_TEST_DEPENDS FileCheck count not split-file yaml2obj)
134127
endif()
128+
set(MLIR_STANDALONE_INSTALL_TEST_PREFIX "${MLIR_BINARY_DIR}/mlir-standalone-test-install")
129+
add_custom_target(
130+
install-mlir-standalone-test-prefix
131+
DEPENDS mlir-headers mlir-libraries mlir-cmake-exports mlir-tblgen
132+
mlir-opt mlir-python-sources FileCheck count not
133+
COMMAND ${CMAKE_COMMAND} -E make_directory "${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
134+
COMMAND "${CMAKE_COMMAND}"
135+
-DCMAKE_INSTALL_COMPONENT=mlir-headers
136+
-DCMAKE_INSTALL_PREFIX="${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
137+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
138+
COMMAND "${CMAKE_COMMAND}"
139+
-DCMAKE_INSTALL_COMPONENT=mlir-libraries
140+
-DCMAKE_INSTALL_PREFIX="${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
141+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
142+
COMMAND "${CMAKE_COMMAND}"
143+
-DCMAKE_INSTALL_COMPONENT=mlir-cmake-exports
144+
-DCMAKE_INSTALL_PREFIX="${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
145+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
146+
COMMAND "${CMAKE_COMMAND}"
147+
-DCMAKE_INSTALL_COMPONENT=mlir-tblgen
148+
-DCMAKE_INSTALL_PREFIX="${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
149+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
150+
COMMAND "${CMAKE_COMMAND}"
151+
-DCMAKE_INSTALL_COMPONENT=mlir-opt
152+
-DCMAKE_INSTALL_PREFIX="${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
153+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
154+
COMMAND "${CMAKE_COMMAND}"
155+
-DCMAKE_INSTALL_COMPONENT=mlir-python-sources
156+
-DCMAKE_INSTALL_PREFIX="${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
157+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
158+
COMMAND "${CMAKE_COMMAND}"
159+
-DCMAKE_INSTALL_COMPONENT=FileCheck
160+
-DCMAKE_INSTALL_PREFIX="${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
161+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
162+
COMMAND "${CMAKE_COMMAND}"
163+
-DCMAKE_INSTALL_COMPONENT=count
164+
-DCMAKE_INSTALL_PREFIX="${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
165+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
166+
COMMAND "${CMAKE_COMMAND}"
167+
-DCMAKE_INSTALL_COMPONENT=not
168+
-DCMAKE_INSTALL_PREFIX="${MLIR_STANDALONE_INSTALL_TEST_PREFIX}"
169+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
170+
)
171+
list(APPEND MLIR_TEST_DEPENDS install-mlir-standalone-test-prefix)
135172

136173
set(MLIR_TEST_DEPENDS ${MLIR_TEST_DEPENDS}
137174
mlir-capi-pdl-test

mlir/test/Examples/standalone/lit.local.cfg

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,4 @@ config.substitutions.append(("%mlir_cmake_dir", config.mlir_cmake_dir))
1212
config.substitutions.append(("%llvm_use_linker", config.llvm_use_linker))
1313
config.substitutions.append(("%cmake_build_type", config.cmake_build_type))
1414
config.substitutions.append(("%llvm_obj_root", config.llvm_obj_root))
15-
config.substitutions.append(("%llvm_src_root", config.llvm_src_root))
16-
config.substitutions.append(("%host_cmake_install_prefix", config.host_cmake_install_prefix))
17-
config.substitutions.append(("%cmake_build_type", config.cmake_build_type))
18-
config.substitutions.append(("%cmake_c_compiler_launcher", config.cmake_c_compiler_launcher))
19-
config.substitutions.append(("%cmake_cxx_compiler_launcher", config.cmake_cxx_compiler_launcher))
20-
21-
if config.run_standalone_install_tests:
22-
config.available_features.add("run-standalone-install-tests")
23-
# see https://github.com/llvm/llvm-project/blob/57782eff31e9d454b54a201c7ac43dc1b93dbb3f/llvm/utils/lit/lit/TestRunner.py#L1858
24-
config.substitutions.insert(0, ("FileCheck", "FileChuck"))
25-
config.substitutions.insert(0, ("count", "kount"))
26-
config.substitutions.insert(0, ("not", "mot"))
27-
config.substitutions.append(("kount", "count"))
28-
config.substitutions.append(("mot", "not"))
29-
config.substitutions.append(("FileChuck", "FileCheck"))
15+
config.substitutions.append(("%standalone_install_test_prefix", config.standalone_install_test_prefix))
Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
# REQUIRES: run-standalone-install-tests
2-
3-
# RUN: echo "test install distribution" | tee %t
4-
# CHECK: test install distribution
5-
6-
# RUN: "%cmake_exe" "%llvm_src_root" -DCMAKE_BUILD_TYPE=%cmake_build_type -B "%llvm_obj_root" \
7-
# RUN: -DLLVM_DISTRIBUTION_COMPONENTS="llvm-headers;llvm-libraries;cmake-exports;FileCheck;count;not;mlir-headers;mlir-libraries;mlir-cmake-exports;mlir-tblgen;mlir-opt;mlir-python-sources" | tee -a %t
8-
9-
# RUN: "%cmake_exe" --build "%llvm_obj_root" --target install-distribution -j | tee -a %t
1+
# RUN: echo "test install" | tee %t
2+
# CHECK: test install
103

114
# RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
125
# RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
13-
# RUN: -DCMAKE_CXX_COMPILER_LAUNCHER=%cmake_cxx_compiler_launcher -DCMAKE_C_COMPILER_LAUNCHER=%cmake_c_compiler_launcher \
146
# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx \
157
# RUN: -DLLVM_EXTERNAL_LIT="%llvm_obj_root/bin/llvm-lit" \
16-
# RUN: -DMLIR_DIR="%host_cmake_install_prefix/lib/cmake/mlir" \
17-
# RUN: -DLLVM_DIR="%host_cmake_install_prefix/lib/cmake/llvm" \
8+
# RUN: -DMLIR_DIR="%standalone_install_test_prefix/lib/cmake/mlir" \
9+
# RUN: -DLLVM_DIR="%standalone_install_test_prefix/lib/cmake/llvm" \
1810
# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
1911
# RUN: -DPython3_EXECUTABLE=%python \
2012
# RUN: -DPython_EXECUTABLE=%python | tee -a %t
@@ -25,4 +17,4 @@
2517

2618
# CHECK: Passed
2719
# CHECK-NOT: Failed
28-
# UNSUPPORTED: target={{.*(windows|android).*}}
20+
# UNSUPPORTED: target={{.*(android).*}}

mlir/test/Examples/standalone/test.toy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
22
# RUN: -DCMAKE_BUILD_TYPE=%cmake_build_type \
33
# RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
4-
# RUN: -DCMAKE_CXX_COMPILER_LAUNCHER=%cmake_cxx_compiler_launcher -DCMAKE_C_COMPILER_LAUNCHER=%cmake_c_compiler_launcher \
54
# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%mlir_cmake_dir \
65
# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
76
# RUN: -DPython3_EXECUTABLE=%python \

mlir/test/lit.cfg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def find_real_python_interpreter():
187187
llvm_config.with_environment("PATH", dirs, append_path=True)
188188

189189
tools = [
190-
ToolSubst("mlir-tblgen", post=";", unresolved="fatal"),
190+
"mlir-tblgen",
191191
"mlir-translate",
192192
"mlir-lsp-server",
193193
"mlir-capi-execution-engine-test",
@@ -318,7 +318,7 @@ def find_real_python_interpreter():
318318
]
319319
)
320320
else:
321-
tools.extend([ToolSubst("mlir-opt", post=";", unresolved="fatal")])
321+
tools.extend(["mlir-opt"])
322322

323323
llvm_config.add_tool_substitutions(tools, tool_dirs)
324324

mlir/test/lit.site.cfg.py.in

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import sys
44

55
config.target_triple = "@LLVM_TARGET_TRIPLE@"
6-
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
76
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
7+
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
88
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
99
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
1010
config.spirv_tools_tests = @LLVM_INCLUDE_SPIRV_TOOLS_TESTS@
@@ -18,12 +18,9 @@ config.host_cc = "@HOST_CC@"
1818
config.host_cxx = "@HOST_CXX@"
1919
config.enable_libcxx = "@LLVM_ENABLE_LIBCXX@"
2020
config.host_cmake = "@CMAKE_COMMAND@"
21-
config.cmake_build_type = "@CMAKE_BUILD_TYPE@"
22-
config.cmake_c_compiler_launcher = "@CMAKE_C_COMPILER_LAUNCHER@"
23-
config.cmake_cxx_compiler_launcher= "@CMAKE_CXX_COMPILER_LAUNCHER@"
2421
config.host_cmake_generator = "@CMAKE_GENERATOR@"
2522
config.cmake_build_type = "@CMAKE_BUILD_TYPE@"
26-
config.host_cmake_install_prefix = "@CMAKE_INSTALL_PREFIX@"
23+
config.standalone_install_test_prefix = "@MLIR_STANDALONE_INSTALL_TEST_PREFIX@"
2724
config.llvm_use_linker = "@LLVM_USE_LINKER@"
2825
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
2926
config.host_arch = "@HOST_ARCH@"
@@ -37,7 +34,6 @@ config.build_examples = @LLVM_BUILD_EXAMPLES@
3734
config.run_nvptx_tests = @LLVM_HAS_NVPTX_TARGET@
3835
config.enable_cuda_runner = @MLIR_ENABLE_CUDA_RUNNER@
3936
config.run_rocm_tests = @MLIR_ENABLE_ROCM_CONVERSIONS@
40-
config.run_standalone_install_tests = @MLIR_RUN_STANDALONE_INSTALL_TESTS@
4137
config.enable_rocm_runner = @MLIR_ENABLE_ROCM_RUNNER@
4238
config.gpu_compilation_format = "@MLIR_GPU_COMPILATION_TEST_FORMAT@"
4339
config.rocm_test_chipset = "@ROCM_TEST_CHIPSET@"

0 commit comments

Comments
 (0)