diff options
| author | ruki <[email protected]> | 2021-03-02 22:45:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-03-02 22:45:30 +0800 |
| commit | 569416446b0cc78535d93614197568fbaffcd497 (patch) | |
| tree | e97c25606ed83cbec58e3241489037799d329836 | |
| parent | 2654dce9ac9d8cfbe30445bcdbe843d912dd16b9 (diff) | |
improve tinyc
| -rw-r--r-- | .github/workflows/windows.yml | 30 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | README_zh.md | 2 | ||||
| -rw-r--r-- | tests/projects/package/toolchain_tinycc/src/main.c | 7 | ||||
| -rw-r--r-- | tests/projects/package/toolchain_tinycc/xmake.lua | 7 | ||||
| -rw-r--r-- | xmake/platforms/windows/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/toolchains/tinycc/xmake.lua (renamed from xmake/toolchains/tinyc/xmake.lua) | 48 |
7 files changed, 35 insertions, 63 deletions
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 290be340e..fca466899 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -88,21 +88,6 @@ jobs: ./nsis/makensis.exe /DMAJOR=$($version.ProductMajorPart) /DMINOR=$($version.ProductMinorPart) /DALTER=$($version.ProductBuildPart) /DBUILD=$($($version.ProductVersion -split '\+')[1]) /D${{ matrix.arch }} .\scripts\installer.nsi (New-Item ./artifacts/${{env.RELEASE_NAME}} -ItemType Directory).FullName Copy-Item scripts/xmake.exe ./artifacts/${{env.RELEASE_NAME}}/xmake.exe - # build installer for tinyc - if ("${{ matrix.arch }}" -eq "x64"){ - Invoke-WebRequest "http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27-win64-bin.zip" -UseBasicParsing -OutFile .\tcc.zip - } else { - Invoke-WebRequest "http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27-win32-bin.zip" -UseBasicParsing -OutFile .\tcc.zip - } - Expand-Archive ./tcc.zip -DestinationPath ./tcc - Copy-Item ./tcc/tcc ./winenv/tcc -Recurse - Invoke-WebRequest "http://download.savannah.gnu.org/releases/tinycc/winapi-full-for-0.9.27.zip" -UseBasicParsing -OutFile .\winapi.zip - Expand-Archive ./winapi.zip -DestinationPath ./winapi - Copy-Item ./winapi/winapi-full-for-0.9.27 ./winenv/tcc/winapi -Recurse - ./nsis/makensis.exe /DMAJOR=$($version.ProductMajorPart) /DMINOR=$($version.ProductMinorPart) /DALTER=$($version.ProductBuildPart) /DBUILD=$($($version.ProductVersion -split '\+')[1]) /D${{ matrix.arch }} .\scripts\installer.nsi - Copy-Item scripts/xmake.exe ./artifacts/${{env.RELEASE_NAME}}/xmake-tinyc.exe - Remove-Item ./winenv/tcc -Recurse - Remove-Item ./scripts/xmake.exe # archive Copy-Item ./*.md ./xmake Copy-Item ./winenv ./xmake -Recurse @@ -129,10 +114,6 @@ jobs: path: artifacts/${{env.RELEASE_NAME}}/xmake.exe - uses: actions/upload-artifact@v2 with: - name: xmake-tinyc-latest.${{env.RELEASE_NAME}}.exe - path: artifacts/${{env.RELEASE_NAME}}/xmake-tinyc.exe - - uses: actions/upload-artifact@v2 - with: name: xmake-latest.${{ env.RELEASE_NAME }}.zip path: artifacts/${{env.RELEASE_NAME}}/archive.zip - uses: actions/upload-artifact@v2 @@ -177,17 +158,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} - asset_path: artifacts/${{env.RELEASE_NAME}}/xmake-tinyc.exe - asset_name: xmake-tinyc-${{ steps.tagName.outputs.tag }}.${{ env.RELEASE_NAME }}.exe - asset_content_type: application/zip - - - name: publish - if: github.event.action == 'published' - uses: actions/[email protected] - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} asset_path: artifacts/${{env.RELEASE_NAME}}/archive.zip asset_name: xmake-${{ steps.tagName.outputs.tag }}.${{ env.RELEASE_NAME }}.zip asset_content_type: application/zip @@ -212,7 +212,7 @@ mingw Minimalist GNU for Windows gnu-rm GNU Arm Embedded Toolchain envs Environment variables toolchain fasm Flat Assembler -tinyc Tiny C Compiler +tinycc Tiny C Compiler emcc A toolchain for compiling to asm.js and WebAssembly icc Intel C/C++ Compiler ifort Intel Fortran Compiler diff --git a/README_zh.md b/README_zh.md index 67bb6cef4..03e9b61e0 100644 --- a/README_zh.md +++ b/README_zh.md @@ -221,7 +221,7 @@ mingw Minimalist GNU for Windows gnu-rm GNU Arm Embedded Toolchain envs Environment variables toolchain fasm Flat Assembler -tinyc Tiny C Compiler +tinycc Tiny C Compiler emcc A toolchain for compiling to asm.js and WebAssembly icc Intel C/C++ Compiler ifort Intel Fortran Compiler diff --git a/tests/projects/package/toolchain_tinycc/src/main.c b/tests/projects/package/toolchain_tinycc/src/main.c new file mode 100644 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/package/toolchain_tinycc/src/main.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char** argv) +{ + printf("hello world!\n"); + return 0; +} diff --git a/tests/projects/package/toolchain_tinycc/xmake.lua b/tests/projects/package/toolchain_tinycc/xmake.lua new file mode 100644 index 000000000..1c1384acb --- /dev/null +++ b/tests/projects/package/toolchain_tinycc/xmake.lua @@ -0,0 +1,7 @@ +add_rules("mode.debug", "mode.release") +add_requires("tinycc") + +target("test") + set_kind("binary") + add_files("src/*.c") + set_toolchains("@tinycc") diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index 589522730..fb075adbe 100644 --- a/xmake/platforms/windows/xmake.lua +++ b/xmake/platforms/windows/xmake.lua @@ -38,7 +38,7 @@ platform("windows") set_formats("symbol", "$(name).pdb") -- set toolchains - set_toolchains("msvc", "clang", "yasm", "nasm", "cuda", "dlang", "rust", "go", "gfortran", "zig", "tinyc") + set_toolchains("msvc", "clang", "yasm", "nasm", "cuda", "dlang", "rust", "go", "gfortran", "zig") -- set menu set_menu { diff --git a/xmake/toolchains/tinyc/xmake.lua b/xmake/toolchains/tinycc/xmake.lua index e64e68167..905b3944f 100644 --- a/xmake/toolchains/tinyc/xmake.lua +++ b/xmake/toolchains/tinycc/xmake.lua @@ -19,7 +19,7 @@ -- -- define toolchain -toolchain("tinyc") +toolchain("tinycc") -- set homepage set_homepage("https://bellard.org/tcc/") @@ -28,12 +28,6 @@ toolchain("tinyc") -- mark as standalone toolchain set_kind("standalone") - -- set toolset - set_toolset("cc", "tcc") - set_toolset("ld", "tcc") - set_toolset("sh", "tcc") - set_toolset("ar", "tcc") - -- check toolchain on_check(function (toolchain) @@ -42,15 +36,20 @@ toolchain("tinyc") import("lib.detect.find_tool") -- find tcc + local paths = {toolchain:bindir()} local sdkdir = toolchain:sdkdir() - if not sdkdir and is_host("windows") then - local winenv_tccsdk = path.join(os.programdir(), "winenv", "tcc") - if os.isdir(winenv_tccsdk) then - sdkdir = winenv_tccsdk + if sdkdir then + table.insert(paths, path.join(sdkdir, "bin")) + end + for _, package in ipairs(toolchain:packages()) do + local installdir = package:installdir() + if installdir then + table.insert(paths, path.join(installdir, "bin")) end end - if find_tool("tcc", {paths = toolchain:bindir() or sdkdir}) then - toolchain:config_set("sdkdir", sdkdir) + local tcc = find_tool("tcc", {paths = paths}) + if tcc then + toolchain:config_set("tcc", tcc.program) toolchain:configs_save() return true end @@ -77,21 +76,10 @@ toolchain("tinyc") toolchain:add("shflags", march) end - -- init linkdirs and sysincludedirs - local sdkdir = toolchain:sdkdir() - if sdkdir then - local includedir = path.join(sdkdir, "include") - if os.isdir(includedir) then - toolchain:add("sysincludedirs", includedir) - end - local winenv_tcc_winapi = path.join(os.programdir(), "winenv", "tcc", "winapi", "include") - if is_host("windows") and os.isdir(winenv_tcc_winapi) then - toolchain:add("sysincludedirs", winenv_tcc_winapi) - toolchain:add("sysincludedirs", path.join(winenv_tcc_winapi, "winapi")) - end - local linkdir = path.join(sdkdir, "lib") - if os.isdir(linkdir) then - toolchain:add("linkdirs", linkdir) - end - end + -- add toolset + local tcc = toolchain:config("tcc") or "tcc" + toolchain:add("toolset", "cc", tcc) + toolchain:add("toolset", "ld", tcc) + toolchain:add("toolset", "sh", tcc) + toolchain:add("toolset", "ar", tcc) end) |
