Skip to content

Commit

Permalink
CLANG_VERSION and GCC_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
mrowrpurr committed Jan 7, 2024
1 parent 53848a8 commit e51a016
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Linux C++11
on:
push:
branches: [ "v3" ]
env:
GCC_VERSION: 11
jobs:
build:
runs-on: ubuntu-22.04
Expand All @@ -10,6 +12,7 @@ jobs:
- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
actions-cache-folder: .xmake-cache
- name: Build
run: xmake build -w -v "Tests cxx11"
- name: Test
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/linux-cxx11-gcc12.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Linux C++11
on:
push:
branches: [ "v3" ]
env:
GCC_VERSION: 12
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
actions-cache-folder: .xmake-cache
- name: Build
run: xmake build -w -v "Tests cxx11"
- name: Test
run: xmake run "Tests cxx11"
21 changes: 15 additions & 6 deletions Tests/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
test_target("cxx11")
clang_test_target("cxx11")

if supports_clang() then
test_target("cxx11", "clang")
end

test_target("cxx14")
clang_test_target("cxx14")

test_target("cxx17")
clang_test_target("cxx17")
if supports_clang() then
test_target("cxx14", "clang")
end

test_target("cxx17")
clang_test_target("cxx17")

if supports_clang() then
test_target("cxx17", "clang")
end

test_target("cxx20")
clang_test_target("cxx20")

if supports_clang() then
test_target("cxx20", "clang")
end

target("Run All Tests")
set_kind("phony")
Expand Down
43 changes: 34 additions & 9 deletions xmake/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,49 @@ function is_linux()
return is_plat("linux") or is_wsl()
end

function supports_clang()
return is_wsl() or not is_plat("windows")
end

function set_compiler(compiler)
if is_plat("windows") and not is_wsl() then
print("WINDOWS returning...")
return -- MSVC, nothing to configure
end
if not compiler then
compiler = "gcc" -- Default to gcc
end
if compiler == "clang" then
local clang_version = os.getenv("CLANG_VERSION")
set_toolchains("clang")
if clang_version then
set_toolset("cc", "clang-" .. clang_version)
set_toolset("cxx", "clang++-" .. clang_version)
set_toolset("ld", "clang++-" .. clang_version)
end
elseif compiler == "gcc" then
local gcc_version = os.getenv("GCC_VERSION")
set_toolchains("gcc")
if gcc_version then
set_toolset("cc", "gcc-" .. gcc_version)
set_toolset("cxx", "g++-" .. gcc_version)
set_toolset("ld", "g++-" .. gcc_version)
end
else
error("Unknown compiler: " .. compiler)
end
end

function test_target(cpp_version, compiler)
target_name = "Tests " .. cpp_version
if compiler then
target_name = target_name .. " " .. compiler
end
target(target_name)
set_languages(cpp_version)
if compiler then
add_toolchains(compiler)
end
set_compiler(compiler)
set_kind("binary")
add_includedirs("Helpers")
add_files("run_tests.cpp")
-- add_files(cpp_version .. "/*.cpp")
end

function clang_test_target(cpp_version)
if is_linux() then
test_target(cpp_version, "clang")
end
end

0 comments on commit e51a016

Please sign in to comment.