diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 00000000..f3a84c8e --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,73 @@ +name: nightly + +permissions: + contents: write + +on: + push: + branches: [ non-existent-branch ] + +jobs: + package: + strategy: + matrix: + include: + - os: windows-2022 + artifact_name: clice.7z + asset_name: clice-x64-windows-msvc.7z + toolchain: clang + + - os: ubuntu-24.04 + artifact_name: clice.tar.xz + asset_name: clice-x86_64-linux-gnu.tar.xz + toolchain: clang-20 + + runs-on: ${{ matrix.os }} + + steps: + - name: Setup llvm + if: matrix.os == 'windows-2022' + uses: MinoruSekine/setup-scoop@v4.0.1 + with: + buckets: main + apps: llvm + + - name: Setup llvm & libstdc++ & cmake & ninja + if: matrix.os == 'ubuntu-24.04' + run: | + sudo apt remove llvm-16-linker-tools llvm-16 llvm-17-linker-tools llvm-17 llvm-18-linker-tools llvm-18 + sudo apt update + sudo apt install -y gcc-14 g++-14 libstdc++-14-dev cmake ninja-build + + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 + sudo update-alternatives --set gcc /usr/bin/gcc-14 + sudo update-alternatives --set g++ /usr/bin/g++-14 + + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 20 all + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup xmake + uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: branch@master + actions-cache-folder: '.xmake-cache' + actions-cache-key: ${{ matrix.os }} + + - name: Package + run: | + xmake config --yes --toolchain=${{ matrix.toolchain }} --enable_test=n --dev=n --release=y + xmake pack + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/xpack/clice/${{ matrix.artifact_name }} + asset_name: ${{ matrix.asset_name }} + tag: nightly + overwrite: true diff --git a/xmake.lua b/xmake.lua index 4a18d600..34992ba9 100644 --- a/xmake.lua +++ b/xmake.lua @@ -6,6 +6,7 @@ set_allowedmodes("debug", "release") option("enable_test", {default = true}) option("dev", {default = true}) +option("release", {default = false}) if has_config("dev") then set_policy("compatibility.version", "3.0") @@ -25,7 +26,22 @@ if has_config("dev") then end end -add_requires("llvm", "libuv", "toml++") +local libuv_require = "libuv" + +if has_config("release") then + set_policy("build.optimization.lto", true) + set_policy("package.cmake_generator.ninja", true) + + if is_plat("windows") then + set_runtimes("MT") + -- workaround cmake + libuv_require = "libuv[toolchains=clang-cl]" + end + + includes("@builtin/xpack") +end + +add_requires("llvm", libuv_require, "toml++") add_rules("mode.release", "mode.debug") set_languages("c++23") @@ -72,10 +88,6 @@ target("clice") add_deps("clice-core") - on_config(function (target) - target:add("rpathdirs", path.join(target:dep("clice-core"):pkg("llvm"):installdir(), "lib")) - end) - target("integration_tests") set_default(false) set_kind("binary") @@ -95,9 +107,8 @@ target("unit_tests") add_packages("gtest") add_tests("default") - + on_config(function (target) - target:add("rpathdirs", path.join(target:dep("clice-core"):pkg("llvm"):installdir(), "lib")) target:set("runargs", "--test-dir=" .. path.absolute("tests"), "--resource-dir=" .. path.join(target:dep("clice-core"):pkg("llvm"):installdir(), "lib/clang/20") @@ -110,7 +121,13 @@ rule("clice_build_config") target:add("cxflags", "/GR-", {tools = {"clang_cl", "cl"}}) target:set("exceptions", "no-cxx") if target:is_plat("windows") then - target:add("ldflags", "-fuse-ld=lld-link") + target:set("toolset", "ar", "llvm-ar") + if target:toolchain("clang-cl") then + target:set("toolset", "ld", "lld-link") + target:set("toolset", "sh", "lld-link") + else + target:add("ldflags", "-fuse-ld=lld-link") + end elseif target:is_plat("linux") then -- gnu ld need to fix link order target:add("ldflags", "-fuse-ld=lld") @@ -118,25 +135,32 @@ rule("clice_build_config") end) package("llvm") - if is_plat("windows") then - if is_mode("release") then - add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x64-windows-msvc-release.7z") - add_versions("20.0.0", "4ef335845ebb52f8237bda3bcc7246b06085fdf5edc5cc6cf7f3a7c9ef655c09") - else + if has_config("release") then + if is_plat("windows") then + add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x64-windows-msvc-release-lto.7z") + add_versions("20.0.0", "c985d60825991eb6c7400be1b9872edf1de929908b12b282829efa52fda4c75c") + elseif is_plat("linux") then + add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x86_64-linux-gnu-release-lto.tar.xz") + add_versions("20.0.0", "adeb46c441265a4e442aea1b9d55f3950bc240aa84e2498b106d8dfd64e123cc") end - elseif is_plat("linux") then - if is_mode("debug") then - add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x86_64-linux-gnu-debug.tar.xz") - add_versions("20.0.0", "7dc045424a9667f20845dec058d211476b84300ebcfc8c3a3aabf41bff37cfd9") - elseif is_mode("release") then - add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x86_64-linux-gnu-release.tar.xz") - add_versions("20.0.0", "30ba7357eb40000f1d13d92242f7d87c3ff623e62205a41d10334d605739af89") + else + if is_plat("windows") then + if is_mode("release") then + add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x64-windows-msvc-release.7z") + add_versions("20.0.0", "4ef335845ebb52f8237bda3bcc7246b06085fdf5edc5cc6cf7f3a7c9ef655c09") + end + elseif is_plat("linux") then + if is_mode("debug") then + add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x86_64-linux-gnu-debug.tar.xz") + add_versions("20.0.0", "7dc045424a9667f20845dec058d211476b84300ebcfc8c3a3aabf41bff37cfd9") + elseif is_mode("release") then + add_urls("https://github.com/clice-project/llvm-binary/releases/download/$(version)/x86_64-linux-gnu-release.tar.xz") + add_versions("20.0.0", "30ba7357eb40000f1d13d92242f7d87c3ff623e62205a41d10334d605739af89") + end end end - if is_plat("windows") then - add_configs("runtimes", {description = "Set compiler runtimes.", default = "MD", readonly = true}) - elseif is_plat("linux") then + if is_plat("linux") then if is_mode("debug") then add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true}) end @@ -155,3 +179,25 @@ package("llvm") os.mv("lib", package:installdir()) os.mv("include", package:installdir()) end) + +if has_config("release") then + xpack("clice") + if is_plat("windows") then + set_formats("zip") + set_extension(".7z") + else + set_formats("targz") + set_extension(".tar.xz") + end + + set_bindir(".") + set_prefixdir("clice") + + add_targets("clice") + add_installfiles(path.join(os.projectdir(), "docs/clice.toml")) + + on_load(function (package) + local llvm_dir = package:target("clice"):dep("clice-core"):pkg("llvm"):installdir() + package:add("installfiles", path.join(llvm_dir, "lib/clang/(**)"), {prefixdir = "lib/clang"}) + end) +end