Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CMake
build/
_buildconfig.py

# Cargo
target/
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ execute_process(
)
message(STATUS ${CLANG_OUTPUT})

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate-buildconfig-py.cmake)
generate_buildconfig_py("${CMAKE_CURRENT_SOURCE_DIR}/tests/lit/lit")

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake)
set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp")

Expand Down
15 changes: 15 additions & 0 deletions cmake/generate-buildconfig-py.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function(generate_buildconfig_py outdir)
file(CONFIGURE
OUTPUT "${outdir}/_buildconfig.py"
CONTENT [[
"""Generated by CMake, do not edit."""

from pathlib import Path

CXX = Path(r"@CMAKE_CXX_COMPILER@")
CC = Path(r"@CMAKE_C_COMPILER@")
]]
ESCAPE_QUOTES
@ONLY
)
endfunction()
8 changes: 2 additions & 6 deletions tests/lit/lit/formats/Cpp2RustTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import lit.Test
import lit.util
from .._buildconfig import CXX, CC
from .base import TestFormat
from dataclasses import dataclass
from pathlib import Path
Expand Down Expand Up @@ -177,12 +178,7 @@ def build_cpp(self):
self.cpp_bin = self.build_dir / "app"
return None

## FIXME: these must use the detected/chosen compiler in cmake
cc = (
os.environ.get("CC", "clang")
if self.cc_input.suffix == ".c"
else os.environ.get("CXX", "clang++")
)
cc = CC if self.cc_input.suffix == ".c" else CXX
self.cpp_bin = self.tmp_dir / "cpp"
cmd = [
cc,
Expand Down
Loading