diff options
| author | Ângelo Andrade Cirino <[email protected]> | 2021-07-15 23:23:48 -0300 |
|---|---|---|
| committer | Ângelo Andrade Cirino <[email protected]> | 2021-07-15 23:23:48 -0300 |
| commit | 81ad292ea67f82d88d785a37d23b1f1603996da1 (patch) | |
| tree | 817b50173948547f7e4b491da271918c67b8a5ff | |
| parent | 942c32f448d9b8a850438aa2af1de2415b7ae872 (diff) | |
| parent | 8c1141aba414c07554179cb28687124514f6e770 (diff) | |
Merge remote-tracking branch 'upstream/master'
544 files changed, 29132 insertions, 5974 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index 3d89a3303..884c8c5f3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,7 +1,6 @@ #version: v2.1.8.{build} image: - Visual Studio 2013 - - Visual Studio 2015 - Visual Studio 2017 platform: @@ -74,6 +73,8 @@ after_build: - ps: Copy-Item .\*.md .\xmake - ps: Copy-Item C:\winenv\ .\xmake -Recurse - ps: Copy-Item .\core\build\xmake.exe .\xmake + - ps: Copy-Item .\scripts\xrepo.bat .\xmake\xrepo.bat + - ps: Copy-Item .\scripts\xrepo.ps1 .\xmake\xrepo.ps1 - ps: |- Add-Type -AssemblyName System.Text.Encoding Add-Type -AssemblyName System.IO.Compression.FileSystem diff --git a/.github/workflows/archlinux.yml b/.github/workflows/archlinux.yml new file mode 100644 index 000000000..2a9755fb2 --- /dev/null +++ b/.github/workflows/archlinux.yml @@ -0,0 +1,35 @@ +name: Archlinux + +on: + pull_request: + push: + release: + types: [published] + +jobs: + build: + + container: archlinux:latest + runs-on: ubuntu-latest + + steps: + - name: Prepare build tools + run: | + pacman -Sy --noconfirm --needed git base-devel perl make unzip + - uses: actions/checkout@v2 + with: + submodules: true + - name: prepare local xmake + run: | + cp -rf . ../xmake-source + - uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: local#../xmake-source + + - name: Tests + env: + XMAKE_ROOT: y + run: | + xmake lua -v -D tests/run.lua + xrepo --version + diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index d134c55cf..f25b4b7d2 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -13,26 +13,24 @@ jobs: runs-on: ubuntu-latest steps: - - name: prepare build tools + - name: Prepare build tools run: | uname -a dnf -y install @development-tools @rpm-development-tools dnf -y install copr-cli make gcc-c++ + dnf -y install perl dnf -y upgrade git - uses: actions/checkout@v2 with: submodules: true - - name: prepare local xmake + - name: Prepare local xmake run: | cp -rf . ../xmake-source - uses: xmake-io/github-action-setup-xmake@v1 with: xmake-version: local#../xmake-source - - uses: little-core-labs/[email protected] - id: tagName - # tests - - name: tests + - name: Tests env: XMAKE_ROOT: y run: | diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml new file mode 100644 index 000000000..a23a653e3 --- /dev/null +++ b/.github/workflows/freebsd.yml @@ -0,0 +1,32 @@ +name: FreeBSD + +on: + pull_request: + push: + release: + types: [published] + +jobs: + build: + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Tests + uses: vmactions/[email protected] + with: + usesh: true + mem: 4096 + prepare: pkg install -y curl unzip gmake llvm gsed bash perl5 + run: | + gmake -j4 + gmake install + export XMAKE_ROOT=y + xrepo --version + xmake lua -v -D tests/run.lua + + diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index fa4cca91a..7c1308060 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -26,26 +26,22 @@ jobs: - uses: little-core-labs/[email protected] id: tagName - # tests - - name: tests + - name: Tests run: | xmake lua -v -D tests/run.lua xrepo --version - # build artifacts - - name: artifact + - name: Artifact run: | sudo apt install -y ruby ruby-dev rubygems build-essential sudo gem install --no-document fpm scripts/makepkg deb - # upload artifacts - uses: actions/upload-artifact@v2 with: name: xmake-latest.amd64.deb path: artifacts/xmake.deb - # publish release - - name: publish + - name: Publish if: github.event.action == 'published' uses: actions/[email protected] env: @@ -56,7 +52,7 @@ jobs: asset_name: xmake-${{ steps.tagName.outputs.tag }}.amd64.deb asset_content_type: application/zip - - name: publish + - name: Publish if: github.event.action == 'published' env: PPA_GPG_PRIKEY_2C0C68C9: ${{ secrets.PPA_GPG_PRIKEY_2C0C68C9 }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index f594617bd..7358074bc 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -15,32 +15,30 @@ jobs: - uses: actions/checkout@v2 with: submodules: true - - name: prepare local xmake + - name: Prepare local xmake run: cp -rf . ../xmake-source - uses: xmake-io/github-action-setup-xmake@v1 with: xmake-version: local#../xmake-source - - uses: dlang-community/setup-dlang@v1 - with: - compiler: dmd-latest - uses: little-core-labs/[email protected] id: tagName - # tests - - name: tests + - name: Installation + run: | + brew install dmd + + - name: Tests run: | xmake lua -v -D tests/run.lua xrepo --version - # build artifacts - - name: artifact + - name: Artifact run: | brew install gnu-tar gem install --no-document fpm - scripts/makepkg osxpkg + scripts/makepkg osxpkg scripts/archive-all - scripts/makeself/build-runfile.sh - # upload artifacts + scripts/makeself/build-runfile.sh - uses: actions/upload-artifact@v2 with: name: xmake-latest.macosx.pkg @@ -62,8 +60,7 @@ jobs: name: xmake-latest.zip path: artifacts/xmake.zip - # publish release - - name: publish + - name: Publish package if: github.event.action == 'published' uses: actions/[email protected] env: @@ -74,7 +71,7 @@ jobs: asset_name: xmake-${{ steps.tagName.outputs.tag }}.macosx.pkg asset_content_type: application/zip - - name: publish + - name: Publish gz runfile if: github.event.action == 'published' uses: actions/[email protected] env: @@ -85,7 +82,7 @@ jobs: asset_name: xmake-${{ steps.tagName.outputs.tag }}.gz.run asset_content_type: application/zip - - name: publish + - name: Publish xz runfile if: github.event.action == 'published' uses: actions/[email protected] env: @@ -96,7 +93,7 @@ jobs: asset_name: xmake-${{ steps.tagName.outputs.tag }}.xz.run asset_content_type: application/zip - - name: publish + - name: Publish gz archive if: github.event.action == 'published' uses: actions/[email protected] env: @@ -107,7 +104,7 @@ jobs: asset_name: xmake-${{ steps.tagName.outputs.tag }}.tar.gz asset_content_type: application/zip - - name: publish + - name: Publish zip archive if: github.event.action == 'published' uses: actions/[email protected] env: diff --git a/.github/workflows/msys2_mingw.yml b/.github/workflows/msys2_mingw.yml index 0f41834aa..3964d5c2f 100644 --- a/.github/workflows/msys2_mingw.yml +++ b/.github/workflows/msys2_mingw.yml @@ -25,7 +25,7 @@ jobs: - uses: msys2/setup-msys2@v2 with: msystem: ${{ matrix.msystem }} - install: git base-devel mingw-w64-${{ matrix.arch }}-toolchain + install: git base-devel unzip mingw-w64-${{ matrix.arch }}-toolchain update: true - name: Move Checkout diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a93e74183..69daa9178 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -17,6 +17,8 @@ jobs: steps: - uses: actions/checkout@v2 with: + # WyriHaximus/github-action-get-previous-tag@master need it + fetch-depth: 0 submodules: true - uses: xmake-io/github-action-setup-xmake@v1 with: @@ -29,12 +31,9 @@ jobs: - uses: little-core-labs/[email protected] id: tagName - # prepare - - name: prepare + - name: Prepare run: | - # xmake xmake show - # nsis Invoke-WebRequest "https://github.com/xmake-mirror/nsis/releases/download/v30b3/nsis-3.04.zip" -UseBasicParsing -OutFile ./nsis.zip Invoke-WebRequest "https://github.com/xmake-mirror/nsis/releases/download/v30b3/nsis-3.04-strlen_8192.zip" -UseBasicParsing -OutFile ./nsis-longstr.zip Invoke-WebRequest "https://github.com/xmake-mirror/nsis/releases/download/v30b3/UAC.zip" -UseBasicParsing -OutFile ./nsis-uac.zip @@ -44,17 +43,16 @@ jobs: Expand-Archive ./nsis-uac.zip -DestinationPath ./nsis -Force Move-Item ./nsis/UAC.nsh ./nsis/Include/ - # build - - name: build + - name: Build run: | xmake f -vD -P core -a ${{ matrix.arch }} xmake -vD -P core - # tests - - name: tests + - name: Tests run: | Copy-Item ./core/build/xmake.exe ./xmake Copy-Item ./scripts/xrepo.bat ./xmake + Copy-Item ./scripts/xrepo.ps1 ./xmake $Env:XMAKE_PROGRAM_DIR = $(Resolve-Path ./xmake) Set-Item -Path Env:Path -Value ($Env:XMAKE_PROGRAM_DIR + ";" + $Env:Path) xrepo --version @@ -62,15 +60,14 @@ jobs: #xmake l -v private.utils.bcsave --rootname='@programdir' -x 'scripts/**|templates/**' xmake xmake lua -v -D tests/run.lua - # build artifacts - - name: set release arch name + - name: Set release arch name run: | if ("${{ matrix.arch }}" -eq "x64") { Write-Output "RELEASE_NAME=win64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append } else { Write-Output "RELEASE_NAME=win32" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append } - - name: artifact + - name: Artifact run: | # build installer (New-Item ./winenv/bin -ItemType Directory).FullName @@ -78,29 +75,14 @@ jobs: Expand-Archive ./7zip.zip -DestinationPath ./7zip Copy-Item ./7zip/7z.exe ./winenv/bin Copy-Item ./7zip/7z.dll ./winenv/bin - Invoke-WebRequest "https://github.com/xmake-io/xmake-win64env/raw/master/bin/curl.exe" -UseBasicParsing -OutFile .\curl.exe - Invoke-WebRequest "https://raw.githubusercontent.com/xmake-io/xmake-win64env/master/bin/curl-ca-bundle.crt" -UseBasicParsing -OutFile .\curl-ca-bundle.crt - Copy-Item ./curl.exe ./winenv/bin - Copy-Item ./curl-ca-bundle.crt ./winenv/bin + Invoke-WebRequest "https://curl.se/windows/dl-7.75.0_3/curl-7.75.0_3-win32-mingw.zip" -UseBasicParsing -OutFile .\curl.zip + Expand-Archive ./curl.zip -DestinationPath ./curl + Copy-Item ./curl/curl-7.75.0-win32-mingw/bin/curl.exe ./winenv/bin + Copy-Item ./curl/curl-7.75.0-win32-mingw/bin/curl-ca-bundle.crt ./winenv/bin $version = (Get-Command xmake/xmake.exe).FileVersionInfo ./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 @@ -127,10 +109,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 @@ -138,8 +116,26 @@ jobs: name: xmake-latest.${{ env.RELEASE_NAME }}.sha256 path: artifacts/${{env.RELEASE_NAME}}/shafile + # upload artifacts to latest release + - name: Inject slug/short variables + uses: rlespinasse/[email protected] + + - name: Get Previous tag + id: previoustag + uses: WyriHaximus/github-action-get-previous-tag@master + + - name: Upload artifacts to lastest release + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: artifacts/${{env.RELEASE_NAME}}/xmake.exe + asset_name: xmake-${{ env.GITHUB_REF_SLUG }}.${{ env.RELEASE_NAME }}.exe + tag: ${{ steps.previoustag.outputs.tag }} + overwrite: true + # publish release - - name: publish + - name: Publish if: github.event.action == 'published' uses: actions/[email protected] env: @@ -150,18 +146,7 @@ jobs: asset_name: xmake-${{ 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}}/xmake-tinyc.exe - asset_name: xmake-tinyc-${{ steps.tagName.outputs.tag }}.${{ env.RELEASE_NAME }}.exe - asset_content_type: application/zip - - - name: publish + - name: Publish if: github.event.action == 'published' uses: actions/[email protected] env: @@ -172,7 +157,7 @@ jobs: asset_name: xmake-${{ steps.tagName.outputs.tag }}.${{ env.RELEASE_NAME }}.zip asset_content_type: application/zip - - name: publish + - name: Publish if: github.event.action == 'published' uses: actions/[email protected] env: diff --git a/.gitignore b/.gitignore index 43b458963..1631dd04d 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,9 @@ winenv/ *.7z *.run +# for compiler +compile_commands.json + # Makefile generation /core/xmake.config.h /core/.config.mak diff --git a/CHANGELOG.md b/CHANGELOG.md index fb75ea518..4df7191fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,149 @@ ### New features +* [#1483](https://github.com/xmake-io/xmake/issues/1483): Add `os.joinenvs()` and improve package tools envirnoments + +### Change + +* Improve vs/vsxmake project generator to support vs2022 + +### Bugs fixed + +* [#489](https://github.com/xmake-io/xmake-repo/pull/489): Fix run os.execv with too long envirnoment value on windows + +## v2.5.5 + +### New features + +* [#1421](https://github.com/xmake-io/xmake/issues/1421): Add prefix, suffix and extension options for target names +* [#1422](https://github.com/xmake-io/xmake/issues/1422): Support search packages from vcpkg, conan +* [#1424](https://github.com/xmake-io/xmake/issues/1424): Set binary as default target kind +* [#1140](https://github.com/xmake-io/xmake/issues/1140): Add a way to ask xmake to try to download dependencies from a certain package manager +* [#1339](https://github.com/xmake-io/xmake/issues/1339): Improve `xmake package` to generate new local/remote packages +* Add `appletvos` platform support for AppleTV, `xmake f -p appletvos` +* [#1437](https://github.com/xmake-io/xmake/issues/1437): Add headeronly library type for package to ignore `vs_runtime` +* [#1351](https://github.com/xmake-io/xmake/issues/1351): Support export/import current configs +* [#1454](https://github.com/xmake-io/xmake/issues/1454): Support to download and install precompiled image packages from xmake-mirror + +### Change + +* [#1425](https://github.com/xmake-io/xmake/issues/1425): Improve tools/meson to load msvc envirnoments +* [#1442](https://github.com/xmake-io/xmake/issues/1442): Support to clone package resources from git url +* [#1389](https://github.com/xmake-io/xmake/issues/1389): Support to add toolchain envs to `xrepo env` +* [#1453](https://github.com/xmake-io/xmake/issues/1453): Support to export protobuf includedirs +* Support vs2022 + +### Bugs fixed + +* [#1413](https://github.com/xmake-io/xmake/issues/1413): Fix hangs on fetching packages +* [#1420](https://github.com/xmake-io/xmake/issues/1420): Fix config and packages cache +* [#1445](https://github.com/xmake-io/xmake/issues/1445): Fix WDK driver sign error +* [#1465](https://github.com/xmake-io/xmake/issues/1465): Fix missing link directory + +## v2.5.4 + +### New features + +* [#1323](https://github.com/xmake-io/xmake/issues/1323): Support find and install package from `apt`, `add_requires("apt::zlib1g-dev")` +* [#1337](https://github.com/xmake-io/xmake/issues/1337): Add environment vars to change package directories +* [#1338](https://github.com/xmake-io/xmake/issues/1338): Support import and export installed packages +* [#1087](https://github.com/xmake-io/xmake/issues/1087): Add `xrepo env shell` and support load envs from `add_requires/xmake.lua` +* [#1313](https://github.com/xmake-io/xmake/issues/1313): Support private package for `add_requires/add_deps` +* [#1358](https://github.com/xmake-io/xmake/issues/1358): Support to set mirror url to speedup download package +* [#1369](https://github.com/xmake-io/xmake/pull/1369): Support arm/arm64 packages for vcpkg, thanks @fallending +* [#1405](https://github.com/xmake-io/xmake/pull/1405): Add portage package manager support, thanks @Phate6660 + +### Change + +* Improve `find_package` and add `package:find_package` for xmake package +* Remove deprecated `set_config_h` and `set_config_h_prefix` apis +* [#1343](https://github.com/xmake-io/xmake/issues/1343): Improve to search local package files +* [#1347](https://github.com/xmake-io/xmake/issues/1347): Improve to vs_runtime configs for binary package +* [#1353](https://github.com/xmake-io/xmake/issues/1353): Improve del_files() to speedup matching files +* [#1349](https://github.com/xmake-io/xmake/issues/1349): Improve `xrepo env shell` to support powershell + +### Bugs fixed + +* [#1380](https://github.com/xmake-io/xmake/issues/1380): Fix add packages errors +* [#1381](https://github.com/xmake-io/xmake/issues/1381): Fix add local git source for package +* [#1391](https://github.com/xmake-io/xmake/issues/1391): Fix cuda/nvcc toolchain + +### v2.5.3 + +### New features + +* [#1259](https://github.com/xmake-io/xmake/issues/1259): Support `add_files("*.def")` to export symbols for windows/dll +* [#1267](https://github.com/xmake-io/xmake/issues/1267): add `find_package("nvtx")` +* [#1274](https://github.com/xmake-io/xmake/issues/1274): add `platform.linux.bpf` rule to build linux/bpf program +* [#1280](https://github.com/xmake-io/xmake/issues/1280): Support fetchonly package to improve find_package +* Support to fetch remote ndk toolchain package +* [#1268](https://github.com/xmake-io/xmake/issues/1268): Add `utils.install.pkgconfig_importfiles` rule to install `*.pc` import file +* [#1268](https://github.com/xmake-io/xmake/issues/1268): Add `utils.install.cmake_importfiles` rule to install `*.cmake` import files +* [#348](https://github.com/xmake-io/xmake-repo/pull/348): Add `platform.longpaths` policy to support git longpaths +* [#1314](https://github.com/xmake-io/xmake/issues/1314): Support to install and use conda packages +* [#1120](https://github.com/xmake-io/xmake/issues/1120): Add `core.base.cpu` module and improve `os.cpuinfo()` +* [#1325](https://github.com/xmake-io/xmake/issues/1325): Add builtin git variables for `add_configfiles` + +### Change + +* [#1275](https://github.com/xmake-io/xmake/issues/1275): Support conditionnal targets for vsxmake plugin +* [#1290](https://github.com/xmake-io/xmake/pull/1290): Improve android ndk to support >= r22 +* [#1311](https://github.com/xmake-io/xmake/issues/1311): Add packages lib folder to PATH for vsxmake project + +### Bugs fixed + +* [#1266](https://github.com/xmake-io/xmake/issues/1266): Fix relative repo path in `add_repositories` +* [#1288](https://github.com/xmake-io/xmake/issues/1288): Fix vsxmake generator with option configs + +## v2.5.2 + +### New features + +* [#955](https://github.com/xmake-io/xmake/issues/955#issuecomment-766481512): Support `zig cc` and `zig c++` as c/c++ compiler +* [#955](https://github.com/xmake-io/xmake/issues/955#issuecomment-768193083): Support zig cross-compilation +* [#1177](https://github.com/xmake-io/xmake/issues/1177): Improve to detect terminal and color codes +* [#1216](https://github.com/xmake-io/xmake/issues/1216): Pass custom configuration scripts to xrepo +* Add linuxos builtin module to get linux system information +* [#1217](https://github.com/xmake-io/xmake/issues/1217): Support to fetch remote toolchain package when building project +* [#1123](https://github.com/xmake-io/xmake/issues/1123): Add `rule("utils.symbols.export_all")` to export all symbols for windows/dll +* [#1181](https://github.com/xmake-io/xmake/issues/1181): Add `utils.platform.gnu2mslib(mslib, gnulib)` module api to convert mingw/xxx.dll.a to msvc xxx.lib +* [#1246](https://github.com/xmake-io/xmake/issues/1246): Improve rules and generators to support commands list +* [#1239](https://github.com/xmake-io/xmake/issues/1239): Add `add_extsources` to improve find external packages +* [#1241](https://github.com/xmake-io/xmake/issues/1241): Support add .manifest files for windows program +* Support to use `xrepo remove --all` to remove all packages +* [#1254](https://github.com/xmake-io/xmake/issues/1254): Support to export packages to parent target + +### Change + +* [#1226](https://github.com/xmake-io/xmake/issues/1226): Add missing qt include directories +* [#1183](https://github.com/xmake-io/xmake/issues/1183): Improve c++ lanuages to support Qt6 +* [#1237](https://github.com/xmake-io/xmake/issues/1237): Add qt.ui files for vsxmake plugin +* Improve vs/vsxmake plugins to support precompiled header and intellisense +* [#1090](https://github.com/xmake-io/xmake/issues/1090): Simplify integration of custom code generators +* [#1065](https://github.com/xmake-io/xmake/issues/1065): Improve protobuf rule to support compile_commands generators +* [#1249](https://github.com/xmake-io/xmake/issues/1249): Improve vs/vsxmake generator to support startproject +* [#605](https://github.com/xmake-io/xmake/issues/605): Improve to link orders for add_deps/add_packages +* Remove deprecated `add_defines_h_if_ok` and `add_defines_h` apis for option + +### Bugs fixed + +* [#1219](https://github.com/xmake-io/xmake/issues/1219): Fix version check and update +* [#1235](https://github.com/xmake-io/xmake/issues/1235): Fix include directories with spaces + +## v2.5.1 + +### New features + * [#1035](https://github.com/xmake-io/xmake/issues/1035): The graphics configuration menu fully supports mouse events, and support scroll bar * [#1098](https://github.com/xmake-io/xmake/issues/1098): Support stdin for os.execv * [#1079](https://github.com/xmake-io/xmake/issues/1079): Add autoupdate plugin rule for vsxmake, `add_rules("plugin.vsxmake.autoupdate")` * Add `xmake f --vs_runtime=MT` and `set_runtimes("MT")` to set vs runtime for targets and packages * [#1032](https://github.com/xmake-io/xmake/issues/1032): Support to enum registry keys and values * [#1026](https://github.com/xmake-io/xmake/issues/1026): Support group for vs/vsxmake project +* [#1178](https://github.com/xmake-io/xmake/issues/1178): Add `add_requireconfs()` api to rewrite configs of depend packages +* [#1043](https://github.com/xmake-io/xmake/issues/1043): Add `luarocks.module` rule for luarocks-build-xmake +* [#1190](https://github.com/xmake-io/xmake/issues/1190): Support for Apple Silicon (macOS ARM) +* [#1145](https://github.com/xmake-io/xmake/pull/1145): Support Qt deploy for Windows, thanks @SirLynix ### Change @@ -21,6 +158,7 @@ * [#1071](https://github.com/xmake-io/xmake/issues/1071): Improve to generate vs/vsxmake project to support for remote packages * Improve vs/vsxmake project plugin to support global `set_arch()` setting * [#1164](https://github.com/xmake-io/xmake/issues/1164): Improve to launch console programs for vsxmake project +* [#1179](https://github.com/xmake-io/xmake/issues/1179): Improve llvm toolchain and add isysroot ### Bugs fixed @@ -29,6 +167,8 @@ * [#1132](https://github.com/xmake-io/xmake/issues/1132): Fix TrimEnd bug for vsxmake * [#1142](https://github.com/xmake-io/xmake/issues/1142): Fix git not found when installing packages * Fix macos.version bug for macOS Big Sur +* [#1084](https://github.com/xmake-io/xmake/issues/1084): Fix `add_defines()` bug (contain spaces) +* [#1195](https://github.com/xmake-io/xmake/pull/1195): Fix unicode problem for vs and improve find_vstudio/os.exec ## v2.3.9 @@ -895,12 +1035,150 @@ ### 新特性 +* [#1483](https://github.com/xmake-io/xmake/issues/1483): 添加 `os.joinenvs()` 和改进包工具环境 + +### 改进 + +* 改进 vs/vsxmake 工程插件支持 vs2022 + +### Bugs 修复 + +* [#489](https://github.com/xmake-io/xmake-repo/pull/489): 修复 run os.execv 带有过长环境变量值出现的一些问题 + + +## v2.5.5 + +### 新特性 + +* [#1421](https://github.com/xmake-io/xmake/issues/1421): 针对 target 目标,增加目标文件名的前缀,后缀和扩展名设置接口。 +* [#1422](https://github.com/xmake-io/xmake/issues/1422): 支持从 vcpkg, conan 中搜索包 +* [#1424](https://github.com/xmake-io/xmake/issues/1424): 设置 binary 作为默认的 target 目标类型 +* [#1140](https://github.com/xmake-io/xmake/issues/1140): 支持安装时候,手动选择从第三包包管理器安装包 +* [#1339](https://github.com/xmake-io/xmake/issues/1339): 改进 `xmake package` 去产生新的本地包格式,无缝集成 `add_requires`,并且新增生成远程包支持 +* 添加 `appletvos` 编译平台支持, `xmake f -p appletvos` +* [#1437](https://github.com/xmake-io/xmake/issues/1437): 为包添加 headeronly 库类型去忽略 `vs_runtime` +* [#1351](https://github.com/xmake-io/xmake/issues/1351): 支持导入导出当前配置 +* [#1454](https://github.com/xmake-io/xmake/issues/1454): 支持下载安装 windows 预编译包 + +### 改进 + +* [#1425](https://github.com/xmake-io/xmake/issues/1425): 改进 tools/meson 去加载 msvc 环境,并且增加一些内置配置。 +* [#1442](https://github.com/xmake-io/xmake/issues/1442): 支持从 git url 去下载包资源文件 +* [#1389](https://github.com/xmake-io/xmake/issues/1389): 支持添加工具链环境到 `xrepo env` +* [#1453](https://github.com/xmake-io/xmake/issues/1453): 支持 protobuf 规则导出头文件搜索目录 +* 新增对 vs2022 的支持 + +### Bugs 修复 + +* [#1413](https://github.com/xmake-io/xmake/issues/1413): 修复查找包过程中出现的挂起卡死问题 +* [#1420](https://github.com/xmake-io/xmake/issues/1420): 修复包检测和配置缓存 +* [#1445](https://github.com/xmake-io/xmake/issues/1445): 修复 WDK 驱动签名错误 +* [#1465](https://github.com/xmake-io/xmake/issues/1465): 修复缺失的链接目录 + +## v2.5.4 + +### 新特性 + +* [#1323](https://github.com/xmake-io/xmake/issues/1323): 支持从 apt 查找安装包,`add_requires("apt::zlib1g-dev")` +* [#1337](https://github.com/xmake-io/xmake/issues/1337): 添加环境变量去改进包安装和缓存目录 +* [#1338](https://github.com/xmake-io/xmake/issues/1338): 支持导入导出已安装的包 +* [#1087](https://github.com/xmake-io/xmake/issues/1087): 添加 `xrepo env shell` 并且支持从 `add_requires/xmake.lua` 加载包环境 +* [#1313](https://github.com/xmake-io/xmake/issues/1313): 为 `add_requires/add_deps` 添加私有包支持 +* [#1358](https://github.com/xmake-io/xmake/issues/1358): 支持设置镜像 url 站点加速包下载 +* [#1369](https://github.com/xmake-io/xmake/pull/1369): 为 vcpkg 增加 arm/arm64 包集成支持,感谢 @fallending +* [#1405](https://github.com/xmake-io/xmake/pull/1405): 添加 portage 包管理器支持,感谢 @Phate6660 + +### 改进 + +* 改进 `find_package` 并且添加 `package:find_package` 接口在包定义中方便查找包 +* 移除废弃的 `set_config_h` 和 `set_config_h_prefix` 接口 +* [#1343](https://github.com/xmake-io/xmake/issues/1343): 改进搜索本地包文件 +* [#1347](https://github.com/xmake-io/xmake/issues/1347): 针对 binary 包改进 vs_runtime 配置 +* [#1353](https://github.com/xmake-io/xmake/issues/1353): 改进 del_files() 去加速匹配文件 +* [#1349](https://github.com/xmake-io/xmake/issues/1349): 改进 xrepo env shell 支持,更好的支持 powershell + +### Bugs 修复 + +* [#1380](https://github.com/xmake-io/xmake/issues/1380): 修复 `add_packages()` 失败问题 +* [#1381](https://github.com/xmake-io/xmake/issues/1381): 修复添加本地 git 包源问题 +* [#1391](https://github.com/xmake-io/xmake/issues/1391): 修复 cuda/nvcc 工具链 + +## v2.5.3 + +### 新特性 + +* [#1259](https://github.com/xmake-io/xmake/issues/1259): 支持 `add_files("*.def")` 添加 def 文件去导出 windows/dll 符号 +* [#1267](https://github.com/xmake-io/xmake/issues/1267): 添加 `find_package("nvtx")` +* [#1274](https://github.com/xmake-io/xmake/issues/1274): 添加 `platform.linux.bpf` 规则去构建 linux/bpf 程序 +* [#1280](https://github.com/xmake-io/xmake/issues/1280): 支持 fetchonly 包去扩展改进 find_package +* 支持自动拉取远程 ndk 工具链包和集成 +* [#1268](https://github.com/xmake-io/xmake/issues/1268): 添加 `utils.install.pkgconfig_importfiles` 规则去安装 `*.pc` 文件 +* [#1268](https://github.com/xmake-io/xmake/issues/1268): 添加 `utils.install.cmake_importfiles` 规则去安装 `*.cmake` 导入文件 +* [#348](https://github.com/xmake-io/xmake-repo/pull/348): 添加 `platform.longpaths` 策略去支持 git longpaths +* [#1314](https://github.com/xmake-io/xmake/issues/1314): 支持安装使用 conda 包 +* [#1120](https://github.com/xmake-io/xmake/issues/1120): 添加 `core.base.cpu` 模块并且改进 `os.cpuinfo()` +* [#1325](https://github.com/xmake-io/xmake/issues/1325): 为 `add_configfiles` 添加内建的 git 变量 + +### 改进 + +* [#1275](https://github.com/xmake-io/xmake/issues/1275): 改进 vsxmake 生成器,支持条件化编译 targets +* [#1290](https://github.com/xmake-io/xmake/pull/1290): 增加对 Android ndk r22 以上版本支持 +* [#1311](https://github.com/xmake-io/xmake/issues/1311): 为 vsxmake 工程添加包 dll 路径,确保调试运行加载正常 + +### Bugs 修复 + +* [#1266](https://github.com/xmake-io/xmake/issues/1266): 修复在 `add_repositories` 中的 repo 相对路径 +* [#1288](https://github.com/xmake-io/xmake/issues/1288): 修复 vsxmake 插件处理 option 配置问题 + +## v2.5.2 + +### 新特性 + +* [#955](https://github.com/xmake-io/xmake/issues/955#issuecomment-766481512): 支持 `zig cc` 和 `zig c++` 作为 c/c++ 编译器 +* [#955](https://github.com/xmake-io/xmake/issues/955#issuecomment-768193083): 支持使用 zig 进行交叉编译 +* [#1177](https://github.com/xmake-io/xmake/issues/1177): 改进终端和 color codes 探测 +* [#1216](https://github.com/xmake-io/xmake/issues/1216): 传递自定义 includes 脚本给 xrepo +* 添加 linuxos 内置模块获取 linux 系统信息 +* [#1217](https://github.com/xmake-io/xmake/issues/1217): 支持当编译项目时自动拉取工具链 +* [#1123](https://github.com/xmake-io/xmake/issues/1123): 添加 `rule("utils.symbols.export_all")` 自动导出所有 windows/dll 中的符号 +* [#1181](https://github.com/xmake-io/xmake/issues/1181): 添加 `utils.platform.gnu2mslib(mslib, gnulib)` 模块接口去转换 mingw/xxx.dll.a 到 msvc xxx.lib +* [#1246](https://github.com/xmake-io/xmake/issues/1246): 改进规则支持新的批处理命令去简化自定义规则实现 +* [#1239](https://github.com/xmake-io/xmake/issues/1239): 添加 `add_extsources` 去改进外部包的查找 +* [#1241](https://github.com/xmake-io/xmake/issues/1241): 支持为 windows 程序添加 .manifest 文件参与链接 +* 支持使用 `xrepo remove --all` 命令去移除所有的包,并且支持模式匹配 +* [#1254](https://github.com/xmake-io/xmake/issues/1254): 支持导出包配置给父 target,实现包配置的依赖继承 + +### 改进 + +* [#1226](https://github.com/xmake-io/xmake/issues/1226): 添加缺失的 Qt 头文件搜索路径 +* [#1183](https://github.com/xmake-io/xmake/issues/1183): 改进 C++ 语言标准,以便支持 Qt6 +* [#1237](https://github.com/xmake-io/xmake/issues/1237): 为 vsxmake 插件添加 qt.ui 文件 +* 改进 vs/vsxmake 插件去支持预编译头文件和智能提示 +* [#1090](https://github.com/xmake-io/xmake/issues/1090): 简化自定义规则 +* [#1065](https://github.com/xmake-io/xmake/issues/1065): 改进 protobuf 规则,支持 compile_commands 生成器 +* [#1249](https://github.com/xmake-io/xmake/issues/1249): 改进 vs/vsxmake 生成器去支持启动工程设置 +* [#605](https://github.com/xmake-io/xmake/issues/605): 改进 add_deps 和 add_packages 直接的导出 links 顺序 +* 移除废弃的 `add_defines_h_if_ok` and `add_defines_h` 接口 + +### Bugs 修复 + +* [#1219](https://github.com/xmake-io/xmake/issues/1219): 修复版本检测和更新 +* [#1235](https://github.com/xmake-io/xmake/issues/1235): 修复 includes 搜索路径中带有空格编译不过问题 + +## v2.5.1 + +### 新特性 + * [#1035](https://github.com/xmake-io/xmake/issues/1035): 图形配置菜单完整支持鼠标事件,并且新增滚动栏 * [#1098](https://github.com/xmake-io/xmake/issues/1098): 支持传递 stdin 到 os.execv 进行输入重定向 * [#1079](https://github.com/xmake-io/xmake/issues/1079): 为 vsxmake 插件添加工程自动更新插件,`add_rules("plugin.vsxmake.autoupdate")` * 添加 `xmake f --vs_runtime=MT` 和 `set_runtimes("MT")` 去更方便的对 target 和 package 进行设置 * [#1032](https://github.com/xmake-io/xmake/issues/1032): 支持枚举注册表 keys 和 values * [#1026](https://github.com/xmake-io/xmake/issues/1026): 支持对 vs/vsmake 工程增加分组设置 +* [#1178](https://github.com/xmake-io/xmake/issues/1178): 添加 `add_requireconfs()` 接口去重写依赖包的配置 +* [#1043](https://github.com/xmake-io/xmake/issues/1043): 为 luarocks 模块添加 `luarocks.module` 构建规则 +* [#1190](https://github.com/xmake-io/xmake/issues/1190): 添加对 Apple Silicon (macOS ARM) 设备的支持 +* [#1145](https://github.com/xmake-io/xmake/pull/1145): 支持在 windows 上安装部署 Qt 程序, 感谢 @SirLynix ### 改进 @@ -912,6 +1190,7 @@ * [#1071](https://github.com/xmake-io/xmake/issues/1071): 改进 vs/vsxmake 生成插件去支持远程依赖包 * 改进 vs/vsxmake 工程生成插件去支持全局的 `set_arch()` 设置 * [#1164](https://github.com/xmake-io/xmake/issues/1164): 改进 vsxmake 插件调试加载 console 程序 +* [#1179](https://github.com/xmake-io/xmake/issues/1179): 改进 llvm 工具链,添加 isysroot ### Bugs 修复 @@ -920,6 +1199,8 @@ * [#1132](https://github.com/xmake-io/xmake/issues/1132): 修复 vsxmake 插件中配置路径被截断问题 * [#1142](https://github.com/xmake-io/xmake/issues/1142): 修复安装包的时候,出现git找不到问题 * 修复在 macOS Big Sur 上 macos.version 问题 +* [#1084](https://github.com/xmake-io/xmake/issues/1084): 修复 `add_defines()` 中带有双引号和空格导致无法正确处理宏定义的问题 +* [#1195](https://github.com/xmake-io/xmake/pull/1195): 修复 unicode 编码问题,改进 vs 环境查找和进程执行 ## v2.3.9 @@ -965,7 +1246,7 @@ * [#978](https://github.com/xmake-io/xmake/issues/978): 改进工具链的flags顺序 * 改进XCode工具链,支持macOS/arm64 -### Bugs修复 +### Bugs 修复 * [#951](https://github.com/xmake-io/xmake/issues/951): 修复 emcc (WebAssembly) 工具链在windows上的支持 * [#992](https://github.com/xmake-io/xmake/issues/992): 修复文件锁偶尔打开失败问题 @@ -992,7 +1273,7 @@ * [#927](https://github.com/xmake-io/xmake/issues/927): 改进android ndk,支持arm/thumb指令模式切换 * 改进 trybuild/cmake 支持 Android/Mingw/iPhoneOS/WatchOS 工具链 -### Bugs修复 +### Bugs 修复 * [#903](https://github.com/xmake-io/xmake/issues/903): 修复vcpkg包安装失败问题 * [#912](https://github.com/xmake-io/xmake/issues/912): 修复自定义工具链 @@ -1033,7 +1314,7 @@ * 改进msvc工具链,去除全局环境变量的依赖 * [#857](https://github.com/xmake-io/xmake/pull/857): 改进`set_toolchains()`支持交叉编译的时候,特定target可以切换到host工具链同时编译 -### Bugs修复 +### Bugs 修复 * 修复进度字符显示 * [#829](https://github.com/xmake-io/xmake/issues/829): 修复由于macOS大小写不敏感系统导致的sysroot无效路径问题 @@ -1060,7 +1341,7 @@ * [#808](https://github.com/xmake-io/xmake/issues/808): 生成cmakelists插件增加对add_frameworks的支持 * [#820](https://github.com/xmake-io/xmake/issues/820): 支持独立的工作目录和构建目录,保持项目目录完全干净 -### Bugs修复 +### Bugs 修复 * [#786](https://github.com/xmake-io/xmake/issues/786): 修复头文件依赖检测 * [#810](https://github.com/xmake-io/xmake/issues/810): 修复linux下gcc strip debug符号问题 @@ -1098,7 +1379,7 @@ * [#732](https://github.com/xmake-io/xmake/issues/732): 改进find_package支持查找homebrew/cmake安装的包 * [#695](https://github.com/xmake-io/xmake/issues/695): 改进采用android ndk最新的abi命名 -### Bugs修复 +### Bugs 修复 * 修复windows下link error显示问题 * [#718](https://github.com/xmake-io/xmake/issues/718): 修复依赖包下载在多镜像时一定概率缓存失效问题 @@ -1125,7 +1406,7 @@ * 改进process调度器 * [#651](https://github.com/xmake-io/xmake/issues/651): 改进os/io模块系统操作错误提示 -### Bugs修复 +### Bugs 修复 * 修复增量编译检测依赖文件的一些问题 * 修复log输出导致xmake-vscode插件解析编译错误信息失败问题 @@ -1152,7 +1433,7 @@ * [#629](https://github.com/xmake-io/xmake/issues/629): 改进hash.uuid并且实现uuid v4 * [#639](https://github.com/xmake-io/xmake/issues/639): 改进参数解析器支持`-jN`风格传参 -### Bugs修复 +### Bugs 修复 * [#567](https://github.com/xmake-io/xmake/issues/567): 修复序列化对象时候出现的内存溢出问题 * [#566](https://github.com/xmake-io/xmake/issues/566): 修复安装远程依赖的链接顺序问题 @@ -1180,7 +1461,7 @@ * [#542](https://github.com/xmake-io/xmake/pull/542): 改进vs系列工具链的unicode输出问题 * 对于安装的lua脚本,启用lua字节码存储,减少安装包大小(<2.4M),提高运行加载效率。 -### Bugs修复 +### Bugs 修复 * [#549](https://github.com/xmake-io/xmake/issues/549): 修复新版vs2019下检测环境会卡死的问题 @@ -1221,7 +1502,7 @@ * 改进`target:on_xxx`自定义脚本,去支持匹配`android|armv7-a@macosx,linux|x86_64`模式 * 改进loadfile,优化启动速度,windows上启动xmake时间提速98% -### Bugs修复 +### Bugs 修复 * [#400](https://github.com/xmake-io/xmake/issues/400): 修复qt项目c++语言标准设置无效问题 @@ -1262,7 +1543,7 @@ * [#351](https://github.com/xmake-io/xmake/issues/351): 生成vs201x插件增加对yasm的支持 * 重构改进整个远程依赖包管理器,更加快速、稳定、可靠,并提供更多的常用包 -### Bugs修复 +### Bugs 修复 * 修复无法通过 `set_optimize()` 设置优化选项,如果存在`add_rules("mode.release")`的情况下 * [#289](https://github.com/xmake-io/xmake/issues/289): 修复在windows下解压gzip文件失败 @@ -1295,7 +1576,7 @@ * 支持only头文件依赖包的安装 * 支持对包内置links的手动调整,`add_packages("xxx", {links = {}})` -### Bugs修复 +### Bugs 修复 * 修复安装依赖包失败中断后的状态不一致性问题 @@ -1322,7 +1603,7 @@ * [#208](https://github.com/xmake-io/xmake/issues/208): 改进rpath对动态库的支持 * [#225](https://github.com/xmake-io/xmake/issues/225): 改进vs环境探测 -### Bugs修复 +### Bugs 修复 * [#177](https://github.com/xmake-io/xmake/issues/177): 修复被依赖的动态库target,如果设置了basename后链接失败问题 * 修复`$ xmake f --menu`中Exit问题以及cpu过高问题 @@ -1354,7 +1635,7 @@ * [#171](https://github.com/xmake-io/xmake/issues/171): 改进Qt环境的构建依赖 * 在makefile生成插件中实现`make clean` -### Bugs修复 +### Bugs 修复 * 修复无法通过`add_ldflags("xx", "xx", {force = true})`强制设置多个flags的问题 * [#157](https://github.com/xmake-io/xmake/issues/157): 修复pdb符号输出目录不存在情况下编译失败问题 @@ -1388,7 +1669,7 @@ * 增加对linux/arm, arm64的支持,可以在arm linux上运行xmake * 改进vs201x工程生成插件,更好的includedirs设置支持 -### Bugs修复 +### Bugs 修复 * 修复依赖修改编译和链接问题 * [#151](https://github.com/xmake-io/xmake/issues/151): 修复`os.nuldev()`在mingw上传入gcc时出现问题 @@ -1411,7 +1692,7 @@ * 改进macOS编译平台的探测,如果没有安装xcode也能够进行编译构建,如果有编译器的话 * 改进`set_config_header`接口,支持局部版本号设置,优先于全局`set_version`,例如:`set_config_header("config", {version = "2.1.8", build = "%Y%m%d%H%M"})` -### Bugs修复 +### Bugs 修复 * [#145](https://github.com/xmake-io/xmake/issues/145): 修复运行target的当前目录环境 @@ -1441,7 +1722,7 @@ * 为windows cmd终端增加彩色输出 * 增加`-w|--warning`参数来启用实时警告输出 -### Bugs修复 +### Bugs 修复 * 修复`set_pcxxheader`编译没有继承flags配置问题 * [#140](https://github.com/xmake-io/xmake/issues/140): 修复`os.tmpdir()`在fakeroot下的冲突问题 @@ -1458,7 +1739,7 @@ * 改进`target.add_deps`接口,添加继承配置,允许手动禁止依赖继承,例如:`add_deps("test", {inherit = false})` * 移除`tbox.pkg`二进制依赖,直接集成tbox源码进行编译 -### Bugs修复 +### Bugs 修复 * 修复目标级联依赖问题 * 修复`target:add`和`option:add`问题 @@ -1508,7 +1789,7 @@ * 将`echo` 和 `app2ipa` 插件迁移到 [xmake-plugins](https://github.com/xmake-io/xmake-plugins) 仓库 * 添加`set_config_header("config.h", {prefix = ""})` 代替 `set_config_h` 和 `set_config_h_prefix` -### Bugs修复 +### Bugs 修复 * 修复`try-catch-finally` * 修复解释器bug,解决当加载多级子目录时,根域属性设置不对 @@ -1532,7 +1813,7 @@ * [#78](https://github.com/xmake-io/xmake/pull/78): 美化非全屏终端窗口下的`xmake --help`输出 * 避免产生不必要的`.xmake`目录,如果不在工程中的时候 -### Bugs修复 +### Bugs 修复 * [#67](https://github.com/xmake-io/xmake/issues/67): 修复 `sudo make install` 命令权限问题 * [#70](https://github.com/xmake-io/xmake/issues/70): 修复检测android编译器错误 @@ -1558,7 +1839,7 @@ * 改进工具链检测,通过延迟延迟检测提升整体检测效率 * 当自动扫面生成`xmake.lua`时,添加更友好的用户提示,避免用户无操作 -### Bugs修复 +### Bugs 修复 * 修复版本检测的错误提示信息 * [#60](https://github.com/xmake-io/xmake/issues/60): 修复macosx和windows平台的xmake自举编译 @@ -1578,7 +1859,7 @@ * 支持编译android版本的rust程序 * 增强vs201x工程生成插件,支持同时多模式、架构编译 -### Bugs修复 +### Bugs 修复 * 修复编译android程序,找不到系统头文件问题 * 修复检测选项行为不正确问题 @@ -1613,7 +1894,7 @@ * 精简和优化构建输出信息,添加`-q|--quiet`选项实现静默构建 * 改进`makefile`生成插件,抽取编译工具和编译选项到全局变量 -### Bugs修复 +### Bugs 修复 * [#41](https://github.com/waruqi/xmake/issues/41): 修复在windows下自动检测x64失败问题 * [#43](https://github.com/waruqi/xmake/issues/43): 避免创建不必要的.xmake工程缓存目录 @@ -1635,7 +1916,7 @@ * 移除`core/tools`目录以及msys工具链,在windows上使用xmake自编译core源码进行安装,优化xmake源码磁盘空间 * 移除`xmake/packages`,默认模板安装不再内置二进制packages,暂时需要手动放置,以后再做成自动包依赖下载编译 -### Bugs修复 +### Bugs 修复 * 修复msvc的编译选项不支持问题:`-def:xxx.def` * 修复ml.exe汇编器脚本 @@ -1657,7 +1938,7 @@ * 增强内建变量的处理 * 支持字符串类型的选项option设置 -### Bugs修复 +### Bugs 修复 * 修复在linux下检测ld连接器失败,如果没装g++的话 * 修复`*.cxx`编译失败问题 @@ -1677,7 +1958,7 @@ * 改进makefile生成插件,移除对xmake的依赖,并且支持`windows/linux/macosx`等大部分pc平台 * 优化多任务编译速度,在windows下编译提升较为明显 -### Bugs修复 +### Bugs 修复 * 修复安装目录错误问题 * 修复`import`根目录错误问题 @@ -1691,7 +1972,7 @@ * 更新工程模板 * 增强函数检测 -### Bugs修复 +### Bugs 修复 * [#7](https://github.com/waruqi/xmake/issues/7): 修复用模板创建工程后,target名不对问题:'[targetname]' * [#9](https://github.com/waruqi/xmake/issues/9): 修复clang不支持c++11的问题 @@ -1733,7 +2014,7 @@ * 简化命令行配置开关, 支持`xmake config --xxx=[y|n|yes|no|true|false]`等开关值 * 合并iphoneos和iphonesimulator平台,以及watchos和watchsimulator平台,通过arch来区分,使得打包更加方便,能够支持一次性打包iphoneos的所有arch到一个包中 -### Bugs修复 +### Bugs 修复 * [#3](https://github.com/waruqi/xmake/issues/3): 修复ArchLinux 编译失败问题 * [#4](https://github.com/waruqi/xmake/issues/4): 修复windows上安装失败问题 @@ -1757,7 +2038,7 @@ * 增强`add_files`接口,支持直接添加`*.o/obj/a/lib`文件,并且支持静态库的合并 * 裁剪xmake的安装过程,移除一些预编译的二进制程序 -### Bugs修复 +### Bugs 修复 * [#1](https://github.com/waruqi/xmake/issues/4): 修复win7上安装失败问题 * 修复和增强工具链检测 @@ -1772,7 +2053,7 @@ * 添加import接口,使得在xmake.lua中可以导入一些扩展模块,例如:os,path,utils等等,使得脚本更灵活 * 添加android平台arm64-v8a支持 -### Bugs修复 +### Bugs 修复 * 修复set_installscript接口的一些bug * 修复在windows x86_64下,安装失败的问题 @@ -38,7 +38,7 @@ <a href="https://jq.qq.com/?_wv=1027&k=5hpwWFv"> <img src="https://img.shields.io/badge/chat-on%20QQ-ff69b4.svg?style=flat-square" alt="QQ" /> </a> - <a href="https://discord.gg/XXRp26A4Gr"> + <a href="https://discord.gg/xmake"> <img src="https://img.shields.io/badge/chat-on%20discord-7289da.svg?style=flat-square" alt="Discord" /> </a> <a href="https://xmake.io/#/sponsor"> @@ -46,12 +46,15 @@ </a> </div> - <p>A cross-platform build utility based on Lua</p> + <b>A cross-platform build utility based on Lua</b><br/> + <i>Modern C/C++ build tools, Simple, Fast, Powerful dependency package integration</i><br/> </div> ## Supporting the project -Support this project by becoming a sponsor. Your logo will show up here with a link to your website. 🙏 [[Become a sponsor](https://xmake.io/#/about/sponsor)] +Support this project by becoming a sponsor. Your logo will show up here with a link to your website. 🙏 + +- [Become a sponsor](https://xmake.io/#/about/sponsor) <a href="https://opencollective.com/xmake#sponsors" target="_blank"><img src="https://opencollective.com/xmake/sponsors.svg?width=890"></a> @@ -61,7 +64,7 @@ xmake is a lightweight cross-platform build utility based on Lua. It uses xmake. It can compile the project directly like Make/Ninja, or generate project files like CMake/Meson, and it also has a built-in package management system to help users solve the integrated use of C/C++ dependent libraries. -If you want to know more, please refer to: [Documents](https://xmake.io/#/home), [Github](https://github.com/xmake-io/xmake) and [Gitee](https://gitee.com/tboox/xmake) and also welcome to join our [community](https://xmake.io/#/about/contact). +If you want to know more, please refer to: [Documents](https://xmake.io/#/getting_started), [Github](https://github.com/xmake-io/xmake) and [Gitee](https://gitee.com/tboox/xmake) and also welcome to join our [community](https://xmake.io/#/about/contact).  @@ -166,11 +169,14 @@ The test project: [xmake-core](https://github.com/xmake-io/xmake/tree/master/cor * Official package manager [Xrepo](https://github.com/xmake-io/xrepo) * [User-built repositories](https://xmake.io/#/package/remote_package?id=using-self-built-private-package-repository) * Conan (conan::openssl/1.1.1g) +* Conda (conda::libpng 1.3.67) * Vcpkg (vcpkg:ffmpeg) * Homebrew/Linuxbrew (brew::pcre2/libpcre2-8) * Pacman on archlinux/msys2 (pacman::libcurl) +* Apt on ubuntu/debian (apt::zlib1g-dev) * Clib (clib::clibs/[email protected]) * Dub (dub::log 0.4.3) +* Portage on Gentoo/Linux (portage::libhandy) ## Supported platforms @@ -181,6 +187,7 @@ The test project: [xmake-core](https://github.com/xmake-io/xmake/tree/master/cor * Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a) * iOS (armv7, armv7s, arm64, i386, x86_64) * WatchOS (armv7k, i386) +* AppleTVOS (armv7, arm64, i386, x86_64) * MSYS (i386, x86_64) * MinGW (i386, x86_64, arm, arm64) * Cygwin (i386, x86_64) @@ -211,11 +218,11 @@ 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 -musl The musl-based cross-compilation toolchains +muslcc The musl-based cross-compilation toolchains ``` ## Supported Languages @@ -230,7 +237,7 @@ musl The musl-based cross-compilation toolchains * Dlang * Fortran * Cuda -* Zig (Experimental) +* Zig ## Support Features @@ -241,13 +248,16 @@ musl The musl-based cross-compilation toolchains * Multi-task parallel compilation support * C++20 Module-TS support * Support cross-platform C/C++ dependency packages -* Support self-built distributed and third-party package repositories +* Support self-built distributed package repositories +* Support the installation of cloud pre-compiled packages +* Support third-party package repositories, such as: vcpkg, conan, conda, etc. * Support multi-language mixed compilation * Flexible lua scripts, rich extension modules * Support for generating vsproj/cmake/makefile/compile_commands files * REPL interactive execution support * Incremental compilation support, automatic analysis of header dependency files * Fast switching toolchains +* Automatic pull toolchain and dependency package integration ## Supported Projects @@ -368,6 +378,56 @@ target("loop") add_packages("libomp") ``` +#### Zig Program + +```lua +target("test") + set_kind("binary") + add_files("src/main.zig") +``` + +### Automatically fetch remote toolchain + +#### fetch the special version of llvm + +We use clang in llvm-10 to compile the project. + +```lua +add_requires("llvm 10.x", {alias = "llvm-10"}) +target("test") + set_kind("binary") + add_files("src/*.c) + set_toolchains("llvm@llvm-10") +```` + +#### Fetch cross-compilation toolchain + +We can also pull the specified cross-compilation tool chain to compile the project. + +```lua +add_requires("muslcc") +target("test") + set_kind("binary") + add_files("src/*.c) + set_toolchains("@muslcc") +``` + +#### Fetch toolchain and packages + +We can also use the specified muslcc cross-compilation toolchain to compile and integrate all dependent packages + +```lua +add_requires("muslcc") +add_requires("zlib", "libogg", {system = false}) + +set_toolchains("@muslcc") + +target("test") + set_kind("binary") + add_files("src/*.c") + add_packages("zlib", "libogg") +``` + ## Plugins #### Generate IDE project file plugin(makefile, vs2002 - vs2019 .. ) @@ -422,7 +482,7 @@ We can uses [xmake-gradle](https://github.com/xmake-io/xmake-gradle) plugin to c ``` plugins { - id 'org.tboox.gradle-xmake-plugin' version '1.0.6' + id 'org.tboox.gradle-xmake-plugin' version '1.1.4' } android { @@ -467,14 +527,14 @@ We also provide paid technical support to help users quickly solve related probl Or you can also consider sponsoring us to get technical support services, [[Become a sponsor](https://xmake.io/#/about/sponsor)] -## Project Examples +## Who is using Xmake? + +Please click [User List](https://xmake.io/#/about/who_is_using_xmake) to view the complete user list. -Some projects using xmake: +If you are using xmake, welcome to submit the information to the above list through PR, so that let more users can known how many users are using xmake. -* [tbox](https://github.com/tboox/tbox) -* [gbox](https://github.com/tboox/gbox) -* [vm86](https://github.com/tboox/vm86) -* [more](https://github.com/xmake-io/awesome-xmake) +Ihis also let users to use xmake more confidently, and we will also have more motivation to maintain it continuously, +so that the xmake project and the community will grow stronger. ## Contacts @@ -484,9 +544,8 @@ Some projects using xmake: - [Chat on reddit](https://www.reddit.com/r/xmake/) - [Chat on telegram](https://t.me/tbooxorg) - [Chat on gitter](https://gitter.im/xmake-io/xmake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - [Chat on discord/en](https://discord.gg/XXRp26A4Gr) - - [Chat on discord/zh](https://discord.gg/aY7RVeKdG7) - - Chat on QQ Group: 343118190(Technical Support), 662147501 + - [Chat on discord](https://discord.gg/xmake) + - Chat on QQ Group: 343118190, 662147501 * Source Code:[Github](https://github.com/xmake-io/xmake), [Gitee](https://gitee.com/tboox/xmake) * Wechat Public: tboox-os @@ -498,3 +557,4 @@ This project exists thanks to all the people who have [contributed](CONTRIBUTING * [TitanSnow](https://github.com/TitanSnow): provide the xmake [logo](https://github.com/TitanSnow/ts-xmake-logo) and install scripts * [uael](https://github.com/uael): provide the semantic versioning library [sv](https://github.com/uael/sv) * [OpportunityLiu](https://github.com/OpportunityLiu): improve cuda, tests and ci +* [xq144](https://github.com/xq114): Improve `xrepo env shell`, and contribute a lot of packages to the [xmake-repo](https://github.com/xmake-io/xmake-repo) repository. diff --git a/README_zh.md b/README_zh.md index 4438b50c8..386c82714 100644 --- a/README_zh.md +++ b/README_zh.md @@ -38,7 +38,7 @@ <a href="https://jq.qq.com/?_wv=1027&k=5hpwWFv"> <img src="https://img.shields.io/badge/chat-on%20QQ-ff69b4.svg?style=flat-square" alt="QQ" /> </a> - <a href="https://discord.gg/aY7RVeKdG7"> + <a href="https://discord.gg/xmake"> <img src="https://img.shields.io/badge/chat-on%20discord-7289da.svg?style=flat-square" alt="Discord" /> </a> <a href="https://xmake.io/#/zh-cn/about/sponsor"> @@ -46,12 +46,15 @@ </a> </div> - <p>A cross-platform build utility based on Lua</p> + <b>A cross-platform build utility based on Lua</b><br/> + <i>Modern C/C++ build tools, Simple, Fast, Powerful dependency package integration</i><br/> </div> ## 项目支持 -通过成为赞助者来支持该项目。您的logo将显示在此处,并带有指向您网站的链接。🙏 [[成为赞助商](https://xmake.io/#/zh-cn/about/sponsor)] +通过成为赞助者来支持该项目。您的logo将显示在此处,并带有指向您网站的链接。🙏 + +- [成为赞助商](https://xmake.io/#/zh-cn/about/sponsor) <a href="https://opencollective.com/xmake#sponsors" target="_blank"><img src="https://opencollective.com/xmake/sponsors.svg?width=890"></a> @@ -175,9 +178,11 @@ $ xmake f --menu * 官方包管理器 [Xrepo](https://github.com/xmake-io/xrepo) * [用户自建仓库](https://xmake.io/#/zh-cn/package/remote_package?id=%e4%bd%bf%e7%94%a8%e8%87%aa%e5%bb%ba%e7%a7%81%e6%9c%89%e5%8c%85%e4%bb%93%e5%ba%93) * Conan (conan::openssl/1.1.1g) +* Conda (conda::libpng 1.3.67) * Vcpkg (vcpkg:ffmpeg) * Homebrew/Linuxbrew (brew::pcre2/libpcre2-8) * Pacman on archlinux/msys2 (pacman::libcurl) +* Apt on ubuntu/debian (apt::zlib1g-dev) * Clib (clib::clibs/[email protected]) * Dub (dub::log 0.4.3) @@ -190,6 +195,7 @@ $ xmake f --menu * Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a) * iOS (armv7, armv7s, arm64, i386, x86_64) * WatchOS (armv7k, i386) +* AppleTVOS (armv7, arm64, i386, x86_64) * MSYS (i386, x86_64) * MinGW (i386, x86_64, arm, arm64) * Cygwin (i386, x86_64) @@ -220,11 +226,11 @@ 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 -musl The musl-based cross-compilation toolchains +muslcc The musl-based cross-compilation toolchains ``` ## 支持语言 @@ -238,7 +244,7 @@ musl The musl-based cross-compilation toolchains * Dlang * Fortran * Cuda -* Zig (Experimental) +* Zig ## 支持特性 @@ -249,13 +255,15 @@ musl The musl-based cross-compilation toolchains * 多任务并行编译支持 * C++20 Module-TS 支持 * 支持跨平台的 C/C++ 依赖包快速集成 -* 自建分布式包仓库,第三方包仓库支持 +* 自建分布式包仓库,支持安装云端预编译包 +* 第三方包仓库支持,例如:vcpkg, conan, conda 等等 * 多语言混合编译支持 * 灵活的 lua 脚本,丰富的扩展模块,可实现高度定制化 * 丰富的插件支持,内置 vs/cmake/makefile/compile_commands 等生成插件 * REPL 交互式执行支持 * 增量编译支持,头文件依赖自动分析 * 工具链的快速切换、定制化支持 +* 自动拉取工具链以及依赖包的快速整合 ## 工程类型 @@ -376,6 +384,56 @@ target("loop") add_packages("libomp") ``` +#### Zig 程序 + +```lua +target("test") + set_kind("binary") + add_files("src/main.zig") +``` + +### 自动拉取远程工具链 + +#### 拉取指定版本的 llvm 工具链 + +我们使用 llvm-10 中的 clang 来编译项目。 + +```lua +add_requires("llvm 10.x", {alias = "llvm-10"}) +target("test") + set_kind("binary") + add_files("src/*.c) + set_toolchains("llvm@llvm-10") +```` + +#### 拉取交叉编译工具链 + +我们也可以拉取指定的交叉编译工具链来编译项目。 + +```lua +add_requires("muslcc") +target("test") + set_kind("binary") + add_files("src/*.c) + set_toolchains("@muslcc") +``` + +#### 拉取工具链并且集成对应工具链编译的依赖包 + +我们也可以使用指定的muslcc交叉编译工具链去编译和集成所有的依赖包。 + +```lua +add_requires("muslcc") +add_requires("zlib", "libogg", {system = false}) + +set_toolchains("@muslcc") + +target("test") + set_kind("binary") + add_files("src/*.c") + add_packages("zlib", "libogg") +``` + ## 插件 #### 生成IDE工程文件插件(makefile, vs2002 - vs2019, ...) @@ -430,7 +488,7 @@ $ xmake l ``` plugins { - id 'org.tboox.gradle-xmake-plugin' version '1.0.6' + id 'org.tboox.gradle-xmake-plugin' version '1.1.4' } android { @@ -475,14 +533,13 @@ $ ./gradlew app:assembleDebug 或者你也可以考虑赞助我们也获取技术支持服务,[[成为赞助商](https://xmake.io/#/zh-cn/about/sponsor)] -## 项目例子 +## 谁在使用 Xmake? + +请点击 [用户列表](https://xmake.io/#/zh-cn/about/who_is_using_xmake) 查看完整用户使用列表。 -一些使用xmake的项目: +如果您在使用 xmake,也欢迎通过 PR 将信息提交至上面的列表,让更多的用户了解有多少用户在使用 xmake,也能让用户更加安心使用 xmake。 -* [tbox](https://github.com/tboox/tbox) -* [gbox](https://github.com/tboox/gbox) -* [vm86](https://github.com/tboox/vm86) -* [更多](https://github.com/xmake-io/awesome-xmake) +我们也会有更多的动力去持续投入,让 xmake 项目和社区更加繁荣。 ## 联系方式 @@ -492,8 +549,8 @@ $ ./gradlew app:assembleDebug - [Reddit论坛](https://www.reddit.com/r/xmake/) - [Telegram群组](https://t.me/tbooxorg) - [Gitter聊天室](https://gitter.im/xmake-io/xmake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - [Discord聊天室](https://discord.gg/aY7RVeKdG7) - - QQ群:343118190(技术支持), 662147501 + - [Discord聊天室](https://discord.gg/xmake) + - QQ群:343118190, 662147501 * 源码:[Github](https://github.com/xmake-io/xmake), [Gitee](https://gitee.com/tboox/xmake) * 微信公众号:tboox-os @@ -502,7 +559,8 @@ $ ./gradlew app:assembleDebug 感谢所有对xmake有所[贡献](CONTRIBUTING.md)的人: <a href="https://github.com/xmake-io/xmake/graphs/contributors"><img src="https://opencollective.com/xmake/contributors.svg?width=890&button=false" /></a> -* [TitanSnow](https://github.com/TitanSnow): 提供xmake [logo](https://github.com/TitanSnow/ts-xmake-logo) 和安装脚本 -* [uael](https://github.com/uael): 提供语义版本跨平台c库 [sv](https://github.com/uael/sv) -* [OpportunityLiu](https://github.com/OpportunityLiu): 改进cuda构建, tests框架和ci +* [TitanSnow](https://github.com/TitanSnow): 提供xmake [logo](https://github.com/TitanSnow/ts-xmake-logo) 和安装脚本。 +* [uael](https://github.com/uael): 提供语义版本跨平台c库 [sv](https://github.com/uael/sv)。 +* [OpportunityLiu](https://github.com/OpportunityLiu): 改进cuda构建, tests框架和ci。 +* [xq144](https://github.com/xq114): 改进 `xrepo env shell`,并贡献大量包到 [xmake-repo](https://github.com/xmake-io/xmake-repo) 仓库。 diff --git a/core/detect/lua-cjson.c b/core/detect/lua-cjson.c new file mode 100644 index 000000000..8e9d36ccd --- /dev/null +++ b/core/detect/lua-cjson.c @@ -0,0 +1,7 @@ +int luaopen_cjson(void *l); + +int main() +{ + luaopen_cjson(0); + return 0; +} diff --git a/core/detect/luajit.c b/core/detect/luajit.c new file mode 100644 index 000000000..96e8c0ccc --- /dev/null +++ b/core/detect/luajit.c @@ -0,0 +1,7 @@ +#include <luajit.h> + +int main() +{ + lua_pcall(0, 0, 0, 0); + return 0; +} diff --git a/core/detect/sv.c b/core/detect/sv.c new file mode 100644 index 000000000..20a071557 --- /dev/null +++ b/core/detect/sv.c @@ -0,0 +1,7 @@ +#include <semver.h> + +int main() +{ + semvern(0, 0, 0); + return 0; +} diff --git a/core/detect/tbox.c b/core/detect/tbox.c new file mode 100644 index 000000000..dfec3eb1e --- /dev/null +++ b/core/detect/tbox.c @@ -0,0 +1,10 @@ +#include <tbox/tbox.h> + +int main() +{ + if (tb_init(tb_null, tb_null)) + { + tb_trace_i("hello tbox!"); + tb_exit(); + } +} diff --git a/core/makefile b/core/makefile index 9d400c75b..0bba754cd 100644 --- a/core/makefile +++ b/core/makefile @@ -53,24 +53,12 @@ install : .null +@$(MAKE) --no-print-directory -C $(SRC_DIR) +@$(MAKE) --no-print-directory -C $(SRC_DIR) install -# make lipo -lipo : .null - ./tool/lipo $(PRO_NAME) $(DEBUG) $(SDK) $(ARCH1) $(ARCH2) - # make clean clean : .null @echo "" > $(TMP_DIR)/$(PRO_NAME).out @echo clean $(PRO_NAME) +@$(MAKE) --no-print-directory -C $(SRC_DIR) clean -# make update -update : .null - @echo "" > $(TMP_DIR)/$(PRO_NAME).out - @echo update $(PRO_NAME) - @$(MAKE) --no-print-directory -C $(SRC_DIR) update - @$(MAKE) --no-print-directory -C $(SRC_DIR) - @$(MAKE) --no-print-directory -C $(SRC_DIR) install - # make output output : .null @echo output $(PRO_NAME) @@ -98,7 +86,7 @@ include project.mak # ###################################################################################### # no-config # # -all : +all : make -r f make -r r @@ -119,9 +107,9 @@ update : make -r f make -r u -output : -error : -warning : +output : +error : +warning : doc : make -r f make -r d @@ -168,10 +156,10 @@ endif BUILD_ARCH :=$(if $(findstring windows,$(PLAT)),x86,$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring msys,$(PLAT)),$(MSYSARCH),$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring cygwin,$(PLAT)),x$(shell getconf LONG_BIT),$(BUILD_ARCH)) -BUILD_ARCH :=$(if $(findstring macosx,$(PLAT)),x$(shell getconf LONG_BIT),$(BUILD_ARCH)) +BUILD_ARCH :=$(if $(findstring macosx,$(PLAT)),$(shell uname -m),$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring linux,$(PLAT)),$(shell uname -m),$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring bsd,$(PLAT)),x$(shell getconf LONG_BIT),$(BUILD_ARCH)) -BUILD_ARCH :=$(if $(findstring iphoneos,$(PLAT)),armv7,$(BUILD_ARCH)) +BUILD_ARCH :=$(if $(findstring iphoneos,$(PLAT)),arm64,$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring android,$(PLAT)),armv7,$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring i686,$(BUILD_ARCH)),i386,$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring x32,$(BUILD_ARCH)),i386,$(BUILD_ARCH)) @@ -239,8 +227,8 @@ TOOL_DIR := $(PRO_DIR)/tool CXFLAG := $(if $(CXFLAG),$(CXFLAG),) # ccache -CCACHE := -DISTCC := +CCACHE := +DISTCC := # sed ifeq ($(HOST),macosx) @@ -268,7 +256,7 @@ SHELL = bash endif ECHO := echo -e -# make upper +# make upper define MAKE_UPPER ${shell echo $(1) | $(SEDX) "s/\(.*\)/\U\1/g"} endef @@ -280,15 +268,21 @@ base_LIBNAMES := curses readline m dl pthread endif ifeq ($(PLAT),windows) -base_LIBPATH := +base_LIBPATH := base_LIBNAMES := ws2_32 endif ifeq ($(PLAT),linux) base_LIBPATH := -base_LIBNAMES := -base_LIBNAMES += $(shell if { cat detect/curses.c | $(CC) -xc - -lcurses -ltinfo -o /dev/null 2>/dev/null; }; then echo curses tinfo; fi ) -base_LIBNAMES += $(shell if { cat detect/readline.c | $(CC) -xc - -lreadline -o /dev/null 2>/dev/null; }; then echo readline; fi ) +base_LIBNAMES := +base_LIBNAMES += $(shell if { cat detect/curses.c | $(CC) -xc - -lcurses -ltinfo -o /dev/null 2>/dev/null; }; then echo curses tinfo; fi ) +base_LIBNAMES += $(shell if { cat detect/readline.c | $(CC) -xc - -lreadline -o /dev/null 2>/dev/null; }; then echo readline; fi ) +base_LIBNAMES += $(shell if { cat detect/tbox.c | $(CC) -xc - -ltbox -o /dev/null 2>/dev/null; }; then echo tbox; fi ) +base_LIBNAMES += $(shell if { cat detect/lua-cjson.c | $(CC) -xc - -llua5.1-cjson -lluajit-5.1 -o /dev/null 2>/dev/null; }; then echo lua5.1-cjson; fi ) +base_LIBNAMES += $(shell if { cat detect/sv.c | $(CC) -xc - -lsv -o /dev/null 2>/dev/null; }; then echo sv; fi ) +ifeq ($(LUAJIT_SYSTEM),y) +base_LIBNAMES += $(shell if { cat detect/luajit.c | $(CC) -xc - $(shell pkg-config --libs --cflags luajit) -o /dev/null 2>/dev/null; }; then echo luajit-5.1; fi ) +endif ifneq ($(TERMUX_ARCH),) # on termux/ci? base_LIBNAMES += m dl else @@ -298,21 +292,24 @@ endif ifeq ($(PLAT),bsd) base_LIBPATH := -base_LIBNAMES := -base_LIBNAMES += $(shell if { cat detect/curses.c | $(CC) -xc - -lcurses -ltinfo -o /dev/null 2>/dev/null; }; then echo curses tinfo; fi ) -base_LIBNAMES += $(shell if { cat detect/readline.c | $(CC) -xc - -lreadline -o /dev/null 2>/dev/null; }; then echo readline; fi ) +base_LIBNAMES := +base_LIBNAMES += $(shell if { cat detect/curses.c | $(CC) -xc - -lcurses -ltinfo -o /dev/null 2>/dev/null; }; then echo curses tinfo; fi ) +base_LIBNAMES += $(shell if { cat detect/readline.c | $(CC) -xc - -lreadline -o /dev/null 2>/dev/null; }; then echo readline; fi ) base_LIBNAMES += m dl pthread endif # check jit compiler ifeq ($(PLAT),linux) luajit_JIT :=$(shell if [ -f "/etc/redhat-release" ]; then echo "nojit"; else echo "jit"; fi ) -ifeq ($(BUILD_ARCH),mips64) # maybe it is not very stable yet, we need to disable it +ifeq ($(BUILD_ARCH),mips64) # maybe it is not very stable yet, we need to disable it luajit_JIT :=nojit endif else luajit_JIT :=jit endif +ifeq ($(PLAT),iphoneos) +luajit_JIT :=nojit +endif # select package directory ifneq ($(PACKAGE),) diff --git a/core/plat/bsd/prefix.mak b/core/plat/bsd/prefix.mak index d0ea68d52..cee3a4406 100644 --- a/core/plat/bsd/prefix.mak +++ b/core/plat/bsd/prefix.mak @@ -1,10 +1,10 @@ # architecture makefile configure # prefix & suffix -BIN_PREFIX = +BIN_PREFIX = BIN_SUFFIX = .b -OBJ_PREFIX = +OBJ_PREFIX = OBJ_SUFFIX = .o LIB_PREFIX = lib @@ -24,7 +24,7 @@ LD := $(if $(CC),$(CC),$(PRE_)gcc) # we do not use ld directly AR := $(if $(AR),$(AR),$(PRE_)ar) STRIP := $(if $(STRIP),$(STRIP),$(PRE_)strip) RANLIB := $(if $(RANLIB),$(RANLIB),$(PRE_)ranlib) -AS := $(CC) +AS := $(CC) RM = rm -f RMDIR = rm -rf CP = cp @@ -40,7 +40,7 @@ AHFLAGS := $(if $(AHFLAGS),$(AHFLAGS),$(if $(findstring i386,$(BUILD_ARCH)),- ifneq ($(AHFLAGS),) ifeq ($(CXFLAGS_CHECK),) CC_CHECK = ${shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } -CXFLAGS_CHECK := +CXFLAGS_CHECK := export CXFLAGS_CHECK endif @@ -52,9 +52,9 @@ endif endif # cxflags: .c/.cc/.cpp files -CXFLAGS_RELEASE = +CXFLAGS_RELEASE = CXFLAGS_DEBUG = -g -D__tb_debug__ -CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall +CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall CXFLAGS-I = -I CXFLAGS-o = -o @@ -70,28 +70,28 @@ endif # profile ifeq ($(PROF),y) -CXFLAGS += -g -pg -fno-omit-frame-pointer +CXFLAGS += -g -pg -fno-omit-frame-pointer else -CXFLAGS_RELEASE += -fomit-frame-pointer +CXFLAGS_RELEASE += -fomit-frame-pointer CXFLAGS_DEBUG += -fno-omit-frame-pointer endif # cflags: .c files -CFLAGS_RELEASE = -CFLAGS_DEBUG = +CFLAGS_RELEASE = +CFLAGS_DEBUG = CFLAGS := $(CFLAGS) \ -std=gnu99 \ -D_GNU_SOURCE=1 -D_REENTRANT \ - -fno-math-errno + -fno-math-errno # ccflags: .cc/.cpp files CCFLAGS_RELEASE = -fno-rtti -CCFLAGS_DEBUG = +CCFLAGS_DEBUG = CCFLAGS := $(CXXFLAGS) -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 # ldflags -LDFLAGS_RELEASE = -LDFLAGS_DEBUG = -rdynamic +LDFLAGS_RELEASE = +LDFLAGS_DEBUG = -rdynamic LDFLAGS := $(LDFLAGS) $(AHFLAGS) $(LDFLAGS_CHECK) LDFLAGS-L = -L LDFLAGS-l = -l @@ -100,24 +100,24 @@ LDFLAGS-o = -o # prof ifeq ($(PROF),y) -LDFLAGS += -pg +LDFLAGS += -pg else LDFLAGS_RELEASE += -s -LDFLAGS_DEBUG += +LDFLAGS_DEBUG += endif # asflags -ASFLAGS_RELEASE = -ASFLAGS_DEBUG = +ASFLAGS_RELEASE = +ASFLAGS_DEBUG = ASFLAGS = -c $(AHFLAGS) ASFLAGS-I = -I ASFLAGS-o = -o # arflags -ARFLAGS_RELEASE = -ARFLAGS_DEBUG = +ARFLAGS_RELEASE = +ARFLAGS_DEBUG = ARFLAGS = -cr -ARFLAGS-o = +ARFLAGS-o = # shflags SHFLAGS_RELEASE = -s diff --git a/core/plat/cygwin/prefix.mak b/core/plat/cygwin/prefix.mak index fc7ac9c30..1eacbda9a 100644 --- a/core/plat/cygwin/prefix.mak +++ b/core/plat/cygwin/prefix.mak @@ -1,10 +1,10 @@ # architecture makefile configure # prefix & suffix -BIN_PREFIX = +BIN_PREFIX = BIN_SUFFIX = .b -OBJ_PREFIX = +OBJ_PREFIX = OBJ_SUFFIX = .o LIB_PREFIX = lib @@ -24,7 +24,7 @@ LD = $(PRE_)gcc AR = $(PRE_)ar STRIP = $(PRE_)strip RANLIB = $(PRE_)ranlib -AS = $(CC) +AS = $(CC) RM = rm -f RMDIR = rm -rf CP = cp @@ -40,7 +40,7 @@ AHFLAGS := $(if $(AHFLAGS),$(AHFLAGS),$(if $(findstring i386,$(BUILD_ARCH)),- ifneq ($(AHFLAGS),) ifeq ($(CXFLAGS_CHECK),) CC_CHECK = ${shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } -CXFLAGS_CHECK := +CXFLAGS_CHECK := export CXFLAGS_CHECK endif @@ -52,9 +52,9 @@ endif endif # cxflags: .c/.cc/.cpp files -CXFLAGS_RELEASE = +CXFLAGS_RELEASE = CXFLAGS_DEBUG = -g -D__tb_debug__ -CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall +CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall CXFLAGS-I = -I CXFLAGS-o = -o @@ -70,28 +70,28 @@ endif # profile ifeq ($(PROF),y) -CXFLAGS += -g -pg -fno-omit-frame-pointer +CXFLAGS += -g -pg -fno-omit-frame-pointer else -CXFLAGS_RELEASE += -fomit-frame-pointer +CXFLAGS_RELEASE += -fomit-frame-pointer CXFLAGS_DEBUG += -fno-omit-frame-pointer endif # cflags: .c files -CFLAGS_RELEASE = -CFLAGS_DEBUG = +CFLAGS_RELEASE = +CFLAGS_DEBUG = CFLAGS = \ -std=gnu99 \ -D_GNU_SOURCE=1 -D_REENTRANT \ - -fno-math-errno + -fno-math-errno # ccflags: .cc/.cpp files CCFLAGS_RELEASE = -fno-rtti -CCFLAGS_DEBUG = +CCFLAGS_DEBUG = CCFLAGS = -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 # ldflags -LDFLAGS_RELEASE = -LDFLAGS_DEBUG = +LDFLAGS_RELEASE = +LDFLAGS_DEBUG = LDFLAGS = $(AHFLAGS) $(LDFLAGS_CHECK) -static-libgcc LDFLAGS-L = -L LDFLAGS-l = -l @@ -100,24 +100,24 @@ LDFLAGS-o = -o # prof ifeq ($(PROF),y) -LDFLAGS += -pg +LDFLAGS += -pg else LDFLAGS_RELEASE += -s -LDFLAGS_DEBUG += +LDFLAGS_DEBUG += endif # asflags -ASFLAGS_RELEASE = -ASFLAGS_DEBUG = +ASFLAGS_RELEASE = +ASFLAGS_DEBUG = ASFLAGS = -c $(AHFLAGS) ASFLAGS-I = -I ASFLAGS-o = -o # arflags -ARFLAGS_RELEASE = -ARFLAGS_DEBUG = +ARFLAGS_RELEASE = +ARFLAGS_DEBUG = ARFLAGS = -cr -ARFLAGS-o = +ARFLAGS-o = # shflags SHFLAGS_RELEASE = -s diff --git a/core/plat/iphoneos/config.h b/core/plat/iphoneos/config.h new file mode 100644 index 000000000..e55edbc80 --- /dev/null +++ b/core/plat/iphoneos/config.h @@ -0,0 +1,22 @@ +#ifndef XM_CONFIG_H +#define XM_CONFIG_H + +// packages +// [packages] + +// major version +#define XM_CONFIG_VERSION_MAJOR [major] + +// minor version +#define XM_CONFIG_VERSION_MINOR [minor] + +// alter version +#define XM_CONFIG_VERSION_ALTER [alter] + +// build version +#define XM_CONFIG_VERSION_BUILD [build] + +// small +#define XM_CONFIG_SMALL [small] + +#endif diff --git a/core/plat/iphoneos/config.mak b/core/plat/iphoneos/config.mak new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/core/plat/iphoneos/config.mak @@ -0,0 +1 @@ + diff --git a/core/plat/iphoneos/prefix.mak b/core/plat/iphoneos/prefix.mak new file mode 100644 index 000000000..d81e6edba --- /dev/null +++ b/core/plat/iphoneos/prefix.mak @@ -0,0 +1,167 @@ +# architecture makefile configure + +# prefix & suffix +BIN_PREFIX = +BIN_SUFFIX = .b + +OBJ_PREFIX = +OBJ_SUFFIX = .o + +LIB_PREFIX = lib +LIB_SUFFIX = .a + +DLL_PREFIX = +DLL_SUFFIX = .dylib + +ASM_SUFFIX = .S + +# target arch +TARGETARCH := $(if $(findstring x86_64,$(BUILD_ARCH)),-arch x86_64,$(TARGETARCH)) +TARGETARCH := $(if $(findstring arm64,$(BUILD_ARCH)),-arch arm64,$(TARGETARCH)) +TARGETARCH := $(if $(findstring i386,$(BUILD_ARCH)),-arch i386,$(TARGETARCH)) +TARGETARCH += -miphoneos-version-min=10.0 + +# prefix +PRE_ := $(if $(BIN),$(BIN)/$(PRE),xcrun -sdk iphoneos ) + +# cc +CC = $(PRE_)clang +ifeq ($(CXFLAGS_CHECK),) +CC_CHECK = ${shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } +CXFLAGS_CHECK := $(call CC_CHECK,-ftrapv,) +export CXFLAGS_CHECK +endif + +# ld +LD = $(PRE_)clang +ifeq ($(LDFLAGS_CHECK),) +LD_CHECK = ${shell if $(LD) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } +LDFLAGS_CHECK := $(call LD_CHECK,-ftrapv,) +export LDFLAGS_CHECK +endif + +# tool +MM = $(PRE_)clang +AR = $(PRE_)ar +STRIP = $(PRE_)strip +RANLIB = $(PRE_)ranlib +AS = $(PRE_)clang +RM = rm -f +RMDIR = rm -rf +CP = cp +CPDIR = cp -r +MKDIR = mkdir -p +MAKE = make -r + +# cxflags: .c/.cc/.cpp files +CXFLAGS_RELEASE = -fvisibility=hidden +CXFLAGS_DEBUG = -g -D__tb_debug__ +CXFLAGS = $(TARGETARCH) -c -Wall -Werror -Wno-error=deprecated-declarations -Qunused-arguments +CXFLAGS-I = -I +CXFLAGS-o = -o + +# opti +ifeq ($(SMALL),y) +CXFLAGS_RELEASE += -Os +else +CXFLAGS_RELEASE += -O3 +endif + +# prof +ifeq ($(PROF),y) +CXFLAGS += -g -fno-omit-frame-pointer +else +CXFLAGS_RELEASE += -fomit-frame-pointer +CXFLAGS_DEBUG += -fno-omit-frame-pointer $(CXFLAGS_CHECK) +endif + +# cflags: .c files +CFLAGS_RELEASE = +CFLAGS_DEBUG = +CFLAGS = \ + -std=c99 \ + -D_GNU_SOURCE=1 -D_REENTRANT \ + -fno-math-errno -fno-tree-vectorize + +# ccflags: .cc/.cpp files +CCFLAGS_RELEASE = +CCFLAGS_DEBUG = +CCFLAGS = \ + -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ + -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 + +# mxflags: .m/.mm files +MXFLAGS_RELEASE = -fvisibility=hidden +MXFLAGS_DEBUG = -g -D__tb_debug__ +MXFLAGS = \ + $(TARGETARCH) -c -Wall -Werror -Wno-error=deprecated-declarations -Qunused-arguments \ + $(ARCH_CXFLAGS) -fmessage-length=0 -pipe -fpascal-strings \ + "-DIBOutlet=__attribute__((iboutlet))" \ + "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" \ + "-DIBAction=void)__attribute__((ibaction)" +MXFLAGS-I = -I +MXFLAGS-o = -o + +# opti +ifeq ($(SMALL),y) +MXFLAGS_RELEASE += -Os +else +MXFLAGS_RELEASE += -O3 +endif + +# prof +ifeq ($(PROF),y) +MXFLAGS += -g -fno-omit-frame-pointer +else +MXFLAGS_RELEASE += -fomit-frame-pointer +MXFLAGS_DEBUG += -fno-omit-frame-pointer $(LDFLAGS_CHECK) +endif + +# mflags: .m files +MFLAGS_RELEASE = +MFLAGS_DEBUG = +MFLAGS = -std=c99 + +# mmflags: .mm files +MMFLAGS_RELEASE = +MMFLAGS_DEBUG = +MMFLAGS = + +# ldflags +LDFLAGS_ARCH := $(if $(findstring arm64,$(BUILD_ARCH)),,-pagezero_size 10000 -image_base 100000000) +LDFLAGS_RELEASE = +LDFLAGS_DEBUG = +LDFLAGS = $(TARGETARCH) -all_load $(LDFLAGS_ARCH) -framework CoreFoundation -framework Foundation +LDFLAGS-L = -L +LDFLAGS-l = -l +LDFLAGS-f = +LDFLAGS-o = -o + +# prof +ifeq ($(PROF),y) +else +LDFLAGS_RELEASE += -s +LDFLAGS_DEBUG += -ftrapv +endif + +# asflags +ASFLAGS_RELEASE = +ASFLAGS_DEBUG = +ASFLAGS = $(TARGETARCH) -c -Wall +ASFLAGS-I = -I +ASFLAGS-o = -o + +# arflags +ARFLAGS_RELEASE = +ARFLAGS_DEBUG = +ARFLAGS = -cr +ARFLAGS-o = + +# shflags +SHFLAGS_RELEASE = -s +SHFLAGS = $(ARCH_LDFLAGS) -dynamiclib + +# config +include $(PLAT_DIR)/config.mak + + diff --git a/core/plat/linux/prefix.mak b/core/plat/linux/prefix.mak index 0bb741c0e..662187051 100644 --- a/core/plat/linux/prefix.mak +++ b/core/plat/linux/prefix.mak @@ -1,10 +1,10 @@ # architecture makefile configure # prefix & suffix -BIN_PREFIX = +BIN_PREFIX = BIN_SUFFIX = .b -OBJ_PREFIX = +OBJ_PREFIX = OBJ_SUFFIX = .o LIB_PREFIX = lib @@ -24,7 +24,7 @@ LD := $(if $(CC),$(CC),$(PRE_)gcc) # we do not use ld directly AR := $(if $(AR),$(AR),$(PRE_)ar) STRIP := $(if $(STRIP),$(STRIP),$(PRE_)strip) RANLIB := $(if $(RANLIB),$(RANLIB),$(PRE_)ranlib) -AS := $(CC) +AS := $(CC) RM = rm -f RMDIR = rm -rf CP = cp @@ -40,7 +40,7 @@ AHFLAGS := $(if $(AHFLAGS),$(AHFLAGS),$(if $(findstring i386,$(BUILD_ARCH)),- ifneq ($(AHFLAGS),) ifeq ($(CXFLAGS_CHECK),) CC_CHECK = ${shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } -CXFLAGS_CHECK := +CXFLAGS_CHECK := export CXFLAGS_CHECK endif @@ -52,9 +52,9 @@ endif endif # cxflags: .c/.cc/.cpp files -CXFLAGS_RELEASE = +CXFLAGS_RELEASE = CXFLAGS_DEBUG = -g -D__tb_debug__ -CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall +CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall CXFLAGS-I = -I CXFLAGS-o = -o @@ -70,28 +70,28 @@ endif # profile ifeq ($(PROF),y) -CXFLAGS += -g -pg -fno-omit-frame-pointer +CXFLAGS += -g -pg -fno-omit-frame-pointer else -CXFLAGS_RELEASE += -fomit-frame-pointer +CXFLAGS_RELEASE += -fomit-frame-pointer CXFLAGS_DEBUG += -fno-omit-frame-pointer endif # cflags: .c files -CFLAGS_RELEASE = -CFLAGS_DEBUG = +CFLAGS_RELEASE = +CFLAGS_DEBUG = CFLAGS := $(CFLAGS) \ -std=gnu99 \ -D_GNU_SOURCE=1 -D_REENTRANT \ - -fno-math-errno + -fno-math-errno # ccflags: .cc/.cpp files CCFLAGS_RELEASE = -fno-rtti -CCFLAGS_DEBUG = +CCFLAGS_DEBUG = CCFLAGS := $(CXXFLAGS) -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 # ldflags -LDFLAGS_RELEASE = -LDFLAGS_DEBUG = -rdynamic +LDFLAGS_RELEASE = +LDFLAGS_DEBUG = -rdynamic LDFLAGS := $(LDFLAGS) $(AHFLAGS) $(LDFLAGS_CHECK) LDFLAGS-L = -L LDFLAGS-l = -l @@ -100,24 +100,24 @@ LDFLAGS-o = -o # prof ifeq ($(PROF),y) -LDFLAGS += -pg +LDFLAGS += -pg else LDFLAGS_RELEASE += -s -LDFLAGS_DEBUG += +LDFLAGS_DEBUG += endif # asflags -ASFLAGS_RELEASE = -ASFLAGS_DEBUG = +ASFLAGS_RELEASE = +ASFLAGS_DEBUG = ASFLAGS = -c $(AHFLAGS) ASFLAGS-I = -I ASFLAGS-o = -o # arflags -ARFLAGS_RELEASE = -ARFLAGS_DEBUG = +ARFLAGS_RELEASE = +ARFLAGS_DEBUG = ARFLAGS = -cr -ARFLAGS-o = +ARFLAGS-o = # shflags SHFLAGS_RELEASE = -s diff --git a/core/plat/macosx/prefix.mak b/core/plat/macosx/prefix.mak index a1199c2d3..2cdf8481b 100644 --- a/core/plat/macosx/prefix.mak +++ b/core/plat/macosx/prefix.mak @@ -1,23 +1,24 @@ # architecture makefile configure # prefix & suffix -BIN_PREFIX = +BIN_PREFIX = BIN_SUFFIX = .b -OBJ_PREFIX = +OBJ_PREFIX = OBJ_SUFFIX = .o LIB_PREFIX = lib LIB_SUFFIX = .a -DLL_PREFIX = +DLL_PREFIX = DLL_SUFFIX = .dylib ASM_SUFFIX = .S # cpu bits -BITS := $(if $(findstring x86_64,$(BUILD_ARCH)),64,) -BITS := $(if $(findstring i386,$(BUILD_ARCH)),32,) +BITS := $(if $(findstring x86_64,$(BUILD_ARCH)),64,$(BITS)) +BITS := $(if $(findstring arm64,$(BUILD_ARCH)),64,$(BITS)) +BITS := $(if $(findstring i386,$(BUILD_ARCH)),32,$(BITS)) BITS := $(if $(BITS),$(BITS),$(shell getconf LONG_BIT)) # prefix @@ -27,7 +28,7 @@ PRE_ := $(if $(BIN),$(BIN)/$(PRE),xcrun -sdk macosx ) CC = $(PRE_)clang ifeq ($(CXFLAGS_CHECK),) CC_CHECK = ${shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } -CXFLAGS_CHECK := $(call CC_CHECK,-ftrapv,) +CXFLAGS_CHECK := $(call CC_CHECK,-ftrapv,) export CXFLAGS_CHECK endif @@ -35,7 +36,7 @@ endif LD = $(PRE_)clang ifeq ($(LDFLAGS_CHECK),) LD_CHECK = ${shell if $(LD) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } -LDFLAGS_CHECK := $(call LD_CHECK,-ftrapv,) +LDFLAGS_CHECK := $(call LD_CHECK,-ftrapv,) export LDFLAGS_CHECK endif @@ -68,23 +69,23 @@ endif # prof ifeq ($(PROF),y) -CXFLAGS += -g -fno-omit-frame-pointer +CXFLAGS += -g -fno-omit-frame-pointer else -CXFLAGS_RELEASE += -fomit-frame-pointer +CXFLAGS_RELEASE += -fomit-frame-pointer CXFLAGS_DEBUG += -fno-omit-frame-pointer $(CXFLAGS_CHECK) endif # cflags: .c files -CFLAGS_RELEASE = -CFLAGS_DEBUG = +CFLAGS_RELEASE = +CFLAGS_DEBUG = CFLAGS = \ -std=c99 \ -D_GNU_SOURCE=1 -D_REENTRANT \ - -fno-math-errno -fno-tree-vectorize + -fno-math-errno -fno-tree-vectorize # ccflags: .cc/.cpp files -CCFLAGS_RELEASE = -CCFLAGS_DEBUG = +CCFLAGS_RELEASE = +CCFLAGS_DEBUG = CCFLAGS = \ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 @@ -97,7 +98,7 @@ MXFLAGS = \ -mssse3 $(ARCH_CXFLAGS) -fmessage-length=0 -pipe -fpascal-strings \ "-DIBOutlet=__attribute__((iboutlet))" \ "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" \ - "-DIBAction=void)__attribute__((ibaction)" + "-DIBAction=void)__attribute__((ibaction)" MXFLAGS-I = -I MXFLAGS-o = -o @@ -110,26 +111,27 @@ endif # prof ifeq ($(PROF),y) -MXFLAGS += -g -fno-omit-frame-pointer +MXFLAGS += -g -fno-omit-frame-pointer else -MXFLAGS_RELEASE += -fomit-frame-pointer +MXFLAGS_RELEASE += -fomit-frame-pointer MXFLAGS_DEBUG += -fno-omit-frame-pointer $(LDFLAGS_CHECK) endif # mflags: .m files -MFLAGS_RELEASE = -MFLAGS_DEBUG = +MFLAGS_RELEASE = +MFLAGS_DEBUG = MFLAGS = -std=c99 # mmflags: .mm files -MMFLAGS_RELEASE = -MMFLAGS_DEBUG = +MMFLAGS_RELEASE = +MMFLAGS_DEBUG = MMFLAGS = # ldflags -LDFLAGS_RELEASE = -LDFLAGS_DEBUG = -LDFLAGS = -m$(BITS) -all_load -pagezero_size 10000 -image_base 100000000 -mmacosx-version-min=10.7 +LDFLAGS_ARCH := $(if $(findstring arm64,$(BUILD_ARCH)),,-pagezero_size 10000 -image_base 100000000) +LDFLAGS_RELEASE = +LDFLAGS_DEBUG = +LDFLAGS = -m$(BITS) -all_load $(LDFLAGS_ARCH) -mmacosx-version-min=10.7 LDFLAGS-L = -L LDFLAGS-l = -l LDFLAGS-f = @@ -143,17 +145,17 @@ LDFLAGS_DEBUG += -ftrapv endif # asflags -ASFLAGS_RELEASE = -ASFLAGS_DEBUG = +ASFLAGS_RELEASE = +ASFLAGS_DEBUG = ASFLAGS = -m$(BITS) -c -Wall ASFLAGS-I = -I ASFLAGS-o = -o # arflags -ARFLAGS_RELEASE = -ARFLAGS_DEBUG = +ARFLAGS_RELEASE = +ARFLAGS_DEBUG = ARFLAGS = -cr -ARFLAGS-o = +ARFLAGS-o = # shflags SHFLAGS_RELEASE = -s diff --git a/core/plat/mingw/prefix.mak b/core/plat/mingw/prefix.mak index 0ad1f2ef0..c190bdb42 100644 --- a/core/plat/mingw/prefix.mak +++ b/core/plat/mingw/prefix.mak @@ -1,16 +1,16 @@ # architecture makefile configure # prefix & suffix -BIN_PREFIX = +BIN_PREFIX = BIN_SUFFIX = .b -OBJ_PREFIX = +OBJ_PREFIX = OBJ_SUFFIX = .obj -LIB_PREFIX = +LIB_PREFIX = LIB_SUFFIX = .lib -DLL_PREFIX = +DLL_PREFIX = DLL_SUFFIX = .dll ASM_SUFFIX = .S @@ -25,7 +25,7 @@ LD = $(PRE_)gcc AR = $(PRE_)ar STRIP = $(PRE_)strip RANLIB = $(PRE_)ranlib -AS = $(CC) +AS = $(CC) RM = rm -f RMDIR = rm -rf CP = cp @@ -41,7 +41,7 @@ AHFLAGS := $(if $(AHFLAGS),$(AHFLAGS),$(if $(findstring i386,$(BUILD_ARCH)),- ifneq ($(AHFLAGS),) ifeq ($(CXFLAGS_CHECK),) CC_CHECK = ${shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } -CXFLAGS_CHECK := +CXFLAGS_CHECK := export CXFLAGS_CHECK endif @@ -53,9 +53,9 @@ endif endif # cxflags: .c/.cc/.cpp files -CXFLAGS_RELEASE = +CXFLAGS_RELEASE = CXFLAGS_DEBUG = -g -D__tb_debug__ -CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall +CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall CXFLAGS-I = -I CXFLAGS-o = -o @@ -71,28 +71,28 @@ endif # profile ifeq ($(PROF),y) -CXFLAGS += -g -pg -fno-omit-frame-pointer +CXFLAGS += -g -pg -fno-omit-frame-pointer else -CXFLAGS_RELEASE += -fomit-frame-pointer +CXFLAGS_RELEASE += -fomit-frame-pointer CXFLAGS_DEBUG += -fno-omit-frame-pointer endif # cflags: .c files -CFLAGS_RELEASE = -CFLAGS_DEBUG = +CFLAGS_RELEASE = +CFLAGS_DEBUG = CFLAGS = \ -std=gnu99 \ -D_GNU_SOURCE=1 -D_REENTRANT \ - -fno-math-errno + -fno-math-errno # ccflags: .cc/.cpp files CCFLAGS_RELEASE = -fno-rtti -CCFLAGS_DEBUG = +CCFLAGS_DEBUG = CCFLAGS = -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 # ldflags -LDFLAGS_RELEASE = -LDFLAGS_DEBUG = +LDFLAGS_RELEASE = +LDFLAGS_DEBUG = LDFLAGS = $(AHFLAGS) $(LDFLAGS_CHECK) -static-libgcc LDFLAGS-L = -L LDFLAGS-l = -l @@ -101,24 +101,24 @@ LDFLAGS-o = -o # prof ifeq ($(PROF),y) -LDFLAGS += -pg +LDFLAGS += -pg else LDFLAGS_RELEASE += -s -LDFLAGS_DEBUG += +LDFLAGS_DEBUG += endif # asflags -ASFLAGS_RELEASE = -ASFLAGS_DEBUG = +ASFLAGS_RELEASE = +ASFLAGS_DEBUG = ASFLAGS = -c $(AHFLAGS) ASFLAGS-I = -I ASFLAGS-o = -o # arflags -ARFLAGS_RELEASE = -ARFLAGS_DEBUG = +ARFLAGS_RELEASE = +ARFLAGS_DEBUG = ARFLAGS = -cr -ARFLAGS-o = +ARFLAGS-o = # shflags SHFLAGS_RELEASE = -s diff --git a/core/plat/msys/prefix.mak b/core/plat/msys/prefix.mak index 9d4dc8dd5..1eacbda9a 100644 --- a/core/plat/msys/prefix.mak +++ b/core/plat/msys/prefix.mak @@ -1,10 +1,10 @@ # architecture makefile configure # prefix & suffix -BIN_PREFIX = +BIN_PREFIX = BIN_SUFFIX = .b -OBJ_PREFIX = +OBJ_PREFIX = OBJ_SUFFIX = .o LIB_PREFIX = lib @@ -24,7 +24,7 @@ LD = $(PRE_)gcc AR = $(PRE_)ar STRIP = $(PRE_)strip RANLIB = $(PRE_)ranlib -AS = $(CC) +AS = $(CC) RM = rm -f RMDIR = rm -rf CP = cp @@ -40,7 +40,7 @@ AHFLAGS := $(if $(AHFLAGS),$(AHFLAGS),$(if $(findstring i386,$(BUILD_ARCH)),- ifneq ($(AHFLAGS),) ifeq ($(CXFLAGS_CHECK),) CC_CHECK = ${shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } -CXFLAGS_CHECK := +CXFLAGS_CHECK := export CXFLAGS_CHECK endif @@ -52,9 +52,9 @@ endif endif # cxflags: .c/.cc/.cpp files -CXFLAGS_RELEASE = +CXFLAGS_RELEASE = CXFLAGS_DEBUG = -g -D__tb_debug__ -CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall +CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall CXFLAGS-I = -I CXFLAGS-o = -o @@ -70,28 +70,28 @@ endif # profile ifeq ($(PROF),y) -CXFLAGS += -g -pg -fno-omit-frame-pointer +CXFLAGS += -g -pg -fno-omit-frame-pointer else -CXFLAGS_RELEASE += -fomit-frame-pointer +CXFLAGS_RELEASE += -fomit-frame-pointer CXFLAGS_DEBUG += -fno-omit-frame-pointer endif # cflags: .c files -CFLAGS_RELEASE = -CFLAGS_DEBUG = +CFLAGS_RELEASE = +CFLAGS_DEBUG = CFLAGS = \ -std=gnu99 \ -D_GNU_SOURCE=1 -D_REENTRANT \ - -fno-math-errno + -fno-math-errno # ccflags: .cc/.cpp files CCFLAGS_RELEASE = -fno-rtti -CCFLAGS_DEBUG = +CCFLAGS_DEBUG = CCFLAGS = -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 # ldflags -LDFLAGS_RELEASE = -LDFLAGS_DEBUG = +LDFLAGS_RELEASE = +LDFLAGS_DEBUG = LDFLAGS = $(AHFLAGS) $(LDFLAGS_CHECK) -static-libgcc LDFLAGS-L = -L LDFLAGS-l = -l @@ -100,24 +100,24 @@ LDFLAGS-o = -o # prof ifeq ($(PROF),y) -LDFLAGS += -pg +LDFLAGS += -pg else LDFLAGS_RELEASE += -s -LDFLAGS_DEBUG += +LDFLAGS_DEBUG += endif # asflags -ASFLAGS_RELEASE = -ASFLAGS_DEBUG = +ASFLAGS_RELEASE = +ASFLAGS_DEBUG = ASFLAGS = -c $(AHFLAGS) ASFLAGS-I = -I ASFLAGS-o = -o # arflags -ARFLAGS_RELEASE = -ARFLAGS_DEBUG = +ARFLAGS_RELEASE = +ARFLAGS_DEBUG = ARFLAGS = -cr -ARFLAGS-o = +ARFLAGS-o = # shflags SHFLAGS_RELEASE = -s diff --git a/core/project.mak b/core/project.mak index 8ffa0e132..4c3aed86c 100644 --- a/core/project.mak +++ b/core/project.mak @@ -7,10 +7,10 @@ PRO_NAME = xmake PRO_VERSION_MAJOR = 2 # the project minor version -PRO_VERSION_MINOR = 3 +PRO_VERSION_MINOR = 5 # the project alter version -PRO_VERSION_ALTER = 9 +PRO_VERSION_ALTER = 5 # the project prefix PRO_PREFIX = XM_ diff --git a/core/src/demo/makefile b/core/src/demo/makefile index 160174661..1a2142db5 100644 --- a/core/src/demo/makefile +++ b/core/src/demo/makefile @@ -1,24 +1,42 @@ -# preifx include $(PRO_DIR)/prefix.mak -# module name -NAMES = demo +NAMES = demo +demo_TYPE = BIN +demo_C_FILES += xmake +demo_PKGS-$(BASE) += base +demo_CXFLAGS += -D__tb_prefix__=\"xmake\" -# type -demo_TYPE = BIN +demo_LIBS += xmake$(DTYPE) +demo_LIB_DIRS += ../xmake -# files -demo_C_FILES += xmake +# lcurses +demo_LIBS += lcurses$(DTYPE) +demo_LIB_DIRS += ../lcurses -# packages -demo_PKGS-$(BASE) += base +# tbox +tbox_DTYPE := $(if $(findstring tbox,$(base_LIBNAMES)),,$(DTYPE)) +demo_LIBS += tbox$(tbox_DTYPE) +demo_INC_DIRS += ../ ../tbox/tbox/src ../tbox/inc/$(PLAT) +demo_LIB_DIRS += ../tbox -# others -demo_LIBS += xmake$(DTYPE) lcurses$(DTYPE) tbox$(DTYPE) luajit$(DTYPE) sv$(DTYPE) lua-cjson$(DTYPE) $(BASE_LIBS) -demo_INC_DIRS += ../ ../tbox/tbox/src ../tbox/inc/$(PLAT) ../luajit/luajit/src ../sv/sv/include -demo_LIB_DIRS += ../xmake ../tbox ../luajit ../sv ../lcurses ../lua-cjson -demo_CXFLAGS += -D__tb_prefix__=\"xmake\" +# luajit +luajit_LIBS := $(if $(findstring luajit,$(base_LIBNAMES)),,luajit$(DTYPE)) +demo_LIBS += $(luajit_LIBS) +demo_INC_DIRS += ../luajit/luajit/src +demo_LIB_DIRS += ../luajit + +# sv +sv_DTYPE := $(if $(findstring sv,$(base_LIBNAMES)),,$(DTYPE)) +demo_LIBS += sv$(sv_DTYPE) +demo_INC_DIRS += ../sv/sv/include +demo_LIB_DIRS += ../sv + +# lua-cjson +lua-cjson_LIBS := $(if $(findstring cjson,$(base_LIBNAMES)),,lua-cjson$(DTYPE)) +demo_LIBS += $(lua-cjson_LIBS) +demo_LIB_DIRS += ../lua-cjson + +demo_LIBS += $(BASE_LIBS) -# suffix include $(PRO_DIR)/suffix.mak diff --git a/core/src/demo/xmake.lua b/core/src/demo/xmake.lua index 6eeb0c771..8b93335fd 100644 --- a/core/src/demo/xmake.lua +++ b/core/src/demo/xmake.lua @@ -1,4 +1,3 @@ --- add target target("demo") -- disable this target if only build libaries diff --git a/core/src/lcurses/makefile b/core/src/lcurses/makefile index ac4384cb8..25752ab47 100644 --- a/core/src/lcurses/makefile +++ b/core/src/lcurses/makefile @@ -12,7 +12,7 @@ lcurses_CONFIG = n # curses files lcurses_C_FILES += lcurses - + # curses flags lcurses_CXFLAGS += $(if $(findstring curses,$(base_LIBNAMES)),-DXM_CONFIG_API_HAVE_CURSES,) diff --git a/core/src/lcurses/xmake.lua b/core/src/lcurses/xmake.lua index 9588518be..f80117f10 100644 --- a/core/src/lcurses/xmake.lua +++ b/core/src/lcurses/xmake.lua @@ -1,25 +1,15 @@ --- add target target("lcurses") - - -- enable this target? - if not has_config("curses") and not has_config("pdcurses") then - set_default(false) - end - - -- make as a static library set_kind("static") - - -- add deps add_deps("luajit") if is_plat("windows") and has_config("pdcurses") then add_deps("pdcurses") + add_defines("XM_CONFIG_API_HAVE_CURSES", {public = true}) + elseif has_config("curses") then + add_defines("XM_CONFIG_API_HAVE_CURSES", {public = true}) + else + set_default(false) end - - -- add the common source files add_files("lcurses.c") - add_defines("XM_CONFIG_API_HAVE_CURSES", {public = true}) - - -- add options if is_plat("windows") then add_options("pdcurses") set_languages("c89") diff --git a/core/src/lua-cjson/makefile b/core/src/lua-cjson/makefile index 0a4263f03..9e96851ae 100644 --- a/core/src/lua-cjson/makefile +++ b/core/src/lua-cjson/makefile @@ -18,13 +18,17 @@ lua-cjson_C_FILES += \ lua-cjson/lua_cjson # cflags -# Use internal strtod() / g_fmt() code for performance and disable multi-thread +# Use internal strtod() / g_fmt() code for performance and disable multi-thread lua-cjson_CFLAGS += -DNDEBUG -DUSE_INTERNAL_FPCONV # includes lua-cjson_INC_DIRS += \ ../luajit/luajit/src +# use given system library? +lua-cjson_C_FILES := $(if $(findstring cjson,$(base_LIBNAMES)),,$(lua-cjson_C_FILES)) +lua-cjson_INC_FILES := $(if $(findstring cjson,$(base_LIBNAMES)),,$(lua-cjson_INC_FILES)) + # suffix include $(PRO_DIR)/suffix.mak diff --git a/core/src/lua-cjson/xmake.lua b/core/src/lua-cjson/xmake.lua index b25640cae..d2eec99f0 100644 --- a/core/src/lua-cjson/xmake.lua +++ b/core/src/lua-cjson/xmake.lua @@ -6,11 +6,11 @@ target("lua-cjson") set_languages("c89") end add_files("lua-cjson/*.c|fpconv.c") - -- Use internal strtod() / g_fmt() code for performance and disable multi-thread + -- Use internal strtod() / g_fmt() code for performance and disable multi-thread add_defines("NDEBUG", "USE_INTERNAL_FPCONV") if is_plat("windows") then -- Windows sprintf()/strtod() handle NaN/inf differently. Not supported. add_defines("DISABLE_INVALID_NUMBERS") add_defines("inline=__inline") end - + diff --git a/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_bcdef.h b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_bcdef.h new file mode 100644 index 000000000..5bb646199 --- /dev/null +++ b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_bcdef.h @@ -0,0 +1,220 @@ +/* This is a generated file. DO NOT EDIT! */ + +LJ_DATADEF const uint16_t lj_bc_ofs[] = { +0, +128, +256, +384, +512, +632, +748, +816, +884, +1008, +1132, +1188, +1244, +1308, +1372, +1428, +1484, +1520, +1556, +1588, +1636, +1704, +1776, +1884, +1992, +2108, +2180, +2296, +2404, +2512, +2628, +2700, +2816, +2924, +3032, +3148, +3220, +3336, +3408, +3484, +3528, +3528, +3564, +3596, +3628, +3676, +3728, +3840, +3944, +3996, +4048, +4108, +4180, +4276, +4360, +4384, +4408, +4548, +4696, +4804, +4876, +5052, +5304, +5448, +5596, +5700, +5716, +5788, +5800, +5988, +6068, +6232, +6420, +6540, +6560, +6728, +6832, +6944, +7088, +7088, +7088, +7228, +7228, +7228, +7280, +7280, +7280, +7304, +7304, +7336, +7336, +7400, +7400, +7400, +7532, +7532, +7604, +9508, +9576, +10016, +10096, +10148, +10268, +9616, +9764, +9852, +9900, +9924, +10320, +10376, +11016, +10436, +10752, +11120, +11048, +11084, +11260, +11332, +11364, +11396, +11428, +11460, +11492, +11524, +11556, +11588, +11620, +11652, +11848, +11908, +11300, +11724, +11684, +11764, +11804, +11956, +12096, +13028, +13100, +13064, +13136, +13192, +13248, +13304, +13360, +12824, +12892, +12960, +12236, +12288, +12368, +12540, +12616, +12692 +}; + +LJ_DATADEF const uint16_t lj_bc_mode[] = { +BCDEF(BCMODE) +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF +}; + diff --git a/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_ffdef.h b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_ffdef.h new file mode 100644 index 000000000..0ea74688b --- /dev/null +++ b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_ffdef.h @@ -0,0 +1,203 @@ +/* This is a generated file. DO NOT EDIT! */ + +FFDEF(assert) +FFDEF(type) +FFDEF(next) +FFDEF(pairs) +FFDEF(ipairs_aux) +FFDEF(ipairs) +FFDEF(getmetatable) +FFDEF(setmetatable) +FFDEF(getfenv) +FFDEF(setfenv) +FFDEF(rawget) +FFDEF(rawset) +FFDEF(rawequal) +FFDEF(unpack) +FFDEF(select) +FFDEF(tonumber) +FFDEF(tostring) +FFDEF(error) +FFDEF(pcall) +FFDEF(xpcall) +FFDEF(loadfile) +FFDEF(load) +FFDEF(loadstring) +FFDEF(dofile) +FFDEF(gcinfo) +FFDEF(collectgarbage) +FFDEF(newproxy) +FFDEF(print) +FFDEF(coroutine_status) +FFDEF(coroutine_running) +FFDEF(coroutine_isyieldable) +FFDEF(coroutine_create) +FFDEF(coroutine_yield) +FFDEF(coroutine_resume) +FFDEF(coroutine_wrap_aux) +FFDEF(coroutine_wrap) +FFDEF(math_abs) +FFDEF(math_floor) +FFDEF(math_ceil) +FFDEF(math_sqrt) +FFDEF(math_log10) +FFDEF(math_exp) +FFDEF(math_sin) +FFDEF(math_cos) +FFDEF(math_tan) +FFDEF(math_asin) +FFDEF(math_acos) +FFDEF(math_atan) +FFDEF(math_sinh) +FFDEF(math_cosh) +FFDEF(math_tanh) +FFDEF(math_frexp) +FFDEF(math_modf) +FFDEF(math_log) +FFDEF(math_atan2) +FFDEF(math_pow) +FFDEF(math_fmod) +FFDEF(math_ldexp) +FFDEF(math_min) +FFDEF(math_max) +FFDEF(math_random) +FFDEF(math_randomseed) +FFDEF(bit_tobit) +FFDEF(bit_bnot) +FFDEF(bit_bswap) +FFDEF(bit_lshift) +FFDEF(bit_rshift) +FFDEF(bit_arshift) +FFDEF(bit_rol) +FFDEF(bit_ror) +FFDEF(bit_band) +FFDEF(bit_bor) +FFDEF(bit_bxor) +FFDEF(bit_tohex) +FFDEF(string_byte) +FFDEF(string_char) +FFDEF(string_sub) +FFDEF(string_rep) +FFDEF(string_reverse) +FFDEF(string_lower) +FFDEF(string_upper) +FFDEF(string_dump) +FFDEF(string_find) +FFDEF(string_match) +FFDEF(string_gmatch_aux) +FFDEF(string_gmatch) +FFDEF(string_gsub) +FFDEF(string_format) +FFDEF(table_maxn) +FFDEF(table_insert) +FFDEF(table_concat) +FFDEF(table_sort) +FFDEF(table_new) +FFDEF(table_clear) +FFDEF(io_method_close) +FFDEF(io_method_read) +FFDEF(io_method_write) +FFDEF(io_method_flush) +FFDEF(io_method_seek) +FFDEF(io_method_setvbuf) +FFDEF(io_method_lines) +FFDEF(io_method___gc) +FFDEF(io_method___tostring) +FFDEF(io_open) +FFDEF(io_popen) +FFDEF(io_tmpfile) +FFDEF(io_close) +FFDEF(io_read) +FFDEF(io_write) +FFDEF(io_flush) +FFDEF(io_input) +FFDEF(io_output) +FFDEF(io_lines) +FFDEF(io_type) +FFDEF(os_execute) +FFDEF(os_remove) +FFDEF(os_rename) +FFDEF(os_tmpname) +FFDEF(os_getenv) +FFDEF(os_exit) +FFDEF(os_clock) +FFDEF(os_date) +FFDEF(os_time) +FFDEF(os_difftime) +FFDEF(os_setlocale) +FFDEF(debug_getregistry) +FFDEF(debug_getmetatable) +FFDEF(debug_setmetatable) +FFDEF(debug_getfenv) +FFDEF(debug_setfenv) +FFDEF(debug_getinfo) +FFDEF(debug_getlocal) +FFDEF(debug_setlocal) +FFDEF(debug_getupvalue) +FFDEF(debug_setupvalue) +FFDEF(debug_upvalueid) +FFDEF(debug_upvaluejoin) +FFDEF(debug_sethook) +FFDEF(debug_gethook) +FFDEF(debug_debug) +FFDEF(debug_traceback) +FFDEF(jit_on) +FFDEF(jit_off) +FFDEF(jit_flush) +FFDEF(jit_status) +FFDEF(jit_security) +FFDEF(jit_attach) +FFDEF(jit_util_funcinfo) +FFDEF(jit_util_funcbc) +FFDEF(jit_util_funck) +FFDEF(jit_util_funcuvname) +FFDEF(jit_profile_start) +FFDEF(jit_profile_stop) +FFDEF(jit_profile_dumpstack) +FFDEF(ffi_meta___index) +FFDEF(ffi_meta___newindex) +FFDEF(ffi_meta___eq) +FFDEF(ffi_meta___len) +FFDEF(ffi_meta___lt) +FFDEF(ffi_meta___le) +FFDEF(ffi_meta___concat) +FFDEF(ffi_meta___call) +FFDEF(ffi_meta___add) +FFDEF(ffi_meta___sub) +FFDEF(ffi_meta___mul) +FFDEF(ffi_meta___div) +FFDEF(ffi_meta___mod) +FFDEF(ffi_meta___pow) +FFDEF(ffi_meta___unm) +FFDEF(ffi_meta___tostring) +FFDEF(ffi_meta___pairs) +FFDEF(ffi_meta___ipairs) +FFDEF(ffi_clib___index) +FFDEF(ffi_clib___newindex) +FFDEF(ffi_clib___gc) +FFDEF(ffi_callback_free) +FFDEF(ffi_callback_set) +FFDEF(ffi_cdef) +FFDEF(ffi_new) +FFDEF(ffi_cast) +FFDEF(ffi_typeof) +FFDEF(ffi_typeinfo) +FFDEF(ffi_istype) +FFDEF(ffi_sizeof) +FFDEF(ffi_alignof) +FFDEF(ffi_offsetof) +FFDEF(ffi_errno) +FFDEF(ffi_string) +FFDEF(ffi_copy) +FFDEF(ffi_fill) +FFDEF(ffi_abi) +FFDEF(ffi_metatype) +FFDEF(ffi_gc) +FFDEF(ffi_load) + +#undef FFDEF + +#ifndef FF_NUM_ASMFUNC +#define FF_NUM_ASMFUNC 57 +#endif + diff --git a/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_folddef.h b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_folddef.h new file mode 100644 index 000000000..45d5daf74 --- /dev/null +++ b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_folddef.h @@ -0,0 +1,1168 @@ +/* This is a generated file. DO NOT EDIT! */ + +static const FoldFunc fold_func[] = { + fold_kfold_numarith, + fold_kfold_numabsneg, + fold_kfold_ldexp, + fold_kfold_fpmath, + fold_kfold_fpcall1, + fold_kfold_fpcall2, + fold_kfold_numpow, + fold_kfold_numcomp, + fold_kfold_intarith, + fold_kfold_intovarith, + fold_kfold_bnot, + fold_kfold_bswap, + fold_kfold_intcomp, + fold_kfold_intcomp0, + fold_kfold_int64arith, + fold_kfold_int64arith2, + fold_kfold_int64shift, + fold_kfold_bnot64, + fold_kfold_bswap64, + fold_kfold_int64comp, + fold_kfold_int64comp0, + fold_kfold_snew_kptr, + fold_kfold_snew_empty, + fold_kfold_strref, + fold_kfold_strref_snew, + fold_kfold_strcmp, + fold_bufput_append, + fold_bufput_kgc, + fold_bufstr_kfold_cse, + fold_bufput_kfold_op, + fold_bufput_kfold_rep, + fold_bufput_kfold_fmt, + fold_kfold_add_kgc, + fold_kfold_add_kptr, + fold_kfold_add_kright, + fold_kfold_tobit, + fold_kfold_conv_kint_num, + fold_kfold_conv_kintu32_num, + fold_kfold_conv_kint_ext, + fold_kfold_conv_kint_i64, + fold_kfold_conv_kint64_num_i64, + fold_kfold_conv_kint64_num_u64, + fold_kfold_conv_kint64_int_i64, + fold_kfold_conv_knum_int_num, + fold_kfold_conv_knum_u32_num, + fold_kfold_conv_knum_i64_num, + fold_kfold_conv_knum_u64_num, + fold_kfold_tostr_knum, + fold_kfold_tostr_kint, + fold_kfold_strto, + lj_opt_cse, + fold_kfold_kref, + fold_shortcut_round, + fold_shortcut_left, + fold_shortcut_dropleft, + fold_shortcut_leftleft, + fold_simplify_numadd_negx, + fold_simplify_numadd_xneg, + fold_simplify_numsub_k, + fold_simplify_numsub_negk, + fold_simplify_numsub_xneg, + fold_simplify_nummuldiv_k, + fold_simplify_nummuldiv_negk, + fold_simplify_nummuldiv_negneg, + fold_simplify_numpow_xkint, + fold_simplify_numpow_xknum, + fold_simplify_numpow_kx, + fold_shortcut_conv_num_int, + fold_simplify_conv_int_num, + fold_simplify_conv_i64_num, + fold_simplify_conv_int_i64, + fold_simplify_conv_flt_num, + fold_simplify_tobit_conv, + fold_simplify_floor_conv, + fold_simplify_conv_sext, + fold_simplify_conv_narrow, + fold_cse_conv, + fold_narrow_convert, + fold_simplify_intadd_k, + fold_simplify_intmul_k, + fold_simplify_intsub_k, + fold_simplify_intsub_kleft, + fold_simplify_intadd_k64, + fold_simplify_intsub_k64, + fold_simplify_intmul_k32, + fold_simplify_intmul_k64, + fold_simplify_intmod_k, + fold_simplify_intmod_kleft, + fold_simplify_intsub, + fold_simplify_intsubadd_leftcancel, + fold_simplify_intsubsub_leftcancel, + fold_simplify_intsubsub_rightcancel, + fold_simplify_intsubadd_rightcancel, + fold_simplify_intsubaddadd_cancel, + fold_simplify_band_k, + fold_simplify_bor_k, + fold_simplify_bxor_k, + fold_simplify_shift_ik, + fold_simplify_shift_andk, + fold_simplify_shift1_ki, + fold_simplify_shift2_ki, + fold_simplify_shiftk_andk, + fold_simplify_andk_shiftk, + fold_simplify_andor_k, + fold_simplify_andor_k64, + fold_reassoc_intarith_k, + fold_reassoc_intarith_k64, + fold_reassoc_dup, + fold_reassoc_dup_minmax, + fold_reassoc_bxor, + fold_reassoc_shift, + fold_reassoc_minmax_k, + fold_abc_fwd, + fold_abc_k, + fold_abc_invar, + fold_comm_swap, + fold_comm_equal, + fold_comm_comp, + fold_comm_dup, + fold_comm_dup_minmax, + fold_comm_bxor, + fold_merge_eqne_snew_kgc, + lj_opt_fwd_aload, + fold_kfold_hload_kkptr, + lj_opt_fwd_hload, + lj_opt_fwd_uload, + lj_opt_fwd_alen, + fold_cse_uref, + lj_opt_fwd_hrefk, + fold_fwd_href_tnew, + fold_fwd_href_tdup, + fold_fload_tab_tnew_asize, + fold_fload_tab_tnew_hmask, + fold_fload_tab_tdup_asize, + fold_fload_tab_tdup_hmask, + fold_fload_tab_ah, + fold_fload_str_len_kgc, + fold_fload_str_len_snew, + fold_fload_str_len_tostr, + fold_fload_cdata_typeid_kgc, + fold_fload_cdata_int64_kgc, + fold_fload_cdata_typeid_cnew, + fold_fload_cdata_ptr_int64_cnew, + lj_opt_cse, + lj_opt_fwd_fload, + fold_fwd_sload, + fold_xload_kptr, + lj_opt_fwd_xload, + fold_barrier_tab, + fold_barrier_tnew_tdup, + fold_prof, + lj_opt_dse_ahstore, + lj_opt_dse_ustore, + lj_opt_dse_fstore, + lj_opt_dse_xstore, + lj_ir_emit +}; + +static const uint32_t fold_hash[1002] = { +0x0f5a741d, +0xffffffff, +0xffffffff, +0x6e4a9417, +0xffffffff, +0x634877ff, +0x8775ffff, +0xffffffff, +0xffffffff, +0x8789fc09, +0x83894008, +0xffffffff, +0x644e5fff, +0xffffffff, +0x0c0c5c17, +0x26b45e71, +0xffffffff, +0x0e52741d, +0xffffffff, +0xffffffff, +0x66429417, +0xffffffff, +0xffffffff, +0x586dffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4db4a6ae, +0x46b56a95, +0x0c045c17, +0x169dfc17, +0x2cb4728e, +0xffffffff, +0xffffffff, +0x30b85fff, +0xffffffff, +0xffffffff, +0x7765ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x37408000, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0e42741d, +0x2253fc18, +0xffffffff, +0xffffffff, +0xffffffff, +0x096e5c17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3468d000, +0xffffffff, +0xffffffff, +0x66429017, +0x5d54a429, +0xffffffff, +0x8f89fc04, +0xffffffff, +0xffffffff, +0xffffffff, +0x6a44881d, +0x08665c17, +0x5855ffff, +0x82754416, +0x624bfc21, +0x86894409, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0712701c, +0xffffffff, +0x6b4287ff, +0xffffffff, +0x085e5c17, +0x27b45ed4, +0xffffffff, +0x0d0bfc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9bbfffff, +0x10507417, +0xffffffff, +0xffffffff, +0x070a701c, +0x5557fc1d, +0xffffffff, +0xffffffff, +0x08565c17, +0x7645ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6844841d, +0x10487417, +0x817543ff, +0x0702701c, +0xffffffff, +0x84894009, +0xffffffff, +0x084e5c17, +0xffffffff, +0x26b45e72, +0xffffffff, +0x7f7863ff, +0x7c85fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4e6dfc17, +0xffffffff, +0x6047fc1d, +0xffffffff, +0xffffffff, +0xffffffff, +0x08465c17, +0x46b56a96, +0x4bb4ae95, +0xffffffff, +0x79113818, +0x01607044, +0xffffffff, +0xffffffff, +0x1dc18c09, +0xffffffff, +0xffffffff, +0x2152681d, +0x3312741d, +0xffffffff, +0x67428817, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0064701c, +0xffffffff, +0x2253fc19, +0xffffffff, +0xffffffff, +0x9b9fffff, +0xffffffff, +0x405dfc17, +0x130a741d, +0xffffffff, +0xffffffff, +0xffffffff, +0x3468d001, +0xffffffff, +0x3213101b, +0xffffffff, +0xffffffff, +0x12407400, +0x065c701c, +0xffffffff, +0xffffffff, +0x654a8417, +0x9897ffff, +0x47b569ae, +0x5055fc17, +0x1302741d, +0x4bb4aa95, +0xffffffff, +0xffffffff, +0xffffffff, +0x2ab47675, +0xffffffff, +0xffffffff, +0x2eb472ce, +0x0054701c, +0x8a897000, +0x2152641d, +0x8b88600e, +0x69428417, +0x5c55fc29, +0x8f8fffff, +0x0a3e5c00, +0x614dfc17, +0x6e4c9817, +0xffffffff, +0xffffffff, +0x6956ac17, +0xffffffff, +0x7215ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x33106fff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x5f45fc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x750dffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4bb4a695, +0xffffffff, +0xffffffff, +0xffffffff, +0x3d59fc1c, +0x23b6701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x2052601d, +0xffffffff, +0x7505ffff, +0xffffffff, +0x0f5c741d, +0x3560c044, +0x44b56a8e, +0xffffffff, +0x928a6bff, +0x634a77ff, +0x9b77ffff, +0x05bd8c3b, +0x88886000, +0x4bb4ae96, +0xffffffff, +0xffffffff, +0x64505fff, +0xffffffff, +0x0c0e5c17, +0x1fc18c0a, +0xffffffff, +0x0e54741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x1dc18c13, +0x736fffff, +0x19bd8c00, +0xffffffff, +0xffffffff, +0x6a468c1d, +0xffffffff, +0x63485fff, +0x2253fc1a, +0x0c065c17, +0x3311fc1b, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7767ffff, +0x3468d002, +0xffffffff, +0x6b448bff, +0x94affc00, +0x28b475d5, +0x3660bc44, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0e44741d, +0x82754418, +0xffffffff, +0x4bb4aa96, +0xffffffff, +0xffffffff, +0xffffffff, +0x4ab5fed3, +0x04bc73ff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8c88600f, +0x5b55fc2a, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7357ffff, +0xffffffff, +0x7115fc17, +0x624dfc21, +0x43b569d3, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7015fc29, +0x24b45dd3, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3b54bc1c, +0xffffffff, +0xffffffff, +0x4bb4a696, +0x9bc1ffff, +0xffffffff, +0xffffffff, +0x070c701c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7847ffff, +0x49696800, +0xffffffff, +0x02627017, +0x95af4400, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x104a7417, +0xffffffff, +0xffffffff, +0x0704701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x08505c17, +0xffffffff, +0xffffffff, +0x1fc18c0b, +0x7f7a63ff, +0x7d87fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0x94b1ffff, +0x1dc18c14, +0x4f6ffc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x08485c17, +0xffffffff, +0xffffffff, +0xffffffff, +0x79133818, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9ba9ffff, +0x31ba6000, +0xffffffff, +0x27b45eb3, +0xffffffff, +0x69448817, +0x29b475d6, +0xffffffff, +0xffffffff, +0x6e4e9c17, +0x95af4000, +0xffffffff, +0x0066701c, +0x45b56ace, +0xffffffff, +0xffffffff, +0xffffffff, +0x9ba1ffff, +0xffffffff, +0xffffffff, +0x130c741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8c886010, +0xffffffff, +0x3852bfff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9999ffff, +0xffffffff, +0x5457fc17, +0x1304741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x187f3bff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0056701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x67448417, +0x7e91ffff, +0x25b45dd4, +0x0b405c00, +0x614ffc17, +0x46b56a75, +0x48b7681c, +0xffffffff, +0x2bb4726e, +0xffffffff, +0x9b17ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x33126fff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9089ffff, +0xffffffff, +0x6047fc17, +0x49696801, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x750fffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6a52a41d, +0xffffffff, +0x515477ff, +0x21526817, +0xffffffff, +0xffffffff, +0xffffffff, +0x1fc18c0c, +0xffffffff, +0x575a5fff, +0xffffffff, +0xffffffff, +0x7507ffff, +0x6d468fff, +0x1dc18c15, +0x9bb20000, +0xffffffff, +0xffffffff, +0xffffffff, +0x644c77ff, +0x9479ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6c64cbff, +0xffffffff, +0xffffffff, +0xffffffff, +0x33105c17, +0xffffffff, +0x425c73ff, +0x0e56741d, +0xffffffff, +0x27b45eb4, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x634a5fff, +0xffffffff, +0x0c085c17, +0x3313fc1b, +0xffffffff, +0x21526417, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8c886011, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0c005c17, +0xffffffff, +0xffffffff, +0x0e46741d, +0xffffffff, +0xffffffff, +0xffffffff, +0x8d894c0e, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x46b56a76, +0x4bb4ae75, +0xffffffff, +0x096a5c17, +0xffffffff, +0xffffffff, +0x624ffc21, +0x8f89fc0e, +0xffffffff, +0x20526017, +0xffffffff, +0x33106018, +0x159c6817, +0xffffffff, +0xffffffff, +0xffffffff, +0x49696802, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3e56bc1c, +0xffffffff, +0xffffffff, +0x9bc3ffff, +0x8d89480e, +0xffffffff, +0xffffffff, +0x070e701c, +0xffffffff, +0x1fc18c0d, +0xffffffff, +0x085a5c17, +0xffffffff, +0xffffffff, +0x69468c17, +0xffffffff, +0x1ec18c16, +0xffffffff, +0x6e50a017, +0xffffffff, +0x4bb4aa75, +0x104c7417, +0x4db6a81c, +0xffffffff, +0x0706701c, +0x5253fc1d, +0x6f64c817, +0x2db472ae, +0x08525c17, +0xffffffff, +0xffffffff, +0xffffffff, +0x065c7017, +0x8f89fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3953fc2f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x084a5c17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x1babffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x5e43fc1d, +0xffffffff, +0xffffffff, +0xffffffff, +0x08425c17, +0xffffffff, +0xffffffff, +0x4bb4a675, +0x4db6a41c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8e894c0f, +0xffffffff, +0xffffffff, +0x130e741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x44b56a6e, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7b846800, +0xffffffff, +0x8789fc06, +0x654e8417, +0x4bb4ae76, +0x9a9bffff, +0xffffffff, +0x1306741d, +0xffffffff, +0x8f89fc0f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0058701c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9793ffff, +0xffffffff, +0x6151fc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6c66cfff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x1fc18c0e, +0x938bffff, +0xffffffff, +0x6149fc17, +0xffffffff, +0x3f56bc2f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7411ffff, +0x4bb4aa76, +0xffffffff, +0xffffffff, +0xffffffff, +0x4ab5feb3, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x415dfc1c, +0xffffffff, +0xffffffff, +0xffffffff, +0x8f89fc01, +0xffffffff, +0xffffffff, +0x7509ffff, +0x1aab5056, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x644e77ff, +0xffffffff, +0xffffffff, +0x3a55fc1c, +0x8275441c, +0xffffffff, +0xffffffff, +0x51545fff, +0xffffffff, +0x33125c17, +0x7501ffff, +0xffffffff, +0x0f58741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8073ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x140bfc1d, +0x4bb4a676, +0x644c5fff, +0xffffffff, +0x0c0a5c17, +0xffffffff, +0x8e894c10, +0xffffffff, +0x2ab47695, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x736bffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0c025c17, +0x8789fc07, +0xffffffff, +0xffffffff, +0xffffffff, +0x26b45e6f, +0xffffffff, +0x8f89fc10, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6e489017, +0xffffffff, +0xffffffff, +0xffffffff, +0x6952a417, +0xffffffff, +0xffffffff, +0xffffffff, +0x096c5c17, +0xffffffff, +0x2fb873ff, +0x6251fc21, +0x6f66cc17, +0x9ba3fc00, +0xffffffff, +0xffffffff, +0x33126018, +0xffffffff, +0x1fc18c0f, +0xffffffff, +0xffffffff, +0xffffffff, +0x4db4aa6e, +0x89893800, +0x6842881d, +0x08645c17, +0x45b56aae, +0x7353ffff, +0x6249fc21, +0xffffffff, +0xffffffff, +0x3e58bc1c, +0xffffffff, +0xffffffff, +0x9bc5ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0710701c, +0xffffffff, +0xffffffff, +0x373e7c00, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x104e7417, +0xffffffff, +0xffffffff, +0x0708701c, +0x5355fc1d, +0xffffffff, +0xffffffff, +0x08545c17, +0x7643ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4db4a66e, +0x4cb5ffff, +0x6a42841d, +0x3c55fc2f, +0xffffffff, +0x0700701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x084c5c17, +0x6a56ac1d, +0xffffffff, +0xffffffff, +0x8e894c11, +0x7a83fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0x1cadffff, +0xffffffff, +0x4e6bfc17, +0xffffffff, +0x5f45fc1d, +0xffffffff, +0xffffffff, +0xffffffff, +0x08445c17, +0x5a54abff, +0x8789fc08, +0xffffffff, +0x375ebfff, +0x015e7044, +0xffffffff, +0x26b45e70, +0xffffffff, +0x8f89fc11, +0x9ba5ffff, +0xffffffff, +0x3310741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x962bffff, +0xffffffff, +0xffffffff, +0x0062701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x65508417, +0xffffffff, +0xffffffff, +0x565bfc17, +0x1308741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3211101b, +0xffffffff, +0xffffffff, +0x113e7400, +0xffffffff, +0xffffffff, +0xffffffff, +0x65488417, +0x9795ffff, +0xffffffff, +0x4e53fc17, +0x5954a7ff, +0x1300741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0052701c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x918dffff, +0xffffffff, +0x614bfc17, +0xffffffff, +0x3f58bc2f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7413ffff, +0x85894408, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x5e43fc17, +0xffffffff, +0xffffffff, +0x177e6017, +0xffffffff, +0x27b45ed3, +0xffffffff, +0x750bffff, +0x036873ff, +0xffffffff, +0xffffffff, +0x4db4aaae, +0xffffffff, +0xffffffff, +0x645077ff, +0xffffffff, +0xffffffff, +0x3d57fc1c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0c145c17, +0x7503ffff, +0xffffffff, +0xffffffff +}; + +#define fold_hashkey(k) (lj_rol(lj_rol((k),21)-(k),1)%1001) + diff --git a/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_libdef.h b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_libdef.h new file mode 100644 index 000000000..521de0174 --- /dev/null +++ b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_libdef.h @@ -0,0 +1,402 @@ +/* This is a generated file. DO NOT EDIT! */ + +#ifdef LJLIB_MODULE_base +#undef LJLIB_MODULE_base +static const lua_CFunction lj_lib_cf_base[] = { + lj_ffh_assert, + lj_ffh_next, + lj_ffh_pairs, + lj_ffh_ipairs_aux, + lj_ffh_ipairs, + lj_ffh_setmetatable, + lj_cf_getfenv, + lj_cf_setfenv, + lj_ffh_rawget, + lj_cf_rawset, + lj_cf_rawequal, + lj_cf_unpack, + lj_cf_select, + lj_ffh_tonumber, + lj_ffh_tostring, + lj_cf_error, + lj_ffh_pcall, + lj_cf_loadfile, + lj_cf_load, + lj_cf_loadstring, + lj_cf_dofile, + lj_cf_gcinfo, + lj_cf_collectgarbage, + lj_cf_newproxy, + lj_cf_print +}; +static const uint8_t lj_lib_init_base[] = { +2,0,28,70,97,115,115,101,114,116,195,110,105,108,199,98,111,111,108,101,97, +110,252,1,200,117,115,101,114,100,97,116,97,198,115,116,114,105,110,103,197, +117,112,118,97,108,198,116,104,114,101,97,100,197,112,114,111,116,111,200,102, +117,110,99,116,105,111,110,197,116,114,97,99,101,197,99,100,97,116,97,197,116, +97,98,108,101,252,9,198,110,117,109,98,101,114,132,116,121,112,101,68,110,101, +120,116,253,69,112,97,105,114,115,64,253,70,105,112,97,105,114,115,140,103, +101,116,109,101,116,97,116,97,98,108,101,76,115,101,116,109,101,116,97,116, +97,98,108,101,7,103,101,116,102,101,110,118,7,115,101,116,102,101,110,118,70, +114,97,119,103,101,116,6,114,97,119,115,101,116,8,114,97,119,101,113,117,97, +108,6,117,110,112,97,99,107,6,115,101,108,101,99,116,72,116,111,110,117,109, +98,101,114,72,116,111,115,116,114,105,110,103,5,101,114,114,111,114,69,112, +99,97,108,108,134,120,112,99,97,108,108,8,108,111,97,100,102,105,108,101,4, +108,111,97,100,10,108,111,97,100,115,116,114,105,110,103,6,100,111,102,105, +108,101,6,103,99,105,110,102,111,14,99,111,108,108,101,99,116,103,97,114,98, +97,103,101,252,2,8,110,101,119,112,114,111,120,121,200,116,111,115,116,114, +105,110,103,5,112,114,105,110,116,252,3,200,95,86,69,82,83,73,79,78,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_coroutine +#undef LJLIB_MODULE_coroutine +static const lua_CFunction lj_lib_cf_coroutine[] = { + lj_cf_coroutine_status, + lj_cf_coroutine_running, + lj_cf_coroutine_isyieldable, + lj_cf_coroutine_create, + lj_ffh_coroutine_yield, + lj_ffh_coroutine_resume, + lj_cf_coroutine_wrap +}; +static const uint8_t lj_lib_init_coroutine[] = { +30,13,7,6,115,116,97,116,117,115,7,114,117,110,110,105,110,103,11,105,115,121, +105,101,108,100,97,98,108,101,6,99,114,101,97,116,101,69,121,105,101,108,100, +70,114,101,115,117,109,101,254,4,119,114,97,112,255 +}; +#endif + +#ifdef LJLIB_MODULE_math +#undef LJLIB_MODULE_math +static const lua_CFunction lj_lib_cf_math[] = { + lj_ffh_math_abs, + lj_ffh_math_sqrt, + lj_ffh_math_log, + lj_ffh_math_atan2, + lj_ffh_math_ldexp, + lj_ffh_math_min, + lj_cf_math_random, + lj_cf_math_randomseed +}; +static const uint8_t lj_lib_init_math[] = { +38,16,30,67,97,98,115,133,102,108,111,111,114,132,99,101,105,108,68,115,113, +114,116,133,108,111,103,49,48,131,101,120,112,131,115,105,110,131,99,111,115, +131,116,97,110,132,97,115,105,110,132,97,99,111,115,132,97,116,97,110,132,115, +105,110,104,132,99,111,115,104,132,116,97,110,104,133,102,114,101,120,112,132, +109,111,100,102,67,108,111,103,249,3,100,101,103,0,1,2,0,0,1,2,24,1,0,0,76, +1,2,0,241,135,158,166,3,220,203,178,130,4,249,3,114,97,100,0,1,2,0,0,1,2,24, +1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,69,97,116,97,110,50,131, +112,111,119,132,102,109,111,100,69,108,100,101,120,112,67,109,105,110,131,109, +97,120,251,24,45,68,84,251,33,9,64,194,112,105,250,251,0,0,0,0,0,0,240,127, +196,104,117,103,101,250,252,2,6,114,97,110,100,111,109,252,2,10,114,97,110, +100,111,109,115,101,101,100,255 +}; +#endif + +#ifdef LJLIB_MODULE_bit +#undef LJLIB_MODULE_bit +static const lua_CFunction lj_lib_cf_bit[] = { + lj_ffh_bit_tobit, + lj_ffh_bit_bnot, + lj_ffh_bit_bswap, + lj_ffh_bit_lshift, + lj_ffh_bit_band, + lj_cf_bit_tohex +}; +static const uint8_t lj_lib_init_bit[] = { +64,40,12,69,116,111,98,105,116,68,98,110,111,116,69,98,115,119,97,112,70,108, +115,104,105,102,116,134,114,115,104,105,102,116,135,97,114,115,104,105,102, +116,131,114,111,108,131,114,111,114,68,98,97,110,100,131,98,111,114,132,98, +120,111,114,5,116,111,104,101,120,255 +}; +#endif + +#ifdef LJLIB_MODULE_string +#undef LJLIB_MODULE_string +static const lua_CFunction lj_lib_cf_string[] = { + lj_ffh_string_byte, + lj_ffh_string_char, + lj_ffh_string_sub, + lj_cf_string_rep, + lj_ffh_string_reverse, + lj_cf_string_dump, + lj_cf_string_find, + lj_cf_string_match, + lj_cf_string_gmatch, + lj_cf_string_gsub, + lj_cf_string_format +}; +static const uint8_t lj_lib_init_string[] = { +76,51,14,249,3,108,101,110,0,1,2,0,0,0,3,16,0,5,0,21,1,0,0,76,1,2,0,68,98,121, +116,101,68,99,104,97,114,67,115,117,98,3,114,101,112,71,114,101,118,101,114, +115,101,133,108,111,119,101,114,133,117,112,112,101,114,4,100,117,109,112,4, +102,105,110,100,5,109,97,116,99,104,254,6,103,109,97,116,99,104,4,103,115,117, +98,6,102,111,114,109,97,116,255 +}; +#endif + +#ifdef LJLIB_MODULE_table +#undef LJLIB_MODULE_table +static const lua_CFunction lj_lib_cf_table[] = { + lj_cf_table_maxn, + lj_cf_table_insert, + lj_cf_table_concat, + lj_cf_table_sort +}; +static const uint8_t lj_lib_init_table[] = { +90,57,9,249,8,102,111,114,101,97,99,104,105,0,2,10,0,0,0,15,16,0,12,0,16,1, +9,0,41,2,1,0,21,3,0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,8,5,0,59,9,5,0,66,6,3, +2,10,6,0,0,88,7,1,128,76,6,2,0,79,2,248,127,75,0,1,0,249,7,102,111,114,101, +97,99,104,0,2,11,0,0,0,16,16,0,12,0,16,1,9,0,43,2,0,0,18,3,0,0,41,4,0,0,88, +5,7,128,18,7,1,0,18,9,5,0,18,10,6,0,66,7,3,2,10,7,0,0,88,8,1,128,76,7,2,0,70, +5,3,3,82,5,247,127,75,0,1,0,249,4,103,101,116,110,0,1,2,0,0,0,3,16,0,12,0,21, +1,0,0,76,1,2,0,4,109,97,120,110,6,105,110,115,101,114,116,249,6,114,101,109, +111,118,101,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128,8,2,0,0, +88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14,0,41,3, +1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2,0,41,6, +1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4,2,0,76, +3,2,0,75,0,1,0,0,2,249,4,109,111,118,101,0,5,12,0,0,0,35,16,0,12,0,16,1,14, +0,16,2,14,0,16,3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88,5,24, +128,33,5,1,3,0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128,18,6, +1,0,18,7,2,0,41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252,127, +88,6,8,128,18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9,0,64, +11,10,4,79,6,252,127,76,4,2,0,6,99,111,110,99,97,116,4,115,111,114,116,254, +254,255 +}; +#endif + +#ifdef LJLIB_MODULE_io_method +#undef LJLIB_MODULE_io_method +static const lua_CFunction lj_lib_cf_io_method[] = { + lj_cf_io_method_close, + lj_cf_io_method_read, + lj_cf_io_method_write, + lj_cf_io_method_flush, + lj_cf_io_method_seek, + lj_cf_io_method_setvbuf, + lj_cf_io_method_lines, + lj_cf_io_method___gc, + lj_cf_io_method___tostring +}; +static const uint8_t lj_lib_init_io_method[] = { +96,57,10,5,99,108,111,115,101,4,114,101,97,100,5,119,114,105,116,101,5,102, +108,117,115,104,4,115,101,101,107,7,115,101,116,118,98,117,102,5,108,105,110, +101,115,4,95,95,103,99,10,95,95,116,111,115,116,114,105,110,103,252,1,199,95, +95,105,110,100,101,120,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_io +#undef LJLIB_MODULE_io +static const lua_CFunction lj_lib_cf_io[] = { + lj_cf_io_open, + lj_cf_io_popen, + lj_cf_io_tmpfile, + lj_cf_io_close, + lj_cf_io_read, + lj_cf_io_write, + lj_cf_io_flush, + lj_cf_io_input, + lj_cf_io_output, + lj_cf_io_lines, + lj_cf_io_type +}; +static const uint8_t lj_lib_init_io[] = { +105,57,12,252,2,192,250,4,111,112,101,110,5,112,111,112,101,110,7,116,109,112, +102,105,108,101,5,99,108,111,115,101,4,114,101,97,100,5,119,114,105,116,101, +5,102,108,117,115,104,5,105,110,112,117,116,6,111,117,116,112,117,116,5,108, +105,110,101,115,4,116,121,112,101,255 +}; +#endif + +#ifdef LJLIB_MODULE_os +#undef LJLIB_MODULE_os +static const lua_CFunction lj_lib_cf_os[] = { + lj_cf_os_execute, + lj_cf_os_remove, + lj_cf_os_rename, + lj_cf_os_tmpname, + lj_cf_os_getenv, + lj_cf_os_exit, + lj_cf_os_clock, + lj_cf_os_date, + lj_cf_os_time, + lj_cf_os_difftime, + lj_cf_os_setlocale +}; +static const uint8_t lj_lib_init_os[] = { +116,57,11,7,101,120,101,99,117,116,101,6,114,101,109,111,118,101,6,114,101, +110,97,109,101,7,116,109,112,110,97,109,101,6,103,101,116,101,110,118,4,101, +120,105,116,5,99,108,111,99,107,4,100,97,116,101,4,116,105,109,101,8,100,105, +102,102,116,105,109,101,9,115,101,116,108,111,99,97,108,101,255 +}; +#endif + +#ifdef LJLIB_MODULE_debug +#undef LJLIB_MODULE_debug +static const lua_CFunction lj_lib_cf_debug[] = { + lj_cf_debug_getregistry, + lj_cf_debug_getmetatable, + lj_cf_debug_setmetatable, + lj_cf_debug_getfenv, + lj_cf_debug_setfenv, + lj_cf_debug_getinfo, + lj_cf_debug_getlocal, + lj_cf_debug_setlocal, + lj_cf_debug_getupvalue, + lj_cf_debug_setupvalue, + lj_cf_debug_upvalueid, + lj_cf_debug_upvaluejoin, + lj_cf_debug_sethook, + lj_cf_debug_gethook, + lj_cf_debug_debug, + lj_cf_debug_traceback +}; +static const uint8_t lj_lib_init_debug[] = { +127,57,16,11,103,101,116,114,101,103,105,115,116,114,121,12,103,101,116,109, +101,116,97,116,97,98,108,101,12,115,101,116,109,101,116,97,116,97,98,108,101, +7,103,101,116,102,101,110,118,7,115,101,116,102,101,110,118,7,103,101,116,105, +110,102,111,8,103,101,116,108,111,99,97,108,8,115,101,116,108,111,99,97,108, +10,103,101,116,117,112,118,97,108,117,101,10,115,101,116,117,112,118,97,108, +117,101,9,117,112,118,97,108,117,101,105,100,11,117,112,118,97,108,117,101, +106,111,105,110,7,115,101,116,104,111,111,107,7,103,101,116,104,111,111,107, +5,100,101,98,117,103,9,116,114,97,99,101,98,97,99,107,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit +#undef LJLIB_MODULE_jit +static const lua_CFunction lj_lib_cf_jit[] = { + lj_cf_jit_on, + lj_cf_jit_off, + lj_cf_jit_flush, + lj_cf_jit_status, + lj_cf_jit_security, + lj_cf_jit_attach +}; +static const uint8_t lj_lib_init_jit[] = { +143,57,10,2,111,110,3,111,102,102,5,102,108,117,115,104,6,115,116,97,116,117, +115,8,115,101,99,117,114,105,116,121,6,97,116,116,97,99,104,252,5,194,111,115, +250,252,4,196,97,114,99,104,250,252,3,203,118,101,114,115,105,111,110,95,110, +117,109,250,252,2,199,118,101,114,115,105,111,110,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit_util +#undef LJLIB_MODULE_jit_util +static const lua_CFunction lj_lib_cf_jit_util[] = { + lj_cf_jit_util_funcinfo, + lj_cf_jit_util_funcbc, + lj_cf_jit_util_funck, + lj_cf_jit_util_funcuvname +}; +static const uint8_t lj_lib_init_jit_util[] = { +149,57,4,8,102,117,110,99,105,110,102,111,6,102,117,110,99,98,99,5,102,117, +110,99,107,10,102,117,110,99,117,118,110,97,109,101,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit_profile +#undef LJLIB_MODULE_jit_profile +static const lua_CFunction lj_lib_cf_jit_profile[] = { + lj_cf_jit_profile_start, + lj_cf_jit_profile_stop, + lj_cf_jit_profile_dumpstack +}; +static const uint8_t lj_lib_init_jit_profile[] = { +153,57,3,5,115,116,97,114,116,4,115,116,111,112,9,100,117,109,112,115,116,97, +99,107,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi_meta +#undef LJLIB_MODULE_ffi_meta +static const lua_CFunction lj_lib_cf_ffi_meta[] = { + lj_cf_ffi_meta___index, + lj_cf_ffi_meta___newindex, + lj_cf_ffi_meta___eq, + lj_cf_ffi_meta___len, + lj_cf_ffi_meta___lt, + lj_cf_ffi_meta___le, + lj_cf_ffi_meta___concat, + lj_cf_ffi_meta___call, + lj_cf_ffi_meta___add, + lj_cf_ffi_meta___sub, + lj_cf_ffi_meta___mul, + lj_cf_ffi_meta___div, + lj_cf_ffi_meta___mod, + lj_cf_ffi_meta___pow, + lj_cf_ffi_meta___unm, + lj_cf_ffi_meta___tostring, + lj_cf_ffi_meta___pairs, + lj_cf_ffi_meta___ipairs +}; +static const uint8_t lj_lib_init_ffi_meta[] = { +156,57,19,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101, +120,4,95,95,101,113,5,95,95,108,101,110,4,95,95,108,116,4,95,95,108,101,8,95, +95,99,111,110,99,97,116,6,95,95,99,97,108,108,5,95,95,97,100,100,5,95,95,115, +117,98,5,95,95,109,117,108,5,95,95,100,105,118,5,95,95,109,111,100,5,95,95, +112,111,119,5,95,95,117,110,109,10,95,95,116,111,115,116,114,105,110,103,7, +95,95,112,97,105,114,115,8,95,95,105,112,97,105,114,115,195,102,102,105,203, +95,95,109,101,116,97,116,97,98,108,101,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi_clib +#undef LJLIB_MODULE_ffi_clib +static const lua_CFunction lj_lib_cf_ffi_clib[] = { + lj_cf_ffi_clib___index, + lj_cf_ffi_clib___newindex, + lj_cf_ffi_clib___gc +}; +static const uint8_t lj_lib_init_ffi_clib[] = { +174,57,3,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101,120, +4,95,95,103,99,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi_callback +#undef LJLIB_MODULE_ffi_callback +static const lua_CFunction lj_lib_cf_ffi_callback[] = { + lj_cf_ffi_callback_free, + lj_cf_ffi_callback_set +}; +static const uint8_t lj_lib_init_ffi_callback[] = { +177,57,3,4,102,114,101,101,3,115,101,116,252,1,199,95,95,105,110,100,101,120, +250,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi +#undef LJLIB_MODULE_ffi +static const lua_CFunction lj_lib_cf_ffi[] = { + lj_cf_ffi_cdef, + lj_cf_ffi_new, + lj_cf_ffi_cast, + lj_cf_ffi_typeof, + lj_cf_ffi_typeinfo, + lj_cf_ffi_istype, + lj_cf_ffi_sizeof, + lj_cf_ffi_alignof, + lj_cf_ffi_offsetof, + lj_cf_ffi_errno, + lj_cf_ffi_string, + lj_cf_ffi_copy, + lj_cf_ffi_fill, + lj_cf_ffi_abi, + lj_cf_ffi_metatype, + lj_cf_ffi_gc, + lj_cf_ffi_load +}; +static const uint8_t lj_lib_init_ffi[] = { +179,57,23,4,99,100,101,102,3,110,101,119,4,99,97,115,116,6,116,121,112,101, +111,102,8,116,121,112,101,105,110,102,111,6,105,115,116,121,112,101,6,115,105, +122,101,111,102,7,97,108,105,103,110,111,102,8,111,102,102,115,101,116,111, +102,5,101,114,114,110,111,6,115,116,114,105,110,103,4,99,111,112,121,4,102, +105,108,108,3,97,98,105,252,8,192,250,8,109,101,116,97,116,121,112,101,252, +7,192,250,2,103,99,252,5,192,250,4,108,111,97,100,252,4,193,67,250,252,3,194, +111,115,250,252,2,196,97,114,99,104,250,255 +}; +#endif + diff --git a/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_recdef.h b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_recdef.h new file mode 100644 index 000000000..ea00647a6 --- /dev/null +++ b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_recdef.h @@ -0,0 +1,262 @@ +/* This is a generated file. DO NOT EDIT! */ + +static const uint16_t recff_idmap[] = { +0, +0x0100, +0x0200, +0x0300, +0, +0x0400+(0), +0x0500, +0x0400+(1), +0x0600, +0x0700, +0x0800, +0, +0x0900, +0x0a00, +0x0b00, +0, +0x0c00, +0x0d00, +0x0e00, +0, +0x0f00, +0x1000, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x1100, +0x1200+(IRFPM_FLOOR), +0x1200+(IRFPM_CEIL), +0x1300+(IRFPM_SQRT), +0x1400+(IRCALL_log10), +0x1400+(IRCALL_exp), +0x1400+(IRCALL_sin), +0x1400+(IRCALL_cos), +0x1400+(IRCALL_tan), +0x1400+(IRCALL_asin), +0x1400+(IRCALL_acos), +0x1400+(IRCALL_atan), +0x1400+(IRCALL_sinh), +0x1400+(IRCALL_cosh), +0x1400+(IRCALL_tanh), +0, +0, +0x1500, +0x1600, +0x1700, +0, +0x1800, +0x1900+(IR_MIN), +0x1900+(IR_MAX), +0x1a00, +0, +0x1b00, +0x1c00+(IR_BNOT), +0x1c00+(IR_BSWAP), +0x1d00+(IR_BSHL), +0x1d00+(IR_BSHR), +0x1d00+(IR_BSAR), +0x1d00+(IR_BROL), +0x1d00+(IR_BROR), +0x1e00+(IR_BAND), +0x1e00+(IR_BOR), +0x1e00+(IR_BXOR), +0x1f00, +0x2000+(0), +0x2100, +0x2000+(1), +0x2200, +0x2300+(IRCALL_lj_buf_putstr_reverse), +0x2300+(IRCALL_lj_buf_putstr_lower), +0x2300+(IRCALL_lj_buf_putstr_upper), +0, +0x2400, +0, +0, +0, +0, +0x2500, +0, +0x2600, +0x2700, +0, +0x2800, +0x2900, +0, +0, +0x2a00+(0), +0x2b00+(0), +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x2a00+(GCROOT_IO_OUTPUT), +0x2b00+(GCROOT_IO_OUTPUT), +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x2c00, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x2d00+(0), +0x2d00+(1), +0x2e00+(MM_eq), +0x2e00+(MM_len), +0x2e00+(MM_lt), +0x2e00+(MM_le), +0x2e00+(MM_concat), +0x2f00, +0x2e00+(MM_add), +0x2e00+(MM_sub), +0x2e00+(MM_mul), +0x2e00+(MM_div), +0x2e00+(MM_mod), +0x2e00+(MM_pow), +0x2e00+(MM_unm), +0, +0, +0, +0x3000+(1), +0x3000+(0), +0, +0, +0, +0, +0x3100, +0x3100, +0x3200, +0, +0x3300, +0x3400+(FF_ffi_sizeof), +0x3400+(FF_ffi_alignof), +0x3400+(FF_ffi_offsetof), +0x3500, +0x3600, +0x3700, +0x3800, +0x3900, +0, +0x3a00 +}; + +static const RecordFunc recff_func[] = { +recff_nyi, +recff_c, +recff_assert, +recff_type, +recff_xpairs, +recff_ipairs_aux, +recff_getmetatable, +recff_setmetatable, +recff_getfenv, +recff_rawget, +recff_rawset, +recff_rawequal, +recff_select, +recff_tonumber, +recff_tostring, +recff_pcall, +recff_xpcall, +recff_math_abs, +recff_math_round, +recff_math_unary, +recff_math_call, +recff_math_log, +recff_math_atan2, +recff_math_pow, +recff_math_ldexp, +recff_math_minmax, +recff_math_random, +recff_bit_tobit, +recff_bit_unary, +recff_bit_shift, +recff_bit_nary, +recff_bit_tohex, +recff_string_range, +recff_string_char, +recff_string_rep, +recff_string_op, +recff_string_find, +recff_string_format, +recff_table_insert, +recff_table_concat, +recff_table_new, +recff_table_clear, +recff_io_write, +recff_io_flush, +recff_debug_getmetatable, +recff_cdata_index, +recff_cdata_arith, +recff_cdata_call, +recff_clib_index, +recff_ffi_new, +recff_ffi_typeof, +recff_ffi_istype, +recff_ffi_xof, +recff_ffi_errno, +recff_ffi_string, +recff_ffi_copy, +recff_ffi_fill, +recff_ffi_abi, +recff_ffi_gc +}; + diff --git a/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_vm.S b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_vm.S new file mode 100644 index 000000000..6abe9ec91 --- /dev/null +++ b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_vm.S @@ -0,0 +1,1915 @@ + .file "buildvm_arm64.dasc" + .text + .align 4 + + .private_extern _lj_vm_asm_begin + .no_dead_strip _lj_vm_asm_begin +_lj_vm_asm_begin: + + .private_extern _lj_BC_ISLT + .no_dead_strip _lj_BC_ISLT +_lj_BC_ISLT: + .long 0xf87b7a60,0x794002b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95b235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x54011843 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x540117c1 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x54011743 + .long 0x1e620000,0x1e612000,0x9a953235,0x17ffffed + + .private_extern _lj_BC_ISGE + .no_dead_strip _lj_BC_ISGE +_lj_BC_ISGE: + .long 0xf87b7a60,0x794002b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95a235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x54011443 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x540113c1 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x54011343 + .long 0x1e620000,0x1e612000,0x9a952235,0x17ffffed + + .private_extern _lj_BC_ISLE + .no_dead_strip _lj_BC_ISLE +_lj_BC_ISLE: + .long 0xf87b7a60,0x794002b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95d235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x54011043 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x54010fc1 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x54010f43 + .long 0x1e620000,0x1e612000,0x9a959235,0x17ffffed + + .private_extern _lj_BC_ISGT + .no_dead_strip _lj_BC_ISGT +_lj_BC_ISGT: + .long 0xf87b7a60,0x794002b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95c235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x54010c43 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x54010bc1 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x54010b43 + .long 0x1e620000,0x1e612000,0x9a958235,0x17ffffed + + .private_extern _lj_BC_ISEQV + .no_dead_strip _lj_BC_ISEQV +_lj_BC_ISEQV: + .long 0xf87b7a60,0x8b1c0e7c,0x794002b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0x936ffc4f + .long 0xb10039ff,0x54000b69,0x936ffc08,0xeb02001f + .long 0x54000101,0xaa1103f5,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xeb0801ff,0xba4c09e2,0x54ffff08,0x9240b801 + .long 0xf940102a,0xb4fffeaa,0x39402949,0x52800003 + .long 0x3727fe49,0x1400085a + + .private_extern _lj_BC_ISNEV + .no_dead_strip _lj_BC_ISNEV +_lj_BC_ISNEV: + .long 0xf87b7a60,0x8b1c0e7c,0x794002b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0x936ffc4f + .long 0xb10039ff,0x54000b89,0x936ffc08,0xeb02001f + .long 0x540000e1,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0xeb0801ff + .long 0xba4c09e2,0x54fffb48,0x9240b801,0xf940102a + .long 0xb4fffaea,0x39402949,0x52800023,0x3727fa89 + .long 0x1400083d + + .private_extern _lj_BC_ISEQS + .no_dead_strip _lj_BC_ISEQS +_lj_BC_ISEQS: + .long 0xf87b7a60,0xaa3c03fc,0x794002b1,0xf87c7a81 + .long 0x910012b5,0x92800088,0x8b110ab1,0x8b08bc21 + .long 0xd1408231,0xeb01001f,0x9a950235,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_ISNES + .no_dead_strip _lj_BC_ISNES +_lj_BC_ISNES: + .long 0xf87b7a60,0xaa3c03fc,0x794002b1,0xf87c7a81 + .long 0x910012b5,0x92800088,0x8b110ab1,0x8b08bc21 + .long 0xd1408231,0xeb01001f,0x9a951235,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_ISEQN + .no_dead_strip _lj_BC_ISEQN +_lj_BC_ISEQN: + .long 0xf87b7a60,0x8b1c0e9c,0x794002b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0xeb40833f + .long 0x54000161,0xeb42833f,0x54000221,0x6b02001f + .long 0x9a950235,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0x54ffff43 + .long 0xfc7b7a60,0xfd400381,0xeb42833f,0x54000041 + .long 0x1e620041,0x1e612000,0x17fffff2,0xfd400381 + .long 0x1e620000,0x1e612000,0x17ffffee + + .private_extern _lj_BC_ISNEN + .no_dead_strip _lj_BC_ISNEN +_lj_BC_ISNEN: + .long 0xf87b7a60,0x8b1c0e9c,0x794002b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0xeb40833f + .long 0x54000161,0xeb42833f,0x54000221,0x6b02001f + .long 0x9a951235,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0x54ffff23 + .long 0xfc7b7a60,0xfd400381,0xeb42833f,0x54000041 + .long 0x1e620041,0x1e612000,0x17fffff2,0xfd400381 + .long 0x1e620000,0x1e612000,0x17ffffee + + .private_extern _lj_BC_ISEQP + .no_dead_strip _lj_BC_ISEQP +_lj_BC_ISEQP: + .long 0xf87b7a68,0x794002b1,0x910012b5,0x9100079c + .long 0x8b110ab1,0xab88bf9f,0xd1408231,0x9a950235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISNEP + .no_dead_strip _lj_BC_ISNEP +_lj_BC_ISNEP: + .long 0xf87b7a68,0x794002b1,0x910012b5,0x9100079c + .long 0x8b110ab1,0xab88bf9f,0xd1408231,0x9a951235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISTC + .no_dead_strip _lj_BC_ISTC +_lj_BC_ISTC: + .long 0x794002b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a9c337b + .long 0x9a953235,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISFC + .no_dead_strip _lj_BC_ISFC +_lj_BC_ISFC: + .long 0x794002b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a9c237b + .long 0x9a952235,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_IST + .no_dead_strip _lj_BC_IST +_lj_BC_IST: + .long 0x794002b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a953235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISF + .no_dead_strip _lj_BC_ISF +_lj_BC_ISF: + .long 0x794002b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a952235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISTYPE + .no_dead_strip _lj_BC_ISTYPE +_lj_BC_ISTYPE: + .long 0xf87b7a68,0xab88bf9f,0x5400f121,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_ISNUM + .no_dead_strip _lj_BC_ISNUM +_lj_BC_ISNUM: + .long 0xf87b6a68,0xeb48833f,0x5400f009,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_MOV + .no_dead_strip _lj_BC_MOV +_lj_BC_MOV: + .long 0xf87c7a68,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_NOT + .no_dead_strip _lj_BC_NOT +_lj_BC_NOT: + .long 0xf87c7a68,0x92d00009,0x92e0002a,0xeb09011f + .long 0x9a8a3128,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_UNM + .no_dead_strip _lj_BC_UNM +_lj_BC_UNM: + .long 0xf87c7a68,0x936ffd0f,0xb10039ff,0x5400ee08 + .long 0xd2410108,0x540000a1,0x6b0803e8,0xd2e83c02 + .long 0x8b180108,0x9a827108,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_LEN + .no_dead_strip _lj_BC_LEN +_lj_BC_LEN: + .long 0xf87c7a60,0x936ffc0f,0xb10015ff,0x9240b800 + .long 0x54000141,0xb9401400,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xb10031ff,0x5400eca1 + bl _lj_tab_len + .long 0x17fffff5 + + .private_extern _lj_BC_ADDVN + .no_dead_strip _lj_BC_ADDVN +_lj_BC_ADDVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x2b010000,0x5400e826,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a81 + .long 0xeb40833f,0x5400e6a9,0xeb41833f,0x5400e669 + .long 0x1e612800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_SUBVN + .no_dead_strip _lj_BC_SUBVN +_lj_BC_SUBVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x6b010000,0x5400e4c6,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a81 + .long 0xeb40833f,0x5400e349,0xeb41833f,0x5400e309 + .long 0x1e613800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_MULVN + .no_dead_strip _lj_BC_MULVN +_lj_BC_MULVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001e1,0xeb41833f,0x540001a1 + .long 0x9b217c00,0xeb20c01f,0x2a0003e0,0x5400e121 + .long 0x8b180000,0xf83b7a60,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xfc717a60,0xfc7c7a81,0xeb40833f,0x5400dfa9 + .long 0xeb41833f,0x5400df69,0x1e610800,0xfc3b7a60 + .long 0x17fffff2 + + .private_extern _lj_BC_DIVVN + .no_dead_strip _lj_BC_DIVVN +_lj_BC_DIVVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xfc717a60,0xfc7c7a81,0xeb40833f,0x5400de09 + .long 0xeb41833f,0x5400ddc9,0x1e611800,0xfc3b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_MODVN + .no_dead_strip _lj_BC_MODVN +_lj_BC_MODVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x3400dba1,0x94000b58,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a81 + .long 0xeb40833f,0x5400da09,0xeb41833f,0x5400d9c9 + .long 0x1e611802,0x1e654042,0x1f418040,0xfc3b7a60 + .long 0x17fffff0 + + .private_extern _lj_BC_ADDNV + .no_dead_strip _lj_BC_ADDNV +_lj_BC_ADDNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x2b010000,0x5400d846,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7c7a80,0xfc717a61 + .long 0xeb40833f,0x5400d6c9,0xeb41833f,0x5400d689 + .long 0x1e612800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_SUBNV + .no_dead_strip _lj_BC_SUBNV +_lj_BC_SUBNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x6b010000,0x5400d4e6,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7c7a80,0xfc717a61 + .long 0xeb40833f,0x5400d369,0xeb41833f,0x5400d329 + .long 0x1e613800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_MULNV + .no_dead_strip _lj_BC_MULNV +_lj_BC_MULNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001e1,0xeb41833f,0x540001a1 + .long 0x9b217c00,0xeb20c01f,0x2a0003e0,0x5400d141 + .long 0x8b180000,0xf83b7a60,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xfc7c7a80,0xfc717a61,0xeb40833f,0x5400cfc9 + .long 0xeb41833f,0x5400cf89,0x1e610800,0xfc3b7a60 + .long 0x17fffff2 + + .private_extern _lj_BC_DIVNV + .no_dead_strip _lj_BC_DIVNV +_lj_BC_DIVNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xfc7c7a80,0xfc717a61,0xeb40833f,0x5400ce29 + .long 0xeb41833f,0x5400cde9,0x1e611800,0xfc3b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_MODNV + .no_dead_strip _lj_BC_MODNV +_lj_BC_MODNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x3400cbc1,0x94000ad6,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7c7a80,0xfc717a61 + .long 0xeb40833f,0x5400ca29,0xeb41833f,0x5400c9e9 + .long 0x1e611802,0x1e654042,0x1f418040,0xfc3b7a60 + .long 0x17fffff0 + + .private_extern _lj_BC_ADDVV + .no_dead_strip _lj_BC_ADDVV +_lj_BC_ADDVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x2b010000,0x5400c8c6,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a61 + .long 0xeb40833f,0x5400c749,0xeb41833f,0x5400c709 + .long 0x1e612800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_SUBVV + .no_dead_strip _lj_BC_SUBVV +_lj_BC_SUBVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x6b010000,0x5400c566,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a61 + .long 0xeb40833f,0x5400c3e9,0xeb41833f,0x5400c3a9 + .long 0x1e613800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_MULVV + .no_dead_strip _lj_BC_MULVV +_lj_BC_MULVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001e1,0xeb41833f,0x540001a1 + .long 0x9b217c00,0xeb20c01f,0x2a0003e0,0x5400c1c1 + .long 0x8b180000,0xf83b7a60,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xfc717a60,0xfc7c7a61,0xeb40833f,0x5400c049 + .long 0xeb41833f,0x5400c009,0x1e610800,0xfc3b7a60 + .long 0x17fffff2 + + .private_extern _lj_BC_DIVVV + .no_dead_strip _lj_BC_DIVVV +_lj_BC_DIVVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xfc717a60,0xfc7c7a61,0xeb40833f,0x5400bea9 + .long 0xeb41833f,0x5400be69,0x1e611800,0xfc3b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_MODVV + .no_dead_strip _lj_BC_MODVV +_lj_BC_MODVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x3400bc41,0x94000a54,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a61 + .long 0xeb40833f,0x5400baa9,0xeb41833f,0x5400ba69 + .long 0x1e611802,0x1e654042,0x1f418040,0xfc3b7a60 + .long 0x17fffff0 + + .private_extern _lj_BC_POW + .no_dead_strip _lj_BC_POW +_lj_BC_POW: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xfc717a60,0xfc7c7a61,0xeb40833f,0x5400b8c9 + .long 0xeb41833f,0x5400b889 + bl _pow + .long 0xfc3b7a60,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_CAT + .no_dead_strip _lj_BC_CAT +_lj_BC_CAT: + .long 0xd3587e11,0x92401f9c,0xf90012f3,0xcb110382 + .long 0x8b1c0e61,0xaa1703e0,0xf90057f5 + bl _lj_meta_cat + .long 0x385fc2b1,0xf94012f3,0xb500b740,0xf8717a68 + .long 0xf83b7a68,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KSTR + .no_dead_strip _lj_BC_KSTR +_lj_BC_KSTR: + .long 0xaa3c03fc,0xf87c7a88,0x92800089,0x8b09bd08 + .long 0xf83b7a68,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KCDATA + .no_dead_strip _lj_BC_KCDATA +_lj_BC_KCDATA: + + .private_extern _lj_BC_KSHORT + .no_dead_strip _lj_BC_KSHORT +_lj_BC_KSHORT: + .long 0x13003f9c,0x8b180388,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_KNUM + .no_dead_strip _lj_BC_KNUM +_lj_BC_KNUM: + .long 0xf87c7a88,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KPRI + .no_dead_strip _lj_BC_KPRI +_lj_BC_KPRI: + .long 0xaa3cbfe8,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KNIL + .no_dead_strip _lj_BC_KNIL +_lj_BC_KNIL: + .long 0x8b1b0e7b,0x8b1c0e7c,0xf800877a,0xeb1c037f + .long 0xf800877a,0x54ffffcb,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_UGET + .no_dead_strip _lj_BC_UGET +_lj_BC_UGET: + .long 0xf85f0261,0x9100179c,0x9240b821,0xf87c7821 + .long 0xf9401021,0xf9400028,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_USETV + .no_dead_strip _lj_BC_USETV +_lj_BC_USETV: + .long 0xf85f0261,0x9100177b,0x9240b821,0xf87b7820 + .long 0xf87c7a62,0xf9401001,0x3940200a,0x39402808 + .long 0x936ffc4f,0xf9000022,0x910011ef,0x721e015f + .long 0x7a401904,0xba4a19e0,0x540000e8,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x9240b842,0x39402049,0x7200053f + .long 0x54fffee0,0xaa1603e0 + bl _lj_gc_barrieruv + .long 0x17fffff4 + + .private_extern _lj_BC_USETS + .no_dead_strip _lj_BC_USETS +_lj_BC_USETS: + .long 0xf85f0261,0x9100177b,0xaa3c03fc,0x9240b821 + .long 0xf87b7820,0xf87c7a82,0x92800088,0xf9401001 + .long 0x3940200a,0x8b08bc48,0x39402049,0xf9000028 + .long 0x371000ea,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0x39402808 + .long 0x7200053f,0x7a401904,0x54fffee0,0xaa1603e0 + bl _lj_gc_barrieruv + .long 0x17fffff4 + + .private_extern _lj_BC_USETN + .no_dead_strip _lj_BC_USETN +_lj_BC_USETN: + .long 0xf85f0261,0x9100177b,0x9240b821,0xf87b7821 + .long 0xf87c7a88,0xf9401021,0xf9000028,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_USETP + .no_dead_strip _lj_BC_USETP +_lj_BC_USETP: + .long 0xf85f0261,0x9100177b,0x9240b821,0xf87b7821 + .long 0xaa3cbfe8,0xf9401021,0xf9000028,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_UCLO + .no_dead_strip _lj_BC_UCLO +_lj_BC_UCLO: + .long 0xf94022e2,0x8b1c0abc,0xf90012f3,0xd1408395 + .long 0xb40000a2,0xaa1703e0,0x8b1b0e61 + bl _lj_func_closeuv + .long 0xf94012f3,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_FNEW + .no_dead_strip _lj_BC_FNEW +_lj_BC_FNEW: + .long 0xaa3c03fc,0xf90012f3,0xf85f0262,0xf90057f5 + .long 0xf87c7a81,0xaa1703e0,0x9240b842 + bl _lj_func_newL_gc + .long 0xf94012f3,0x92800108,0x8b08bc00,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_TNEW + .no_dead_strip _lj_BC_TNEW +_lj_BC_TNEW: + .long 0xa9410ec2,0xf90012f3,0xf90057f5,0xaa1703e0 + .long 0xeb03005f,0x54000202,0x92402b81,0xd34bff82 + .long 0xf11ffc3f,0x52810028,0x9a881021 + bl _lj_tab_new + .long 0xf94012f3,0xf2ffff40,0xf83b7a60,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + bl _lj_gc_step_fixtop + .long 0xaa1703e0,0x17ffffef + + .private_extern _lj_BC_TDUP + .no_dead_strip _lj_BC_TDUP +_lj_BC_TDUP: + .long 0xa9410ec2,0xf90012f3,0xf90057f5,0xaa1703e0 + .long 0xeb03005f,0x540001a2,0xaa3c03fc,0xf87c7a81 + bl _lj_tab_dup + .long 0xf94012f3,0xf2ffff40,0xf83b7a60,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + bl _lj_gc_step_fixtop + .long 0xaa1703e0,0x17fffff2 + + .private_extern _lj_BC_GGET + .no_dead_strip _lj_BC_GGET +_lj_BC_GGET: + .long 0xf85f0260,0xaa3c03fc,0x9240b800,0xf9400801 + .long 0xf87c7a9c,0x14000033 + + .private_extern _lj_BC_GSET + .no_dead_strip _lj_BC_GSET +_lj_BC_GSET: + .long 0xf85f0260,0xaa3c03fc,0x9240b800,0xf9400801 + .long 0xf87c7a9c,0x140000ab + + .private_extern _lj_BC_TGETV + .no_dead_strip _lj_BC_TGETV +_lj_BC_TGETV: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xf87c7a69 + .long 0x936ffc2f,0xb10031ff,0x9240b821,0x540086c1 + .long 0xeb49833f,0x540002a1,0xf9400822,0xb9403020 + .long 0x8b294c42,0x6b00013f,0x540085e2,0xf9400048 + .long 0xeb1a011f,0x54000100,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xf9401020,0xb4ffff00,0x39402809 + .long 0x3707fec9,0x14000420,0x936ffd2f,0xb10015ff + .long 0x540083a1,0x9240b93c,0x1400000a + + .private_extern _lj_BC_TGETS + .no_dead_strip _lj_BC_TGETS +_lj_BC_TGETS: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xaa3c03fc + .long 0xf87c7a9c,0x936ffc2f,0xb10031ff,0x9240b821 + .long 0x54008061,0xb9403429,0xb9400f8a,0xf9401422 + .long 0x0a0a0129,0x8b090529,0x92800083,0x8b090c42 + .long 0x8b03bf83,0xa9400048,0xf9400842,0xeb03001f + .long 0x54000141,0xeb1a011f,0x54000140,0xf83b7a68 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xb5fffe62,0xaa1a03e8 + .long 0xf9401020,0xb4fffec0,0x39402809,0x3707fe89 + .long 0x140003eb + + .private_extern _lj_BC_TGETB + .no_dead_strip _lj_BC_TGETB +_lj_BC_TGETB: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0x936ffc2f + .long 0xb10031ff,0x9240b821,0x54007d41,0xf9400822 + .long 0xb9403020,0x8b1c0c42,0x6b00039f,0x54007ca2 + .long 0xf9400048,0xeb1a011f,0x54000100,0xf83b7a68 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xf9401020,0xb4ffff00 + .long 0x39402809,0x3707fec9,0x140003d6 + + .private_extern _lj_BC_TGETR + .no_dead_strip _lj_BC_TGETR +_lj_BC_TGETR: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a69 + .long 0x9240b800,0xf9400802,0xb940300a,0x8b294c42 + .long 0x6b0a013f,0x54007d02,0xf9400048,0xf83b7a68 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_TSETV + .no_dead_strip _lj_BC_TSETV +_lj_BC_TSETV: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xf87c7a69 + .long 0x936ffc2f,0xb10031ff,0x9240b821,0x54007da1 + .long 0xeb49833f,0x540003c1,0xf9400822,0xb9403020 + .long 0x8b294c42,0x6b00013f,0x54007cc2,0xf9400049 + .long 0xf87b7a68,0x3940202a,0xeb1a013f,0x54000120 + .long 0xf9000048,0x3710018a,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xf9401020,0xb4fffee0,0x39402809,0x370ffea9 + .long 0x140003d4,0xf94022c9,0x121d794a,0xf90022c1 + .long 0x3900202a,0xf9000c29,0x17fffff0,0x936ffd2f + .long 0xb10015ff,0x54007961,0x9240b93c,0x1400000a + + .private_extern _lj_BC_TSETS + .no_dead_strip _lj_BC_TSETS +_lj_BC_TSETS: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xaa3c03fc + .long 0xf87c7a9c,0x936ffc2f,0xb10031ff,0x9240b821 + .long 0x54007621,0xb9403429,0xb9400f8a,0xf9401422 + .long 0x0a0a0129,0x8b090529,0x92800083,0x8b090c42 + .long 0x8b03bf83,0x3900283f,0xa9400049,0xf940084b + .long 0x3940202a,0xeb03001f,0x54000221,0xf87b7a68 + .long 0xeb1a013f,0x54000120,0xf9000048,0x371003ca + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xf9401020,0xb4fffee0 + .long 0x39402809,0x370ffea9,0x14000397,0xaa0b03e2 + .long 0xb5fffd4b,0xf9401020,0xb4000060,0x39402809 + .long 0x36087229,0x92800089,0xf90057f5,0x8b09bf88 + .long 0xf90012f3,0xaa1703e0,0xf9005fe8,0x9102e3e2 + bl _lj_tab_newkey + .long 0xf94012f3,0xf87b7a68,0xf9000008,0x17ffffe4 + .long 0xf94022c9,0x121d794a,0xf90022c1,0x3900202a + .long 0xf9000c29,0x17ffffde + + .private_extern _lj_BC_TSETB + .no_dead_strip _lj_BC_TSETB +_lj_BC_TSETB: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0x936ffc2f + .long 0xb10031ff,0x9240b821,0x54006fc1,0xf9400822 + .long 0xb9403020,0x8b1c0c42,0x6b00039f,0x54006f22 + .long 0xf9400049,0xf87b7a68,0x3940202a,0xeb1a013f + .long 0x54000120,0xf9000048,0x3710018a,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xf9401020,0xb4fffee0,0x39402809 + .long 0x370ffea9,0x14000367,0xf94022c9,0x121d794a + .long 0xf90022c1,0x3900202a,0xf9000c29,0x17fffff0 + + .private_extern _lj_BC_TSETM + .no_dead_strip _lj_BC_TSETM +_lj_BC_TSETM: + .long 0x8b1b0e7b,0xb940c3f1,0xf85f8361,0xf87c7a89 + .long 0xd1002231,0xb40001f1,0x9240b821,0xb9403020 + .long 0x0b510d22,0xf9400823,0xeb00005f,0x8b110371 + .long 0x540001c8,0x8b294c69,0x3940202a,0xf8408768 + .long 0xf8008528,0xeb11037f,0x54ffffa3,0x3710018a + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_tab_reasize + .long 0x17ffffe3,0xf94022c9,0x121d794a,0xf90022c1 + .long 0x3900202a,0xf9000c29,0x17fffff0 + + .private_extern _lj_BC_TSETR + .no_dead_strip _lj_BC_TSETR +_lj_BC_TSETR: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xf87c7a69 + .long 0x9240b821,0xf9400820,0x3940202a,0xb9403023 + .long 0x8b294c00,0x3710016a,0x6b03013f,0x540069a2 + .long 0xf87b7a68,0xf9000008,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xf94022c8,0x121d794a,0xf90022c1,0x3900202a + .long 0xf9000c28,0x17fffff1 + + .private_extern _lj_BC_CALLM + .no_dead_strip _lj_BC_CALLM +_lj_BC_CALLM: + .long 0xb940c3e8,0xd37d1f9c,0x8b08039c,0x14000002 + + .private_extern _lj_BC_CALL + .no_dead_strip _lj_BC_CALL +_lj_BC_CALL: + .long 0xd37d1f9c,0xaa1303f1,0x8b1b0e73,0xf9400262 + .long 0xd100239c,0x91004273,0x936ffc4f,0xb10025ff + .long 0x9240b842,0x540070c1,0xf81f8275,0xf9401055 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_BC_CALLMT + .no_dead_strip _lj_BC_CALLMT +_lj_BC_CALLMT: + .long 0xb940c3e8,0x8b1c0d1c,0x14000002 + + .private_extern _lj_BC_CALLT + .no_dead_strip _lj_BC_CALLT +_lj_BC_CALLT: + .long 0xd37df39c,0x8b1b0e7b,0xf9400369,0xd100239c + .long 0x9100437b,0x936ffd2f,0xb10025ff,0x9240b922 + .long 0x54007061,0xf85f8275,0x52800011,0x3940284a + .long 0xf24006bf,0x54000321,0xf81f0269,0xb40000fc + .long 0xf8716b68,0x91002229,0xeb1c013f,0xf8316a68 + .long 0xaa0903f1,0x54ffff61,0xf100055f,0x54000108 + .long 0xf9401055,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0x8b1b0e7b,0xd61f0100,0x385fe2bb + .long 0xcb1b0e60,0xf85e0000,0x9240b800,0xf9401000 + .long 0xf85b8014,0x17fffff3,0xd24006b5,0xf2400abf + .long 0x9a8a122a,0x54fffca1,0xcb150273,0xf85f8275 + .long 0xf24006bf,0x9a8a122a,0x17ffffe0 + + .private_extern _lj_BC_ITERC + .no_dead_strip _lj_BC_ITERC +_lj_BC_ITERC: + .long 0x8b1b0e7b,0xf85e8362,0xaa1303f1,0xa97f0760 + .long 0x91004373,0x5280021c,0xf9000362,0xa9010760 + .long 0x936ffc4f,0xb10025ff,0x9240b842,0x54006801 + .long 0xf81f8275,0xf9401055,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_BC_ITERN + .no_dead_strip _lj_BC_ITERN +_lj_BC_ITERN: + .long 0x8b1b0e7b,0xf85f0371,0x794002ab,0xb85fc360 + .long 0x910012b5,0x8b0b0aab,0x9240ba31,0xd140816b + .long 0xb9403229,0xf9400a21,0xeb09001c,0x8b000c22 + .long 0x54000202,0xf9400048,0xeb1a011f,0x9a801400 + .long 0x54ffff40,0x8b180000,0xa9002360,0x91000400 + .long 0xb81fc360,0xaa0b03f5,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xb940362a,0xf9401631,0x8b1c0780,0xeb0a039f + .long 0x8b000e22,0x54fffea8,0xa9400048,0xeb1a011f + .long 0x9100079c,0x54ffff20,0xa9002360,0x8b090380 + .long 0x17ffffec + + .private_extern _lj_BC_VARG + .no_dead_strip _lj_BC_VARG +_lj_BC_VARG: + .long 0xd3587e11,0x92401f9c,0xf85f8269,0x8b1c0e7c + .long 0x8b1b0e7b,0x91000f9c,0x8b110f6a,0xcb09039c + .long 0xd100426b,0xb40001d1,0xd100414a,0xeb0b039f + .long 0xf8408788,0x9a9a3108,0xeb0a037f,0xf8008768 + .long 0x54ffff63,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0xf9401ae8 + .long 0xeb1c016a,0x9a8ad3f1,0x91002231,0x8b0a0369 + .long 0xb900c3f1,0x54fffe8d,0xeb08013f,0x540000c8 + .long 0xf8408788,0xf8008768,0xeb0b039f,0x54ffffa3 + .long 0x17ffffed,0xd343fd41,0xa9026ef3,0xaa1703e0 + .long 0xcb13039c,0xf90057f5 + bl _lj_state_growstack + .long 0xa9426ef3,0x8b1c027c,0xd100426b,0x17fffff2 + + .private_extern _lj_BC_ISNEXT + .no_dead_strip _lj_BC_ISNEXT +_lj_BC_ISNEXT: + .long 0x8b1b0e7b,0xf85e8360,0x8b1c0abc,0xa97f0f62 + .long 0xd140839c,0x936ffc0f,0xb10025ff,0x9240b800 + .long 0x54000221,0x936ffc48,0x39402809,0xb100311f + .long 0xfa5a0060,0x7a440920,0x54000161,0x320f77e8 + .long 0xd3607d08,0xf81f8368,0xaa1c03f5,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x52800b08,0x528008a9,0x381ff2a8 + .long 0x39000f89,0x17fffff5 + + .private_extern _lj_BC_RETM + .no_dead_strip _lj_BC_RETM +_lj_BC_RETM: + .long 0xb940c3e8,0xf85f8275,0x8b1b0e7b,0x8b1c0d1c + .long 0x14000004 + + .private_extern _lj_BC_RET + .no_dead_strip _lj_BC_RET +_lj_BC_RET: + .long 0xf85f8275,0xd37df39c,0x8b1b0e7b,0xb900c3fc + .long 0xf24006a0,0xd24006a1,0x540003e1,0xb85fc2b0 + .long 0xf1002389,0xd1004262,0x540000c0,0xf8408768 + .long 0x91002273,0xd1002129,0xf81e8268,0xb5ffff89 + .long 0xd3483e1b,0xcb1b0c43,0xd3587e11,0xf85f0060 + .long 0xeb110f9f,0x54000163,0x9240b800,0xaa0303f3 + .long 0xf9401001,0xf85b8034,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0x91002273,0x9100239c,0xf81e827a,0x17fffff1 + .long 0x8b1b0e7b,0xf240083f,0x54001fa1,0xcb010273 + .long 0xf85f8275,0x17ffffdb + + .private_extern _lj_BC_RET0 + .no_dead_strip _lj_BC_RET0 +_lj_BC_RET0: + .long 0xf85f8275,0xd37df39c,0xb900c3fc,0xf24006a0 + .long 0xd24006a1,0x54fffea1,0xb85fc2b0,0xd1004263 + .long 0xd3483e1b,0xcb1b0c73,0xd3587e11,0xf85f0260 + .long 0xeb110f9f,0x54000143,0x9240b800,0xf9401001 + .long 0xf85b8034,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0x9100239c + .long 0xf800847a,0x17fffff3 + + .private_extern _lj_BC_RET1 + .no_dead_strip _lj_BC_RET1 +_lj_BC_RET1: + .long 0xf85f8275,0xd37df39c,0xb900c3fc,0xf24006a0 + .long 0xd24006a1,0x54fffb61,0xb85fc2b0,0xf87b7a68 + .long 0xd1004263,0xd3483e1b,0xcb1b0c73,0xf8008468 + .long 0xd3587e11,0xf85f0260,0xeb110f9f,0x54000143 + .long 0x9240b800,0xf9401001,0xf85b8034,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x9100239c,0xf800847a,0x17fffff3 + + .private_extern _lj_BC_FORI + .no_dead_strip _lj_BC_FORI +_lj_BC_FORI: + .long 0x8b1b0e7b,0xa9400760,0xf9400b62,0x8b1c0abc + .long 0xd140839c,0xeb40833f,0x54000221,0xeb41833f + .long 0x54004e01,0xeb42833f,0x54004dc1,0x37f80142 + .long 0x6b01001f,0x9a95c395,0xf9000f60,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x6b00003f,0x17fffff7,0x6d400760 + .long 0x54004c03,0xeb41833f,0x54004bc9,0xeb42833f + .long 0x54004b89,0xfd000f60,0xb7f80082,0x1e612000 + .long 0x9a958395,0x17ffffee,0x1e602020,0x17fffffd + + .private_extern _lj_BC_FORL + .no_dead_strip _lj_BC_FORL +_lj_BC_FORL: + .long 0x8b1b0e7b,0xa9400760,0xf9400b62,0x8b1c0abc + .long 0xd140839c,0xeb40833f,0x54000221,0x2b020000 + .long 0x540000e6,0x8b180008,0x37f80162,0x6b01001f + .long 0x9a95d395,0xf9000368,0xf9000f68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x6b00003f,0x17fffff6,0x6d400760 + .long 0x54004783,0xfd400b62,0x1e622800,0xb7f800c2 + .long 0x1e612000,0xfd000360,0xfd000f60,0x9a959395 + .long 0x17ffffef,0x1e602020,0x17fffffb + + .private_extern _lj_BC_ITERL + .no_dead_strip _lj_BC_ITERL +_lj_BC_ITERL: + .long 0xf87b7a60,0x8b1b0e69,0xeb1a001f,0x54000080 + .long 0x8b1c0aa8,0xd1408115,0xf81f8120,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_LOOP + .no_dead_strip _lj_BC_LOOP +_lj_BC_LOOP: + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_JMP + .no_dead_strip _lj_BC_JMP +_lj_BC_JMP: + .long 0x8b1c0abc,0xd1408395,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_FUNCF + .no_dead_strip _lj_BC_FUNCF +_lj_BC_FUNCF: + + .private_extern _lj_BC_IFUNCF + .no_dead_strip _lj_BC_IFUNCF +_lj_BC_IFUNCF: + .long 0xf9401ae0,0x3859e2a9,0xf85b42b4,0xeb00037f + .long 0x540014a8,0xeb090f9f,0x540000e3,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xf83c6a7a,0x9100239c,0x17fffff6 + + .private_extern _lj_BC_JFUNCF + .no_dead_strip _lj_BC_JFUNCF +_lj_BC_JFUNCF: + + .private_extern _lj_BC_FUNCV + .no_dead_strip _lj_BC_FUNCV +_lj_BC_FUNCV: + + .private_extern _lj_BC_IFUNCV + .no_dead_strip _lj_BC_IFUNCV +_lj_BC_IFUNCV: + .long 0xf9401ae0,0x92800108,0x8b1c026a,0x8b08bc42 + .long 0x8b1c037b,0x91004f88,0xf8008542,0xf85b42b4 + .long 0xeb00037f,0xf8008548,0x540011e2,0xd100415c + .long 0x3859e2a9,0xaa1303fb,0xaa0a03f3,0xb4000109 + .long 0xeb1c037f,0x54000182,0xf9400368,0xd1000529 + .long 0xf800877a,0xf8008548,0xb5ffff49,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xd1000529,0xf800855a,0xb4ffff09 + .long 0x17fffffd + + .private_extern _lj_BC_JFUNCV + .no_dead_strip _lj_BC_JFUNCV +_lj_BC_JFUNCV: + + .private_extern _lj_BC_FUNCC + .no_dead_strip _lj_BC_FUNCC +_lj_BC_FUNCC: + .long 0xf9401443,0x8b1c0361,0xf9401ae0,0x8b1c027c + .long 0xeb00003f,0xa90272f3,0x12800028,0xaa1703e0 + .long 0x54000dc8,0xb900bac8,0xd63f0060,0xa94226f3 + .long 0xf900bad7,0x937d7c1c,0xb900bada,0xf85f8275 + .long 0xcb1c013b,0x14000019 + + .private_extern _lj_BC_FUNCCW + .no_dead_strip _lj_BC_FUNCCW +_lj_BC_FUNCCW: + .long 0xf940aec3,0x8b1c0361,0xf9401ae0,0x8b1c027c + .long 0xeb00003f,0xa90272f3,0xf9401441,0x12800028 + .long 0xaa1703e0,0x54000b68,0xb900bac8,0xd63f0060 + .long 0xa94226f3,0xf900bad7,0x937d7c1c,0xb900bada + .long 0xf85f8275,0xcb1c013b,0x14000006 + + .private_extern _lj_vm_returnp + .no_dead_strip _lj_vm_returnp +_lj_vm_returnp: + .long 0x36101c75,0xf85f8235,0x92e00028,0xaa1103f3 + .long 0xf81f8f68 + + .private_extern _lj_vm_returnc + .no_dead_strip _lj_vm_returnc +_lj_vm_returnc: + .long 0xb100239c,0x52800020,0x540006e0,0xb900c3fc + .long 0xf24006a0,0x54ffdca0 + + .private_extern _lj_vm_return + .no_dead_strip _lj_vm_return +_lj_vm_return: + .long 0x927df2b1,0xf100041f,0xcb110271,0x54fffe41 + .long 0xf90012f1,0xb980cbe1,0x12800028,0xd1004273 + .long 0xf100238a,0xb900bac8,0x540000a0,0xf100214a + .long 0xf8408768,0xf8008668,0x54ffffa1,0xeb010f9f + .long 0x54000201,0xf90016f3 + + .private_extern _lj_vm_leave_cp + .no_dead_strip _lj_vm_leave_cp +_lj_vm_leave_cp: + .long 0xf94053fc,0x52800000,0xf9002afc + + .private_extern _lj_vm_leave_unw + .no_dead_strip _lj_vm_leave_unw +_lj_vm_leave_unw: + .long 0xa94153f3,0x6d4627e8,0xa9425bf5,0x6d472fea + .long 0xa94363f7,0x6d4837ec,0xa9446bf9,0x6d493fee + .long 0xa94573fb,0xa8cd7bfd,0xd65f03c0,0x540000ec + .long 0xf9401ae2,0xeb02027f,0x54000102,0xf800867a + .long 0x9100239c,0x17ffffe9,0xb4fffd41,0xcb010f80 + .long 0xcb000273,0x17ffffe7,0xf90016f3,0xaa1703e0 + bl _lj_state_growstack + .long 0xf94016f3,0xb980cbe1,0x17ffffdf + + .private_extern _lj_vm_unwind_c + .no_dead_strip _lj_vm_unwind_c +_lj_vm_unwind_c: + .long 0x9100001f,0xaa0103e0 + + .private_extern _lj_vm_unwind_c_eh + .no_dead_strip _lj_vm_unwind_c_eh +_lj_vm_unwind_c_eh: + .long 0xf9405bf7,0x12800028,0xf9400af6,0xb900bac8 + .long 0x17ffffde + + .private_extern _lj_vm_unwind_ff + .no_dead_strip _lj_vm_unwind_ff +_lj_vm_unwind_ff: + .long 0x927ef41f + + .private_extern _lj_vm_unwind_ff_eh + .no_dead_strip _lj_vm_unwind_ff_eh +_lj_vm_unwind_ff_eh: + .long 0xf9405bf7,0xd2ffff38,0xd2bfff39,0x9280001a + .long 0x5280021c,0xf94012f3,0xf9400af6,0x92d00008 + .long 0xd100227b,0xf85f8275,0xf81f8268,0xb900bada + .long 0x17ffffb5 + + .private_extern _lj_vm_growstack_c + .no_dead_strip _lj_vm_growstack_c +_lj_vm_growstack_c: + .long 0x52800281,0x14000007 + + .private_extern _lj_vm_growstack_l + .no_dead_strip _lj_vm_growstack_l +_lj_vm_growstack_l: + .long 0x8b1c027c,0xcb13037b,0xaa1703e0,0xa90272f3 + .long 0x910012b5,0xd343ff61,0xf90057f5 + bl _lj_state_growstack + .long 0xa94272f3,0xf85f0262,0xcb13039c,0x9240b842 + .long 0xf9401055,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_vm_resume + .no_dead_strip _lj_vm_resume +_lj_vm_resume: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0xaa0003f7 + .long 0xf9400af6,0xaa0103f3,0xf9005bf7,0x528000b5 + .long 0xb900cbff,0x910007e8,0x39402ee9,0xb900c7ff + .long 0xf90057f7,0xf90053ff,0xf9002ae8,0x34000669 + .long 0xf900bad7,0xaa1303fb,0xa94202f3,0xd2ffff38 + .long 0xd2bfff39,0xf85f8275,0x39002eff,0x9280001a + .long 0xcb13001c,0xf24006a0,0x9100239c,0xb900bada + .long 0xb900c3fc,0x54ffcc80,0x17ffff7f + + .private_extern _lj_vm_pcall + .no_dead_strip _lj_vm_pcall +_lj_vm_pcall: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0x528000b5 + .long 0xb900c7e3,0x1400000d + + .private_extern _lj_vm_call + .no_dead_strip _lj_vm_call +_lj_vm_call: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0x52800035 + .long 0xf940281c,0xb900cbe2,0xaa0003f7,0xf9005be0 + .long 0xf9400af6,0xaa0103f3,0xf90057e0,0xf90053fc + .long 0xf9002afd,0xf900bad7,0xa94202f1,0xd2ffff38 + .long 0xd2bfff39,0x8b1302b5,0x9280001a,0xcb1102b5 + .long 0xcb13001c,0xb900bada + + .private_extern _lj_vm_call_dispatch + .no_dead_strip _lj_vm_call_dispatch +_lj_vm_call_dispatch: + .long 0xf85f0262,0x936ffc4f,0xb10025ff,0x9240b842 + .long 0x54001ce1 + + .private_extern _lj_vm_call_dispatch_f + .no_dead_strip _lj_vm_call_dispatch_f +_lj_vm_call_dispatch_f: + .long 0xf81f8275,0xf9401055,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_vm_cpcall + .no_dead_strip _lj_vm_cpcall +_lj_vm_cpcall: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0xaa0003f7 + .long 0xf9401c1b,0xf9005be0,0xf9400af6,0xf94016f1 + .long 0xf90057e0,0xf9402afc,0xcb11037b,0xb900cbfb + .long 0xb900c7ff,0xf90053fc,0xf9002afd,0xf900bad7 + .long 0xd63f0060,0xaa0003f3,0x528000b5,0xb5fff9f3 + .long 0x17ffff3b + + .private_extern _lj_cont_dispatch + .no_dead_strip _lj_cont_dispatch +_lj_cont_dispatch: + .long 0xf85f0222,0xf85e0260,0xaa1303e3,0xaa1103f3 + .long 0x9240b842,0xf85e8075,0xf9401042,0x8b1c0368 + .long 0xf81f811a,0xf85b8054,0xd61f0000 + + .private_extern _lj_cont_cat + .no_dead_strip _lj_cont_cat +_lj_cont_cat: + .long 0xb85fc2b0,0xd1008061,0xf9400368,0xf90012f3 + .long 0xd3587e11,0xd3483e1b,0x8b110e69,0xeb090029 + .long 0x54000080,0xf9000028,0xd343fd22,0x17fffae0 + .long 0xf83b7a68,0x14000069 + + .private_extern _lj_vmeta_tgets1 + .no_dead_strip _lj_vmeta_tgets1 +_lj_vmeta_tgets1: + .long 0x92800083,0x8b110e61,0x8b03bf83,0x14000004 + + .private_extern _lj_vmeta_tgets + .no_dead_strip _lj_vmeta_tgets +_lj_vmeta_tgets: + .long 0xf2ffff41,0xf90076c1,0x9103a2c1,0x9102e3e2 + .long 0xf9005fe3,0x14000008 + + .private_extern _lj_vmeta_tgetb + .no_dead_strip _lj_vmeta_tgetb +_lj_vmeta_tgetb: + .long 0x8b18039c,0x8b110e61,0x9102e3e2,0xf9005ffc + .long 0x14000003 + + .private_extern _lj_vmeta_tgetv + .no_dead_strip _lj_vmeta_tgetv +_lj_vmeta_tgetv: + .long 0x8b110e61,0x8b1c0e62,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_meta_tget + .long 0xb4000120,0xf9400008,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xd1000a69,0xf94016f3,0x5280021c + .long 0xf85f0262,0xf81e8275,0xcb090275,0x9240b842 + .long 0x17ffff9d + + .private_extern _lj_vmeta_tgetr + .no_dead_strip _lj_vmeta_tgetr +_lj_vmeta_tgetr: + .long 0x93407d21 + bl _lj_tab_getinth + .long 0xaa1a03e8,0xb4ff82e0,0xf9400008,0x17fffc15 + + .private_extern _lj_vmeta_tsets1 + .no_dead_strip _lj_vmeta_tsets1 +_lj_vmeta_tsets1: + .long 0x92800083,0x8b110e61,0x8b03bf83,0x14000004 + + .private_extern _lj_vmeta_tsets + .no_dead_strip _lj_vmeta_tsets +_lj_vmeta_tsets: + .long 0xf2ffff41,0xf90076c1,0x9103a2c1,0x9102e3e2 + .long 0xf9005fe3,0x14000008 + + .private_extern _lj_vmeta_tsetb + .no_dead_strip _lj_vmeta_tsetb +_lj_vmeta_tsetb: + .long 0x8b18039c,0x8b110e61,0x9102e3e2,0xf9005ffc + .long 0x14000003 + + .private_extern _lj_vmeta_tsetv + .no_dead_strip _lj_vmeta_tsetv +_lj_vmeta_tsetv: + .long 0x8b110e61,0x8b1c0e62,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_meta_tset + .long 0xf87b7a68,0xb4000100,0xf9000008,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xd1000a69,0xf94016f3,0x5280031c + .long 0xf85f0262,0xf9000a68,0xf81e8275,0xcb090275 + .long 0x9240b842,0x17ffff70 + + .private_extern _lj_vmeta_tsetr + .no_dead_strip _lj_vmeta_tsetr +_lj_vmeta_tsetr: + .long 0x93407d22,0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_tab_setinth + .long 0x17fffcaf + + .private_extern _lj_vmeta_comp + .no_dead_strip _lj_vmeta_comp +_lj_vmeta_comp: + .long 0x8b1b0e61,0xd10012b5,0x8b1c0e62,0xf90012f3 + .long 0xaa1703e0,0xf90057f5,0x53001e03 + bl _lj_meta_comp + .long 0xf100041f,0x54000748,0x794002b1,0x910012b5 + .long 0x8b110ab1,0xd1408231,0x9a9132b5 + + .private_extern _lj_cont_nop + .no_dead_strip _lj_cont_nop +_lj_cont_nop: + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_cont_ra + .no_dead_strip _lj_cont_ra +_lj_cont_ra: + .long 0xb85fc2b0,0xf9400368,0xd3483e09,0xf8297a68 + .long 0x17fffff6 + + .private_extern _lj_cont_condt + .no_dead_strip _lj_cont_condt +_lj_cont_condt: + .long 0xf9400368,0x92e00029,0xeb08013f,0x17ffffed + + .private_extern _lj_cont_condf + .no_dead_strip _lj_cont_condf +_lj_cont_condf: + .long 0xf9400368,0x92d00009,0xeb09011f,0x17ffffe9 + + .private_extern _lj_vmeta_equal + .no_dead_strip _lj_vmeta_equal +_lj_vmeta_equal: + .long 0x9240b842,0xd10012b5,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_meta_equal + .long 0x17ffffe0 + + .private_extern _lj_vmeta_equal_cd + .no_dead_strip _lj_vmeta_equal_cd +_lj_vmeta_equal_cd: + + .private_extern _lj_vmeta_istype + .no_dead_strip _lj_vmeta_istype +_lj_vmeta_istype: + .long 0xd10012b5,0xf90012f3,0xaa1703e0,0xaa1b03e1 + .long 0xaa1c03e2,0xf90057f5 + bl _lj_meta_istype + .long 0x17ffffdf + + .private_extern _lj_vmeta_arith_vn + .no_dead_strip _lj_vmeta_arith_vn +_lj_vmeta_arith_vn: + .long 0x8b110e62,0x8b1c0e83,0x14000009 + + .private_extern _lj_vmeta_arith_nv + .no_dead_strip _lj_vmeta_arith_nv +_lj_vmeta_arith_nv: + .long 0x8b110e63,0x8b1c0e82,0x14000006 + + .private_extern _lj_vmeta_unm + .no_dead_strip _lj_vmeta_unm +_lj_vmeta_unm: + .long 0x8b1c0e62,0xaa0203e3,0x14000003 + + .private_extern _lj_vmeta_arith_vv + .no_dead_strip _lj_vmeta_arith_vv +_lj_vmeta_arith_vv: + .long 0x8b110e62,0x8b1c0e63,0x53001e04,0x8b1b0e61 + .long 0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_meta_arith + .long 0xb4fff9a0 + + .private_extern _lj_vmeta_binop + .no_dead_strip _lj_vmeta_binop +_lj_vmeta_binop: + .long 0xcb130009,0xf81e8015,0x91000935,0xaa0003f3 + .long 0x5280021c,0x17ffff1c + + .private_extern _lj_vmeta_len + .no_dead_strip _lj_vmeta_len +_lj_vmeta_len: + .long 0x8b1c0e61,0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_meta_len + .long 0x17fffff5 + + .private_extern _lj_vmeta_call + .no_dead_strip _lj_vmeta_call +_lj_vmeta_call: + .long 0xaa1703e0,0xf90012f1,0xd1004261,0xf90057f5 + .long 0x8b1c0262 + bl _lj_meta_call + .long 0xf85f0262,0x9100239c,0x9240b842,0xf81f8275 + .long 0xf9401055,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_vmeta_callt + .no_dead_strip _lj_vmeta_callt +_lj_vmeta_callt: + .long 0xaa1703e0,0xf90012f3,0xd1004361,0xf90057f5 + .long 0x8b1c0362 + bl _lj_meta_call + .long 0xf85f0369,0xf85f8275,0x9100239c,0x9240b922 + .long 0x17fffc75 + + .private_extern _lj_vmeta_for + .no_dead_strip _lj_vmeta_for +_lj_vmeta_for: + .long 0xaa1703e0,0xf90012f3,0xaa1b03e1,0xf90057f5 + bl _lj_meta_for + .long 0xb85fc2b0,0xd3483e1b,0xd3507e1c,0x17fffd80 + + .private_extern _lj_ff_assert + .no_dead_strip _lj_ff_assert +_lj_ff_assert: + .long 0xf9400260,0xf100239f,0x540079e3,0xf85f8275 + .long 0x92d00009,0xeb09001f,0x54007962,0xf81f0260 + .long 0xd1002271,0xf100239b,0x9100239c,0xb40032fb + .long 0xf9400a20,0xd100237b,0xf8008620,0xb5ffffbb + .long 0x14000192 + + .private_extern _lj_ff_type + .no_dead_strip _lj_ff_type +_lj_ff_type: + .long 0xf9400260,0xf100239f,0x540077c3,0x528001a8 + .long 0x936ffc0f,0xb10035ff,0xda8f3109,0x91001929 + .long 0xf8697840,0x14000185 + + .private_extern _lj_ff_getmetatable + .no_dead_strip _lj_ff_getmetatable +_lj_ff_getmetatable: + .long 0xf9400260,0xf100239f,0x54007683,0x936ffc0f + .long 0xb10031ff,0xba4d19e4,0x9240b800,0x54000301 + .long 0xf9401011,0xaa1a03e0,0xf9411adc,0xb4002f31 + .long 0xb9403629,0xb9400f8a,0xf9401622,0x0a0a0129 + .long 0x8b090529,0x92800083,0x8b090c42,0x8b03bf83 + .long 0xa9402040,0xf9400842,0xeb03011f,0x540000a0 + .long 0xb5ffff82,0xaa1103e0,0xf2ffff40,0x14000169 + .long 0xeb1a011f,0x54002ce1,0x17fffffb,0x928001a8 + .long 0xeb0801ff,0x9a8821ef,0xcb0f0ec9,0xf9412931 + .long 0x17ffffe5 + + .private_extern _lj_ff_setmetatable + .no_dead_strip _lj_ff_setmetatable +_lj_ff_setmetatable: + .long 0xa9400660,0xf100439f,0x540071e3,0x936ffc0f + .long 0xb10031ff,0x9240b809,0x54007161,0xf9401128 + .long 0x936ffc2f,0x3940212a,0xb10031ff,0x9240b821 + .long 0xfa400900,0x54007081,0xf9001121,0x36102a0a + .long 0xf94022c8,0x121d794a,0xf90022c9,0x3900212a + .long 0xf9000d28,0x1400014a + + .private_extern _lj_ff_rawget + .no_dead_strip _lj_ff_rawget +_lj_ff_rawget: + .long 0xf9400261,0xf100439f,0x54006f23,0x936ffc2f + .long 0xb10031ff,0x9240b821,0x54006ea1,0xaa1703e0 + .long 0x91002262 + bl _lj_tab_get + .long 0xf9400000,0x1400013e + + .private_extern _lj_ff_tonumber + .no_dead_strip _lj_ff_tonumber +_lj_ff_tonumber: + .long 0xf9400260,0xf100239f,0x54006da1,0xeb40833f + .long 0x54006d63,0x14000138 + + .private_extern _lj_ff_tostring + .no_dead_strip _lj_ff_tostring +_lj_ff_tostring: + .long 0xf9400260,0xf100239f,0x54006ce3,0x936ffc0f + .long 0xb10015ff,0x54002640,0xf94162c9,0xf90012f3 + .long 0xb10039ff,0xfa409920,0xf90057f5,0x54006bc1 + .long 0xa94106c0,0xeb01001f,0x5400004b,0x94000384 + .long 0xaa1703e0,0xaa1303e1 + bl _lj_strfmt_number + .long 0x92800089,0xf94012f3,0x8b09bc00,0x14000121 + + .private_extern _lj_ff_next + .no_dead_strip _lj_ff_next +_lj_ff_next: + .long 0xf9400260,0xf100239f,0x54006a03,0x936ffc0f + .long 0xb10031ff,0x9240b801,0x54006981,0xf83c6a7a + .long 0xf85f8275,0xa9024ef3,0xaa1703e0,0x91002262 + .long 0xf90057f5 + bl _lj_tab_next + .long 0xf81f027a,0xb4002260,0xa9408660,0x5280031c + .long 0xa93f0660,0x14000110 + + .private_extern _lj_ff_pairs + .no_dead_strip _lj_ff_pairs +_lj_ff_pairs: + .long 0xf9400260,0xf100239f,0x54006783,0x936ffc0f + .long 0xb10031ff,0x9240b809,0x54006701,0xf9401843 + .long 0xf85f8275,0x5280041c,0xa93fea60,0xf81f0263 + .long 0x14000103 + + .private_extern _lj_ff_ipairs_aux + .no_dead_strip _lj_ff_ipairs_aux +_lj_ff_ipairs_aux: + .long 0xa9400660,0xf100439f,0x540065e3,0x936ffc0f + .long 0xb10031ff,0x9240b800,0x54006561,0xeb41833f + .long 0x54006521,0xb9403009,0xf9400802,0xb9403408 + .long 0x11000421,0x6b09003f,0xf85f8275,0x8b18002a + .long 0x5280011c,0xf81f026a,0x540000e2,0xf8617848 + .long 0x52800309,0xeb1a011f,0xf81f8268,0x9a89039c + .long 0x140000ea,0x34001d28 + bl _lj_tab_getinth + .long 0xb4001ce0,0xf9400008,0x17fffff7 + + .private_extern _lj_ff_ipairs + .no_dead_strip _lj_ff_ipairs +_lj_ff_ipairs: + .long 0xf9400260,0xf100239f,0x54006223,0x936ffc0f + .long 0xb10031ff,0x9240b809,0x540061a1,0xf9401843 + .long 0xf85f8275,0x5280041c,0xa93fe260,0xf81f0263 + .long 0x140000d8 + + .private_extern _lj_ff_pcall + .no_dead_strip _lj_ff_pcall +_lj_ff_pcall: + .long 0x394246c8,0xf100239c,0x54006083,0xaa1303f1 + .long 0x91004273,0x53041108,0x91005915,0x54ffc3c0 + .long 0x8b1c026a,0xf85f0148,0xf81f8d48,0xeb13015f + .long 0x54ffffa1,0x17fffe18 + + .private_extern _lj_ff_xpcall + .no_dead_strip _lj_ff_xpcall +_lj_ff_xpcall: + .long 0xa9400660,0x394246c8,0xf1004389,0x54005ea3 + .long 0xaa1303f1,0x936ffc2f,0x53041108,0xb10025ff + .long 0x91007915,0x54005de1,0xaa0903fc,0x91006273 + .long 0xa9000221,0xb4ffc15c,0x17ffffec + + .private_extern _lj_ff_coroutine_resume + .no_dead_strip _lj_ff_coroutine_resume +_lj_ff_coroutine_resume: + .long 0xf9400260,0xf100239f,0x54005ce3,0x936ffc0f + .long 0xb1001dff,0x9240b800,0x54005c61,0xf85f8275 + .long 0xf90012f3,0xa9420411,0x39402c09,0x8b090028 + .long 0xf90057f5,0xeb11011f,0x54005b60,0xf100053f + .long 0x91002028,0x9a882021,0xf9401803,0x8b1c0022 + .long 0xf9402811,0xfa439042,0xfa409a22,0x54005a48 + .long 0xd1002042,0x91002273,0xd100239c,0xf9001402 + .long 0xf90016f3,0xb40000dc,0xf8716a68,0xeb1c023f + .long 0xf8316828,0x91002231,0x54ffff81,0x52800002 + .long 0xaa0003fb,0x52800003,0x97fffd8f,0xa9420f62 + .long 0xf100041f,0xf94012f3,0xf900bad7,0xb900bada + .long 0x54000308,0xcb02007c,0xf9401ae0,0x8b1c0261 + .long 0xb400017c,0xeb00003f,0x52800011,0x540002e8 + .long 0xd1002383,0xf9001762,0xf8716848,0xeb03023f + .long 0xf8316a68,0x91002231,0x54ffff81,0x92e00029 + .long 0x9100439c,0xf81f8269,0xd100227b,0xf24006a0 + .long 0xf90057f5,0xb900c3fc,0x54ff7f80,0x17fffd17 + .long 0xf85f8c68,0x92d00009,0x5280031c,0xf9001763 + .long 0xf9000268,0x17fffff4,0xaa1703e0,0xd343ff81 + bl _lj_state_growstack + .long 0x52800000,0x17ffffd9 + + .private_extern _lj_ff_coroutine_wrap_aux + .no_dead_strip _lj_ff_coroutine_wrap_aux +_lj_ff_coroutine_wrap_aux: + .long 0xf9401840,0x9240b800,0xf85f8275,0xf90012f3 + .long 0xa9420411,0x39402c09,0x8b090028,0xf90057f5 + .long 0xeb11011f,0x54005220,0xf100053f,0x91002028 + .long 0x9a882021,0xf9401803,0x8b1c0022,0xf9402811 + .long 0xfa439042,0xfa409a22,0x54005108,0xf9001402 + .long 0xf90016f3,0xb40000dc,0xf8716a68,0xeb1c023f + .long 0xf8316828,0x91002231,0x54ffff81,0x52800002 + .long 0xaa0003fb,0x52800003,0x97fffd48,0xa9420f62 + .long 0xf100041f,0xf94012f3,0xf900bad7,0xb900bada + .long 0x540002c8,0xcb02007c,0xf9401ae0,0x8b1c0261 + .long 0xb400017c,0xeb00003f,0x52800011,0x54000248 + .long 0xd1002383,0xf9001762,0xf8716848,0xeb03023f + .long 0xf8316a68,0x91002231,0x54ffff81,0xaa1303fb + .long 0x9100239c,0xf24006a0,0xf90057f5,0xb900c3fc + .long 0x54ff76e0,0x17fffcd2,0xaa1703e0,0xaa1b03e1 + bl _lj_ffh_coroutine_wrap_err + .long 0xaa1703e0,0xd343ff81 + bl _lj_state_growstack + .long 0x52800000,0x17ffffde + + .private_extern _lj_ff_coroutine_yield + .no_dead_strip _lj_ff_coroutine_yield +_lj_ff_coroutine_yield: + .long 0xf9402ae8,0x8b1c0269,0x52800020,0xa90226f3 + .long 0x36004a88,0xf9002aff,0x39002ee0,0x17fffcd7 + + .private_extern _lj_ff_math_floor + .no_dead_strip _lj_ff_math_floor +_lj_ff_math_floor: + .long 0xf9400260,0xf100239f,0xfd400260,0x540049a3 + .long 0xeb40833f,0x54000320,0x54004943,0x1e654000 + .long 0x14000034 + + .private_extern _lj_ff_math_ceil + .no_dead_strip _lj_ff_math_ceil +_lj_ff_math_ceil: + .long 0xf9400260,0xf100239f,0xfd400260,0x54004883 + .long 0xeb40833f,0x54000200,0x54004823,0x1e64c000 + .long 0x1400002b + + .private_extern _lj_ff_math_abs + .no_dead_strip _lj_ff_math_abs +_lj_ff_math_abs: + .long 0xf9400260,0xf100239f,0x54004783,0xeb40833f + .long 0x54004743,0x9240f800,0x540000c1,0x4a807c01 + .long 0xd2e83c02,0x6b807c20,0x8b180000,0x9a825000 + + .private_extern _lj_fff_restv + .no_dead_strip _lj_fff_restv +_lj_fff_restv: + .long 0xf85f8275,0xf81f0260 + + .private_extern _lj_fff_res1 + .no_dead_strip _lj_fff_res1 +_lj_fff_res1: + .long 0x5280021c + + .private_extern _lj_fff_res + .no_dead_strip _lj_fff_res +_lj_fff_res: + .long 0xf24006a0,0xb900c3fc,0xd100427b,0x54ff93a1 + .long 0xb85fc2b0,0xd3587e11,0xeb110f9f,0x54000123 + .long 0xd3483e09,0xcb090f73,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0x8b1c0369,0x9100239c,0xf81f813a,0x17fffff3 + + .private_extern _lj_ff_math_sqrt + .no_dead_strip _lj_ff_math_sqrt +_lj_ff_math_sqrt: + .long 0xf9400260,0xf100239f,0xfd400260,0x54004303 + .long 0xeb40833f,0x540042c9,0x1e61c000 + + .private_extern _lj_fff_resn + .no_dead_strip _lj_fff_resn +_lj_fff_resn: + .long 0xf85f8275,0xfc1f0260,0x17ffffe2 + + .private_extern _lj_ff_math_log + .no_dead_strip _lj_ff_math_log +_lj_ff_math_log: + .long 0xf9400260,0xf100239f,0xfd400260,0x540041c1 + .long 0xeb40833f,0x54004189 + bl _log + .long 0x17fffff6 + + .private_extern _lj_ff_math_log10 + .no_dead_strip _lj_ff_math_log10 +_lj_ff_math_log10: + .long 0xf9400260,0xf100239f,0xfd400260,0x540040c3 + .long 0xeb40833f,0x54004089 + bl _log10 + .long 0x17ffffee + + .private_extern _lj_ff_math_exp + .no_dead_strip _lj_ff_math_exp +_lj_ff_math_exp: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003fc3 + .long 0xeb40833f,0x54003f89 + bl _exp + .long 0x17ffffe6 + + .private_extern _lj_ff_math_sin + .no_dead_strip _lj_ff_math_sin +_lj_ff_math_sin: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003ec3 + .long 0xeb40833f,0x54003e89 + bl _sin + .long 0x17ffffde + + .private_extern _lj_ff_math_cos + .no_dead_strip _lj_ff_math_cos +_lj_ff_math_cos: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003dc3 + .long 0xeb40833f,0x54003d89 + bl _cos + .long 0x17ffffd6 + + .private_extern _lj_ff_math_tan + .no_dead_strip _lj_ff_math_tan +_lj_ff_math_tan: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003cc3 + .long 0xeb40833f,0x54003c89 + bl _tan + .long 0x17ffffce + + .private_extern _lj_ff_math_asin + .no_dead_strip _lj_ff_math_asin +_lj_ff_math_asin: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003bc3 + .long 0xeb40833f,0x54003b89 + bl _asin + .long 0x17ffffc6 + + .private_extern _lj_ff_math_acos + .no_dead_strip _lj_ff_math_acos +_lj_ff_math_acos: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003ac3 + .long 0xeb40833f,0x54003a89 + bl _acos + .long 0x17ffffbe + + .private_extern _lj_ff_math_atan + .no_dead_strip _lj_ff_math_atan +_lj_ff_math_atan: + .long 0xf9400260,0xf100239f,0xfd400260,0x540039c3 + .long 0xeb40833f,0x54003989 + bl _atan + .long 0x17ffffb6 + + .private_extern _lj_ff_math_sinh + .no_dead_strip _lj_ff_math_sinh +_lj_ff_math_sinh: + .long 0xf9400260,0xf100239f,0xfd400260,0x540038c3 + .long 0xeb40833f,0x54003889 + bl _sinh + .long 0x17ffffae + + .private_extern _lj_ff_math_cosh + .no_dead_strip _lj_ff_math_cosh +_lj_ff_math_cosh: + .long 0xf9400260,0xf100239f,0xfd400260,0x540037c3 + .long 0xeb40833f,0x54003789 + bl _cosh + .long 0x17ffffa6 + + .private_extern _lj_ff_math_tanh + .no_dead_strip _lj_ff_math_tanh +_lj_ff_math_tanh: + .long 0xf9400260,0xf100239f,0xfd400260,0x540036c3 + .long 0xeb40833f,0x54003689 + bl _tanh + .long 0x17ffff9e + + .private_extern _lj_ff_math_pow + .no_dead_strip _lj_ff_math_pow +_lj_ff_math_pow: + .long 0xa9400660,0xf100439f,0x6d400660,0x540035c3 + .long 0xeb40833f,0x54003589,0xeb41833f,0x54003549 + bl _pow + .long 0x17ffff94 + + .private_extern _lj_ff_math_atan2 + .no_dead_strip _lj_ff_math_atan2 +_lj_ff_math_atan2: + .long 0xa9400660,0xf100439f,0x6d400660,0x54003483 + .long 0xeb40833f,0x54003449,0xeb41833f,0x54003409 + bl _atan2 + .long 0x17ffff8a + + .private_extern _lj_ff_math_fmod + .no_dead_strip _lj_ff_math_fmod +_lj_ff_math_fmod: + .long 0xa9400660,0xf100439f,0x6d400660,0x54003343 + .long 0xeb40833f,0x54003309,0xeb41833f,0x540032c9 + bl _fmod + .long 0x17ffff80 + + .private_extern _lj_ff_math_ldexp + .no_dead_strip _lj_ff_math_ldexp +_lj_ff_math_ldexp: + .long 0xa9400660,0xf100439f,0x54003223,0xfd400260 + .long 0xeb40833f,0x540031c9,0xeb41833f,0x54003181 + .long 0x93407c20 + bl _ldexp + .long 0x17ffff75 + + .private_extern _lj_ff_math_frexp + .no_dead_strip _lj_ff_math_frexp +_lj_ff_math_frexp: + .long 0xf9400260,0xf100239f,0xfd400260,0x540030a3 + .long 0xeb40833f,0x54003069,0x9102e3e0 + bl _frexp + .long 0xb940bbe1,0xf85f8275,0xfc1f0260,0x5280031c + .long 0x8b180021,0xf81f8261,0x17ffff4b + + .private_extern _lj_ff_math_modf + .no_dead_strip _lj_ff_math_modf +_lj_ff_math_modf: + .long 0xf9400260,0xf100239f,0xfd400260,0x54002ec3 + .long 0xeb40833f,0x54002e89,0xd1004260,0xf85f8275 + bl _modf + .long 0x5280031c,0xfc1f8260,0x17ffff3f + + .private_extern _lj_ff_math_min + .no_dead_strip _lj_ff_math_min +_lj_ff_math_min: + .long 0xf9400260,0xf100239f,0x54002d63,0x8b1c0271 + .long 0x9100227b,0xeb40833f,0x540001c1,0xf9400361 + .long 0xeb11037f,0x54ffe642,0xeb41833f,0x540000a1 + .long 0x6b01001f,0x9100237b,0x9a80c020,0x17fffff8 + .long 0x1e620000,0x54002b83,0xfd400361,0x14000009 + .long 0xfd400260,0x54002b03,0xf9400361,0xfd400361 + .long 0xeb11037f,0x54ffe802,0xeb41833f,0x540000a9 + .long 0x1e612000,0x9100237b,0x1e605c20,0x17fffff7 + .long 0x1e620021,0x54002983,0x17fffffa + + .private_extern _lj_ff_math_max + .no_dead_strip _lj_ff_math_max +_lj_ff_math_max: + .long 0xf9400260,0xf100239f,0x54002903,0x8b1c0271 + .long 0x9100227b,0xeb40833f,0x540001c1,0xf9400361 + .long 0xeb11037f,0x54ffe1e2,0xeb41833f,0x540000a1 + .long 0x6b01001f,0x9100237b,0x9a80b020,0x17fffff8 + .long 0x1e620000,0x54002723,0xfd400361,0x14000009 + .long 0xfd400260,0x540026a3,0xf9400361,0xfd400361 + .long 0xeb11037f,0x54ffe3a2,0xeb41833f,0x540000a9 + .long 0x1e612000,0x9100237b,0x1e60dc20,0x17fffff7 + .long 0x1e620021,0x54002523,0x17fffffa + + .private_extern _lj_ff_string_byte + .no_dead_strip _lj_ff_string_byte +_lj_ff_string_byte: + .long 0xa97f8275,0xf100239f,0x936ffc0f,0xba4509e0 + .long 0x9240b800,0x54002441,0x39406008,0xb9401402 + .long 0x8b180108,0xf81f0268,0x5280011c,0xb4ffdda2 + .long 0x17fffeeb + + .private_extern _lj_ff_string_char + .no_dead_strip _lj_ff_string_char +_lj_ff_string_char: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x94000141 + .long 0xa97f8275,0x7103fc1f,0xfa489b80,0x54002261 + .long 0xeb40833f,0x54002221,0x52800022,0x91001e61 + + .private_extern _lj_fff_newstr + .no_dead_strip _lj_fff_newstr +_lj_fff_newstr: + .long 0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_str_new + + .private_extern _lj_fff_resstr + .no_dead_strip _lj_fff_resstr +_lj_fff_resstr: + .long 0xf94012f3,0x92800089,0x8b09bc00,0x17fffed5 + + .private_extern _lj_ff_string_sub + .no_dead_strip _lj_ff_string_sub +_lj_ff_string_sub: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x9400012d + .long 0xf9400260,0xf9400a62,0xf100439f,0x92800011 + .long 0x540000a0,0x54001fa3,0xeb42833f,0x54001f61 + .long 0x93407c51,0xf9400661,0x936ffc0f,0xb10015ff + .long 0x9240b800,0x54001ea1,0xb9401409,0xeb41833f + .long 0x54001e41,0x93407c21,0x8b09022a,0xf100023f + .long 0x8b090028,0x9a8aa631,0xf100003f,0x9a88a421 + .long 0xf100023f,0x9a9fa231,0xf100043f,0x9a9fa421 + .long 0xeb09023f,0x9a89d231,0x91005c00,0xeb010222 + .long 0x8b010001,0x91000442,0x54fffa4a,0x9101e2c0 + .long 0x92800089,0x8b09bc00,0x17fffeaa + + .private_extern _lj_ff_string_reverse + .no_dead_strip _lj_ff_string_reverse +_lj_ff_string_reverse: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x94000102 + .long 0xf9400261,0xf100239f,0x936ffc2f,0xba4529e0 + .long 0x9240b821,0x54001a41,0xf9406ec8,0x910322c0 + .long 0xf90012f3,0xf90057f5,0xf90072d7,0xf90066c8 + bl _lj_buf_putstr_reverse + bl _lj_buf_tostr + .long 0x17ffffbf + + .private_extern _lj_ff_string_lower + .no_dead_strip _lj_ff_string_lower +_lj_ff_string_lower: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x940000ef + .long 0xf9400261,0xf100239f,0x936ffc2f,0xba4529e0 + .long 0x9240b821,0x540017e1,0xf9406ec8,0x910322c0 + .long 0xf90012f3,0xf90057f5,0xf90072d7,0xf90066c8 + bl _lj_buf_putstr_lower + bl _lj_buf_tostr + .long 0x17ffffac + + .private_extern _lj_ff_string_upper + .no_dead_strip _lj_ff_string_upper +_lj_ff_string_upper: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x940000dc + .long 0xf9400261,0xf100239f,0x936ffc2f,0xba4529e0 + .long 0x9240b821,0x54001581,0xf9406ec8,0x910322c0 + .long 0xf90012f3,0xf90057f5,0xf90072d7,0xf90066c8 + bl _lj_buf_putstr_upper + bl _lj_buf_tostr + .long 0x17ffff99 + + .private_extern _lj_vm_tobit_fb + .no_dead_strip _lj_vm_tobit_fb +_lj_vm_tobit_fb: + .long 0x54001449,0x8b000001,0x52808682,0xcb41d442 + .long 0xf100d45f,0x540000e8,0x9240d021,0xb24b0021 + .long 0xf100001f,0x9ac22421,0x5a815420,0xd61f03c0 + .long 0x52800000,0xd61f03c0 + + .private_extern _lj_ff_bit_band + .no_dead_strip _lj_ff_bit_band +_lj_ff_bit_band: + .long 0xf9400260,0xf100239f,0x54001243,0x1000007e + .long 0xeb40833f,0x54fffda1,0x5280011b,0x2a0003e8 + .long 0x100000fe,0xf87b6a60,0xeb1c037f,0x9100237b + .long 0x540005ca,0xeb40833f,0x54fffc81,0x0a000108 + .long 0x17fffff9 + + .private_extern _lj_ff_bit_bor + .no_dead_strip _lj_ff_bit_bor +_lj_ff_bit_bor: + .long 0xf9400260,0xf100239f,0x54001023,0x1000007e + .long 0xeb40833f,0x54fffb81,0x5280011b,0x2a0003e8 + .long 0x100000fe,0xf87b6a60,0xeb1c037f,0x9100237b + .long 0x540003aa,0xeb40833f,0x54fffa61,0x2a000108 + .long 0x17fffff9 + + .private_extern _lj_ff_bit_bxor + .no_dead_strip _lj_ff_bit_bxor +_lj_ff_bit_bxor: + .long 0xf9400260,0xf100239f,0x54000e03,0x1000007e + .long 0xeb40833f,0x54fff961,0x5280011b,0x2a0003e8 + .long 0x100000fe,0xf87b6a60,0xeb1c037f,0x9100237b + .long 0x5400018a,0xeb40833f,0x54fff841,0x4a000108 + .long 0x17fffff9 + + .private_extern _lj_ff_bit_tobit + .no_dead_strip _lj_ff_bit_tobit +_lj_ff_bit_tobit: + .long 0xf9400260,0xf100239f,0x54000be3,0x1000007e + .long 0xeb40833f,0x54fff741,0x2a0003e8,0x8b180100 + .long 0x17fffe27 + + .private_extern _lj_ff_bit_bswap + .no_dead_strip _lj_ff_bit_bswap +_lj_ff_bit_bswap: + .long 0xf9400260,0xf100239f,0x54000ac3,0x1000007e + .long 0xeb40833f,0x54fff621,0x5ac00808,0x8b180100 + .long 0x17fffe1e + + .private_extern _lj_ff_bit_bnot + .no_dead_strip _lj_ff_bit_bnot +_lj_ff_bit_bnot: + .long 0xf9400260,0xf100239f,0x540009a3,0x1000007e + .long 0xeb40833f,0x54fff501,0x2a2003e8,0x8b180100 + .long 0x17fffe15 + + .private_extern _lj_ff_bit_lshift + .no_dead_strip _lj_ff_bit_lshift +_lj_ff_bit_lshift: + .long 0xa9400268,0xf100439f,0x54000883,0x1000007e + .long 0xeb40833f,0x54fff3e1,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54fff341,0x1ac92008 + .long 0x8b180100,0x17fffe07 + + .private_extern _lj_ff_bit_rshift + .no_dead_strip _lj_ff_bit_rshift +_lj_ff_bit_rshift: + .long 0xa9400268,0xf100439f,0x540006c3,0x1000007e + .long 0xeb40833f,0x54fff221,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54fff181,0x1ac92408 + .long 0x8b180100,0x17fffdf9 + + .private_extern _lj_ff_bit_arshift + .no_dead_strip _lj_ff_bit_arshift +_lj_ff_bit_arshift: + .long 0xa9400268,0xf100439f,0x54000503,0x1000007e + .long 0xeb40833f,0x54fff061,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54ffefc1,0x1ac92808 + .long 0x8b180100,0x17fffdeb + + .private_extern _lj_ff_bit_rol + .no_dead_strip _lj_ff_bit_rol +_lj_ff_bit_rol: + .long 0xa9400268,0xf100439f,0x54000343,0x1000007e + .long 0xeb40833f,0x54ffeea1,0xcb0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54ffee01,0x1ac92c08 + .long 0x8b180100,0x17fffddd + + .private_extern _lj_ff_bit_ror + .no_dead_strip _lj_ff_bit_ror +_lj_ff_bit_ror: + .long 0xa9400268,0xf100439f,0x54000183,0x1000007e + .long 0xeb40833f,0x54ffece1,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54ffec41,0x1ac92c08 + .long 0x8b180100,0x17fffdcf + + .private_extern _lj_fff_fallback + .no_dead_strip _lj_fff_fallback +_lj_fff_fallback: + .long 0xa97f5662,0xf9401aea,0x8b1c0269,0xa90226f3 + .long 0x9240b842,0x91028129,0xf9401442,0xf90057f5 + .long 0xeb0a013f,0xaa1703e0,0x54000368,0xd63f0040 + .long 0xf94012f3,0x7100001f,0xd37df01c,0xd100427b + .long 0x54ffb82c,0xf94016e0,0xf85f0262,0xcb13001c + .long 0x54000121,0x9240b842,0xf9401055,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0x8b1b0e7b + .long 0xd61f0100 + + .private_extern _lj_vm_call_tail + .no_dead_strip _lj_vm_call_tail +_lj_vm_call_tail: + .long 0xf24006a8,0x927df2a9,0x54000081,0x385fe2bb + .long 0xd37df37b,0x91004369,0xcb090271,0x17fffafb + .long 0x52800281 + bl _lj_state_growstack + .long 0xf94012f3,0xeb00001f,0x17ffffe8 + + .private_extern _lj_fff_gcstep + .no_dead_strip _lj_fff_gcstep +_lj_fff_gcstep: + .long 0x8b1c0261,0xaa1e03fb,0xa90206f3,0xf90057f5 + .long 0xaa1703e0 + bl _lj_gc_step + .long 0xa94206f3,0xf85f0262,0xaa1b03fe,0xcb13003c + .long 0x9240b842,0xd65f03c0 + + .private_extern _lj_vm_record + .no_dead_strip _lj_vm_record +_lj_vm_record: + + .private_extern _lj_vm_rethook + .no_dead_strip _lj_vm_rethook +_lj_vm_rethook: + .long 0x394246ca,0x3620018a,0xf943d528,0xd61f0100 + + .private_extern _lj_vm_inshook + .no_dead_strip _lj_vm_inshook +_lj_vm_inshook: + .long 0x394246ca,0xb9414acb,0x3727ff8a,0x721e055f + .long 0x54ffff40,0x5100056b,0xb9014acb,0x3400004b + .long 0x3617feca,0xaa1703e0,0xf90012f3,0xaa1503e1 + bl _lj_dispatch_ins + .long 0xf94012f3,0xb85fc2b0,0x8b300ec9,0xd3483e1b + .long 0xf943d528,0xd3507e1c,0xd61f0100 + + .private_extern _lj_cont_hook + .no_dead_strip _lj_cont_hook +_lj_cont_hook: + .long 0xf85d8060,0x910012b5,0xb900c3e0,0x17fffff7 + + .private_extern _lj_vm_hotloop + .no_dead_strip _lj_vm_hotloop +_lj_vm_hotloop: + + .private_extern _lj_vm_callhook + .no_dead_strip _lj_vm_callhook +_lj_vm_callhook: + .long 0xaa1503e1 + + .private_extern _lj_vm_hotcall + .no_dead_strip _lj_vm_hotcall +_lj_vm_hotcall: + .long 0x8b1c0269,0xf90057f5,0xaa1703e0,0xcb13037b + .long 0xa90226f3 + bl _lj_dispatch_call + .long 0xa94226f3,0xf90057ff,0xf85f0262,0x8b1b027b + .long 0xcb13013c,0xb85fc2b0,0x9240b842,0xd61f0000 + + .private_extern _lj_cont_stitch + .no_dead_strip _lj_cont_stitch +_lj_cont_stitch: + + .private_extern _lj_vm_profhook + .no_dead_strip _lj_vm_profhook +_lj_vm_profhook: + .long 0xaa1703e0,0xf90012f3,0xaa1503e1 + bl _lj_dispatch_profile + .long 0xf94012f3,0xd10012b5,0x17fffb63 + + .private_extern _lj_vm_exit_handler + .no_dead_strip _lj_vm_exit_handler +_lj_vm_exit_handler: + + .private_extern _lj_vm_exit_interp + .no_dead_strip _lj_vm_exit_interp +_lj_vm_exit_interp: + + .private_extern _lj_vm_modi + .no_dead_strip _lj_vm_modi +_lj_vm_modi: + .long 0x4a010003,0x7100007f,0x4a807c02,0x4a817c23 + .long 0x4b807c42,0x4b817c63,0x1ac30840,0x1b038800 + .long 0x7a404804,0x4b030002,0x1a820000,0x4a010002 + .long 0x7100005f,0x5a805400,0xd65f03c0 + + .private_extern _lj_vm_ffi_callback + .no_dead_strip _lj_vm_ffi_callback +_lj_vm_ffi_callback: + + .private_extern _lj_cont_ffi_callback + .no_dead_strip _lj_cont_ffi_callback +_lj_cont_ffi_callback: + + .private_extern _lj_vm_ffi_call + .no_dead_strip _lj_vm_ffi_call +_lj_vm_ffi_call: + + .cstring + .ascii "DynASM 1.4.0\0" + diff --git a/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_vmdef.h b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_vmdef.h new file mode 100644 index 000000000..db4fcd74a --- /dev/null +++ b/core/src/luajit/autogen/iphoneos/nojit/arm64/lj_vmdef.h @@ -0,0 +1,360 @@ +-- This is a generated file. DO NOT EDIT! + +return { + +bcnames = "ISLT ISGE ISLE ISGT ISEQV ISNEV ISEQS ISNES ISEQN ISNEN ISEQP ISNEP ISTC ISFC IST ISF ISTYPEISNUM MOV NOT UNM LEN ADDVN SUBVN MULVN DIVVN MODVN ADDNV SUBNV MULNV DIVNV MODNV ADDVV SUBVV MULVV DIVVV MODVV POW CAT KSTR KCDATAKSHORTKNUM KPRI KNIL UGET USETV USETS USETN USETP UCLO FNEW TNEW TDUP GGET GSET TGETV TGETS TGETB TGETR TSETV TSETS TSETB TSETM TSETR CALLM CALL CALLMTCALLT ITERC ITERN VARG ISNEXTRETM RET RET0 RET1 FORI JFORI FORL IFORL JFORL ITERL IITERLJITERLLOOP ILOOP JLOOP JMP FUNCF IFUNCFJFUNCFFUNCV IFUNCVJFUNCVFUNCC FUNCCW", + +irnames = "LT GE LE GT ULT UGE ULE UGT EQ NE ABC RETF NOP BASE PVAL GCSTEPHIOP LOOP USE PHI RENAMEPROF KPRI KINT KGC KPTR KKPTR KNULL KNUM KINT64KSLOT BNOT BSWAP BAND BOR BXOR BSHL BSHR BSAR BROL BROR ADD SUB MUL DIV MOD POW NEG ABS LDEXP MIN MAX FPMATHADDOV SUBOV MULOV AREF HREFK HREF NEWREFUREFO UREFC FREF STRREFLREF ALOAD HLOAD ULOAD FLOAD XLOAD SLOAD VLOAD ALEN ASTOREHSTOREUSTOREFSTOREXSTORESNEW XSNEW TNEW TDUP CNEW CNEWI BUFHDRBUFPUTBUFSTRTBAR OBAR XBAR CONV TOBIT TOSTR STRTO CALLN CALLA CALLL CALLS CALLXSCARG ", + +irfpm = { [0]="floor", "ceil", "trunc", "sqrt", "log", "log2", "other", }, + +irfield = { [0]="str.len", "func.env", "func.pc", "func.ffid", "thread.env", "tab.meta", "tab.array", "tab.node", "tab.asize", "tab.hmask", "tab.nomm", "udata.meta", "udata.udtype", "udata.file", "cdata.ctypeid", "cdata.ptr", "cdata.int", "cdata.int64", "cdata.int64_4", }, + +ircall = { +[0]="lj_str_cmp", +"lj_str_find", +"lj_str_new", +"lj_strscan_num", +"lj_strfmt_int", +"lj_strfmt_num", +"lj_strfmt_char", +"lj_strfmt_putint", +"lj_strfmt_putnum", +"lj_strfmt_putquoted", +"lj_strfmt_putfxint", +"lj_strfmt_putfnum_int", +"lj_strfmt_putfnum_uint", +"lj_strfmt_putfnum", +"lj_strfmt_putfstr", +"lj_strfmt_putfchar", +"lj_buf_putmem", +"lj_buf_putstr", +"lj_buf_putchar", +"lj_buf_putstr_reverse", +"lj_buf_putstr_lower", +"lj_buf_putstr_upper", +"lj_buf_putstr_rep", +"lj_buf_puttab", +"lj_buf_tostr", +"lj_tab_new_ah", +"lj_tab_new1", +"lj_tab_dup", +"lj_tab_clear", +"lj_tab_newkey", +"lj_tab_len", +"lj_tab_len_hint", +"lj_gc_step_jit", +"lj_gc_barrieruv", +"lj_mem_newgco", +"lj_prng_u64d", +"lj_vm_modi", +"log10", +"exp", +"sin", +"cos", +"tan", +"asin", +"acos", +"atan", +"sinh", +"cosh", +"tanh", +"fputc", +"fwrite", +"fflush", +"lj_vm_floor", +"lj_vm_ceil", +"lj_vm_trunc", +"sqrt", +"log", +"lj_vm_log2", +"lj_vm_powi", +"pow", +"atan2", +"ldexp", +"lj_vm_tobit", +"softfp_add", +"softfp_sub", +"softfp_mul", +"softfp_div", +"softfp_cmp", +"softfp_i2d", +"softfp_d2i", +"lj_vm_sfmin", +"lj_vm_sfmax", +"lj_vm_tointg", +"softfp_ui2d", +"softfp_f2d", +"softfp_d2ui", +"softfp_d2f", +"softfp_i2f", +"softfp_ui2f", +"softfp_f2i", +"softfp_f2ui", +"fp64_l2d", +"fp64_ul2d", +"fp64_l2f", +"fp64_ul2f", +"fp64_d2l", +"fp64_d2ul", +"fp64_f2l", +"fp64_f2ul", +"lj_carith_divi64", +"lj_carith_divu64", +"lj_carith_modi64", +"lj_carith_modu64", +"lj_carith_powi64", +"lj_carith_powu64", +"lj_cdata_newv", +"lj_cdata_setfin", +"strlen", +"memcpy", +"memset", +"lj_vm_errno", +"lj_carith_mul64", +"lj_carith_shl64", +"lj_carith_shr64", +"lj_carith_sar64", +"lj_carith_rol64", +"lj_carith_ror64", +}, + +traceerr = { +[0]="error thrown or hook called during recording", +"trace too short", +"trace too long", +"trace too deep", +"too many snapshots", +"blacklisted", +"retry recording", +"NYI: bytecode %d", +"leaving loop in root trace", +"inner loop in root trace", +"loop unroll limit reached", +"bad argument type", +"JIT compilation disabled for function", +"call unroll limit reached", +"down-recursion, restarting", +"NYI: unsupported variant of FastFunc %s", +"NYI: return to lower frame", +"store with nil or NaN key", +"missing metamethod", +"looping index lookup", +"NYI: mixed sparse/dense table", +"symbol not in cache", +"NYI: unsupported C type conversion", +"NYI: unsupported C function type", +"guard would always fail", +"too many PHIs", +"persistent type instability", +"failed to allocate mcode memory", +"machine code too long", +"hit mcode limit (retrying)", +"too many spill slots", +"inconsistent register allocation", +"NYI: cannot assemble IR instruction %d", +"NYI: PHI shuffling too complex", +"NYI: register coalescing too complex", +}, + +ffnames = { +[0]="Lua", +"C", +"assert", +"type", +"next", +"pairs", +"ipairs_aux", +"ipairs", +"getmetatable", +"setmetatable", +"getfenv", +"setfenv", +"rawget", +"rawset", +"rawequal", +"unpack", +"select", +"tonumber", +"tostring", +"error", +"pcall", +"xpcall", +"loadfile", +"load", +"loadstring", +"dofile", +"gcinfo", +"collectgarbage", +"newproxy", +"print", +"coroutine.status", +"coroutine.running", +"coroutine.isyieldable", +"coroutine.create", +"coroutine.yield", +"coroutine.resume", +"coroutine.wrap_aux", +"coroutine.wrap", +"math.abs", +"math.floor", +"math.ceil", +"math.sqrt", +"math.log10", +"math.exp", +"math.sin", +"math.cos", +"math.tan", +"math.asin", +"math.acos", +"math.atan", +"math.sinh", +"math.cosh", +"math.tanh", +"math.frexp", +"math.modf", +"math.log", +"math.atan2", +"math.pow", +"math.fmod", +"math.ldexp", +"math.min", +"math.max", +"math.random", +"math.randomseed", +"bit.tobit", +"bit.bnot", +"bit.bswap", +"bit.lshift", +"bit.rshift", +"bit.arshift", +"bit.rol", +"bit.ror", +"bit.band", +"bit.bor", +"bit.bxor", +"bit.tohex", +"string.byte", +"string.char", +"string.sub", +"string.rep", +"string.reverse", +"string.lower", +"string.upper", +"string.dump", +"string.find", +"string.match", +"string.gmatch_aux", +"string.gmatch", +"string.gsub", +"string.format", +"table.maxn", +"table.insert", +"table.concat", +"table.sort", +"table.new", +"table.clear", +"io.method.close", +"io.method.read", +"io.method.write", +"io.method.flush", +"io.method.seek", +"io.method.setvbuf", +"io.method.lines", +"io.method.__gc", +"io.method.__tostring", +"io.open", +"io.popen", +"io.tmpfile", +"io.close", +"io.read", +"io.write", +"io.flush", +"io.input", +"io.output", +"io.lines", +"io.type", +"os.execute", +"os.remove", +"os.rename", +"os.tmpname", +"os.getenv", +"os.exit", +"os.clock", +"os.date", +"os.time", +"os.difftime", +"os.setlocale", +"debug.getregistry", +"debug.getmetatable", +"debug.setmetatable", +"debug.getfenv", +"debug.setfenv", +"debug.getinfo", +"debug.getlocal", +"debug.setlocal", +"debug.getupvalue", +"debug.setupvalue", +"debug.upvalueid", +"debug.upvaluejoin", +"debug.sethook", +"debug.gethook", +"debug.debug", +"debug.traceback", +"jit.on", +"jit.off", +"jit.flush", +"jit.status", +"jit.security", +"jit.attach", +"jit.util.funcinfo", +"jit.util.funcbc", +"jit.util.funck", +"jit.util.funcuvname", +"jit.profile.start", +"jit.profile.stop", +"jit.profile.dumpstack", +"ffi.meta.__index", +"ffi.meta.__newindex", +"ffi.meta.__eq", +"ffi.meta.__len", +"ffi.meta.__lt", +"ffi.meta.__le", +"ffi.meta.__concat", +"ffi.meta.__call", +"ffi.meta.__add", +"ffi.meta.__sub", +"ffi.meta.__mul", +"ffi.meta.__div", +"ffi.meta.__mod", +"ffi.meta.__pow", +"ffi.meta.__unm", +"ffi.meta.__tostring", +"ffi.meta.__pairs", +"ffi.meta.__ipairs", +"ffi.clib.__index", +"ffi.clib.__newindex", +"ffi.clib.__gc", +"ffi.callback.free", +"ffi.callback.set", +"ffi.cdef", +"ffi.new", +"ffi.cast", +"ffi.typeof", +"ffi.typeinfo", +"ffi.istype", +"ffi.sizeof", +"ffi.alignof", +"ffi.offsetof", +"ffi.errno", +"ffi.string", +"ffi.copy", +"ffi.fill", +"ffi.abi", +"ffi.metatype", +"ffi.gc", +"ffi.load", +}, + +} + diff --git a/core/src/luajit/autogen/macosx/jit/arm64/lj_bcdef.h b/core/src/luajit/autogen/macosx/jit/arm64/lj_bcdef.h new file mode 100644 index 000000000..349b9c940 --- /dev/null +++ b/core/src/luajit/autogen/macosx/jit/arm64/lj_bcdef.h @@ -0,0 +1,220 @@ +/* This is a generated file. DO NOT EDIT! */ + +LJ_DATADEF const uint16_t lj_bc_ofs[] = { +0, +128, +256, +384, +512, +644, +772, +852, +932, +1072, +1212, +1280, +1348, +1412, +1476, +1532, +1588, +1624, +1660, +1692, +1740, +1808, +1880, +1988, +2096, +2212, +2284, +2400, +2508, +2616, +2732, +2804, +2920, +3028, +3136, +3252, +3324, +3440, +3512, +3588, +3632, +3676, +3712, +3744, +3776, +3824, +3876, +3988, +4092, +4144, +4196, +4256, +4328, +4424, +4508, +4532, +4556, +4696, +4844, +4952, +5024, +5200, +5452, +5596, +5744, +5848, +5864, +5936, +5948, +6136, +6216, +6380, +6568, +6688, +6708, +6876, +6980, +7092, +7236, +7392, +7420, +7560, +7692, +7720, +7772, +7820, +7848, +7872, +7908, +7940, +7968, +8032, +8080, +8080, +8212, +8216, +8288, +10256, +10324, +10764, +10844, +10896, +11016, +10364, +10512, +10600, +10648, +10672, +11068, +11124, +11764, +11184, +11500, +11868, +11796, +11832, +12008, +12080, +12112, +12144, +12176, +12208, +12240, +12272, +12304, +12336, +12368, +12400, +12596, +12656, +12048, +12472, +12432, +12512, +12552, +12704, +12844, +13776, +13848, +13812, +13884, +13940, +13996, +14052, +14108, +13572, +13640, +13708, +12984, +13036, +13116, +13288, +13364, +13440 +}; + +LJ_DATADEF const uint16_t lj_bc_mode[] = { +BCDEF(BCMODE) +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF +}; + diff --git a/core/src/luajit/autogen/macosx/jit/arm64/lj_ffdef.h b/core/src/luajit/autogen/macosx/jit/arm64/lj_ffdef.h new file mode 100644 index 000000000..428e44ccc --- /dev/null +++ b/core/src/luajit/autogen/macosx/jit/arm64/lj_ffdef.h @@ -0,0 +1,211 @@ +/* This is a generated file. DO NOT EDIT! */ + +FFDEF(assert) +FFDEF(type) +FFDEF(next) +FFDEF(pairs) +FFDEF(ipairs_aux) +FFDEF(ipairs) +FFDEF(getmetatable) +FFDEF(setmetatable) +FFDEF(getfenv) +FFDEF(setfenv) +FFDEF(rawget) +FFDEF(rawset) +FFDEF(rawequal) +FFDEF(unpack) +FFDEF(select) +FFDEF(tonumber) +FFDEF(tostring) +FFDEF(error) +FFDEF(pcall) +FFDEF(xpcall) +FFDEF(loadfile) +FFDEF(load) +FFDEF(loadstring) +FFDEF(dofile) +FFDEF(gcinfo) +FFDEF(collectgarbage) +FFDEF(newproxy) +FFDEF(print) +FFDEF(coroutine_status) +FFDEF(coroutine_running) +FFDEF(coroutine_isyieldable) +FFDEF(coroutine_create) +FFDEF(coroutine_yield) +FFDEF(coroutine_resume) +FFDEF(coroutine_wrap_aux) +FFDEF(coroutine_wrap) +FFDEF(math_abs) +FFDEF(math_floor) +FFDEF(math_ceil) +FFDEF(math_sqrt) +FFDEF(math_log10) +FFDEF(math_exp) +FFDEF(math_sin) +FFDEF(math_cos) +FFDEF(math_tan) +FFDEF(math_asin) +FFDEF(math_acos) +FFDEF(math_atan) +FFDEF(math_sinh) +FFDEF(math_cosh) +FFDEF(math_tanh) +FFDEF(math_frexp) +FFDEF(math_modf) +FFDEF(math_log) +FFDEF(math_atan2) +FFDEF(math_pow) +FFDEF(math_fmod) +FFDEF(math_ldexp) +FFDEF(math_min) +FFDEF(math_max) +FFDEF(math_random) +FFDEF(math_randomseed) +FFDEF(bit_tobit) +FFDEF(bit_bnot) +FFDEF(bit_bswap) +FFDEF(bit_lshift) +FFDEF(bit_rshift) +FFDEF(bit_arshift) +FFDEF(bit_rol) +FFDEF(bit_ror) +FFDEF(bit_band) +FFDEF(bit_bor) +FFDEF(bit_bxor) +FFDEF(bit_tohex) +FFDEF(string_byte) +FFDEF(string_char) +FFDEF(string_sub) +FFDEF(string_rep) +FFDEF(string_reverse) +FFDEF(string_lower) +FFDEF(string_upper) +FFDEF(string_dump) +FFDEF(string_find) +FFDEF(string_match) +FFDEF(string_gmatch_aux) +FFDEF(string_gmatch) +FFDEF(string_gsub) +FFDEF(string_format) +FFDEF(table_maxn) +FFDEF(table_insert) +FFDEF(table_concat) +FFDEF(table_sort) +FFDEF(table_new) +FFDEF(table_clear) +FFDEF(io_method_close) +FFDEF(io_method_read) +FFDEF(io_method_write) +FFDEF(io_method_flush) +FFDEF(io_method_seek) +FFDEF(io_method_setvbuf) +FFDEF(io_method_lines) +FFDEF(io_method___gc) +FFDEF(io_method___tostring) +FFDEF(io_open) +FFDEF(io_popen) +FFDEF(io_tmpfile) +FFDEF(io_close) +FFDEF(io_read) +FFDEF(io_write) +FFDEF(io_flush) +FFDEF(io_input) +FFDEF(io_output) +FFDEF(io_lines) +FFDEF(io_type) +FFDEF(os_execute) +FFDEF(os_remove) +FFDEF(os_rename) +FFDEF(os_tmpname) +FFDEF(os_getenv) +FFDEF(os_exit) +FFDEF(os_clock) +FFDEF(os_date) +FFDEF(os_time) +FFDEF(os_difftime) +FFDEF(os_setlocale) +FFDEF(debug_getregistry) +FFDEF(debug_getmetatable) +FFDEF(debug_setmetatable) +FFDEF(debug_getfenv) +FFDEF(debug_setfenv) +FFDEF(debug_getinfo) +FFDEF(debug_getlocal) +FFDEF(debug_setlocal) +FFDEF(debug_getupvalue) +FFDEF(debug_setupvalue) +FFDEF(debug_upvalueid) +FFDEF(debug_upvaluejoin) +FFDEF(debug_sethook) +FFDEF(debug_gethook) +FFDEF(debug_debug) +FFDEF(debug_traceback) +FFDEF(jit_on) +FFDEF(jit_off) +FFDEF(jit_flush) +FFDEF(jit_status) +FFDEF(jit_security) +FFDEF(jit_attach) +FFDEF(jit_util_funcinfo) +FFDEF(jit_util_funcbc) +FFDEF(jit_util_funck) +FFDEF(jit_util_funcuvname) +FFDEF(jit_util_traceinfo) +FFDEF(jit_util_traceir) +FFDEF(jit_util_tracek) +FFDEF(jit_util_tracesnap) +FFDEF(jit_util_tracemc) +FFDEF(jit_util_traceexitstub) +FFDEF(jit_util_ircalladdr) +FFDEF(jit_opt_start) +FFDEF(jit_profile_start) +FFDEF(jit_profile_stop) +FFDEF(jit_profile_dumpstack) +FFDEF(ffi_meta___index) +FFDEF(ffi_meta___newindex) +FFDEF(ffi_meta___eq) +FFDEF(ffi_meta___len) +FFDEF(ffi_meta___lt) +FFDEF(ffi_meta___le) +FFDEF(ffi_meta___concat) +FFDEF(ffi_meta___call) +FFDEF(ffi_meta___add) +FFDEF(ffi_meta___sub) +FFDEF(ffi_meta___mul) +FFDEF(ffi_meta___div) +FFDEF(ffi_meta___mod) +FFDEF(ffi_meta___pow) +FFDEF(ffi_meta___unm) +FFDEF(ffi_meta___tostring) +FFDEF(ffi_meta___pairs) +FFDEF(ffi_meta___ipairs) +FFDEF(ffi_clib___index) +FFDEF(ffi_clib___newindex) +FFDEF(ffi_clib___gc) +FFDEF(ffi_callback_free) +FFDEF(ffi_callback_set) +FFDEF(ffi_cdef) +FFDEF(ffi_new) +FFDEF(ffi_cast) +FFDEF(ffi_typeof) +FFDEF(ffi_typeinfo) +FFDEF(ffi_istype) +FFDEF(ffi_sizeof) +FFDEF(ffi_alignof) +FFDEF(ffi_offsetof) +FFDEF(ffi_errno) +FFDEF(ffi_string) +FFDEF(ffi_copy) +FFDEF(ffi_fill) +FFDEF(ffi_abi) +FFDEF(ffi_metatype) +FFDEF(ffi_gc) +FFDEF(ffi_load) + +#undef FFDEF + +#ifndef FF_NUM_ASMFUNC +#define FF_NUM_ASMFUNC 57 +#endif + diff --git a/core/src/luajit/autogen/macosx/jit/arm64/lj_folddef.h b/core/src/luajit/autogen/macosx/jit/arm64/lj_folddef.h new file mode 100644 index 000000000..45d5daf74 --- /dev/null +++ b/core/src/luajit/autogen/macosx/jit/arm64/lj_folddef.h @@ -0,0 +1,1168 @@ +/* This is a generated file. DO NOT EDIT! */ + +static const FoldFunc fold_func[] = { + fold_kfold_numarith, + fold_kfold_numabsneg, + fold_kfold_ldexp, + fold_kfold_fpmath, + fold_kfold_fpcall1, + fold_kfold_fpcall2, + fold_kfold_numpow, + fold_kfold_numcomp, + fold_kfold_intarith, + fold_kfold_intovarith, + fold_kfold_bnot, + fold_kfold_bswap, + fold_kfold_intcomp, + fold_kfold_intcomp0, + fold_kfold_int64arith, + fold_kfold_int64arith2, + fold_kfold_int64shift, + fold_kfold_bnot64, + fold_kfold_bswap64, + fold_kfold_int64comp, + fold_kfold_int64comp0, + fold_kfold_snew_kptr, + fold_kfold_snew_empty, + fold_kfold_strref, + fold_kfold_strref_snew, + fold_kfold_strcmp, + fold_bufput_append, + fold_bufput_kgc, + fold_bufstr_kfold_cse, + fold_bufput_kfold_op, + fold_bufput_kfold_rep, + fold_bufput_kfold_fmt, + fold_kfold_add_kgc, + fold_kfold_add_kptr, + fold_kfold_add_kright, + fold_kfold_tobit, + fold_kfold_conv_kint_num, + fold_kfold_conv_kintu32_num, + fold_kfold_conv_kint_ext, + fold_kfold_conv_kint_i64, + fold_kfold_conv_kint64_num_i64, + fold_kfold_conv_kint64_num_u64, + fold_kfold_conv_kint64_int_i64, + fold_kfold_conv_knum_int_num, + fold_kfold_conv_knum_u32_num, + fold_kfold_conv_knum_i64_num, + fold_kfold_conv_knum_u64_num, + fold_kfold_tostr_knum, + fold_kfold_tostr_kint, + fold_kfold_strto, + lj_opt_cse, + fold_kfold_kref, + fold_shortcut_round, + fold_shortcut_left, + fold_shortcut_dropleft, + fold_shortcut_leftleft, + fold_simplify_numadd_negx, + fold_simplify_numadd_xneg, + fold_simplify_numsub_k, + fold_simplify_numsub_negk, + fold_simplify_numsub_xneg, + fold_simplify_nummuldiv_k, + fold_simplify_nummuldiv_negk, + fold_simplify_nummuldiv_negneg, + fold_simplify_numpow_xkint, + fold_simplify_numpow_xknum, + fold_simplify_numpow_kx, + fold_shortcut_conv_num_int, + fold_simplify_conv_int_num, + fold_simplify_conv_i64_num, + fold_simplify_conv_int_i64, + fold_simplify_conv_flt_num, + fold_simplify_tobit_conv, + fold_simplify_floor_conv, + fold_simplify_conv_sext, + fold_simplify_conv_narrow, + fold_cse_conv, + fold_narrow_convert, + fold_simplify_intadd_k, + fold_simplify_intmul_k, + fold_simplify_intsub_k, + fold_simplify_intsub_kleft, + fold_simplify_intadd_k64, + fold_simplify_intsub_k64, + fold_simplify_intmul_k32, + fold_simplify_intmul_k64, + fold_simplify_intmod_k, + fold_simplify_intmod_kleft, + fold_simplify_intsub, + fold_simplify_intsubadd_leftcancel, + fold_simplify_intsubsub_leftcancel, + fold_simplify_intsubsub_rightcancel, + fold_simplify_intsubadd_rightcancel, + fold_simplify_intsubaddadd_cancel, + fold_simplify_band_k, + fold_simplify_bor_k, + fold_simplify_bxor_k, + fold_simplify_shift_ik, + fold_simplify_shift_andk, + fold_simplify_shift1_ki, + fold_simplify_shift2_ki, + fold_simplify_shiftk_andk, + fold_simplify_andk_shiftk, + fold_simplify_andor_k, + fold_simplify_andor_k64, + fold_reassoc_intarith_k, + fold_reassoc_intarith_k64, + fold_reassoc_dup, + fold_reassoc_dup_minmax, + fold_reassoc_bxor, + fold_reassoc_shift, + fold_reassoc_minmax_k, + fold_abc_fwd, + fold_abc_k, + fold_abc_invar, + fold_comm_swap, + fold_comm_equal, + fold_comm_comp, + fold_comm_dup, + fold_comm_dup_minmax, + fold_comm_bxor, + fold_merge_eqne_snew_kgc, + lj_opt_fwd_aload, + fold_kfold_hload_kkptr, + lj_opt_fwd_hload, + lj_opt_fwd_uload, + lj_opt_fwd_alen, + fold_cse_uref, + lj_opt_fwd_hrefk, + fold_fwd_href_tnew, + fold_fwd_href_tdup, + fold_fload_tab_tnew_asize, + fold_fload_tab_tnew_hmask, + fold_fload_tab_tdup_asize, + fold_fload_tab_tdup_hmask, + fold_fload_tab_ah, + fold_fload_str_len_kgc, + fold_fload_str_len_snew, + fold_fload_str_len_tostr, + fold_fload_cdata_typeid_kgc, + fold_fload_cdata_int64_kgc, + fold_fload_cdata_typeid_cnew, + fold_fload_cdata_ptr_int64_cnew, + lj_opt_cse, + lj_opt_fwd_fload, + fold_fwd_sload, + fold_xload_kptr, + lj_opt_fwd_xload, + fold_barrier_tab, + fold_barrier_tnew_tdup, + fold_prof, + lj_opt_dse_ahstore, + lj_opt_dse_ustore, + lj_opt_dse_fstore, + lj_opt_dse_xstore, + lj_ir_emit +}; + +static const uint32_t fold_hash[1002] = { +0x0f5a741d, +0xffffffff, +0xffffffff, +0x6e4a9417, +0xffffffff, +0x634877ff, +0x8775ffff, +0xffffffff, +0xffffffff, +0x8789fc09, +0x83894008, +0xffffffff, +0x644e5fff, +0xffffffff, +0x0c0c5c17, +0x26b45e71, +0xffffffff, +0x0e52741d, +0xffffffff, +0xffffffff, +0x66429417, +0xffffffff, +0xffffffff, +0x586dffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4db4a6ae, +0x46b56a95, +0x0c045c17, +0x169dfc17, +0x2cb4728e, +0xffffffff, +0xffffffff, +0x30b85fff, +0xffffffff, +0xffffffff, +0x7765ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x37408000, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0e42741d, +0x2253fc18, +0xffffffff, +0xffffffff, +0xffffffff, +0x096e5c17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3468d000, +0xffffffff, +0xffffffff, +0x66429017, +0x5d54a429, +0xffffffff, +0x8f89fc04, +0xffffffff, +0xffffffff, +0xffffffff, +0x6a44881d, +0x08665c17, +0x5855ffff, +0x82754416, +0x624bfc21, +0x86894409, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0712701c, +0xffffffff, +0x6b4287ff, +0xffffffff, +0x085e5c17, +0x27b45ed4, +0xffffffff, +0x0d0bfc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9bbfffff, +0x10507417, +0xffffffff, +0xffffffff, +0x070a701c, +0x5557fc1d, +0xffffffff, +0xffffffff, +0x08565c17, +0x7645ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6844841d, +0x10487417, +0x817543ff, +0x0702701c, +0xffffffff, +0x84894009, +0xffffffff, +0x084e5c17, +0xffffffff, +0x26b45e72, +0xffffffff, +0x7f7863ff, +0x7c85fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4e6dfc17, +0xffffffff, +0x6047fc1d, +0xffffffff, +0xffffffff, +0xffffffff, +0x08465c17, +0x46b56a96, +0x4bb4ae95, +0xffffffff, +0x79113818, +0x01607044, +0xffffffff, +0xffffffff, +0x1dc18c09, +0xffffffff, +0xffffffff, +0x2152681d, +0x3312741d, +0xffffffff, +0x67428817, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0064701c, +0xffffffff, +0x2253fc19, +0xffffffff, +0xffffffff, +0x9b9fffff, +0xffffffff, +0x405dfc17, +0x130a741d, +0xffffffff, +0xffffffff, +0xffffffff, +0x3468d001, +0xffffffff, +0x3213101b, +0xffffffff, +0xffffffff, +0x12407400, +0x065c701c, +0xffffffff, +0xffffffff, +0x654a8417, +0x9897ffff, +0x47b569ae, +0x5055fc17, +0x1302741d, +0x4bb4aa95, +0xffffffff, +0xffffffff, +0xffffffff, +0x2ab47675, +0xffffffff, +0xffffffff, +0x2eb472ce, +0x0054701c, +0x8a897000, +0x2152641d, +0x8b88600e, +0x69428417, +0x5c55fc29, +0x8f8fffff, +0x0a3e5c00, +0x614dfc17, +0x6e4c9817, +0xffffffff, +0xffffffff, +0x6956ac17, +0xffffffff, +0x7215ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x33106fff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x5f45fc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x750dffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4bb4a695, +0xffffffff, +0xffffffff, +0xffffffff, +0x3d59fc1c, +0x23b6701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x2052601d, +0xffffffff, +0x7505ffff, +0xffffffff, +0x0f5c741d, +0x3560c044, +0x44b56a8e, +0xffffffff, +0x928a6bff, +0x634a77ff, +0x9b77ffff, +0x05bd8c3b, +0x88886000, +0x4bb4ae96, +0xffffffff, +0xffffffff, +0x64505fff, +0xffffffff, +0x0c0e5c17, +0x1fc18c0a, +0xffffffff, +0x0e54741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x1dc18c13, +0x736fffff, +0x19bd8c00, +0xffffffff, +0xffffffff, +0x6a468c1d, +0xffffffff, +0x63485fff, +0x2253fc1a, +0x0c065c17, +0x3311fc1b, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7767ffff, +0x3468d002, +0xffffffff, +0x6b448bff, +0x94affc00, +0x28b475d5, +0x3660bc44, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0e44741d, +0x82754418, +0xffffffff, +0x4bb4aa96, +0xffffffff, +0xffffffff, +0xffffffff, +0x4ab5fed3, +0x04bc73ff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8c88600f, +0x5b55fc2a, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7357ffff, +0xffffffff, +0x7115fc17, +0x624dfc21, +0x43b569d3, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7015fc29, +0x24b45dd3, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3b54bc1c, +0xffffffff, +0xffffffff, +0x4bb4a696, +0x9bc1ffff, +0xffffffff, +0xffffffff, +0x070c701c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7847ffff, +0x49696800, +0xffffffff, +0x02627017, +0x95af4400, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x104a7417, +0xffffffff, +0xffffffff, +0x0704701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x08505c17, +0xffffffff, +0xffffffff, +0x1fc18c0b, +0x7f7a63ff, +0x7d87fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0x94b1ffff, +0x1dc18c14, +0x4f6ffc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x08485c17, +0xffffffff, +0xffffffff, +0xffffffff, +0x79133818, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9ba9ffff, +0x31ba6000, +0xffffffff, +0x27b45eb3, +0xffffffff, +0x69448817, +0x29b475d6, +0xffffffff, +0xffffffff, +0x6e4e9c17, +0x95af4000, +0xffffffff, +0x0066701c, +0x45b56ace, +0xffffffff, +0xffffffff, +0xffffffff, +0x9ba1ffff, +0xffffffff, +0xffffffff, +0x130c741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8c886010, +0xffffffff, +0x3852bfff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9999ffff, +0xffffffff, +0x5457fc17, +0x1304741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x187f3bff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0056701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x67448417, +0x7e91ffff, +0x25b45dd4, +0x0b405c00, +0x614ffc17, +0x46b56a75, +0x48b7681c, +0xffffffff, +0x2bb4726e, +0xffffffff, +0x9b17ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x33126fff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9089ffff, +0xffffffff, +0x6047fc17, +0x49696801, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x750fffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6a52a41d, +0xffffffff, +0x515477ff, +0x21526817, +0xffffffff, +0xffffffff, +0xffffffff, +0x1fc18c0c, +0xffffffff, +0x575a5fff, +0xffffffff, +0xffffffff, +0x7507ffff, +0x6d468fff, +0x1dc18c15, +0x9bb20000, +0xffffffff, +0xffffffff, +0xffffffff, +0x644c77ff, +0x9479ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6c64cbff, +0xffffffff, +0xffffffff, +0xffffffff, +0x33105c17, +0xffffffff, +0x425c73ff, +0x0e56741d, +0xffffffff, +0x27b45eb4, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x634a5fff, +0xffffffff, +0x0c085c17, +0x3313fc1b, +0xffffffff, +0x21526417, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8c886011, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0c005c17, +0xffffffff, +0xffffffff, +0x0e46741d, +0xffffffff, +0xffffffff, +0xffffffff, +0x8d894c0e, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x46b56a76, +0x4bb4ae75, +0xffffffff, +0x096a5c17, +0xffffffff, +0xffffffff, +0x624ffc21, +0x8f89fc0e, +0xffffffff, +0x20526017, +0xffffffff, +0x33106018, +0x159c6817, +0xffffffff, +0xffffffff, +0xffffffff, +0x49696802, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3e56bc1c, +0xffffffff, +0xffffffff, +0x9bc3ffff, +0x8d89480e, +0xffffffff, +0xffffffff, +0x070e701c, +0xffffffff, +0x1fc18c0d, +0xffffffff, +0x085a5c17, +0xffffffff, +0xffffffff, +0x69468c17, +0xffffffff, +0x1ec18c16, +0xffffffff, +0x6e50a017, +0xffffffff, +0x4bb4aa75, +0x104c7417, +0x4db6a81c, +0xffffffff, +0x0706701c, +0x5253fc1d, +0x6f64c817, +0x2db472ae, +0x08525c17, +0xffffffff, +0xffffffff, +0xffffffff, +0x065c7017, +0x8f89fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3953fc2f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x084a5c17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x1babffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x5e43fc1d, +0xffffffff, +0xffffffff, +0xffffffff, +0x08425c17, +0xffffffff, +0xffffffff, +0x4bb4a675, +0x4db6a41c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8e894c0f, +0xffffffff, +0xffffffff, +0x130e741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x44b56a6e, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7b846800, +0xffffffff, +0x8789fc06, +0x654e8417, +0x4bb4ae76, +0x9a9bffff, +0xffffffff, +0x1306741d, +0xffffffff, +0x8f89fc0f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0058701c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9793ffff, +0xffffffff, +0x6151fc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6c66cfff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x1fc18c0e, +0x938bffff, +0xffffffff, +0x6149fc17, +0xffffffff, +0x3f56bc2f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7411ffff, +0x4bb4aa76, +0xffffffff, +0xffffffff, +0xffffffff, +0x4ab5feb3, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x415dfc1c, +0xffffffff, +0xffffffff, +0xffffffff, +0x8f89fc01, +0xffffffff, +0xffffffff, +0x7509ffff, +0x1aab5056, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x644e77ff, +0xffffffff, +0xffffffff, +0x3a55fc1c, +0x8275441c, +0xffffffff, +0xffffffff, +0x51545fff, +0xffffffff, +0x33125c17, +0x7501ffff, +0xffffffff, +0x0f58741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8073ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x140bfc1d, +0x4bb4a676, +0x644c5fff, +0xffffffff, +0x0c0a5c17, +0xffffffff, +0x8e894c10, +0xffffffff, +0x2ab47695, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x736bffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0c025c17, +0x8789fc07, +0xffffffff, +0xffffffff, +0xffffffff, +0x26b45e6f, +0xffffffff, +0x8f89fc10, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6e489017, +0xffffffff, +0xffffffff, +0xffffffff, +0x6952a417, +0xffffffff, +0xffffffff, +0xffffffff, +0x096c5c17, +0xffffffff, +0x2fb873ff, +0x6251fc21, +0x6f66cc17, +0x9ba3fc00, +0xffffffff, +0xffffffff, +0x33126018, +0xffffffff, +0x1fc18c0f, +0xffffffff, +0xffffffff, +0xffffffff, +0x4db4aa6e, +0x89893800, +0x6842881d, +0x08645c17, +0x45b56aae, +0x7353ffff, +0x6249fc21, +0xffffffff, +0xffffffff, +0x3e58bc1c, +0xffffffff, +0xffffffff, +0x9bc5ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0710701c, +0xffffffff, +0xffffffff, +0x373e7c00, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x104e7417, +0xffffffff, +0xffffffff, +0x0708701c, +0x5355fc1d, +0xffffffff, +0xffffffff, +0x08545c17, +0x7643ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4db4a66e, +0x4cb5ffff, +0x6a42841d, +0x3c55fc2f, +0xffffffff, +0x0700701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x084c5c17, +0x6a56ac1d, +0xffffffff, +0xffffffff, +0x8e894c11, +0x7a83fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0x1cadffff, +0xffffffff, +0x4e6bfc17, +0xffffffff, +0x5f45fc1d, +0xffffffff, +0xffffffff, +0xffffffff, +0x08445c17, +0x5a54abff, +0x8789fc08, +0xffffffff, +0x375ebfff, +0x015e7044, +0xffffffff, +0x26b45e70, +0xffffffff, +0x8f89fc11, +0x9ba5ffff, +0xffffffff, +0x3310741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x962bffff, +0xffffffff, +0xffffffff, +0x0062701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x65508417, +0xffffffff, +0xffffffff, +0x565bfc17, +0x1308741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3211101b, +0xffffffff, +0xffffffff, +0x113e7400, +0xffffffff, +0xffffffff, +0xffffffff, +0x65488417, +0x9795ffff, +0xffffffff, +0x4e53fc17, +0x5954a7ff, +0x1300741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0052701c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x918dffff, +0xffffffff, +0x614bfc17, +0xffffffff, +0x3f58bc2f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7413ffff, +0x85894408, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x5e43fc17, +0xffffffff, +0xffffffff, +0x177e6017, +0xffffffff, +0x27b45ed3, +0xffffffff, +0x750bffff, +0x036873ff, +0xffffffff, +0xffffffff, +0x4db4aaae, +0xffffffff, +0xffffffff, +0x645077ff, +0xffffffff, +0xffffffff, +0x3d57fc1c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0c145c17, +0x7503ffff, +0xffffffff, +0xffffffff +}; + +#define fold_hashkey(k) (lj_rol(lj_rol((k),21)-(k),1)%1001) + diff --git a/core/src/luajit/autogen/macosx/jit/arm64/lj_libdef.h b/core/src/luajit/autogen/macosx/jit/arm64/lj_libdef.h new file mode 100644 index 000000000..6e35da521 --- /dev/null +++ b/core/src/luajit/autogen/macosx/jit/arm64/lj_libdef.h @@ -0,0 +1,422 @@ +/* This is a generated file. DO NOT EDIT! */ + +#ifdef LJLIB_MODULE_base +#undef LJLIB_MODULE_base +static const lua_CFunction lj_lib_cf_base[] = { + lj_ffh_assert, + lj_ffh_next, + lj_ffh_pairs, + lj_ffh_ipairs_aux, + lj_ffh_ipairs, + lj_ffh_setmetatable, + lj_cf_getfenv, + lj_cf_setfenv, + lj_ffh_rawget, + lj_cf_rawset, + lj_cf_rawequal, + lj_cf_unpack, + lj_cf_select, + lj_ffh_tonumber, + lj_ffh_tostring, + lj_cf_error, + lj_ffh_pcall, + lj_cf_loadfile, + lj_cf_load, + lj_cf_loadstring, + lj_cf_dofile, + lj_cf_gcinfo, + lj_cf_collectgarbage, + lj_cf_newproxy, + lj_cf_print +}; +static const uint8_t lj_lib_init_base[] = { +2,0,28,70,97,115,115,101,114,116,195,110,105,108,199,98,111,111,108,101,97, +110,252,1,200,117,115,101,114,100,97,116,97,198,115,116,114,105,110,103,197, +117,112,118,97,108,198,116,104,114,101,97,100,197,112,114,111,116,111,200,102, +117,110,99,116,105,111,110,197,116,114,97,99,101,197,99,100,97,116,97,197,116, +97,98,108,101,252,9,198,110,117,109,98,101,114,132,116,121,112,101,68,110,101, +120,116,253,69,112,97,105,114,115,64,253,70,105,112,97,105,114,115,140,103, +101,116,109,101,116,97,116,97,98,108,101,76,115,101,116,109,101,116,97,116, +97,98,108,101,7,103,101,116,102,101,110,118,7,115,101,116,102,101,110,118,70, +114,97,119,103,101,116,6,114,97,119,115,101,116,8,114,97,119,101,113,117,97, +108,6,117,110,112,97,99,107,6,115,101,108,101,99,116,72,116,111,110,117,109, +98,101,114,72,116,111,115,116,114,105,110,103,5,101,114,114,111,114,69,112, +99,97,108,108,134,120,112,99,97,108,108,8,108,111,97,100,102,105,108,101,4, +108,111,97,100,10,108,111,97,100,115,116,114,105,110,103,6,100,111,102,105, +108,101,6,103,99,105,110,102,111,14,99,111,108,108,101,99,116,103,97,114,98, +97,103,101,252,2,8,110,101,119,112,114,111,120,121,200,116,111,115,116,114, +105,110,103,5,112,114,105,110,116,252,3,200,95,86,69,82,83,73,79,78,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_coroutine +#undef LJLIB_MODULE_coroutine +static const lua_CFunction lj_lib_cf_coroutine[] = { + lj_cf_coroutine_status, + lj_cf_coroutine_running, + lj_cf_coroutine_isyieldable, + lj_cf_coroutine_create, + lj_ffh_coroutine_yield, + lj_ffh_coroutine_resume, + lj_cf_coroutine_wrap +}; +static const uint8_t lj_lib_init_coroutine[] = { +30,13,7,6,115,116,97,116,117,115,7,114,117,110,110,105,110,103,11,105,115,121, +105,101,108,100,97,98,108,101,6,99,114,101,97,116,101,69,121,105,101,108,100, +70,114,101,115,117,109,101,254,4,119,114,97,112,255 +}; +#endif + +#ifdef LJLIB_MODULE_math +#undef LJLIB_MODULE_math +static const lua_CFunction lj_lib_cf_math[] = { + lj_ffh_math_abs, + lj_ffh_math_sqrt, + lj_ffh_math_log, + lj_ffh_math_atan2, + lj_ffh_math_ldexp, + lj_ffh_math_min, + lj_cf_math_random, + lj_cf_math_randomseed +}; +static const uint8_t lj_lib_init_math[] = { +38,16,30,67,97,98,115,133,102,108,111,111,114,132,99,101,105,108,68,115,113, +114,116,133,108,111,103,49,48,131,101,120,112,131,115,105,110,131,99,111,115, +131,116,97,110,132,97,115,105,110,132,97,99,111,115,132,97,116,97,110,132,115, +105,110,104,132,99,111,115,104,132,116,97,110,104,133,102,114,101,120,112,132, +109,111,100,102,67,108,111,103,249,3,100,101,103,0,1,2,0,0,1,2,24,1,0,0,76, +1,2,0,241,135,158,166,3,220,203,178,130,4,249,3,114,97,100,0,1,2,0,0,1,2,24, +1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,69,97,116,97,110,50,131, +112,111,119,132,102,109,111,100,69,108,100,101,120,112,67,109,105,110,131,109, +97,120,251,24,45,68,84,251,33,9,64,194,112,105,250,251,0,0,0,0,0,0,240,127, +196,104,117,103,101,250,252,2,6,114,97,110,100,111,109,252,2,10,114,97,110, +100,111,109,115,101,101,100,255 +}; +#endif + +#ifdef LJLIB_MODULE_bit +#undef LJLIB_MODULE_bit +static const lua_CFunction lj_lib_cf_bit[] = { + lj_ffh_bit_tobit, + lj_ffh_bit_bnot, + lj_ffh_bit_bswap, + lj_ffh_bit_lshift, + lj_ffh_bit_band, + lj_cf_bit_tohex +}; +static const uint8_t lj_lib_init_bit[] = { +64,40,12,69,116,111,98,105,116,68,98,110,111,116,69,98,115,119,97,112,70,108, +115,104,105,102,116,134,114,115,104,105,102,116,135,97,114,115,104,105,102, +116,131,114,111,108,131,114,111,114,68,98,97,110,100,131,98,111,114,132,98, +120,111,114,5,116,111,104,101,120,255 +}; +#endif + +#ifdef LJLIB_MODULE_string +#undef LJLIB_MODULE_string +static const lua_CFunction lj_lib_cf_string[] = { + lj_ffh_string_byte, + lj_ffh_string_char, + lj_ffh_string_sub, + lj_cf_string_rep, + lj_ffh_string_reverse, + lj_cf_string_dump, + lj_cf_string_find, + lj_cf_string_match, + lj_cf_string_gmatch, + lj_cf_string_gsub, + lj_cf_string_format +}; +static const uint8_t lj_lib_init_string[] = { +76,51,14,249,3,108,101,110,0,1,2,0,0,0,3,16,0,5,0,21,1,0,0,76,1,2,0,68,98,121, +116,101,68,99,104,97,114,67,115,117,98,3,114,101,112,71,114,101,118,101,114, +115,101,133,108,111,119,101,114,133,117,112,112,101,114,4,100,117,109,112,4, +102,105,110,100,5,109,97,116,99,104,254,6,103,109,97,116,99,104,4,103,115,117, +98,6,102,111,114,109,97,116,255 +}; +#endif + +#ifdef LJLIB_MODULE_table +#undef LJLIB_MODULE_table +static const lua_CFunction lj_lib_cf_table[] = { + lj_cf_table_maxn, + lj_cf_table_insert, + lj_cf_table_concat, + lj_cf_table_sort +}; +static const uint8_t lj_lib_init_table[] = { +90,57,9,249,8,102,111,114,101,97,99,104,105,0,2,10,0,0,0,15,16,0,12,0,16,1, +9,0,41,2,1,0,21,3,0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,8,5,0,59,9,5,0,66,6,3, +2,10,6,0,0,88,7,1,128,76,6,2,0,79,2,248,127,75,0,1,0,249,7,102,111,114,101, +97,99,104,0,2,11,0,0,0,16,16,0,12,0,16,1,9,0,43,2,0,0,18,3,0,0,41,4,0,0,88, +5,7,128,18,7,1,0,18,9,5,0,18,10,6,0,66,7,3,2,10,7,0,0,88,8,1,128,76,7,2,0,70, +5,3,3,82,5,247,127,75,0,1,0,249,4,103,101,116,110,0,1,2,0,0,0,3,16,0,12,0,21, +1,0,0,76,1,2,0,4,109,97,120,110,6,105,110,115,101,114,116,249,6,114,101,109, +111,118,101,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128,8,2,0,0, +88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14,0,41,3, +1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2,0,41,6, +1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4,2,0,76, +3,2,0,75,0,1,0,0,2,249,4,109,111,118,101,0,5,12,0,0,0,35,16,0,12,0,16,1,14, +0,16,2,14,0,16,3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88,5,24, +128,33,5,1,3,0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128,18,6, +1,0,18,7,2,0,41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252,127, +88,6,8,128,18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9,0,64, +11,10,4,79,6,252,127,76,4,2,0,6,99,111,110,99,97,116,4,115,111,114,116,254, +254,255 +}; +#endif + +#ifdef LJLIB_MODULE_io_method +#undef LJLIB_MODULE_io_method +static const lua_CFunction lj_lib_cf_io_method[] = { + lj_cf_io_method_close, + lj_cf_io_method_read, + lj_cf_io_method_write, + lj_cf_io_method_flush, + lj_cf_io_method_seek, + lj_cf_io_method_setvbuf, + lj_cf_io_method_lines, + lj_cf_io_method___gc, + lj_cf_io_method___tostring +}; +static const uint8_t lj_lib_init_io_method[] = { +96,57,10,5,99,108,111,115,101,4,114,101,97,100,5,119,114,105,116,101,5,102, +108,117,115,104,4,115,101,101,107,7,115,101,116,118,98,117,102,5,108,105,110, +101,115,4,95,95,103,99,10,95,95,116,111,115,116,114,105,110,103,252,1,199,95, +95,105,110,100,101,120,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_io +#undef LJLIB_MODULE_io +static const lua_CFunction lj_lib_cf_io[] = { + lj_cf_io_open, + lj_cf_io_popen, + lj_cf_io_tmpfile, + lj_cf_io_close, + lj_cf_io_read, + lj_cf_io_write, + lj_cf_io_flush, + lj_cf_io_input, + lj_cf_io_output, + lj_cf_io_lines, + lj_cf_io_type +}; +static const uint8_t lj_lib_init_io[] = { +105,57,12,252,2,192,250,4,111,112,101,110,5,112,111,112,101,110,7,116,109,112, +102,105,108,101,5,99,108,111,115,101,4,114,101,97,100,5,119,114,105,116,101, +5,102,108,117,115,104,5,105,110,112,117,116,6,111,117,116,112,117,116,5,108, +105,110,101,115,4,116,121,112,101,255 +}; +#endif + +#ifdef LJLIB_MODULE_os +#undef LJLIB_MODULE_os +static const lua_CFunction lj_lib_cf_os[] = { + lj_cf_os_execute, + lj_cf_os_remove, + lj_cf_os_rename, + lj_cf_os_tmpname, + lj_cf_os_getenv, + lj_cf_os_exit, + lj_cf_os_clock, + lj_cf_os_date, + lj_cf_os_time, + lj_cf_os_difftime, + lj_cf_os_setlocale +}; +static const uint8_t lj_lib_init_os[] = { +116,57,11,7,101,120,101,99,117,116,101,6,114,101,109,111,118,101,6,114,101, +110,97,109,101,7,116,109,112,110,97,109,101,6,103,101,116,101,110,118,4,101, +120,105,116,5,99,108,111,99,107,4,100,97,116,101,4,116,105,109,101,8,100,105, +102,102,116,105,109,101,9,115,101,116,108,111,99,97,108,101,255 +}; +#endif + +#ifdef LJLIB_MODULE_debug +#undef LJLIB_MODULE_debug +static const lua_CFunction lj_lib_cf_debug[] = { + lj_cf_debug_getregistry, + lj_cf_debug_getmetatable, + lj_cf_debug_setmetatable, + lj_cf_debug_getfenv, + lj_cf_debug_setfenv, + lj_cf_debug_getinfo, + lj_cf_debug_getlocal, + lj_cf_debug_setlocal, + lj_cf_debug_getupvalue, + lj_cf_debug_setupvalue, + lj_cf_debug_upvalueid, + lj_cf_debug_upvaluejoin, + lj_cf_debug_sethook, + lj_cf_debug_gethook, + lj_cf_debug_debug, + lj_cf_debug_traceback +}; +static const uint8_t lj_lib_init_debug[] = { +127,57,16,11,103,101,116,114,101,103,105,115,116,114,121,12,103,101,116,109, +101,116,97,116,97,98,108,101,12,115,101,116,109,101,116,97,116,97,98,108,101, +7,103,101,116,102,101,110,118,7,115,101,116,102,101,110,118,7,103,101,116,105, +110,102,111,8,103,101,116,108,111,99,97,108,8,115,101,116,108,111,99,97,108, +10,103,101,116,117,112,118,97,108,117,101,10,115,101,116,117,112,118,97,108, +117,101,9,117,112,118,97,108,117,101,105,100,11,117,112,118,97,108,117,101, +106,111,105,110,7,115,101,116,104,111,111,107,7,103,101,116,104,111,111,107, +5,100,101,98,117,103,9,116,114,97,99,101,98,97,99,107,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit +#undef LJLIB_MODULE_jit +static const lua_CFunction lj_lib_cf_jit[] = { + lj_cf_jit_on, + lj_cf_jit_off, + lj_cf_jit_flush, + lj_cf_jit_status, + lj_cf_jit_security, + lj_cf_jit_attach +}; +static const uint8_t lj_lib_init_jit[] = { +143,57,10,2,111,110,3,111,102,102,5,102,108,117,115,104,6,115,116,97,116,117, +115,8,115,101,99,117,114,105,116,121,6,97,116,116,97,99,104,252,5,194,111,115, +250,252,4,196,97,114,99,104,250,252,3,203,118,101,114,115,105,111,110,95,110, +117,109,250,252,2,199,118,101,114,115,105,111,110,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit_util +#undef LJLIB_MODULE_jit_util +static const lua_CFunction lj_lib_cf_jit_util[] = { + lj_cf_jit_util_funcinfo, + lj_cf_jit_util_funcbc, + lj_cf_jit_util_funck, + lj_cf_jit_util_funcuvname, + lj_cf_jit_util_traceinfo, + lj_cf_jit_util_traceir, + lj_cf_jit_util_tracek, + lj_cf_jit_util_tracesnap, + lj_cf_jit_util_tracemc, + lj_cf_jit_util_traceexitstub, + lj_cf_jit_util_ircalladdr +}; +static const uint8_t lj_lib_init_jit_util[] = { +149,57,11,8,102,117,110,99,105,110,102,111,6,102,117,110,99,98,99,5,102,117, +110,99,107,10,102,117,110,99,117,118,110,97,109,101,9,116,114,97,99,101,105, +110,102,111,7,116,114,97,99,101,105,114,6,116,114,97,99,101,107,9,116,114,97, +99,101,115,110,97,112,7,116,114,97,99,101,109,99,13,116,114,97,99,101,101,120, +105,116,115,116,117,98,10,105,114,99,97,108,108,97,100,100,114,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit_opt +#undef LJLIB_MODULE_jit_opt +static const lua_CFunction lj_lib_cf_jit_opt[] = { + lj_cf_jit_opt_start +}; +static const uint8_t lj_lib_init_jit_opt[] = { +160,57,1,5,115,116,97,114,116,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit_profile +#undef LJLIB_MODULE_jit_profile +static const lua_CFunction lj_lib_cf_jit_profile[] = { + lj_cf_jit_profile_start, + lj_cf_jit_profile_stop, + lj_cf_jit_profile_dumpstack +}; +static const uint8_t lj_lib_init_jit_profile[] = { +161,57,3,5,115,116,97,114,116,4,115,116,111,112,9,100,117,109,112,115,116,97, +99,107,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi_meta +#undef LJLIB_MODULE_ffi_meta +static const lua_CFunction lj_lib_cf_ffi_meta[] = { + lj_cf_ffi_meta___index, + lj_cf_ffi_meta___newindex, + lj_cf_ffi_meta___eq, + lj_cf_ffi_meta___len, + lj_cf_ffi_meta___lt, + lj_cf_ffi_meta___le, + lj_cf_ffi_meta___concat, + lj_cf_ffi_meta___call, + lj_cf_ffi_meta___add, + lj_cf_ffi_meta___sub, + lj_cf_ffi_meta___mul, + lj_cf_ffi_meta___div, + lj_cf_ffi_meta___mod, + lj_cf_ffi_meta___pow, + lj_cf_ffi_meta___unm, + lj_cf_ffi_meta___tostring, + lj_cf_ffi_meta___pairs, + lj_cf_ffi_meta___ipairs +}; +static const uint8_t lj_lib_init_ffi_meta[] = { +164,57,19,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101, +120,4,95,95,101,113,5,95,95,108,101,110,4,95,95,108,116,4,95,95,108,101,8,95, +95,99,111,110,99,97,116,6,95,95,99,97,108,108,5,95,95,97,100,100,5,95,95,115, +117,98,5,95,95,109,117,108,5,95,95,100,105,118,5,95,95,109,111,100,5,95,95, +112,111,119,5,95,95,117,110,109,10,95,95,116,111,115,116,114,105,110,103,7, +95,95,112,97,105,114,115,8,95,95,105,112,97,105,114,115,195,102,102,105,203, +95,95,109,101,116,97,116,97,98,108,101,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi_clib +#undef LJLIB_MODULE_ffi_clib +static const lua_CFunction lj_lib_cf_ffi_clib[] = { + lj_cf_ffi_clib___index, + lj_cf_ffi_clib___newindex, + lj_cf_ffi_clib___gc +}; +static const uint8_t lj_lib_init_ffi_clib[] = { +182,57,3,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101,120, +4,95,95,103,99,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi_callback +#undef LJLIB_MODULE_ffi_callback +static const lua_CFunction lj_lib_cf_ffi_callback[] = { + lj_cf_ffi_callback_free, + lj_cf_ffi_callback_set +}; +static const uint8_t lj_lib_init_ffi_callback[] = { +185,57,3,4,102,114,101,101,3,115,101,116,252,1,199,95,95,105,110,100,101,120, +250,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi +#undef LJLIB_MODULE_ffi +static const lua_CFunction lj_lib_cf_ffi[] = { + lj_cf_ffi_cdef, + lj_cf_ffi_new, + lj_cf_ffi_cast, + lj_cf_ffi_typeof, + lj_cf_ffi_typeinfo, + lj_cf_ffi_istype, + lj_cf_ffi_sizeof, + lj_cf_ffi_alignof, + lj_cf_ffi_offsetof, + lj_cf_ffi_errno, + lj_cf_ffi_string, + lj_cf_ffi_copy, + lj_cf_ffi_fill, + lj_cf_ffi_abi, + lj_cf_ffi_metatype, + lj_cf_ffi_gc, + lj_cf_ffi_load +}; +static const uint8_t lj_lib_init_ffi[] = { +187,57,23,4,99,100,101,102,3,110,101,119,4,99,97,115,116,6,116,121,112,101, +111,102,8,116,121,112,101,105,110,102,111,6,105,115,116,121,112,101,6,115,105, +122,101,111,102,7,97,108,105,103,110,111,102,8,111,102,102,115,101,116,111, +102,5,101,114,114,110,111,6,115,116,114,105,110,103,4,99,111,112,121,4,102, +105,108,108,3,97,98,105,252,8,192,250,8,109,101,116,97,116,121,112,101,252, +7,192,250,2,103,99,252,5,192,250,4,108,111,97,100,252,4,193,67,250,252,3,194, +111,115,250,252,2,196,97,114,99,104,250,255 +}; +#endif + diff --git a/core/src/luajit/autogen/macosx/jit/arm64/lj_recdef.h b/core/src/luajit/autogen/macosx/jit/arm64/lj_recdef.h new file mode 100644 index 000000000..608f6f60c --- /dev/null +++ b/core/src/luajit/autogen/macosx/jit/arm64/lj_recdef.h @@ -0,0 +1,270 @@ +/* This is a generated file. DO NOT EDIT! */ + +static const uint16_t recff_idmap[] = { +0, +0x0100, +0x0200, +0x0300, +0, +0x0400+(0), +0x0500, +0x0400+(1), +0x0600, +0x0700, +0x0800, +0, +0x0900, +0x0a00, +0x0b00, +0, +0x0c00, +0x0d00, +0x0e00, +0, +0x0f00, +0x1000, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x1100, +0x1200+(IRFPM_FLOOR), +0x1200+(IRFPM_CEIL), +0x1300+(IRFPM_SQRT), +0x1400+(IRCALL_log10), +0x1400+(IRCALL_exp), +0x1400+(IRCALL_sin), +0x1400+(IRCALL_cos), +0x1400+(IRCALL_tan), +0x1400+(IRCALL_asin), +0x1400+(IRCALL_acos), +0x1400+(IRCALL_atan), +0x1400+(IRCALL_sinh), +0x1400+(IRCALL_cosh), +0x1400+(IRCALL_tanh), +0, +0, +0x1500, +0x1600, +0x1700, +0, +0x1800, +0x1900+(IR_MIN), +0x1900+(IR_MAX), +0x1a00, +0, +0x1b00, +0x1c00+(IR_BNOT), +0x1c00+(IR_BSWAP), +0x1d00+(IR_BSHL), +0x1d00+(IR_BSHR), +0x1d00+(IR_BSAR), +0x1d00+(IR_BROL), +0x1d00+(IR_BROR), +0x1e00+(IR_BAND), +0x1e00+(IR_BOR), +0x1e00+(IR_BXOR), +0x1f00, +0x2000+(0), +0x2100, +0x2000+(1), +0x2200, +0x2300+(IRCALL_lj_buf_putstr_reverse), +0x2300+(IRCALL_lj_buf_putstr_lower), +0x2300+(IRCALL_lj_buf_putstr_upper), +0, +0x2400, +0, +0, +0, +0, +0x2500, +0, +0x2600, +0x2700, +0, +0x2800, +0x2900, +0, +0, +0x2a00+(0), +0x2b00+(0), +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x2a00+(GCROOT_IO_OUTPUT), +0x2b00+(GCROOT_IO_OUTPUT), +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x2c00, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x2d00+(0), +0x2d00+(1), +0x2e00+(MM_eq), +0x2e00+(MM_len), +0x2e00+(MM_lt), +0x2e00+(MM_le), +0x2e00+(MM_concat), +0x2f00, +0x2e00+(MM_add), +0x2e00+(MM_sub), +0x2e00+(MM_mul), +0x2e00+(MM_div), +0x2e00+(MM_mod), +0x2e00+(MM_pow), +0x2e00+(MM_unm), +0, +0, +0, +0x3000+(1), +0x3000+(0), +0, +0, +0, +0, +0x3100, +0x3100, +0x3200, +0, +0x3300, +0x3400+(FF_ffi_sizeof), +0x3400+(FF_ffi_alignof), +0x3400+(FF_ffi_offsetof), +0x3500, +0x3600, +0x3700, +0x3800, +0x3900, +0, +0x3a00 +}; + +static const RecordFunc recff_func[] = { +recff_nyi, +recff_c, +recff_assert, +recff_type, +recff_xpairs, +recff_ipairs_aux, +recff_getmetatable, +recff_setmetatable, +recff_getfenv, +recff_rawget, +recff_rawset, +recff_rawequal, +recff_select, +recff_tonumber, +recff_tostring, +recff_pcall, +recff_xpcall, +recff_math_abs, +recff_math_round, +recff_math_unary, +recff_math_call, +recff_math_log, +recff_math_atan2, +recff_math_pow, +recff_math_ldexp, +recff_math_minmax, +recff_math_random, +recff_bit_tobit, +recff_bit_unary, +recff_bit_shift, +recff_bit_nary, +recff_bit_tohex, +recff_string_range, +recff_string_char, +recff_string_rep, +recff_string_op, +recff_string_find, +recff_string_format, +recff_table_insert, +recff_table_concat, +recff_table_new, +recff_table_clear, +recff_io_write, +recff_io_flush, +recff_debug_getmetatable, +recff_cdata_index, +recff_cdata_arith, +recff_cdata_call, +recff_clib_index, +recff_ffi_new, +recff_ffi_typeof, +recff_ffi_istype, +recff_ffi_xof, +recff_ffi_errno, +recff_ffi_string, +recff_ffi_copy, +recff_ffi_fill, +recff_ffi_abi, +recff_ffi_gc +}; + diff --git a/core/src/luajit/autogen/macosx/jit/arm64/lj_vm.S b/core/src/luajit/autogen/macosx/jit/arm64/lj_vm.S new file mode 100644 index 000000000..615768283 --- /dev/null +++ b/core/src/luajit/autogen/macosx/jit/arm64/lj_vm.S @@ -0,0 +1,2067 @@ + .file "buildvm_arm64.dasc" + .text + .align 4 + + .private_extern _lj_vm_asm_begin + .no_dead_strip _lj_vm_asm_begin +_lj_vm_asm_begin: + + .private_extern _lj_BC_ISLT + .no_dead_strip _lj_BC_ISLT +_lj_BC_ISLT: + .long 0xf87b7a60,0x794006b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95b235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x54012e63 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x54012de1 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x54012d63 + .long 0x1e620000,0x1e612000,0x9a953235,0x17ffffed + + .private_extern _lj_BC_ISGE + .no_dead_strip _lj_BC_ISGE +_lj_BC_ISGE: + .long 0xf87b7a60,0x794006b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95a235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x54012a63 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x540129e1 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x54012963 + .long 0x1e620000,0x1e612000,0x9a952235,0x17ffffed + + .private_extern _lj_BC_ISLE + .no_dead_strip _lj_BC_ISLE +_lj_BC_ISLE: + .long 0xf87b7a60,0x794006b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95d235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x54012663 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x540125e1 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x54012563 + .long 0x1e620000,0x1e612000,0x9a959235,0x17ffffed + + .private_extern _lj_BC_ISGT + .no_dead_strip _lj_BC_ISGT +_lj_BC_ISGT: + .long 0xf87b7a60,0x794006b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95c235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x54012263 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x540121e1 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x54012163 + .long 0x1e620000,0x1e612000,0x9a958235,0x17ffffed + + .private_extern _lj_BC_ISEQV + .no_dead_strip _lj_BC_ISEQV +_lj_BC_ISEQV: + .long 0xf87b7a60,0x8b1c0e7c,0x794006b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0x936ffc4f + .long 0xb10039ff,0x54000ce9,0x936ffc08,0xb1002dff + .long 0xba4b1904,0x54012440,0xeb02001f,0x54000101 + .long 0xaa1103f5,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100,0xeb0801ff + .long 0xba4c09e2,0x54ffff08,0x9240b801,0xf940102a + .long 0xb4fffeaa,0x39402949,0x52800003,0x3727fe49 + .long 0x14000908 + + .private_extern _lj_BC_ISNEV + .no_dead_strip _lj_BC_ISNEV +_lj_BC_ISNEV: + .long 0xf87b7a60,0x8b1c0e7c,0x794006b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0x936ffc4f + .long 0xb10039ff,0x54000d29,0x936ffc08,0xb1002dff + .long 0xba4b1904,0x54012020,0xeb02001f,0x540000e1 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xeb0801ff,0xba4c09e2 + .long 0x54fffae8,0x9240b801,0xf940102a,0xb4fffa8a + .long 0x39402949,0x52800023,0x3727fa29,0x140008e8 + + .private_extern _lj_BC_ISEQS + .no_dead_strip _lj_BC_ISEQS +_lj_BC_ISEQS: + .long 0xf87b7a60,0xaa3c03fc,0x794006b1,0xf87c7a81 + .long 0x910012b5,0x92800088,0x936ffc0f,0x8b110ab1 + .long 0x8b08bc21,0xd1408231,0xb1002dff,0x54011c60 + .long 0xeb01001f,0x9a950235,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISNES + .no_dead_strip _lj_BC_ISNES +_lj_BC_ISNES: + .long 0xf87b7a60,0xaa3c03fc,0x794006b1,0xf87c7a81 + .long 0x910012b5,0x92800088,0x936ffc0f,0x8b110ab1 + .long 0x8b08bc21,0xd1408231,0xb1002dff,0x540119e0 + .long 0xeb01001f,0x9a951235,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISEQN + .no_dead_strip _lj_BC_ISEQN +_lj_BC_ISEQN: + .long 0xf87b7a60,0x8b1c0e9c,0x794006b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0xeb40833f + .long 0x54000161,0xeb42833f,0x54000221,0x6b02001f + .long 0x9a950235,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100,0x54000183 + .long 0xfc7b7a60,0xfd400381,0xeb42833f,0x54000041 + .long 0x1e620041,0x1e612000,0x17fffff2,0xfd400381 + .long 0x1e620000,0x1e612000,0x17ffffee,0x936ffc0f + .long 0xb1002dff,0x54fffd81,0x140008a4 + + .private_extern _lj_BC_ISNEN + .no_dead_strip _lj_BC_ISNEN +_lj_BC_ISNEN: + .long 0xf87b7a60,0x8b1c0e9c,0x794006b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0xeb40833f + .long 0x54000161,0xeb42833f,0x54000221,0x6b02001f + .long 0x9a951235,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100,0x54000183 + .long 0xfc7b7a60,0xfd400381,0xeb42833f,0x54000041 + .long 0x1e620041,0x1e612000,0x17fffff2,0xfd400381 + .long 0x1e620000,0x1e612000,0x17ffffee,0x936ffc0f + .long 0xb1002dff,0x54fffd61,0x14000881 + + .private_extern _lj_BC_ISEQP + .no_dead_strip _lj_BC_ISEQP +_lj_BC_ISEQP: + .long 0xf87b7a68,0x794006b1,0x910012b5,0x9100079c + .long 0x8b110ab1,0x936ffd0f,0xb1002dff,0x54010f20 + .long 0xab0f039f,0xd1408231,0x9a950235,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_ISNEP + .no_dead_strip _lj_BC_ISNEP +_lj_BC_ISNEP: + .long 0xf87b7a68,0x794006b1,0x910012b5,0x9100079c + .long 0x8b110ab1,0x936ffd0f,0xb1002dff,0x54010d00 + .long 0xab0f039f,0xd1408231,0x9a951235,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_ISTC + .no_dead_strip _lj_BC_ISTC +_lj_BC_ISTC: + .long 0x794006b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a9c337b + .long 0x9a953235,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISFC + .no_dead_strip _lj_BC_ISFC +_lj_BC_ISFC: + .long 0x794006b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a9c237b + .long 0x9a952235,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_IST + .no_dead_strip _lj_BC_IST +_lj_BC_IST: + .long 0x794006b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a953235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISF + .no_dead_strip _lj_BC_ISF +_lj_BC_ISF: + .long 0x794006b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a952235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISTYPE + .no_dead_strip _lj_BC_ISTYPE +_lj_BC_ISTYPE: + .long 0xf87b7a68,0xab88bf9f,0x540104e1,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_ISNUM + .no_dead_strip _lj_BC_ISNUM +_lj_BC_ISNUM: + .long 0xf87b6a68,0xeb48833f,0x540103c9,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_MOV + .no_dead_strip _lj_BC_MOV +_lj_BC_MOV: + .long 0xf87c7a68,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_NOT + .no_dead_strip _lj_BC_NOT +_lj_BC_NOT: + .long 0xf87c7a68,0x92d00009,0x92e0002a,0xeb09011f + .long 0x9a8a3128,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_UNM + .no_dead_strip _lj_BC_UNM +_lj_BC_UNM: + .long 0xf87c7a68,0x936ffd0f,0xb10039ff,0x540101c8 + .long 0xd2410108,0x540000a1,0x6b0803e8,0xd2e83c02 + .long 0x8b180108,0x9a827108,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_LEN + .no_dead_strip _lj_BC_LEN +_lj_BC_LEN: + .long 0xf87c7a60,0x936ffc0f,0xb10015ff,0x9240b800 + .long 0x54000141,0xb9401400,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xb10031ff,0x54010061 + bl _lj_tab_len + .long 0x17fffff5 + + .private_extern _lj_BC_ADDVN + .no_dead_strip _lj_BC_ADDVN +_lj_BC_ADDVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x2b010000,0x5400fbe6,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a81 + .long 0xeb40833f,0x5400fa69,0xeb41833f,0x5400fa29 + .long 0x1e612800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_SUBVN + .no_dead_strip _lj_BC_SUBVN +_lj_BC_SUBVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x6b010000,0x5400f886,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a81 + .long 0xeb40833f,0x5400f709,0xeb41833f,0x5400f6c9 + .long 0x1e613800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_MULVN + .no_dead_strip _lj_BC_MULVN +_lj_BC_MULVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001e1,0xeb41833f,0x540001a1 + .long 0x9b217c00,0xeb20c01f,0x2a0003e0,0x5400f4e1 + .long 0x8b180000,0xf83b7a60,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + .long 0xfc717a60,0xfc7c7a81,0xeb40833f,0x5400f369 + .long 0xeb41833f,0x5400f329,0x1e610800,0xfc3b7a60 + .long 0x17fffff2 + + .private_extern _lj_BC_DIVVN + .no_dead_strip _lj_BC_DIVVN +_lj_BC_DIVVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xfc717a60,0xfc7c7a81,0xeb40833f,0x5400f1c9 + .long 0xeb41833f,0x5400f189,0x1e611800,0xfc3b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_MODVN + .no_dead_strip _lj_BC_MODVN +_lj_BC_MODVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x3400ef61,0x94000ca0,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a81 + .long 0xeb40833f,0x5400edc9,0xeb41833f,0x5400ed89 + .long 0x1e611802,0x1e654042,0x1f418040,0xfc3b7a60 + .long 0x17fffff0 + + .private_extern _lj_BC_ADDNV + .no_dead_strip _lj_BC_ADDNV +_lj_BC_ADDNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x2b010000,0x5400ec06,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc7c7a80,0xfc717a61 + .long 0xeb40833f,0x5400ea89,0xeb41833f,0x5400ea49 + .long 0x1e612800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_SUBNV + .no_dead_strip _lj_BC_SUBNV +_lj_BC_SUBNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x6b010000,0x5400e8a6,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc7c7a80,0xfc717a61 + .long 0xeb40833f,0x5400e729,0xeb41833f,0x5400e6e9 + .long 0x1e613800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_MULNV + .no_dead_strip _lj_BC_MULNV +_lj_BC_MULNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001e1,0xeb41833f,0x540001a1 + .long 0x9b217c00,0xeb20c01f,0x2a0003e0,0x5400e501 + .long 0x8b180000,0xf83b7a60,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + .long 0xfc7c7a80,0xfc717a61,0xeb40833f,0x5400e389 + .long 0xeb41833f,0x5400e349,0x1e610800,0xfc3b7a60 + .long 0x17fffff2 + + .private_extern _lj_BC_DIVNV + .no_dead_strip _lj_BC_DIVNV +_lj_BC_DIVNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xfc7c7a80,0xfc717a61,0xeb40833f,0x5400e1e9 + .long 0xeb41833f,0x5400e1a9,0x1e611800,0xfc3b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_MODNV + .no_dead_strip _lj_BC_MODNV +_lj_BC_MODNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x3400df81,0x94000c1e,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc7c7a80,0xfc717a61 + .long 0xeb40833f,0x5400dde9,0xeb41833f,0x5400dda9 + .long 0x1e611802,0x1e654042,0x1f418040,0xfc3b7a60 + .long 0x17fffff0 + + .private_extern _lj_BC_ADDVV + .no_dead_strip _lj_BC_ADDVV +_lj_BC_ADDVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x2b010000,0x5400dc86,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a61 + .long 0xeb40833f,0x5400db09,0xeb41833f,0x5400dac9 + .long 0x1e612800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_SUBVV + .no_dead_strip _lj_BC_SUBVV +_lj_BC_SUBVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x6b010000,0x5400d926,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a61 + .long 0xeb40833f,0x5400d7a9,0xeb41833f,0x5400d769 + .long 0x1e613800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_MULVV + .no_dead_strip _lj_BC_MULVV +_lj_BC_MULVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001e1,0xeb41833f,0x540001a1 + .long 0x9b217c00,0xeb20c01f,0x2a0003e0,0x5400d581 + .long 0x8b180000,0xf83b7a60,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + .long 0xfc717a60,0xfc7c7a61,0xeb40833f,0x5400d409 + .long 0xeb41833f,0x5400d3c9,0x1e610800,0xfc3b7a60 + .long 0x17fffff2 + + .private_extern _lj_BC_DIVVV + .no_dead_strip _lj_BC_DIVVV +_lj_BC_DIVVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xfc717a60,0xfc7c7a61,0xeb40833f,0x5400d269 + .long 0xeb41833f,0x5400d229,0x1e611800,0xfc3b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_MODVV + .no_dead_strip _lj_BC_MODVV +_lj_BC_MODVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x3400d001,0x94000b9c,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a61 + .long 0xeb40833f,0x5400ce69,0xeb41833f,0x5400ce29 + .long 0x1e611802,0x1e654042,0x1f418040,0xfc3b7a60 + .long 0x17fffff0 + + .private_extern _lj_BC_POW + .no_dead_strip _lj_BC_POW +_lj_BC_POW: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xfc717a60,0xfc7c7a61,0xeb40833f,0x5400cc89 + .long 0xeb41833f,0x5400cc49 + bl _pow + .long 0xfc3b7a60,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_CAT + .no_dead_strip _lj_BC_CAT +_lj_BC_CAT: + .long 0xd3587e11,0x92401f9c,0xf90012f3,0xcb110382 + .long 0x8b1c0e61,0xaa1703e0,0xf90057f5 + bl _lj_meta_cat + .long 0x385ff2b1,0xf94012f3,0xb500cb00,0xf8717a68 + .long 0xf83b7a68,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KSTR + .no_dead_strip _lj_BC_KSTR +_lj_BC_KSTR: + .long 0xaa3c03fc,0xf87c7a88,0x92800089,0x8b09bd08 + .long 0xf83b7a68,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KCDATA + .no_dead_strip _lj_BC_KCDATA +_lj_BC_KCDATA: + .long 0xaa3c03fc,0xf87c7a88,0x92800149,0x8b09bd08 + .long 0xf83b7a68,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KSHORT + .no_dead_strip _lj_BC_KSHORT +_lj_BC_KSHORT: + .long 0x13003f9c,0x8b180388,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_KNUM + .no_dead_strip _lj_BC_KNUM +_lj_BC_KNUM: + .long 0xf87c7a88,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KPRI + .no_dead_strip _lj_BC_KPRI +_lj_BC_KPRI: + .long 0xaa3cbfe8,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KNIL + .no_dead_strip _lj_BC_KNIL +_lj_BC_KNIL: + .long 0x8b1b0e7b,0x8b1c0e7c,0xf800877a,0xeb1c037f + .long 0xf800877a,0x54ffffcb,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_UGET + .no_dead_strip _lj_BC_UGET +_lj_BC_UGET: + .long 0xf85f0261,0x9100179c,0x9240b821,0xf87c7821 + .long 0xf9401021,0xf9400028,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_USETV + .no_dead_strip _lj_BC_USETV +_lj_BC_USETV: + .long 0xf85f0261,0x9100177b,0x9240b821,0xf87b7820 + .long 0xf87c7a62,0xf9401001,0x3940200a,0x39402808 + .long 0x936ffc4f,0xf9000022,0x910011ef,0x721e015f + .long 0x7a401904,0xba4a19e0,0x540000e8,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0x9240b842,0x39402049,0x7200053f + .long 0x54fffee0,0xaa1603e0 + bl _lj_gc_barrieruv + .long 0x17fffff4 + + .private_extern _lj_BC_USETS + .no_dead_strip _lj_BC_USETS +_lj_BC_USETS: + .long 0xf85f0261,0x9100177b,0xaa3c03fc,0x9240b821 + .long 0xf87b7820,0xf87c7a82,0x92800088,0xf9401001 + .long 0x3940200a,0x8b08bc48,0x39402049,0xf9000028 + .long 0x371000ea,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100,0x39402808 + .long 0x7200053f,0x7a401904,0x54fffee0,0xaa1603e0 + bl _lj_gc_barrieruv + .long 0x17fffff4 + + .private_extern _lj_BC_USETN + .no_dead_strip _lj_BC_USETN +_lj_BC_USETN: + .long 0xf85f0261,0x9100177b,0x9240b821,0xf87b7821 + .long 0xf87c7a88,0xf9401021,0xf9000028,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_USETP + .no_dead_strip _lj_BC_USETP +_lj_BC_USETP: + .long 0xf85f0261,0x9100177b,0x9240b821,0xf87b7821 + .long 0xaa3cbfe8,0xf9401021,0xf9000028,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_UCLO + .no_dead_strip _lj_BC_UCLO +_lj_BC_UCLO: + .long 0xf94022e2,0x8b1c0abc,0xf90012f3,0xd1408395 + .long 0xb40000a2,0xaa1703e0,0x8b1b0e61 + bl _lj_func_closeuv + .long 0xf94012f3,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_FNEW + .no_dead_strip _lj_BC_FNEW +_lj_BC_FNEW: + .long 0xaa3c03fc,0xf90012f3,0xf85f0262,0xf90057f5 + .long 0xf87c7a81,0xaa1703e0,0x9240b842 + bl _lj_func_newL_gc + .long 0xf94012f3,0x92800108,0x8b08bc00,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_TNEW + .no_dead_strip _lj_BC_TNEW +_lj_BC_TNEW: + .long 0xa9410ec2,0xf90012f3,0xf90057f5,0xaa1703e0 + .long 0xeb03005f,0x54000202,0x92402b81,0xd34bff82 + .long 0xf11ffc3f,0x52810028,0x9a881021 + bl _lj_tab_new + .long 0xf94012f3,0xf2ffff40,0xf83b7a60,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + bl _lj_gc_step_fixtop + .long 0xaa1703e0,0x17ffffef + + .private_extern _lj_BC_TDUP + .no_dead_strip _lj_BC_TDUP +_lj_BC_TDUP: + .long 0xa9410ec2,0xf90012f3,0xf90057f5,0xaa1703e0 + .long 0xeb03005f,0x540001a2,0xaa3c03fc,0xf87c7a81 + bl _lj_tab_dup + .long 0xf94012f3,0xf2ffff40,0xf83b7a60,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + bl _lj_gc_step_fixtop + .long 0xaa1703e0,0x17fffff2 + + .private_extern _lj_BC_GGET + .no_dead_strip _lj_BC_GGET +_lj_BC_GGET: + .long 0xf85f0260,0xaa3c03fc,0x9240b800,0xf9400801 + .long 0xf87c7a9c,0x14000033 + + .private_extern _lj_BC_GSET + .no_dead_strip _lj_BC_GSET +_lj_BC_GSET: + .long 0xf85f0260,0xaa3c03fc,0x9240b800,0xf9400801 + .long 0xf87c7a9c,0x140000ab + + .private_extern _lj_BC_TGETV + .no_dead_strip _lj_BC_TGETV +_lj_BC_TGETV: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xf87c7a69 + .long 0x936ffc2f,0xb10031ff,0x9240b821,0x54009841 + .long 0xeb49833f,0x540002a1,0xf9400822,0xb9403020 + .long 0x8b294c42,0x6b00013f,0x54009762,0xf9400048 + .long 0xeb1a011f,0x54000100,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0xf9401020,0xb4ffff00,0x39402809 + .long 0x3707fec9,0x140004ac,0x936ffd2f,0xb10015ff + .long 0x54009521,0x9240b93c,0x1400000a + + .private_extern _lj_BC_TGETS + .no_dead_strip _lj_BC_TGETS +_lj_BC_TGETS: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xaa3c03fc + .long 0xf87c7a9c,0x936ffc2f,0xb10031ff,0x9240b821 + .long 0x540091e1,0xb9403429,0xb9400f8a,0xf9401422 + .long 0x0a0a0129,0x8b090529,0x92800083,0x8b090c42 + .long 0x8b03bf83,0xa9400048,0xf9400842,0xeb03001f + .long 0x54000141,0xeb1a011f,0x54000140,0xf83b7a68 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xb5fffe62,0xaa1a03e8 + .long 0xf9401020,0xb4fffec0,0x39402809,0x3707fe89 + .long 0x14000477 + + .private_extern _lj_BC_TGETB + .no_dead_strip _lj_BC_TGETB +_lj_BC_TGETB: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0x936ffc2f + .long 0xb10031ff,0x9240b821,0x54008ec1,0xf9400822 + .long 0xb9403020,0x8b1c0c42,0x6b00039f,0x54008e22 + .long 0xf9400048,0xeb1a011f,0x54000100,0xf83b7a68 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xf9401020,0xb4ffff00 + .long 0x39402809,0x3707fec9,0x14000462 + + .private_extern _lj_BC_TGETR + .no_dead_strip _lj_BC_TGETR +_lj_BC_TGETR: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a69 + .long 0x9240b800,0xf9400802,0xb940300a,0x8b294c42 + .long 0x6b0a013f,0x54008e82,0xf9400048,0xf83b7a68 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_TSETV + .no_dead_strip _lj_BC_TSETV +_lj_BC_TSETV: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xf87c7a69 + .long 0x936ffc2f,0xb10031ff,0x9240b821,0x54008f21 + .long 0xeb49833f,0x540003c1,0xf9400822,0xb9403020 + .long 0x8b294c42,0x6b00013f,0x54008e42,0xf9400049 + .long 0xf87b7a68,0x3940202a,0xeb1a013f,0x54000120 + .long 0xf9000048,0x3710018a,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + .long 0xf9401020,0xb4fffee0,0x39402809,0x370ffea9 + .long 0x14000460,0xf94022c9,0x121d794a,0xf90022c1 + .long 0x3900202a,0xf9000c29,0x17fffff0,0x936ffd2f + .long 0xb10015ff,0x54008ae1,0x9240b93c,0x1400000a + + .private_extern _lj_BC_TSETS + .no_dead_strip _lj_BC_TSETS +_lj_BC_TSETS: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xaa3c03fc + .long 0xf87c7a9c,0x936ffc2f,0xb10031ff,0x9240b821 + .long 0x540087a1,0xb9403429,0xb9400f8a,0xf9401422 + .long 0x0a0a0129,0x8b090529,0x92800083,0x8b090c42 + .long 0x8b03bf83,0x3900283f,0xa9400049,0xf940084b + .long 0x3940202a,0xeb03001f,0x54000221,0xf87b7a68 + .long 0xeb1a013f,0x54000120,0xf9000048,0x371003ca + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xf9401020,0xb4fffee0 + .long 0x39402809,0x370ffea9,0x14000423,0xaa0b03e2 + .long 0xb5fffd4b,0xf9401020,0xb4000060,0x39402809 + .long 0x360883a9,0x92800089,0xf90057f5,0x8b09bf88 + .long 0xf90012f3,0xaa1703e0,0xf9005fe8,0x9102e3e2 + bl _lj_tab_newkey + .long 0xf94012f3,0xf87b7a68,0xf9000008,0x17ffffe4 + .long 0xf94022c9,0x121d794a,0xf90022c1,0x3900202a + .long 0xf9000c29,0x17ffffde + + .private_extern _lj_BC_TSETB + .no_dead_strip _lj_BC_TSETB +_lj_BC_TSETB: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0x936ffc2f + .long 0xb10031ff,0x9240b821,0x54008141,0xf9400822 + .long 0xb9403020,0x8b1c0c42,0x6b00039f,0x540080a2 + .long 0xf9400049,0xf87b7a68,0x3940202a,0xeb1a013f + .long 0x54000120,0xf9000048,0x3710018a,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0xf9401020,0xb4fffee0,0x39402809 + .long 0x370ffea9,0x140003f3,0xf94022c9,0x121d794a + .long 0xf90022c1,0x3900202a,0xf9000c29,0x17fffff0 + + .private_extern _lj_BC_TSETM + .no_dead_strip _lj_BC_TSETM +_lj_BC_TSETM: + .long 0x8b1b0e7b,0xb940c3f1,0xf85f8361,0xf87c7a89 + .long 0xd1002231,0xb40001f1,0x9240b821,0xb9403020 + .long 0x0b510d22,0xf9400823,0xeb00005f,0x8b110371 + .long 0x540001c8,0x8b294c69,0x3940202a,0xf8408768 + .long 0xf8008528,0xeb11037f,0x54ffffa3,0x3710018a + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_tab_reasize + .long 0x17ffffe3,0xf94022c9,0x121d794a,0xf90022c1 + .long 0x3900202a,0xf9000c29,0x17fffff0 + + .private_extern _lj_BC_TSETR + .no_dead_strip _lj_BC_TSETR +_lj_BC_TSETR: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xf87c7a69 + .long 0x9240b821,0xf9400820,0x3940202a,0xb9403023 + .long 0x8b294c00,0x3710016a,0x6b03013f,0x54007b22 + .long 0xf87b7a68,0xf9000008,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + .long 0xf94022c8,0x121d794a,0xf90022c1,0x3900202a + .long 0xf9000c28,0x17fffff1 + + .private_extern _lj_BC_CALLM + .no_dead_strip _lj_BC_CALLM +_lj_BC_CALLM: + .long 0xb940c3e8,0xd37d1f9c,0x8b08039c,0x14000002 + + .private_extern _lj_BC_CALL + .no_dead_strip _lj_BC_CALL +_lj_BC_CALL: + .long 0xd37d1f9c,0xaa1303f1,0x8b1b0e73,0xf9400262 + .long 0xd100239c,0x91004273,0x936ffc4f,0xb10025ff + .long 0x9240b842,0x54008321,0xf81f8275,0xf9401055 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_BC_CALLMT + .no_dead_strip _lj_BC_CALLMT +_lj_BC_CALLMT: + .long 0xb940c3e8,0x8b1c0d1c,0x14000002 + + .private_extern _lj_BC_CALLT + .no_dead_strip _lj_BC_CALLT +_lj_BC_CALLT: + .long 0xd37df39c,0x8b1b0e7b,0xf9400369,0xd100239c + .long 0x9100437b,0x936ffd2f,0xb10025ff,0x9240b922 + .long 0x540082c1,0xf85f8275,0x52800011,0x3940284a + .long 0xf24006bf,0x54000321,0xf81f0269,0xb40000fc + .long 0xf8716b68,0x91002229,0xeb1c013f,0xf8316a68 + .long 0xaa0903f1,0x54ffff61,0xf100055f,0x54000108 + .long 0xf9401055,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0x8b1b0e7b,0xd61f0100,0x385fd2bb + .long 0xcb1b0e60,0xf85e0000,0x9240b800,0xf9401000 + .long 0xf85b8014,0x17fffff3,0xd24006b5,0xf2400abf + .long 0x9a8a122a,0x54fffca1,0xcb150273,0xf85f8275 + .long 0xf24006bf,0x9a8a122a,0x17ffffe0 + + .private_extern _lj_BC_ITERC + .no_dead_strip _lj_BC_ITERC +_lj_BC_ITERC: + .long 0x8b1b0e7b,0xf85e8362,0xaa1303f1,0xa97f0760 + .long 0x91004373,0x5280021c,0xf9000362,0xa9010760 + .long 0x936ffc4f,0xb10025ff,0x9240b842,0x54007a61 + .long 0xf81f8275,0xf9401055,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_BC_ITERN + .no_dead_strip _lj_BC_ITERN +_lj_BC_ITERN: + .long 0x8b1b0e7b,0xf85f0371,0x794006ab,0xb85f8360 + .long 0x910012b5,0x8b0b0aab,0x9240ba31,0xd140816b + .long 0xb9403229,0xf9400a21,0xeb09001c,0x8b000c22 + .long 0x54000202,0xf9400048,0xeb1a011f,0x9a801400 + .long 0x54ffff40,0x8b180000,0xa9002360,0x91000400 + .long 0xb81f8360,0xaa0b03f5,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + .long 0xb940362a,0xf9401631,0x8b1c0780,0xeb0a039f + .long 0x8b000e22,0x54fffea8,0xa9400048,0xeb1a011f + .long 0x9100079c,0x54ffff20,0xa9002360,0x8b090380 + .long 0x17ffffec + + .private_extern _lj_BC_VARG + .no_dead_strip _lj_BC_VARG +_lj_BC_VARG: + .long 0xd3587e11,0x92401f9c,0xf85f8269,0x8b1c0e7c + .long 0x8b1b0e7b,0x91000f9c,0x8b110f6a,0xcb09039c + .long 0xd100426b,0xb40001d1,0xd100414a,0xeb0b039f + .long 0xf8408788,0x9a9a3108,0xeb0a037f,0xf8008768 + .long 0x54ffff63,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100,0xf9401ae8 + .long 0xeb1c016a,0x9a8ad3f1,0x91002231,0x8b0a0369 + .long 0xb900c3f1,0x54fffe8d,0xeb08013f,0x540000c8 + .long 0xf8408788,0xf8008768,0xeb0b039f,0x54ffffa3 + .long 0x17ffffed,0xd343fd41,0xa9026ef3,0xaa1703e0 + .long 0xcb13039c,0xf90057f5 + bl _lj_state_growstack + .long 0xa9426ef3,0x8b1c027c,0xd100426b,0x17fffff2 + + .private_extern _lj_BC_ISNEXT + .no_dead_strip _lj_BC_ISNEXT +_lj_BC_ISNEXT: + .long 0x8b1b0e7b,0xf85e8360,0x8b1c0abc,0xa97f0f62 + .long 0xd140839c,0x936ffc0f,0xb10025ff,0x9240b800 + .long 0x54000221,0x936ffc48,0x39402809,0xb100311f + .long 0xfa5a0060,0x7a440920,0x54000161,0x320f77e8 + .long 0xd3607d08,0xf81f8368,0xaa1c03f5,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0x52800b08,0x528008a9,0x381fc2a8 + .long 0x39000389,0x17fffff5 + + .private_extern _lj_BC_RETM + .no_dead_strip _lj_BC_RETM +_lj_BC_RETM: + .long 0xb940c3e8,0xf85f8275,0x8b1b0e7b,0x8b1c0d1c + .long 0x14000004 + + .private_extern _lj_BC_RET + .no_dead_strip _lj_BC_RET +_lj_BC_RET: + .long 0xf85f8275,0xd37df39c,0x8b1b0e7b,0xb900c3fc + .long 0xf24006a0,0xd24006a1,0x540003e1,0xb85fc2b0 + .long 0xf1002389,0xd1004262,0x540000c0,0xf8408768 + .long 0x91002273,0xd1002129,0xf81e8268,0xb5ffff89 + .long 0xd3483e1b,0xcb1b0c43,0xd3587e11,0xf85f0060 + .long 0xeb110f9f,0x54000163,0x9240b800,0xaa0303f3 + .long 0xf9401001,0xf85b8034,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + .long 0x91002273,0x9100239c,0xf81e827a,0x17fffff1 + .long 0x8b1b0e7b,0xf240083f,0x54003061,0xcb010273 + .long 0xf85f8275,0x17ffffdb + + .private_extern _lj_BC_RET0 + .no_dead_strip _lj_BC_RET0 +_lj_BC_RET0: + .long 0xf85f8275,0xd37df39c,0xb900c3fc,0xf24006a0 + .long 0xd24006a1,0x54fffea1,0xb85fc2b0,0xd1004263 + .long 0xd3483e1b,0xcb1b0c73,0xd3587e11,0xf85f0260 + .long 0xeb110f9f,0x54000143,0x9240b800,0xf9401001 + .long 0xf85b8034,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100,0x9100239c + .long 0xf800847a,0x17fffff3 + + .private_extern _lj_BC_RET1 + .no_dead_strip _lj_BC_RET1 +_lj_BC_RET1: + .long 0xf85f8275,0xd37df39c,0xb900c3fc,0xf24006a0 + .long 0xd24006a1,0x54fffb61,0xb85fc2b0,0xf87b7a68 + .long 0xd1004263,0xd3483e1b,0xcb1b0c73,0xf8008468 + .long 0xd3587e11,0xf85f0260,0xeb110f9f,0x54000143 + .long 0x9240b800,0xf9401001,0xf85b8034,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0x9100239c,0xf800847a,0x17fffff3 + + .private_extern _lj_BC_FORI + .no_dead_strip _lj_BC_FORI +_lj_BC_FORI: + .long 0x8b1b0e7b,0xa9400760,0xf9400b62,0x8b1c0abc + .long 0xd140839c,0xeb40833f,0x54000221,0xeb41833f + .long 0x54006061,0xeb42833f,0x54006021,0x37f80142 + .long 0x6b01001f,0x9a95c395,0xf9000f60,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0x6b00003f,0x17fffff7,0x6d400760 + .long 0x54005e63,0xeb41833f,0x54005e29,0xeb42833f + .long 0x54005de9,0xfd000f60,0xb7f80082,0x1e612000 + .long 0x9a958395,0x17ffffee,0x1e602020,0x17fffffd + + .private_extern _lj_BC_JFORI + .no_dead_strip _lj_BC_JFORI +_lj_BC_JFORI: + .long 0x8b1b0e7b,0xa9400760,0xf9400b62,0x8b1c0abc + .long 0xd140839c,0xeb40833f,0x54000261,0xeb41833f + .long 0x54005be1,0xeb42833f,0x54005ba1,0x37f80182 + .long 0x6b01001f,0xaa1c03f5,0x785fe39c,0xf9000f60 + .long 0x540011ed,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100,0x6b00003f + .long 0x17fffff5,0x6d400760,0x540059a3,0xeb41833f + .long 0x54005969,0xeb42833f,0x54005929,0xfd000f60 + .long 0xb7f800a2,0x1e612000,0x785fe39c,0x54000f89 + .long 0x17ffffed,0x1e602020,0x17fffffc + + .private_extern _lj_BC_FORL + .no_dead_strip _lj_BC_FORL +_lj_BC_FORL: + .long 0xd341fea0,0x927f1400,0x913b8000,0x78606ac1 + .long 0xf1000821,0x78206ac1,0x5400de83 + + .private_extern _lj_BC_IFORL + .no_dead_strip _lj_BC_IFORL +_lj_BC_IFORL: + .long 0x8b1b0e7b,0xa9400760,0xf9400b62,0x8b1c0abc + .long 0xd140839c,0xeb40833f,0x54000221,0x2b020000 + .long 0x540000e6,0x8b180008,0x37f80162,0x6b01001f + .long 0x9a95d395,0xf9000368,0xf9000f68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0x6b00003f,0x17fffff6,0x6d400760 + .long 0x54005423,0xfd400b62,0x1e622800,0xb7f800c2 + .long 0x1e612000,0xfd000360,0xfd000f60,0x9a959395 + .long 0x17ffffef,0x1e602020,0x17fffffb + + .private_extern _lj_BC_JFORL + .no_dead_strip _lj_BC_JFORL +_lj_BC_JFORL: + .long 0x8b1b0e7b,0xa9400760,0xf9400b62,0xeb40833f + .long 0x54000221,0x2b020000,0x540000e6,0x8b180008 + .long 0x37f80162,0x6b01001f,0xf9000368,0xf9000f68 + .long 0x5400084d,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0xd3507e1c,0xd61f0100,0x6b00003f + .long 0x17fffff6,0x6d400760,0x54005003,0xfd400b62 + .long 0x1e622800,0xb7f800c2,0x1e612000,0xfd000360 + .long 0xfd000f60,0x54000629,0x17ffffef,0x1e602020 + .long 0x17fffffb + + .private_extern _lj_BC_ITERL + .no_dead_strip _lj_BC_ITERL +_lj_BC_ITERL: + .long 0xd341fea0,0x927f1400,0x913b8000,0x78606ac1 + .long 0xf1000821,0x78206ac1,0x5400d523 + + .private_extern _lj_BC_IITERL + .no_dead_strip _lj_BC_IITERL +_lj_BC_IITERL: + .long 0xf87b7a60,0x8b1b0e69,0xeb1a001f,0x54000080 + .long 0x8b1c0aa8,0xd1408115,0xf81f8120,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_JITERL + .no_dead_strip _lj_BC_JITERL +_lj_BC_JITERL: + .long 0xf87b7a60,0x8b1b0e69,0xeb1a001f,0x54000060 + .long 0xf81f8120,0x14000014,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_LOOP + .no_dead_strip _lj_BC_LOOP +_lj_BC_LOOP: + .long 0xd341fea0,0x927f1400,0x913b8000,0x78606ac1 + .long 0xf1000821,0x78206ac1,0x5400d123 + + .private_extern _lj_BC_ILOOP + .no_dead_strip _lj_BC_ILOOP +_lj_BC_ILOOP: + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_JLOOP + .no_dead_strip _lj_BC_JLOOP +_lj_BC_JLOOP: + .long 0xf94222c0,0x52800001,0xf87c781c,0xb900bac1 + .long 0xf9402f9b,0xf900bed3,0xf90072d7,0xd10043ff + .long 0xd61f0360 + + .private_extern _lj_BC_JMP + .no_dead_strip _lj_BC_JMP +_lj_BC_JMP: + .long 0x8b1c0abc,0xd1408395,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_FUNCF + .no_dead_strip _lj_BC_FUNCF +_lj_BC_FUNCF: + .long 0xd341fea0,0x927f1400,0x913b8000,0x78606ac1 + .long 0xf1000421,0x78206ac1,0x5400cf43 + + .private_extern _lj_BC_IFUNCF + .no_dead_strip _lj_BC_IFUNCF +_lj_BC_IFUNCF: + .long 0xf9401ae0,0x3859e2a9,0xf85b42b4,0xeb00037f + .long 0x54001648,0xeb090f9f,0x540000e3,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0xf83c6a7a,0x9100239c,0x17fffff6 + + .private_extern _lj_BC_JFUNCF + .no_dead_strip _lj_BC_JFUNCF +_lj_BC_JFUNCF: + .long 0xf9401ae0,0x3859e2a9,0xf85b42b4,0xeb00037f + .long 0x54001448,0xeb090f9f,0x54000063,0xd3507e1c + .long 0x17ffffd0,0xf83c6a7a,0x9100239c,0x17fffffa + + .private_extern _lj_BC_FUNCV + .no_dead_strip _lj_BC_FUNCV +_lj_BC_FUNCV: + + .private_extern _lj_BC_IFUNCV + .no_dead_strip _lj_BC_IFUNCV +_lj_BC_IFUNCV: + .long 0xf9401ae0,0x92800108,0x8b1c026a,0x8b08bc42 + .long 0x8b1c037b,0x91004f88,0xf8008542,0xf85b42b4 + .long 0xeb00037f,0xf8008548,0x54001202,0xd100415c + .long 0x3859e2a9,0xaa1303fb,0xaa0a03f3,0xb4000109 + .long 0xeb1c037f,0x54000182,0xf9400368,0xd1000529 + .long 0xf800877a,0xf8008548,0xb5ffff49,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0xd1000529,0xf800855a,0xb4ffff09 + .long 0x17fffffd + + .private_extern _lj_BC_JFUNCV + .no_dead_strip _lj_BC_JFUNCV +_lj_BC_JFUNCV: + .long 0xd4200000 + + .private_extern _lj_BC_FUNCC + .no_dead_strip _lj_BC_FUNCC +_lj_BC_FUNCC: + .long 0xf9401443,0x8b1c0361,0xf9401ae0,0x8b1c027c + .long 0xeb00003f,0xa90272f3,0x12800028,0xaa1703e0 + .long 0x54000dc8,0xb900bac8,0xd63f0060,0xa94226f3 + .long 0xf900bad7,0x937d7c1c,0xb900bada,0xf85f8275 + .long 0xcb1c013b,0x14000019 + + .private_extern _lj_BC_FUNCCW + .no_dead_strip _lj_BC_FUNCCW +_lj_BC_FUNCCW: + .long 0xf940aec3,0x8b1c0361,0xf9401ae0,0x8b1c027c + .long 0xeb00003f,0xa90272f3,0xf9401441,0x12800028 + .long 0xaa1703e0,0x54000b68,0xb900bac8,0xd63f0060 + .long 0xa94226f3,0xf900bad7,0x937d7c1c,0xb900bada + .long 0xf85f8275,0xcb1c013b,0x14000006 + + .private_extern _lj_vm_returnp + .no_dead_strip _lj_vm_returnp +_lj_vm_returnp: + .long 0x36101c75,0xf85f8235,0x92e00028,0xaa1103f3 + .long 0xf81f8f68 + + .private_extern _lj_vm_returnc + .no_dead_strip _lj_vm_returnc +_lj_vm_returnc: + .long 0xb100239c,0x52800020,0x540006e0,0xb900c3fc + .long 0xf24006a0,0x54ffcbe0 + + .private_extern _lj_vm_return + .no_dead_strip _lj_vm_return +_lj_vm_return: + .long 0x927df2b1,0xf100041f,0xcb110271,0x54fffe41 + .long 0xf90012f1,0xb980cbe1,0x12800028,0xd1004273 + .long 0xf100238a,0xb900bac8,0x540000a0,0xf100214a + .long 0xf8408768,0xf8008668,0x54ffffa1,0xeb010f9f + .long 0x54000201,0xf90016f3 + + .private_extern _lj_vm_leave_cp + .no_dead_strip _lj_vm_leave_cp +_lj_vm_leave_cp: + .long 0xf94053fc,0x52800000,0xf9002afc + + .private_extern _lj_vm_leave_unw + .no_dead_strip _lj_vm_leave_unw +_lj_vm_leave_unw: + .long 0xa94153f3,0x6d4627e8,0xa9425bf5,0x6d472fea + .long 0xa94363f7,0x6d4837ec,0xa9446bf9,0x6d493fee + .long 0xa94573fb,0xa8cd7bfd,0xd65f03c0,0x540000ec + .long 0xf9401ae2,0xeb02027f,0x54000102,0xf800867a + .long 0x9100239c,0x17ffffe9,0xb4fffd41,0xcb010f80 + .long 0xcb000273,0x17ffffe7,0xf90016f3,0xaa1703e0 + bl _lj_state_growstack + .long 0xf94016f3,0xb980cbe1,0x17ffffdf + + .private_extern _lj_vm_unwind_c + .no_dead_strip _lj_vm_unwind_c +_lj_vm_unwind_c: + .long 0x9100001f,0xaa0103e0 + + .private_extern _lj_vm_unwind_c_eh + .no_dead_strip _lj_vm_unwind_c_eh +_lj_vm_unwind_c_eh: + .long 0xf9405bf7,0x12800028,0xf9400af6,0xb900bac8 + .long 0x17ffffde + + .private_extern _lj_vm_unwind_ff + .no_dead_strip _lj_vm_unwind_ff +_lj_vm_unwind_ff: + .long 0x927ef41f + + .private_extern _lj_vm_unwind_ff_eh + .no_dead_strip _lj_vm_unwind_ff_eh +_lj_vm_unwind_ff_eh: + .long 0xf9405bf7,0xd2ffff38,0xd2bfff39,0x9280001a + .long 0x5280021c,0xf94012f3,0xf9400af6,0x92d00008 + .long 0xd100227b,0xf85f8275,0xf81f8268,0xb900bada + .long 0x17ffffb5 + + .private_extern _lj_vm_growstack_c + .no_dead_strip _lj_vm_growstack_c +_lj_vm_growstack_c: + .long 0x52800281,0x14000007 + + .private_extern _lj_vm_growstack_l + .no_dead_strip _lj_vm_growstack_l +_lj_vm_growstack_l: + .long 0x8b1c027c,0xcb13037b,0xaa1703e0,0xa90272f3 + .long 0x910012b5,0xd343ff61,0xf90057f5 + bl _lj_state_growstack + .long 0xa94272f3,0xf85f0262,0xcb13039c,0x9240b842 + .long 0xf9401055,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_vm_resume + .no_dead_strip _lj_vm_resume +_lj_vm_resume: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0xaa0003f7 + .long 0xf9400af6,0xaa0103f3,0xf9005bf7,0x528000b5 + .long 0xb900cbff,0x910007e8,0x39402ee9,0xb900c7ff + .long 0xf90057f7,0xf90053ff,0xf9002ae8,0x34000669 + .long 0xf900bad7,0xaa1303fb,0xa94202f3,0xd2ffff38 + .long 0xd2bfff39,0xf85f8275,0x39002eff,0x9280001a + .long 0xcb13001c,0xf24006a0,0x9100239c,0xb900bada + .long 0xb900c3fc,0x54ffbbc0,0x17ffff7f + + .private_extern _lj_vm_pcall + .no_dead_strip _lj_vm_pcall +_lj_vm_pcall: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0x528000b5 + .long 0xb900c7e3,0x1400000d + + .private_extern _lj_vm_call + .no_dead_strip _lj_vm_call +_lj_vm_call: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0x52800035 + .long 0xf940281c,0xb900cbe2,0xaa0003f7,0xf9005be0 + .long 0xf9400af6,0xaa0103f3,0xf90057e0,0xf90053fc + .long 0xf9002afd,0xf900bad7,0xa94202f1,0xd2ffff38 + .long 0xd2bfff39,0x8b1302b5,0x9280001a,0xcb1102b5 + .long 0xcb13001c,0xb900bada + + .private_extern _lj_vm_call_dispatch + .no_dead_strip _lj_vm_call_dispatch +_lj_vm_call_dispatch: + .long 0xf85f0262,0x936ffc4f,0xb10025ff,0x9240b842 + .long 0x54001e81 + + .private_extern _lj_vm_call_dispatch_f + .no_dead_strip _lj_vm_call_dispatch_f +_lj_vm_call_dispatch_f: + .long 0xf81f8275,0xf9401055,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_vm_cpcall + .no_dead_strip _lj_vm_cpcall +_lj_vm_cpcall: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0xaa0003f7 + .long 0xf9401c1b,0xf9005be0,0xf9400af6,0xf94016f1 + .long 0xf90057e0,0xf9402afc,0xcb11037b,0xb900cbfb + .long 0xb900c7ff,0xf90053fc,0xf9002afd,0xf900bad7 + .long 0xd63f0060,0xaa0003f3,0x528000b5,0xb5fff9f3 + .long 0x17ffff3b + + .private_extern _lj_cont_dispatch + .no_dead_strip _lj_cont_dispatch +_lj_cont_dispatch: + .long 0xf85f0222,0xf85e0260,0xaa1303e3,0xaa1103f3 + .long 0x9240b842,0xf100041f,0xf85e8075,0xf9401042 + .long 0x8b1c0368,0xf81f811a,0x54000069,0xf85b8054 + .long 0xd61f0000,0x5400c080,0xd1008063,0xcb13007c + .long 0x140004d4 + + .private_extern _lj_cont_cat + .no_dead_strip _lj_cont_cat +_lj_cont_cat: + .long 0xb85fc2b0,0xd1008061,0xf9400368,0xf90012f3 + .long 0xd3587e11,0xd3483e1b,0x8b110e69,0xeb090029 + .long 0x54000080,0xf9000028,0xd343fd22,0x17fffa49 + .long 0xf83b7a68,0x14000069 + + .private_extern _lj_vmeta_tgets1 + .no_dead_strip _lj_vmeta_tgets1 +_lj_vmeta_tgets1: + .long 0x92800083,0x8b110e61,0x8b03bf83,0x14000004 + + .private_extern _lj_vmeta_tgets + .no_dead_strip _lj_vmeta_tgets +_lj_vmeta_tgets: + .long 0xf2ffff41,0xf90076c1,0x9103a2c1,0x9102e3e2 + .long 0xf9005fe3,0x14000008 + + .private_extern _lj_vmeta_tgetb + .no_dead_strip _lj_vmeta_tgetb +_lj_vmeta_tgetb: + .long 0x8b18039c,0x8b110e61,0x9102e3e2,0xf9005ffc + .long 0x14000003 + + .private_extern _lj_vmeta_tgetv + .no_dead_strip _lj_vmeta_tgetv +_lj_vmeta_tgetv: + .long 0x8b110e61,0x8b1c0e62,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_meta_tget + .long 0xb4000120,0xf9400008,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0xd1000a69,0xf94016f3,0x5280021c + .long 0xf85f0262,0xf81e8275,0xcb090275,0x9240b842 + .long 0x17ffff97 + + .private_extern _lj_vmeta_tgetr + .no_dead_strip _lj_vmeta_tgetr +_lj_vmeta_tgetr: + .long 0x93407d21 + bl _lj_tab_getinth + .long 0xaa1a03e8,0xb4ff7160,0xf9400008,0x17fffb89 + + .private_extern _lj_vmeta_tsets1 + .no_dead_strip _lj_vmeta_tsets1 +_lj_vmeta_tsets1: + .long 0x92800083,0x8b110e61,0x8b03bf83,0x14000004 + + .private_extern _lj_vmeta_tsets + .no_dead_strip _lj_vmeta_tsets +_lj_vmeta_tsets: + .long 0xf2ffff41,0xf90076c1,0x9103a2c1,0x9102e3e2 + .long 0xf9005fe3,0x14000008 + + .private_extern _lj_vmeta_tsetb + .no_dead_strip _lj_vmeta_tsetb +_lj_vmeta_tsetb: + .long 0x8b18039c,0x8b110e61,0x9102e3e2,0xf9005ffc + .long 0x14000003 + + .private_extern _lj_vmeta_tsetv + .no_dead_strip _lj_vmeta_tsetv +_lj_vmeta_tsetv: + .long 0x8b110e61,0x8b1c0e62,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_meta_tset + .long 0xf87b7a68,0xb4000100,0xf9000008,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0xd3507e1c + .long 0xd61f0100,0xd1000a69,0xf94016f3,0x5280031c + .long 0xf85f0262,0xf9000a68,0xf81e8275,0xcb090275 + .long 0x9240b842,0x17ffff6a + + .private_extern _lj_vmeta_tsetr + .no_dead_strip _lj_vmeta_tsetr +_lj_vmeta_tsetr: + .long 0x93407d22,0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_tab_setinth + .long 0x17fffc23 + + .private_extern _lj_vmeta_comp + .no_dead_strip _lj_vmeta_comp +_lj_vmeta_comp: + .long 0x8b1b0e61,0xd10012b5,0x8b1c0e62,0xf90012f3 + .long 0xaa1703e0,0xf90057f5,0x53001e03 + bl _lj_meta_comp + .long 0xf100041f,0x54000828,0x794006b1,0x910012b5 + .long 0x8b110ab1,0xd1408231,0x9a9132b5 + + .private_extern _lj_cont_nop + .no_dead_strip _lj_cont_nop +_lj_cont_nop: + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf947b128 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_cont_ra + .no_dead_strip _lj_cont_ra +_lj_cont_ra: + .long 0xb85fc2b0,0xf9400368,0xd3483e09,0xf8297a68 + .long 0x17fffff6 + + .private_extern _lj_cont_condt + .no_dead_strip _lj_cont_condt +_lj_cont_condt: + .long 0xf9400368,0x92e00029,0xeb08013f,0x17ffffed + + .private_extern _lj_cont_condf + .no_dead_strip _lj_cont_condf +_lj_cont_condf: + .long 0xf9400368,0x92d00009,0xeb09011f,0x17ffffe9 + + .private_extern _lj_vmeta_equal + .no_dead_strip _lj_vmeta_equal +_lj_vmeta_equal: + .long 0x9240b842,0xd10012b5,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_meta_equal + .long 0x17ffffe0 + + .private_extern _lj_vmeta_equal_cd + .no_dead_strip _lj_vmeta_equal_cd +_lj_vmeta_equal_cd: + .long 0xd10012b5,0xf90012f3,0xaa1703e0,0xaa1003e1 + .long 0xf90057f5 + bl _lj_meta_equal_cd + .long 0x17ffffd9 + + .private_extern _lj_vmeta_istype + .no_dead_strip _lj_vmeta_istype +_lj_vmeta_istype: + .long 0xd10012b5,0xf90012f3,0xaa1703e0,0xaa1b03e1 + .long 0xaa1c03e2,0xf90057f5 + bl _lj_meta_istype + .long 0x17ffffd8 + + .private_extern _lj_vmeta_arith_vn + .no_dead_strip _lj_vmeta_arith_vn +_lj_vmeta_arith_vn: + .long 0x8b110e62,0x8b1c0e83,0x14000009 + + .private_extern _lj_vmeta_arith_nv + .no_dead_strip _lj_vmeta_arith_nv +_lj_vmeta_arith_nv: + .long 0x8b110e63,0x8b1c0e82,0x14000006 + + .private_extern _lj_vmeta_unm + .no_dead_strip _lj_vmeta_unm +_lj_vmeta_unm: + .long 0x8b1c0e62,0xaa0203e3,0x14000003 + + .private_extern _lj_vmeta_arith_vv + .no_dead_strip _lj_vmeta_arith_vv +_lj_vmeta_arith_vv: + .long 0x8b110e62,0x8b1c0e63,0x53001e04,0x8b1b0e61 + .long 0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_meta_arith + .long 0xb4fff8c0 + + .private_extern _lj_vmeta_binop + .no_dead_strip _lj_vmeta_binop +_lj_vmeta_binop: + .long 0xcb130009,0xf81e8015,0x91000935,0xaa0003f3 + .long 0x5280021c,0x17ffff0f + + .private_extern _lj_vmeta_len + .no_dead_strip _lj_vmeta_len +_lj_vmeta_len: + .long 0x8b1c0e61,0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_meta_len + .long 0x17fffff5 + + .private_extern _lj_vmeta_call + .no_dead_strip _lj_vmeta_call +_lj_vmeta_call: + .long 0xaa1703e0,0xf90012f1,0xd1004261,0xf90057f5 + .long 0x8b1c0262 + bl _lj_meta_call + .long 0xf85f0262,0x9100239c,0x9240b842,0xf81f8275 + .long 0xf9401055,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf947b128,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_vmeta_callt + .no_dead_strip _lj_vmeta_callt +_lj_vmeta_callt: + .long 0xaa1703e0,0xf90012f3,0xd1004361,0xf90057f5 + .long 0x8b1c0362 + bl _lj_meta_call + .long 0xf85f0369,0xf85f8275,0x9100239c,0x9240b922 + .long 0x17fffbe2 + + .private_extern _lj_vmeta_for + .no_dead_strip _lj_vmeta_for +_lj_vmeta_for: + .long 0xaa1703e0,0xf90012f3,0xaa1b03e1,0xf90057f5 + bl _lj_meta_for + .long 0xb85fc2b0,0x53001e08,0xd3483e1b,0xd3507e1c + .long 0xf101391f,0x54ffa1e0,0x17fffcea + + .private_extern _lj_ff_assert + .no_dead_strip _lj_ff_assert +_lj_ff_assert: + .long 0xf9400260,0xf100239f,0x540079e3,0xf85f8275 + .long 0x92d00009,0xeb09001f,0x54007962,0xf81f0260 + .long 0xd1002271,0xf100239b,0x9100239c,0xb40032fb + .long 0xf9400a20,0xd100237b,0xf8008620,0xb5ffffbb + .long 0x14000192 + + .private_extern _lj_ff_type + .no_dead_strip _lj_ff_type +_lj_ff_type: + .long 0xf9400260,0xf100239f,0x540077c3,0x528001a8 + .long 0x936ffc0f,0xb10035ff,0xda8f3109,0x91001929 + .long 0xf8697840,0x14000185 + + .private_extern _lj_ff_getmetatable + .no_dead_strip _lj_ff_getmetatable +_lj_ff_getmetatable: + .long 0xf9400260,0xf100239f,0x54007683,0x936ffc0f + .long 0xb10031ff,0xba4d19e4,0x9240b800,0x54000301 + .long 0xf9401011,0xaa1a03e0,0xf9411adc,0xb4002f31 + .long 0xb9403629,0xb9400f8a,0xf9401622,0x0a0a0129 + .long 0x8b090529,0x92800083,0x8b090c42,0x8b03bf83 + .long 0xa9402040,0xf9400842,0xeb03011f,0x540000a0 + .long 0xb5ffff82,0xaa1103e0,0xf2ffff40,0x14000169 + .long 0xeb1a011f,0x54002ce1,0x17fffffb,0x928001a8 + .long 0xeb0801ff,0x9a8821ef,0xcb0f0ec9,0xf9412931 + .long 0x17ffffe5 + + .private_extern _lj_ff_setmetatable + .no_dead_strip _lj_ff_setmetatable +_lj_ff_setmetatable: + .long 0xa9400660,0xf100439f,0x540071e3,0x936ffc0f + .long 0xb10031ff,0x9240b809,0x54007161,0xf9401128 + .long 0x936ffc2f,0x3940212a,0xb10031ff,0x9240b821 + .long 0xfa400900,0x54007081,0xf9001121,0x36102a0a + .long 0xf94022c8,0x121d794a,0xf90022c9,0x3900212a + .long 0xf9000d28,0x1400014a + + .private_extern _lj_ff_rawget + .no_dead_strip _lj_ff_rawget +_lj_ff_rawget: + .long 0xf9400261,0xf100439f,0x54006f23,0x936ffc2f + .long 0xb10031ff,0x9240b821,0x54006ea1,0xaa1703e0 + .long 0x91002262 + bl _lj_tab_get + .long 0xf9400000,0x1400013e + + .private_extern _lj_ff_tonumber + .no_dead_strip _lj_ff_tonumber +_lj_ff_tonumber: + .long 0xf9400260,0xf100239f,0x54006da1,0xeb40833f + .long 0x54006d63,0x14000138 + + .private_extern _lj_ff_tostring + .no_dead_strip _lj_ff_tostring +_lj_ff_tostring: + .long 0xf9400260,0xf100239f,0x54006ce3,0x936ffc0f + .long 0xb10015ff,0x54002640,0xf94162c9,0xf90012f3 + .long 0xb10039ff,0xfa409920,0xf90057f5,0x54006bc1 + .long 0xa94106c0,0xeb01001f,0x5400004b,0x94000384 + .long 0xaa1703e0,0xaa1303e1 + bl _lj_strfmt_number + .long 0x92800089,0xf94012f3,0x8b09bc00,0x14000121 + + .private_extern _lj_ff_next + .no_dead_strip _lj_ff_next +_lj_ff_next: + .long 0xf9400260,0xf100239f,0x54006a03,0x936ffc0f + .long 0xb10031ff,0x9240b801,0x54006981,0xf83c6a7a + .long 0xf85f8275,0xa9024ef3,0xaa1703e0,0x91002262 + .long 0xf90057f5 + bl _lj_tab_next + .long 0xf81f027a,0xb4002260,0xa9408660,0x5280031c + .long 0xa93f0660,0x14000110 + + .private_extern _lj_ff_pairs + .no_dead_strip _lj_ff_pairs +_lj_ff_pairs: + .long 0xf9400260,0xf100239f,0x54006783,0x936ffc0f + .long 0xb10031ff,0x9240b809,0x54006701,0xf9401843 + .long 0xf85f8275,0x5280041c,0xa93fea60,0xf81f0263 + .long 0x14000103 + + .private_extern _lj_ff_ipairs_aux + .no_dead_strip _lj_ff_ipairs_aux +_lj_ff_ipairs_aux: + .long 0xa9400660,0xf100439f,0x540065e3,0x936ffc0f + .long 0xb10031ff,0x9240b800,0x54006561,0xeb41833f + .long 0x54006521,0xb9403009,0xf9400802,0xb9403408 + .long 0x11000421,0x6b09003f,0xf85f8275,0x8b18002a + .long 0x5280011c,0xf81f026a,0x540000e2,0xf8617848 + .long 0x52800309,0xeb1a011f,0xf81f8268,0x9a89039c + .long 0x140000ea,0x34001d28 + bl _lj_tab_getinth + .long 0xb4001ce0,0xf9400008,0x17fffff7 + + .private_extern _lj_ff_ipairs + .no_dead_strip _lj_ff_ipairs +_lj_ff_ipairs: + .long 0xf9400260,0xf100239f,0x54006223,0x936ffc0f + .long 0xb10031ff,0x9240b809,0x540061a1,0xf9401843 + .long 0xf85f8275,0x5280041c,0xa93fe260,0xf81f0263 + .long 0x140000d8 + + .private_extern _lj_ff_pcall + .no_dead_strip _lj_ff_pcall +_lj_ff_pcall: + .long 0x394246c8,0xf100239c,0x54006083,0xaa1303f1 + .long 0x91004273,0x53041108,0x91005915,0x54ffc1c0 + .long 0x8b1c026a,0xf85f0148,0xf81f8d48,0xeb13015f + .long 0x54ffffa1,0x17fffe08 + + .private_extern _lj_ff_xpcall + .no_dead_strip _lj_ff_xpcall +_lj_ff_xpcall: + .long 0xa9400660,0x394246c8,0xf1004389,0x54005ea3 + .long 0xaa1303f1,0x936ffc2f,0x53041108,0xb10025ff + .long 0x91007915,0x54005de1,0xaa0903fc,0x91006273 + .long 0xa9000221,0xb4ffbf5c,0x17ffffec + + .private_extern _lj_ff_coroutine_resume + .no_dead_strip _lj_ff_coroutine_resume +_lj_ff_coroutine_resume: + .long 0xf9400260,0xf100239f,0x54005ce3,0x936ffc0f + .long 0xb1001dff,0x9240b800,0x54005c61,0xf85f8275 + .long 0xf90012f3,0xa9420411,0x39402c09,0x8b090028 + .long 0xf90057f5,0xeb11011f,0x54005b60,0xf100053f + .long 0x91002028,0x9a882021,0xf9401803,0x8b1c0022 + .long 0xf9402811,0xfa439042,0xfa409a22,0x54005a48 + .long 0xd1002042,0x91002273,0xd100239c,0xf9001402 + .long 0xf90016f3,0xb40000dc,0xf8716a68,0xeb1c023f + .long 0xf8316828,0x91002231,0x54ffff81,0x52800002 + .long 0xaa0003fb,0x52800003,0x97fffd7f,0xa9420f62 + .long 0xf100041f,0xf94012f3,0xf900bad7,0xb900bada + .long 0x54000308,0xcb02007c,0xf9401ae0,0x8b1c0261 + .long 0xb400017c,0xeb00003f,0x52800011,0x540002e8 + .long 0xd1002383,0xf9001762,0xf8716848,0xeb03023f + .long 0xf8316a68,0x91002231,0x54ffff81,0x92e00029 + .long 0x9100439c,0xf81f8269,0xd100227b,0xf24006a0 + .long 0xf90057f5,0xb900c3fc,0x54ff6cc0,0x17fffd07 + .long 0xf85f8c68,0x92d00009,0x5280031c,0xf9001763 + .long 0xf9000268,0x17fffff4,0xaa1703e0,0xd343ff81 + bl _lj_state_growstack + .long 0x52800000,0x17ffffd9 + + .private_extern _lj_ff_coroutine_wrap_aux + .no_dead_strip _lj_ff_coroutine_wrap_aux +_lj_ff_coroutine_wrap_aux: + .long 0xf9401840,0x9240b800,0xf85f8275,0xf90012f3 + .long 0xa9420411,0x39402c09,0x8b090028,0xf90057f5 + .long 0xeb11011f,0x54005220,0xf100053f,0x91002028 + .long 0x9a882021,0xf9401803,0x8b1c0022,0xf9402811 + .long 0xfa439042,0xfa409a22,0x54005108,0xf9001402 + .long 0xf90016f3,0xb40000dc,0xf8716a68,0xeb1c023f + .long 0xf8316828,0x91002231,0x54ffff81,0x52800002 + .long 0xaa0003fb,0x52800003,0x97fffd38,0xa9420f62 + .long 0xf100041f,0xf94012f3,0xf900bad7,0xb900bada + .long 0x540002c8,0xcb02007c,0xf9401ae0,0x8b1c0261 + .long 0xb400017c,0xeb00003f,0x52800011,0x54000248 + .long 0xd1002383,0xf9001762,0xf8716848,0xeb03023f + .long 0xf8316a68,0x91002231,0x54ffff81,0xaa1303fb + .long 0x9100239c,0xf24006a0,0xf90057f5,0xb900c3fc + .long 0x54ff6420,0x17fffcc2,0xaa1703e0,0xaa1b03e1 + bl _lj_ffh_coroutine_wrap_err + .long 0xaa1703e0,0xd343ff81 + bl _lj_state_growstack + .long 0x52800000,0x17ffffde + + .private_extern _lj_ff_coroutine_yield + .no_dead_strip _lj_ff_coroutine_yield +_lj_ff_coroutine_yield: + .long 0xf9402ae8,0x8b1c0269,0x52800020,0xa90226f3 + .long 0x36004a88,0xf9002aff,0x39002ee0,0x17fffcc7 + + .private_extern _lj_ff_math_floor + .no_dead_strip _lj_ff_math_floor +_lj_ff_math_floor: + .long 0xf9400260,0xf100239f,0xfd400260,0x540049a3 + .long 0xeb40833f,0x54000320,0x54004943,0x1e654000 + .long 0x14000034 + + .private_extern _lj_ff_math_ceil + .no_dead_strip _lj_ff_math_ceil +_lj_ff_math_ceil: + .long 0xf9400260,0xf100239f,0xfd400260,0x54004883 + .long 0xeb40833f,0x54000200,0x54004823,0x1e64c000 + .long 0x1400002b + + .private_extern _lj_ff_math_abs + .no_dead_strip _lj_ff_math_abs +_lj_ff_math_abs: + .long 0xf9400260,0xf100239f,0x54004783,0xeb40833f + .long 0x54004743,0x9240f800,0x540000c1,0x4a807c01 + .long 0xd2e83c02,0x6b807c20,0x8b180000,0x9a825000 + + .private_extern _lj_fff_restv + .no_dead_strip _lj_fff_restv +_lj_fff_restv: + .long 0xf85f8275,0xf81f0260 + + .private_extern _lj_fff_res1 + .no_dead_strip _lj_fff_res1 +_lj_fff_res1: + .long 0x5280021c + + .private_extern _lj_fff_res + .no_dead_strip _lj_fff_res +_lj_fff_res: + .long 0xf24006a0,0xb900c3fc,0xd100427b,0x54ff91a1 + .long 0xb85fc2b0,0xd3587e11,0xeb110f9f,0x54000123 + .long 0xd3483e09,0xcb090f73,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0xd3507e1c,0xd61f0100 + .long 0x8b1c0369,0x9100239c,0xf81f813a,0x17fffff3 + + .private_extern _lj_ff_math_sqrt + .no_dead_strip _lj_ff_math_sqrt +_lj_ff_math_sqrt: + .long 0xf9400260,0xf100239f,0xfd400260,0x54004303 + .long 0xeb40833f,0x540042c9,0x1e61c000 + + .private_extern _lj_fff_resn + .no_dead_strip _lj_fff_resn +_lj_fff_resn: + .long 0xf85f8275,0xfc1f0260,0x17ffffe2 + + .private_extern _lj_ff_math_log + .no_dead_strip _lj_ff_math_log +_lj_ff_math_log: + .long 0xf9400260,0xf100239f,0xfd400260,0x540041c1 + .long 0xeb40833f,0x54004189 + bl _log + .long 0x17fffff6 + + .private_extern _lj_ff_math_log10 + .no_dead_strip _lj_ff_math_log10 +_lj_ff_math_log10: + .long 0xf9400260,0xf100239f,0xfd400260,0x540040c3 + .long 0xeb40833f,0x54004089 + bl _log10 + .long 0x17ffffee + + .private_extern _lj_ff_math_exp + .no_dead_strip _lj_ff_math_exp +_lj_ff_math_exp: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003fc3 + .long 0xeb40833f,0x54003f89 + bl _exp + .long 0x17ffffe6 + + .private_extern _lj_ff_math_sin + .no_dead_strip _lj_ff_math_sin +_lj_ff_math_sin: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003ec3 + .long 0xeb40833f,0x54003e89 + bl _sin + .long 0x17ffffde + + .private_extern _lj_ff_math_cos + .no_dead_strip _lj_ff_math_cos +_lj_ff_math_cos: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003dc3 + .long 0xeb40833f,0x54003d89 + bl _cos + .long 0x17ffffd6 + + .private_extern _lj_ff_math_tan + .no_dead_strip _lj_ff_math_tan +_lj_ff_math_tan: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003cc3 + .long 0xeb40833f,0x54003c89 + bl _tan + .long 0x17ffffce + + .private_extern _lj_ff_math_asin + .no_dead_strip _lj_ff_math_asin +_lj_ff_math_asin: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003bc3 + .long 0xeb40833f,0x54003b89 + bl _asin + .long 0x17ffffc6 + + .private_extern _lj_ff_math_acos + .no_dead_strip _lj_ff_math_acos +_lj_ff_math_acos: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003ac3 + .long 0xeb40833f,0x54003a89 + bl _acos + .long 0x17ffffbe + + .private_extern _lj_ff_math_atan + .no_dead_strip _lj_ff_math_atan +_lj_ff_math_atan: + .long 0xf9400260,0xf100239f,0xfd400260,0x540039c3 + .long 0xeb40833f,0x54003989 + bl _atan + .long 0x17ffffb6 + + .private_extern _lj_ff_math_sinh + .no_dead_strip _lj_ff_math_sinh +_lj_ff_math_sinh: + .long 0xf9400260,0xf100239f,0xfd400260,0x540038c3 + .long 0xeb40833f,0x54003889 + bl _sinh + .long 0x17ffffae + + .private_extern _lj_ff_math_cosh + .no_dead_strip _lj_ff_math_cosh +_lj_ff_math_cosh: + .long 0xf9400260,0xf100239f,0xfd400260,0x540037c3 + .long 0xeb40833f,0x54003789 + bl _cosh + .long 0x17ffffa6 + + .private_extern _lj_ff_math_tanh + .no_dead_strip _lj_ff_math_tanh +_lj_ff_math_tanh: + .long 0xf9400260,0xf100239f,0xfd400260,0x540036c3 + .long 0xeb40833f,0x54003689 + bl _tanh + .long 0x17ffff9e + + .private_extern _lj_ff_math_pow + .no_dead_strip _lj_ff_math_pow +_lj_ff_math_pow: + .long 0xa9400660,0xf100439f,0x6d400660,0x540035c3 + .long 0xeb40833f,0x54003589,0xeb41833f,0x54003549 + bl _pow + .long 0x17ffff94 + + .private_extern _lj_ff_math_atan2 + .no_dead_strip _lj_ff_math_atan2 +_lj_ff_math_atan2: + .long 0xa9400660,0xf100439f,0x6d400660,0x54003483 + .long 0xeb40833f,0x54003449,0xeb41833f,0x54003409 + bl _atan2 + .long 0x17ffff8a + + .private_extern _lj_ff_math_fmod + .no_dead_strip _lj_ff_math_fmod +_lj_ff_math_fmod: + .long 0xa9400660,0xf100439f,0x6d400660,0x54003343 + .long 0xeb40833f,0x54003309,0xeb41833f,0x540032c9 + bl _fmod + .long 0x17ffff80 + + .private_extern _lj_ff_math_ldexp + .no_dead_strip _lj_ff_math_ldexp +_lj_ff_math_ldexp: + .long 0xa9400660,0xf100439f,0x54003223,0xfd400260 + .long 0xeb40833f,0x540031c9,0xeb41833f,0x54003181 + .long 0x93407c20 + bl _ldexp + .long 0x17ffff75 + + .private_extern _lj_ff_math_frexp + .no_dead_strip _lj_ff_math_frexp +_lj_ff_math_frexp: + .long 0xf9400260,0xf100239f,0xfd400260,0x540030a3 + .long 0xeb40833f,0x54003069,0x9102e3e0 + bl _frexp + .long 0xb940bbe1,0xf85f8275,0xfc1f0260,0x5280031c + .long 0x8b180021,0xf81f8261,0x17ffff4b + + .private_extern _lj_ff_math_modf + .no_dead_strip _lj_ff_math_modf +_lj_ff_math_modf: + .long 0xf9400260,0xf100239f,0xfd400260,0x54002ec3 + .long 0xeb40833f,0x54002e89,0xd1004260,0xf85f8275 + bl _modf + .long 0x5280031c,0xfc1f8260,0x17ffff3f + + .private_extern _lj_ff_math_min + .no_dead_strip _lj_ff_math_min +_lj_ff_math_min: + .long 0xf9400260,0xf100239f,0x54002d63,0x8b1c0271 + .long 0x9100227b,0xeb40833f,0x540001c1,0xf9400361 + .long 0xeb11037f,0x54ffe642,0xeb41833f,0x540000a1 + .long 0x6b01001f,0x9100237b,0x9a80c020,0x17fffff8 + .long 0x1e620000,0x54002b83,0xfd400361,0x14000009 + .long 0xfd400260,0x54002b03,0xf9400361,0xfd400361 + .long 0xeb11037f,0x54ffe802,0xeb41833f,0x540000a9 + .long 0x1e612000,0x9100237b,0x1e605c20,0x17fffff7 + .long 0x1e620021,0x54002983,0x17fffffa + + .private_extern _lj_ff_math_max + .no_dead_strip _lj_ff_math_max +_lj_ff_math_max: + .long 0xf9400260,0xf100239f,0x54002903,0x8b1c0271 + .long 0x9100227b,0xeb40833f,0x540001c1,0xf9400361 + .long 0xeb11037f,0x54ffe1e2,0xeb41833f,0x540000a1 + .long 0x6b01001f,0x9100237b,0x9a80b020,0x17fffff8 + .long 0x1e620000,0x54002723,0xfd400361,0x14000009 + .long 0xfd400260,0x540026a3,0xf9400361,0xfd400361 + .long 0xeb11037f,0x54ffe3a2,0xeb41833f,0x540000a9 + .long 0x1e612000,0x9100237b,0x1e60dc20,0x17fffff7 + .long 0x1e620021,0x54002523,0x17fffffa + + .private_extern _lj_ff_string_byte + .no_dead_strip _lj_ff_string_byte +_lj_ff_string_byte: + .long 0xa97f8275,0xf100239f,0x936ffc0f,0xba4509e0 + .long 0x9240b800,0x54002441,0x39406008,0xb9401402 + .long 0x8b180108,0xf81f0268,0x5280011c,0xb4ffdda2 + .long 0x17fffeeb + + .private_extern _lj_ff_string_char + .no_dead_strip _lj_ff_string_char +_lj_ff_string_char: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x94000141 + .long 0xa97f8275,0x7103fc1f,0xfa489b80,0x54002261 + .long 0xeb40833f,0x54002221,0x52800022,0xaa1303e1 + + .private_extern _lj_fff_newstr + .no_dead_strip _lj_fff_newstr +_lj_fff_newstr: + .long 0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_str_new + + .private_extern _lj_fff_resstr + .no_dead_strip _lj_fff_resstr +_lj_fff_resstr: + .long 0xf94012f3,0x92800089,0x8b09bc00,0x17fffed5 + + .private_extern _lj_ff_string_sub + .no_dead_strip _lj_ff_string_sub +_lj_ff_string_sub: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x9400012d + .long 0xf9400260,0xf9400a62,0xf100439f,0x92800011 + .long 0x540000a0,0x54001fa3,0xeb42833f,0x54001f61 + .long 0x93407c51,0xf9400661,0x936ffc0f,0xb10015ff + .long 0x9240b800,0x54001ea1,0xb9401409,0xeb41833f + .long 0x54001e41,0x93407c21,0x8b09022a,0xf100023f + .long 0x8b090028,0x9a8aa631,0xf100003f,0x9a88a421 + .long 0xf100023f,0x9a9fa231,0xf100043f,0x9a9fa421 + .long 0xeb09023f,0x9a89d231,0x91005c00,0xeb010222 + .long 0x8b010001,0x91000442,0x54fffa4a,0x9101e2c0 + .long 0x92800089,0x8b09bc00,0x17fffeaa + + .private_extern _lj_ff_string_reverse + .no_dead_strip _lj_ff_string_reverse +_lj_ff_string_reverse: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x94000102 + .long 0xf9400261,0xf100239f,0x936ffc2f,0xba4529e0 + .long 0x9240b821,0x54001a41,0xf9406ec8,0x910322c0 + .long 0xf90012f3,0xf90057f5,0xf90072d7,0xf90066c8 + bl _lj_buf_putstr_reverse + bl _lj_buf_tostr + .long 0x17ffffbf + + .private_extern _lj_ff_string_lower + .no_dead_strip _lj_ff_string_lower +_lj_ff_string_lower: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x940000ef + .long 0xf9400261,0xf100239f,0x936ffc2f,0xba4529e0 + .long 0x9240b821,0x540017e1,0xf9406ec8,0x910322c0 + .long 0xf90012f3,0xf90057f5,0xf90072d7,0xf90066c8 + bl _lj_buf_putstr_lower + bl _lj_buf_tostr + .long 0x17ffffac + + .private_extern _lj_ff_string_upper + .no_dead_strip _lj_ff_string_upper +_lj_ff_string_upper: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x940000dc + .long 0xf9400261,0xf100239f,0x936ffc2f,0xba4529e0 + .long 0x9240b821,0x54001581,0xf9406ec8,0x910322c0 + .long 0xf90012f3,0xf90057f5,0xf90072d7,0xf90066c8 + bl _lj_buf_putstr_upper + bl _lj_buf_tostr + .long 0x17ffff99 + + .private_extern _lj_vm_tobit_fb + .no_dead_strip _lj_vm_tobit_fb +_lj_vm_tobit_fb: + .long 0x54001449,0x8b000001,0x52808682,0xcb41d442 + .long 0xf100d45f,0x540000e8,0x9240d021,0xb24b0021 + .long 0xf100001f,0x9ac22421,0x5a815420,0xd61f03c0 + .long 0x52800000,0xd61f03c0 + + .private_extern _lj_ff_bit_band + .no_dead_strip _lj_ff_bit_band +_lj_ff_bit_band: + .long 0xf9400260,0xf100239f,0x54001243,0x1000007e + .long 0xeb40833f,0x54fffda1,0x5280011b,0x2a0003e8 + .long 0x100000fe,0xf87b6a60,0xeb1c037f,0x9100237b + .long 0x540005ca,0xeb40833f,0x54fffc81,0x0a000108 + .long 0x17fffff9 + + .private_extern _lj_ff_bit_bor + .no_dead_strip _lj_ff_bit_bor +_lj_ff_bit_bor: + .long 0xf9400260,0xf100239f,0x54001023,0x1000007e + .long 0xeb40833f,0x54fffb81,0x5280011b,0x2a0003e8 + .long 0x100000fe,0xf87b6a60,0xeb1c037f,0x9100237b + .long 0x540003aa,0xeb40833f,0x54fffa61,0x2a000108 + .long 0x17fffff9 + + .private_extern _lj_ff_bit_bxor + .no_dead_strip _lj_ff_bit_bxor +_lj_ff_bit_bxor: + .long 0xf9400260,0xf100239f,0x54000e03,0x1000007e + .long 0xeb40833f,0x54fff961,0x5280011b,0x2a0003e8 + .long 0x100000fe,0xf87b6a60,0xeb1c037f,0x9100237b + .long 0x5400018a,0xeb40833f,0x54fff841,0x4a000108 + .long 0x17fffff9 + + .private_extern _lj_ff_bit_tobit + .no_dead_strip _lj_ff_bit_tobit +_lj_ff_bit_tobit: + .long 0xf9400260,0xf100239f,0x54000be3,0x1000007e + .long 0xeb40833f,0x54fff741,0x2a0003e8,0x8b180100 + .long 0x17fffe27 + + .private_extern _lj_ff_bit_bswap + .no_dead_strip _lj_ff_bit_bswap +_lj_ff_bit_bswap: + .long 0xf9400260,0xf100239f,0x54000ac3,0x1000007e + .long 0xeb40833f,0x54fff621,0x5ac00808,0x8b180100 + .long 0x17fffe1e + + .private_extern _lj_ff_bit_bnot + .no_dead_strip _lj_ff_bit_bnot +_lj_ff_bit_bnot: + .long 0xf9400260,0xf100239f,0x540009a3,0x1000007e + .long 0xeb40833f,0x54fff501,0x2a2003e8,0x8b180100 + .long 0x17fffe15 + + .private_extern _lj_ff_bit_lshift + .no_dead_strip _lj_ff_bit_lshift +_lj_ff_bit_lshift: + .long 0xa9400268,0xf100439f,0x54000883,0x1000007e + .long 0xeb40833f,0x54fff3e1,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54fff341,0x1ac92008 + .long 0x8b180100,0x17fffe07 + + .private_extern _lj_ff_bit_rshift + .no_dead_strip _lj_ff_bit_rshift +_lj_ff_bit_rshift: + .long 0xa9400268,0xf100439f,0x540006c3,0x1000007e + .long 0xeb40833f,0x54fff221,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54fff181,0x1ac92408 + .long 0x8b180100,0x17fffdf9 + + .private_extern _lj_ff_bit_arshift + .no_dead_strip _lj_ff_bit_arshift +_lj_ff_bit_arshift: + .long 0xa9400268,0xf100439f,0x54000503,0x1000007e + .long 0xeb40833f,0x54fff061,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54ffefc1,0x1ac92808 + .long 0x8b180100,0x17fffdeb + + .private_extern _lj_ff_bit_rol + .no_dead_strip _lj_ff_bit_rol +_lj_ff_bit_rol: + .long 0xa9400268,0xf100439f,0x54000343,0x1000007e + .long 0xeb40833f,0x54ffeea1,0xcb0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54ffee01,0x1ac92c08 + .long 0x8b180100,0x17fffddd + + .private_extern _lj_ff_bit_ror + .no_dead_strip _lj_ff_bit_ror +_lj_ff_bit_ror: + .long 0xa9400268,0xf100439f,0x54000183,0x1000007e + .long 0xeb40833f,0x54ffece1,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54ffec41,0x1ac92c08 + .long 0x8b180100,0x17fffdcf + + .private_extern _lj_fff_fallback + .no_dead_strip _lj_fff_fallback +_lj_fff_fallback: + .long 0xa97f5662,0xf9401aea,0x8b1c0269,0xa90226f3 + .long 0x9240b842,0x91028129,0xf9401442,0xf90057f5 + .long 0xeb0a013f,0xaa1703e0,0x54000368,0xd63f0040 + .long 0xf94012f3,0x7100001f,0xd37df01c,0xd100427b + .long 0x54ffb82c,0xf94016e0,0xf85f0262,0xcb13001c + .long 0x54000121,0x9240b842,0xf9401055,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf947b128,0x8b1b0e7b + .long 0xd61f0100 + + .private_extern _lj_vm_call_tail + .no_dead_strip _lj_vm_call_tail +_lj_vm_call_tail: + .long 0xf24006a8,0x927df2a9,0x54000081,0x385fd2bb + .long 0xd37df37b,0x91004369,0xcb090271,0x17fffaeb + .long 0x52800281 + bl _lj_state_growstack + .long 0xf94012f3,0xeb00001f,0x17ffffe8 + + .private_extern _lj_fff_gcstep + .no_dead_strip _lj_fff_gcstep +_lj_fff_gcstep: + .long 0x8b1c0261,0xaa1e03fb,0xa90206f3,0xf90057f5 + .long 0xaa1703e0 + bl _lj_gc_step + .long 0xa94206f3,0xf85f0262,0xaa1b03fe,0xcb13003c + .long 0x9240b842,0xd65f03c0 + + .private_extern _lj_vm_record + .no_dead_strip _lj_vm_record +_lj_vm_record: + .long 0x394246c0,0xf27b001f,0x54000161,0xb9414ac1 + .long 0xf27c001f,0x54000261,0x51000421,0xf27e041f + .long 0x54000200,0xb9014ac1,0x1400000e + + .private_extern _lj_vm_rethook + .no_dead_strip _lj_vm_rethook +_lj_vm_rethook: + .long 0x394246ca,0x3620018a,0xf94a1928,0xd61f0100 + + .private_extern _lj_vm_inshook + .no_dead_strip _lj_vm_inshook +_lj_vm_inshook: + .long 0x394246ca,0xb9414acb,0x3727ff8a,0x721e055f + .long 0x54ffff40,0x5100056b,0xb9014acb,0x3400004b + .long 0x3617feca,0xaa1703e0,0xf90012f3,0xaa1503e1 + bl _lj_dispatch_ins + .long 0xf94012f3,0xb85fc2b0,0x8b300ec9,0xd3483e1b + .long 0xf94a1928,0xd3507e1c,0xd61f0100 + + .private_extern _lj_cont_hook + .no_dead_strip _lj_cont_hook +_lj_cont_hook: + .long 0xf85d8060,0x910012b5,0xb900c3e0,0x17fffff7 + + .private_extern _lj_vm_hotloop + .no_dead_strip _lj_vm_hotloop +_lj_vm_hotloop: + .long 0xf85f0262,0x910b62c0,0x9240b842,0xf90057f5 + .long 0xf9401042,0xaa1503e1,0xf901aed7,0x385a3042 + .long 0xf90012f3,0x8b020e62,0xf90016e2 + bl _lj_trace_hot + .long 0x17ffffe9 + + .private_extern _lj_vm_callhook + .no_dead_strip _lj_vm_callhook +_lj_vm_callhook: + .long 0xaa1503e1,0x14000002 + + .private_extern _lj_vm_hotcall + .no_dead_strip _lj_vm_hotcall +_lj_vm_hotcall: + .long 0xb24002a1,0x8b1c0269,0xf90057f5,0xaa1703e0 + .long 0xcb13037b,0xa90226f3 + bl _lj_dispatch_call + .long 0xa94226f3,0xf90057ff,0xf85f0262,0x8b1b027b + .long 0xcb13013c,0xb85fc2b0,0x9240b842,0xd61f0000 + + .private_extern _lj_cont_stitch + .no_dead_strip _lj_cont_stitch +_lj_cont_stitch: + .long 0xb940c3f1,0xb85fc2b0,0xf85d8062,0xf1002231 + .long 0xd3483e1c,0x9240b842,0x540000e0,0xf9400360 + .long 0x9100237b,0xf1002231,0xf83c7a60,0x9100079c + .long 0x54ffff61,0xd3483e1b,0xd3587e11,0x8b11037b + .long 0xeb1c037f,0x54000228,0x7940d05b,0x7940d45c + .long 0x6b1b039f,0x54ff6600,0x7100039f,0x54ff2921 + .long 0x5281d180,0xb8206adb,0x52806b00,0xf8206ad7 + .long 0xf90012f3,0x910b62c0,0xaa1503e1 + bl _lj_dispatch_stitch + .long 0xf94012f3,0x17fffb24,0xf83c7a7a,0x9100079c + .long 0x17ffffec + + .private_extern _lj_vm_profhook + .no_dead_strip _lj_vm_profhook +_lj_vm_profhook: + .long 0xaa1703e0,0xf90012f3,0xaa1503e1 + bl _lj_dispatch_profile + .long 0xf94012f3,0xd10012b5,0x17fffb1a + + .private_extern _lj_vm_exit_handler + .no_dead_strip _lj_vm_exit_handler +_lj_vm_exit_handler: + .long 0xd10803ff,0x6d0007e0,0xa91007e0,0x6d010fe2 + .long 0xa9110fe2,0x6d0217e4,0xa91217e4,0x6d031fe6 + .long 0xa9131fe6,0x6d0427e8,0xa91427e8,0x6d052fea + .long 0xa9152fea,0x6d0637ec,0xa91637ec,0x6d073fee + .long 0xa9173fee,0x6d0847f0,0xa91847f0,0x6d094ff2 + .long 0xa9194ff2,0x6d0a57f4,0xa91a57f4,0x6d0b5ff6 + .long 0xa91b5ff6,0x6d0c67f8,0xa91c67f8,0x6d0d6ffa + .long 0xa91d6ffa,0x6d0e77fc,0xa91e77fc,0x6d0f7ffe + .long 0xf94103e0,0x910803e2,0x12800063,0xa91f0bff + .long 0xcb1e0000,0xf940bad7,0xd342fc00,0xf940bed3 + .long 0xd1000800,0xb94003c1,0xb900bac3,0xf90012f3 + .long 0x53055021,0xb90e8ec0,0xb90e8ac1,0xf901aed7 + .long 0xf900bedf,0x910b62c0,0x910003e1 + bl _lj_trace_exit + .long 0xf9402ae1,0xf94012f3,0x927ef43f,0xf94057f5 + .long 0xf9005bf7,0x14000002 + + .private_extern _lj_vm_exit_interp + .no_dead_strip _lj_vm_exit_interp +_lj_vm_exit_interp: + .long 0xf9405bf7,0x7100001f,0x5400054b,0xd37df01c + .long 0xf85f0261,0xd2ffff38,0xd2bfff39,0x9280001a + .long 0x9240b821,0xb900c3fc,0xf90012f3,0xf9401021 + .long 0xf900bedf,0x12800003,0xf85b8034,0x394002b1 + .long 0xb84046b0,0xb900bac3,0x7101863f,0x8b300ec9 + .long 0x540001a2,0x7101663f,0x8b310ec8,0xf947b111 + .long 0xd3483e1b,0xd350fe08,0x9a9c311c,0x540000a3 + .long 0xf85f0262,0xd100239c,0x8b1b0e7b,0x9240b842 + .long 0xd61f0220,0xf85f8260,0xf2400401,0x54fffe41 + .long 0xb85fc002,0xd3483c40,0xcb000e61,0xf85e0022 + .long 0x9240b842,0xf9401042,0xf85b8054,0x17ffffea + .long 0xaa1703e0 + bl _lj_err_run + + .private_extern _lj_vm_modi + .no_dead_strip _lj_vm_modi +_lj_vm_modi: + .long 0x4a010003,0x7100007f,0x4a807c02,0x4a817c23 + .long 0x4b807c42,0x4b817c63,0x1ac30840,0x1b038800 + .long 0x7a404804,0x4b030002,0x1a820000,0x4a010002 + .long 0x7100005f,0x5a805400,0xd65f03c0 + + .private_extern _lj_vm_ffi_callback + .no_dead_strip _lj_vm_ffi_callback +_lj_vm_ffi_callback: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0xf940c155 + .long 0xaa0a03f6,0x910343ea,0xb900d2a9,0xa90706a0 + .long 0x6d0306a0,0xa9080ea2,0x6d040ea2,0xa90916a4 + .long 0x6d0516a4,0xa90a1ea6,0x6d061ea6,0xf9005aaa + .long 0xaa1503e0,0xf90057f5,0x910003e1 + bl _lj_ccallback_enter + .long 0xa9427013,0xd2ffff38,0xd2bfff39,0x9280001a + .long 0xaa0003f7,0xf85f0262,0xcb13039c,0xb900bada + .long 0x9240b842,0xf9401055,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf947b128,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_cont_ffi_callback + .no_dead_strip _lj_cont_ffi_callback +_lj_cont_ffi_callback: + .long 0xf940c2d5,0xa9020ef3,0xf9000ab7,0xaa1503e0 + .long 0xaa1b03e1 + bl _lj_ccallback_leave + .long 0xa94706a0,0x6d4306a0,0x17fff924 + + .private_extern _lj_vm_ffi_call + .no_dead_strip _lj_vm_ffi_call +_lj_vm_ffi_call: + .long 0xa9be7bfd,0x910003fd,0xf9000bf3,0xaa0003f3 + .long 0xb9400808,0x39403269,0x9102626a,0xf1000529 + .long 0xf940026b,0xcb2863bf,0x540000a4,0xf8697948 + .long 0xf8297be8,0xf1000529,0x54ffffa5,0xa9458660 + .long 0x6d418660,0xa9468e62,0x6d428e62,0xa9479664 + .long 0x6d439664,0xa9489e66,0x6d449e66,0xf9400a68 + .long 0xd63f0160,0x910003bf,0xa9058660,0x6d018660 + .long 0x6d028e62,0xf9400bf3,0xa8c27bfd,0xd65f03c0 + + .cstring + .ascii "DynASM 1.4.0\0" + diff --git a/core/src/luajit/autogen/macosx/jit/arm64/lj_vmdef.h b/core/src/luajit/autogen/macosx/jit/arm64/lj_vmdef.h new file mode 100644 index 000000000..1e07b537f --- /dev/null +++ b/core/src/luajit/autogen/macosx/jit/arm64/lj_vmdef.h @@ -0,0 +1,368 @@ +-- This is a generated file. DO NOT EDIT! + +return { + +bcnames = "ISLT ISGE ISLE ISGT ISEQV ISNEV ISEQS ISNES ISEQN ISNEN ISEQP ISNEP ISTC ISFC IST ISF ISTYPEISNUM MOV NOT UNM LEN ADDVN SUBVN MULVN DIVVN MODVN ADDNV SUBNV MULNV DIVNV MODNV ADDVV SUBVV MULVV DIVVV MODVV POW CAT KSTR KCDATAKSHORTKNUM KPRI KNIL UGET USETV USETS USETN USETP UCLO FNEW TNEW TDUP GGET GSET TGETV TGETS TGETB TGETR TSETV TSETS TSETB TSETM TSETR CALLM CALL CALLMTCALLT ITERC ITERN VARG ISNEXTRETM RET RET0 RET1 FORI JFORI FORL IFORL JFORL ITERL IITERLJITERLLOOP ILOOP JLOOP JMP FUNCF IFUNCFJFUNCFFUNCV IFUNCVJFUNCVFUNCC FUNCCW", + +irnames = "LT GE LE GT ULT UGE ULE UGT EQ NE ABC RETF NOP BASE PVAL GCSTEPHIOP LOOP USE PHI RENAMEPROF KPRI KINT KGC KPTR KKPTR KNULL KNUM KINT64KSLOT BNOT BSWAP BAND BOR BXOR BSHL BSHR BSAR BROL BROR ADD SUB MUL DIV MOD POW NEG ABS LDEXP MIN MAX FPMATHADDOV SUBOV MULOV AREF HREFK HREF NEWREFUREFO UREFC FREF STRREFLREF ALOAD HLOAD ULOAD FLOAD XLOAD SLOAD VLOAD ALEN ASTOREHSTOREUSTOREFSTOREXSTORESNEW XSNEW TNEW TDUP CNEW CNEWI BUFHDRBUFPUTBUFSTRTBAR OBAR XBAR CONV TOBIT TOSTR STRTO CALLN CALLA CALLL CALLS CALLXSCARG ", + +irfpm = { [0]="floor", "ceil", "trunc", "sqrt", "log", "log2", "other", }, + +irfield = { [0]="str.len", "func.env", "func.pc", "func.ffid", "thread.env", "tab.meta", "tab.array", "tab.node", "tab.asize", "tab.hmask", "tab.nomm", "udata.meta", "udata.udtype", "udata.file", "cdata.ctypeid", "cdata.ptr", "cdata.int", "cdata.int64", "cdata.int64_4", }, + +ircall = { +[0]="lj_str_cmp", +"lj_str_find", +"lj_str_new", +"lj_strscan_num", +"lj_strfmt_int", +"lj_strfmt_num", +"lj_strfmt_char", +"lj_strfmt_putint", +"lj_strfmt_putnum", +"lj_strfmt_putquoted", +"lj_strfmt_putfxint", +"lj_strfmt_putfnum_int", +"lj_strfmt_putfnum_uint", +"lj_strfmt_putfnum", +"lj_strfmt_putfstr", +"lj_strfmt_putfchar", +"lj_buf_putmem", +"lj_buf_putstr", +"lj_buf_putchar", +"lj_buf_putstr_reverse", +"lj_buf_putstr_lower", +"lj_buf_putstr_upper", +"lj_buf_putstr_rep", +"lj_buf_puttab", +"lj_buf_tostr", +"lj_tab_new_ah", +"lj_tab_new1", +"lj_tab_dup", +"lj_tab_clear", +"lj_tab_newkey", +"lj_tab_len", +"lj_tab_len_hint", +"lj_gc_step_jit", +"lj_gc_barrieruv", +"lj_mem_newgco", +"lj_prng_u64d", +"lj_vm_modi", +"log10", +"exp", +"sin", +"cos", +"tan", +"asin", +"acos", +"atan", +"sinh", +"cosh", +"tanh", +"fputc", +"fwrite", +"fflush", +"lj_vm_floor", +"lj_vm_ceil", +"lj_vm_trunc", +"sqrt", +"log", +"lj_vm_log2", +"lj_vm_powi", +"pow", +"atan2", +"ldexp", +"lj_vm_tobit", +"softfp_add", +"softfp_sub", +"softfp_mul", +"softfp_div", +"softfp_cmp", +"softfp_i2d", +"softfp_d2i", +"lj_vm_sfmin", +"lj_vm_sfmax", +"lj_vm_tointg", +"softfp_ui2d", +"softfp_f2d", +"softfp_d2ui", +"softfp_d2f", +"softfp_i2f", +"softfp_ui2f", +"softfp_f2i", +"softfp_f2ui", +"fp64_l2d", +"fp64_ul2d", +"fp64_l2f", +"fp64_ul2f", +"fp64_d2l", +"fp64_d2ul", +"fp64_f2l", +"fp64_f2ul", +"lj_carith_divi64", +"lj_carith_divu64", +"lj_carith_modi64", +"lj_carith_modu64", +"lj_carith_powi64", +"lj_carith_powu64", +"lj_cdata_newv", +"lj_cdata_setfin", +"strlen", +"memcpy", +"memset", +"lj_vm_errno", +"lj_carith_mul64", +"lj_carith_shl64", +"lj_carith_shr64", +"lj_carith_sar64", +"lj_carith_rol64", +"lj_carith_ror64", +}, + +traceerr = { +[0]="error thrown or hook called during recording", +"trace too short", +"trace too long", +"trace too deep", +"too many snapshots", +"blacklisted", +"retry recording", +"NYI: bytecode %d", +"leaving loop in root trace", +"inner loop in root trace", +"loop unroll limit reached", +"bad argument type", +"JIT compilation disabled for function", +"call unroll limit reached", +"down-recursion, restarting", +"NYI: unsupported variant of FastFunc %s", +"NYI: return to lower frame", +"store with nil or NaN key", +"missing metamethod", +"looping index lookup", +"NYI: mixed sparse/dense table", +"symbol not in cache", +"NYI: unsupported C type conversion", +"NYI: unsupported C function type", +"guard would always fail", +"too many PHIs", +"persistent type instability", +"failed to allocate mcode memory", +"machine code too long", +"hit mcode limit (retrying)", +"too many spill slots", +"inconsistent register allocation", +"NYI: cannot assemble IR instruction %d", +"NYI: PHI shuffling too complex", +"NYI: register coalescing too complex", +}, + +ffnames = { +[0]="Lua", +"C", +"assert", +"type", +"next", +"pairs", +"ipairs_aux", +"ipairs", +"getmetatable", +"setmetatable", +"getfenv", +"setfenv", +"rawget", +"rawset", +"rawequal", +"unpack", +"select", +"tonumber", +"tostring", +"error", +"pcall", +"xpcall", +"loadfile", +"load", +"loadstring", +"dofile", +"gcinfo", +"collectgarbage", +"newproxy", +"print", +"coroutine.status", +"coroutine.running", +"coroutine.isyieldable", +"coroutine.create", +"coroutine.yield", +"coroutine.resume", +"coroutine.wrap_aux", +"coroutine.wrap", +"math.abs", +"math.floor", +"math.ceil", +"math.sqrt", +"math.log10", +"math.exp", +"math.sin", +"math.cos", +"math.tan", +"math.asin", +"math.acos", +"math.atan", +"math.sinh", +"math.cosh", +"math.tanh", +"math.frexp", +"math.modf", +"math.log", +"math.atan2", +"math.pow", +"math.fmod", +"math.ldexp", +"math.min", +"math.max", +"math.random", +"math.randomseed", +"bit.tobit", +"bit.bnot", +"bit.bswap", +"bit.lshift", +"bit.rshift", +"bit.arshift", +"bit.rol", +"bit.ror", +"bit.band", +"bit.bor", +"bit.bxor", +"bit.tohex", +"string.byte", +"string.char", +"string.sub", +"string.rep", +"string.reverse", +"string.lower", +"string.upper", +"string.dump", +"string.find", +"string.match", +"string.gmatch_aux", +"string.gmatch", +"string.gsub", +"string.format", +"table.maxn", +"table.insert", +"table.concat", +"table.sort", +"table.new", +"table.clear", +"io.method.close", +"io.method.read", +"io.method.write", +"io.method.flush", +"io.method.seek", +"io.method.setvbuf", +"io.method.lines", +"io.method.__gc", +"io.method.__tostring", +"io.open", +"io.popen", +"io.tmpfile", +"io.close", +"io.read", +"io.write", +"io.flush", +"io.input", +"io.output", +"io.lines", +"io.type", +"os.execute", +"os.remove", +"os.rename", +"os.tmpname", +"os.getenv", +"os.exit", +"os.clock", +"os.date", +"os.time", +"os.difftime", +"os.setlocale", +"debug.getregistry", +"debug.getmetatable", +"debug.setmetatable", +"debug.getfenv", +"debug.setfenv", +"debug.getinfo", +"debug.getlocal", +"debug.setlocal", +"debug.getupvalue", +"debug.setupvalue", +"debug.upvalueid", +"debug.upvaluejoin", +"debug.sethook", +"debug.gethook", +"debug.debug", +"debug.traceback", +"jit.on", +"jit.off", +"jit.flush", +"jit.status", +"jit.security", +"jit.attach", +"jit.util.funcinfo", +"jit.util.funcbc", +"jit.util.funck", +"jit.util.funcuvname", +"jit.util.traceinfo", +"jit.util.traceir", +"jit.util.tracek", +"jit.util.tracesnap", +"jit.util.tracemc", +"jit.util.traceexitstub", +"jit.util.ircalladdr", +"jit.opt.start", +"jit.profile.start", +"jit.profile.stop", +"jit.profile.dumpstack", +"ffi.meta.__index", +"ffi.meta.__newindex", +"ffi.meta.__eq", +"ffi.meta.__len", +"ffi.meta.__lt", +"ffi.meta.__le", +"ffi.meta.__concat", +"ffi.meta.__call", +"ffi.meta.__add", +"ffi.meta.__sub", +"ffi.meta.__mul", +"ffi.meta.__div", +"ffi.meta.__mod", +"ffi.meta.__pow", +"ffi.meta.__unm", +"ffi.meta.__tostring", +"ffi.meta.__pairs", +"ffi.meta.__ipairs", +"ffi.clib.__index", +"ffi.clib.__newindex", +"ffi.clib.__gc", +"ffi.callback.free", +"ffi.callback.set", +"ffi.cdef", +"ffi.new", +"ffi.cast", +"ffi.typeof", +"ffi.typeinfo", +"ffi.istype", +"ffi.sizeof", +"ffi.alignof", +"ffi.offsetof", +"ffi.errno", +"ffi.string", +"ffi.copy", +"ffi.fill", +"ffi.abi", +"ffi.metatype", +"ffi.gc", +"ffi.load", +}, + +} + diff --git a/core/src/luajit/autogen/macosx/nojit/arm64/lj_bcdef.h b/core/src/luajit/autogen/macosx/nojit/arm64/lj_bcdef.h new file mode 100644 index 000000000..699c1f6a4 --- /dev/null +++ b/core/src/luajit/autogen/macosx/nojit/arm64/lj_bcdef.h @@ -0,0 +1,220 @@ +/* This is a generated file. DO NOT EDIT! */ + +LJ_DATADEF const uint16_t lj_bc_ofs[] = { +0, +128, +256, +384, +512, +644, +772, +852, +932, +1072, +1212, +1280, +1348, +1412, +1476, +1532, +1588, +1624, +1660, +1692, +1740, +1808, +1880, +1988, +2096, +2212, +2284, +2400, +2508, +2616, +2732, +2804, +2920, +3028, +3136, +3252, +3324, +3440, +3512, +3588, +3632, +3676, +3712, +3744, +3776, +3824, +3876, +3988, +4092, +4144, +4196, +4256, +4328, +4424, +4508, +4532, +4556, +4696, +4844, +4952, +5024, +5200, +5452, +5596, +5744, +5848, +5864, +5936, +5948, +6136, +6216, +6380, +6568, +6688, +6708, +6876, +6980, +7092, +7236, +7236, +7236, +7376, +7376, +7376, +7428, +7428, +7428, +7452, +7452, +7484, +7484, +7548, +7548, +7548, +7680, +7680, +7752, +9708, +9776, +10216, +10296, +10348, +10468, +9816, +9964, +10052, +10100, +10124, +10520, +10576, +11216, +10636, +10952, +11320, +11248, +11284, +11460, +11532, +11564, +11596, +11628, +11660, +11692, +11724, +11756, +11788, +11820, +11852, +12048, +12108, +11500, +11924, +11884, +11964, +12004, +12156, +12296, +13228, +13300, +13264, +13336, +13392, +13448, +13504, +13560, +13024, +13092, +13160, +12436, +12488, +12568, +12740, +12816, +12892 +}; + +LJ_DATADEF const uint16_t lj_bc_mode[] = { +BCDEF(BCMODE) +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF, +BCMODE_FF +}; + diff --git a/core/src/luajit/autogen/macosx/nojit/arm64/lj_ffdef.h b/core/src/luajit/autogen/macosx/nojit/arm64/lj_ffdef.h new file mode 100644 index 000000000..0ea74688b --- /dev/null +++ b/core/src/luajit/autogen/macosx/nojit/arm64/lj_ffdef.h @@ -0,0 +1,203 @@ +/* This is a generated file. DO NOT EDIT! */ + +FFDEF(assert) +FFDEF(type) +FFDEF(next) +FFDEF(pairs) +FFDEF(ipairs_aux) +FFDEF(ipairs) +FFDEF(getmetatable) +FFDEF(setmetatable) +FFDEF(getfenv) +FFDEF(setfenv) +FFDEF(rawget) +FFDEF(rawset) +FFDEF(rawequal) +FFDEF(unpack) +FFDEF(select) +FFDEF(tonumber) +FFDEF(tostring) +FFDEF(error) +FFDEF(pcall) +FFDEF(xpcall) +FFDEF(loadfile) +FFDEF(load) +FFDEF(loadstring) +FFDEF(dofile) +FFDEF(gcinfo) +FFDEF(collectgarbage) +FFDEF(newproxy) +FFDEF(print) +FFDEF(coroutine_status) +FFDEF(coroutine_running) +FFDEF(coroutine_isyieldable) +FFDEF(coroutine_create) +FFDEF(coroutine_yield) +FFDEF(coroutine_resume) +FFDEF(coroutine_wrap_aux) +FFDEF(coroutine_wrap) +FFDEF(math_abs) +FFDEF(math_floor) +FFDEF(math_ceil) +FFDEF(math_sqrt) +FFDEF(math_log10) +FFDEF(math_exp) +FFDEF(math_sin) +FFDEF(math_cos) +FFDEF(math_tan) +FFDEF(math_asin) +FFDEF(math_acos) +FFDEF(math_atan) +FFDEF(math_sinh) +FFDEF(math_cosh) +FFDEF(math_tanh) +FFDEF(math_frexp) +FFDEF(math_modf) +FFDEF(math_log) +FFDEF(math_atan2) +FFDEF(math_pow) +FFDEF(math_fmod) +FFDEF(math_ldexp) +FFDEF(math_min) +FFDEF(math_max) +FFDEF(math_random) +FFDEF(math_randomseed) +FFDEF(bit_tobit) +FFDEF(bit_bnot) +FFDEF(bit_bswap) +FFDEF(bit_lshift) +FFDEF(bit_rshift) +FFDEF(bit_arshift) +FFDEF(bit_rol) +FFDEF(bit_ror) +FFDEF(bit_band) +FFDEF(bit_bor) +FFDEF(bit_bxor) +FFDEF(bit_tohex) +FFDEF(string_byte) +FFDEF(string_char) +FFDEF(string_sub) +FFDEF(string_rep) +FFDEF(string_reverse) +FFDEF(string_lower) +FFDEF(string_upper) +FFDEF(string_dump) +FFDEF(string_find) +FFDEF(string_match) +FFDEF(string_gmatch_aux) +FFDEF(string_gmatch) +FFDEF(string_gsub) +FFDEF(string_format) +FFDEF(table_maxn) +FFDEF(table_insert) +FFDEF(table_concat) +FFDEF(table_sort) +FFDEF(table_new) +FFDEF(table_clear) +FFDEF(io_method_close) +FFDEF(io_method_read) +FFDEF(io_method_write) +FFDEF(io_method_flush) +FFDEF(io_method_seek) +FFDEF(io_method_setvbuf) +FFDEF(io_method_lines) +FFDEF(io_method___gc) +FFDEF(io_method___tostring) +FFDEF(io_open) +FFDEF(io_popen) +FFDEF(io_tmpfile) +FFDEF(io_close) +FFDEF(io_read) +FFDEF(io_write) +FFDEF(io_flush) +FFDEF(io_input) +FFDEF(io_output) +FFDEF(io_lines) +FFDEF(io_type) +FFDEF(os_execute) +FFDEF(os_remove) +FFDEF(os_rename) +FFDEF(os_tmpname) +FFDEF(os_getenv) +FFDEF(os_exit) +FFDEF(os_clock) +FFDEF(os_date) +FFDEF(os_time) +FFDEF(os_difftime) +FFDEF(os_setlocale) +FFDEF(debug_getregistry) +FFDEF(debug_getmetatable) +FFDEF(debug_setmetatable) +FFDEF(debug_getfenv) +FFDEF(debug_setfenv) +FFDEF(debug_getinfo) +FFDEF(debug_getlocal) +FFDEF(debug_setlocal) +FFDEF(debug_getupvalue) +FFDEF(debug_setupvalue) +FFDEF(debug_upvalueid) +FFDEF(debug_upvaluejoin) +FFDEF(debug_sethook) +FFDEF(debug_gethook) +FFDEF(debug_debug) +FFDEF(debug_traceback) +FFDEF(jit_on) +FFDEF(jit_off) +FFDEF(jit_flush) +FFDEF(jit_status) +FFDEF(jit_security) +FFDEF(jit_attach) +FFDEF(jit_util_funcinfo) +FFDEF(jit_util_funcbc) +FFDEF(jit_util_funck) +FFDEF(jit_util_funcuvname) +FFDEF(jit_profile_start) +FFDEF(jit_profile_stop) +FFDEF(jit_profile_dumpstack) +FFDEF(ffi_meta___index) +FFDEF(ffi_meta___newindex) +FFDEF(ffi_meta___eq) +FFDEF(ffi_meta___len) +FFDEF(ffi_meta___lt) +FFDEF(ffi_meta___le) +FFDEF(ffi_meta___concat) +FFDEF(ffi_meta___call) +FFDEF(ffi_meta___add) +FFDEF(ffi_meta___sub) +FFDEF(ffi_meta___mul) +FFDEF(ffi_meta___div) +FFDEF(ffi_meta___mod) +FFDEF(ffi_meta___pow) +FFDEF(ffi_meta___unm) +FFDEF(ffi_meta___tostring) +FFDEF(ffi_meta___pairs) +FFDEF(ffi_meta___ipairs) +FFDEF(ffi_clib___index) +FFDEF(ffi_clib___newindex) +FFDEF(ffi_clib___gc) +FFDEF(ffi_callback_free) +FFDEF(ffi_callback_set) +FFDEF(ffi_cdef) +FFDEF(ffi_new) +FFDEF(ffi_cast) +FFDEF(ffi_typeof) +FFDEF(ffi_typeinfo) +FFDEF(ffi_istype) +FFDEF(ffi_sizeof) +FFDEF(ffi_alignof) +FFDEF(ffi_offsetof) +FFDEF(ffi_errno) +FFDEF(ffi_string) +FFDEF(ffi_copy) +FFDEF(ffi_fill) +FFDEF(ffi_abi) +FFDEF(ffi_metatype) +FFDEF(ffi_gc) +FFDEF(ffi_load) + +#undef FFDEF + +#ifndef FF_NUM_ASMFUNC +#define FF_NUM_ASMFUNC 57 +#endif + diff --git a/core/src/luajit/autogen/macosx/nojit/arm64/lj_folddef.h b/core/src/luajit/autogen/macosx/nojit/arm64/lj_folddef.h new file mode 100644 index 000000000..45d5daf74 --- /dev/null +++ b/core/src/luajit/autogen/macosx/nojit/arm64/lj_folddef.h @@ -0,0 +1,1168 @@ +/* This is a generated file. DO NOT EDIT! */ + +static const FoldFunc fold_func[] = { + fold_kfold_numarith, + fold_kfold_numabsneg, + fold_kfold_ldexp, + fold_kfold_fpmath, + fold_kfold_fpcall1, + fold_kfold_fpcall2, + fold_kfold_numpow, + fold_kfold_numcomp, + fold_kfold_intarith, + fold_kfold_intovarith, + fold_kfold_bnot, + fold_kfold_bswap, + fold_kfold_intcomp, + fold_kfold_intcomp0, + fold_kfold_int64arith, + fold_kfold_int64arith2, + fold_kfold_int64shift, + fold_kfold_bnot64, + fold_kfold_bswap64, + fold_kfold_int64comp, + fold_kfold_int64comp0, + fold_kfold_snew_kptr, + fold_kfold_snew_empty, + fold_kfold_strref, + fold_kfold_strref_snew, + fold_kfold_strcmp, + fold_bufput_append, + fold_bufput_kgc, + fold_bufstr_kfold_cse, + fold_bufput_kfold_op, + fold_bufput_kfold_rep, + fold_bufput_kfold_fmt, + fold_kfold_add_kgc, + fold_kfold_add_kptr, + fold_kfold_add_kright, + fold_kfold_tobit, + fold_kfold_conv_kint_num, + fold_kfold_conv_kintu32_num, + fold_kfold_conv_kint_ext, + fold_kfold_conv_kint_i64, + fold_kfold_conv_kint64_num_i64, + fold_kfold_conv_kint64_num_u64, + fold_kfold_conv_kint64_int_i64, + fold_kfold_conv_knum_int_num, + fold_kfold_conv_knum_u32_num, + fold_kfold_conv_knum_i64_num, + fold_kfold_conv_knum_u64_num, + fold_kfold_tostr_knum, + fold_kfold_tostr_kint, + fold_kfold_strto, + lj_opt_cse, + fold_kfold_kref, + fold_shortcut_round, + fold_shortcut_left, + fold_shortcut_dropleft, + fold_shortcut_leftleft, + fold_simplify_numadd_negx, + fold_simplify_numadd_xneg, + fold_simplify_numsub_k, + fold_simplify_numsub_negk, + fold_simplify_numsub_xneg, + fold_simplify_nummuldiv_k, + fold_simplify_nummuldiv_negk, + fold_simplify_nummuldiv_negneg, + fold_simplify_numpow_xkint, + fold_simplify_numpow_xknum, + fold_simplify_numpow_kx, + fold_shortcut_conv_num_int, + fold_simplify_conv_int_num, + fold_simplify_conv_i64_num, + fold_simplify_conv_int_i64, + fold_simplify_conv_flt_num, + fold_simplify_tobit_conv, + fold_simplify_floor_conv, + fold_simplify_conv_sext, + fold_simplify_conv_narrow, + fold_cse_conv, + fold_narrow_convert, + fold_simplify_intadd_k, + fold_simplify_intmul_k, + fold_simplify_intsub_k, + fold_simplify_intsub_kleft, + fold_simplify_intadd_k64, + fold_simplify_intsub_k64, + fold_simplify_intmul_k32, + fold_simplify_intmul_k64, + fold_simplify_intmod_k, + fold_simplify_intmod_kleft, + fold_simplify_intsub, + fold_simplify_intsubadd_leftcancel, + fold_simplify_intsubsub_leftcancel, + fold_simplify_intsubsub_rightcancel, + fold_simplify_intsubadd_rightcancel, + fold_simplify_intsubaddadd_cancel, + fold_simplify_band_k, + fold_simplify_bor_k, + fold_simplify_bxor_k, + fold_simplify_shift_ik, + fold_simplify_shift_andk, + fold_simplify_shift1_ki, + fold_simplify_shift2_ki, + fold_simplify_shiftk_andk, + fold_simplify_andk_shiftk, + fold_simplify_andor_k, + fold_simplify_andor_k64, + fold_reassoc_intarith_k, + fold_reassoc_intarith_k64, + fold_reassoc_dup, + fold_reassoc_dup_minmax, + fold_reassoc_bxor, + fold_reassoc_shift, + fold_reassoc_minmax_k, + fold_abc_fwd, + fold_abc_k, + fold_abc_invar, + fold_comm_swap, + fold_comm_equal, + fold_comm_comp, + fold_comm_dup, + fold_comm_dup_minmax, + fold_comm_bxor, + fold_merge_eqne_snew_kgc, + lj_opt_fwd_aload, + fold_kfold_hload_kkptr, + lj_opt_fwd_hload, + lj_opt_fwd_uload, + lj_opt_fwd_alen, + fold_cse_uref, + lj_opt_fwd_hrefk, + fold_fwd_href_tnew, + fold_fwd_href_tdup, + fold_fload_tab_tnew_asize, + fold_fload_tab_tnew_hmask, + fold_fload_tab_tdup_asize, + fold_fload_tab_tdup_hmask, + fold_fload_tab_ah, + fold_fload_str_len_kgc, + fold_fload_str_len_snew, + fold_fload_str_len_tostr, + fold_fload_cdata_typeid_kgc, + fold_fload_cdata_int64_kgc, + fold_fload_cdata_typeid_cnew, + fold_fload_cdata_ptr_int64_cnew, + lj_opt_cse, + lj_opt_fwd_fload, + fold_fwd_sload, + fold_xload_kptr, + lj_opt_fwd_xload, + fold_barrier_tab, + fold_barrier_tnew_tdup, + fold_prof, + lj_opt_dse_ahstore, + lj_opt_dse_ustore, + lj_opt_dse_fstore, + lj_opt_dse_xstore, + lj_ir_emit +}; + +static const uint32_t fold_hash[1002] = { +0x0f5a741d, +0xffffffff, +0xffffffff, +0x6e4a9417, +0xffffffff, +0x634877ff, +0x8775ffff, +0xffffffff, +0xffffffff, +0x8789fc09, +0x83894008, +0xffffffff, +0x644e5fff, +0xffffffff, +0x0c0c5c17, +0x26b45e71, +0xffffffff, +0x0e52741d, +0xffffffff, +0xffffffff, +0x66429417, +0xffffffff, +0xffffffff, +0x586dffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4db4a6ae, +0x46b56a95, +0x0c045c17, +0x169dfc17, +0x2cb4728e, +0xffffffff, +0xffffffff, +0x30b85fff, +0xffffffff, +0xffffffff, +0x7765ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x37408000, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0e42741d, +0x2253fc18, +0xffffffff, +0xffffffff, +0xffffffff, +0x096e5c17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3468d000, +0xffffffff, +0xffffffff, +0x66429017, +0x5d54a429, +0xffffffff, +0x8f89fc04, +0xffffffff, +0xffffffff, +0xffffffff, +0x6a44881d, +0x08665c17, +0x5855ffff, +0x82754416, +0x624bfc21, +0x86894409, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0712701c, +0xffffffff, +0x6b4287ff, +0xffffffff, +0x085e5c17, +0x27b45ed4, +0xffffffff, +0x0d0bfc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9bbfffff, +0x10507417, +0xffffffff, +0xffffffff, +0x070a701c, +0x5557fc1d, +0xffffffff, +0xffffffff, +0x08565c17, +0x7645ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6844841d, +0x10487417, +0x817543ff, +0x0702701c, +0xffffffff, +0x84894009, +0xffffffff, +0x084e5c17, +0xffffffff, +0x26b45e72, +0xffffffff, +0x7f7863ff, +0x7c85fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4e6dfc17, +0xffffffff, +0x6047fc1d, +0xffffffff, +0xffffffff, +0xffffffff, +0x08465c17, +0x46b56a96, +0x4bb4ae95, +0xffffffff, +0x79113818, +0x01607044, +0xffffffff, +0xffffffff, +0x1dc18c09, +0xffffffff, +0xffffffff, +0x2152681d, +0x3312741d, +0xffffffff, +0x67428817, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0064701c, +0xffffffff, +0x2253fc19, +0xffffffff, +0xffffffff, +0x9b9fffff, +0xffffffff, +0x405dfc17, +0x130a741d, +0xffffffff, +0xffffffff, +0xffffffff, +0x3468d001, +0xffffffff, +0x3213101b, +0xffffffff, +0xffffffff, +0x12407400, +0x065c701c, +0xffffffff, +0xffffffff, +0x654a8417, +0x9897ffff, +0x47b569ae, +0x5055fc17, +0x1302741d, +0x4bb4aa95, +0xffffffff, +0xffffffff, +0xffffffff, +0x2ab47675, +0xffffffff, +0xffffffff, +0x2eb472ce, +0x0054701c, +0x8a897000, +0x2152641d, +0x8b88600e, +0x69428417, +0x5c55fc29, +0x8f8fffff, +0x0a3e5c00, +0x614dfc17, +0x6e4c9817, +0xffffffff, +0xffffffff, +0x6956ac17, +0xffffffff, +0x7215ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x33106fff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x5f45fc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x750dffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4bb4a695, +0xffffffff, +0xffffffff, +0xffffffff, +0x3d59fc1c, +0x23b6701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x2052601d, +0xffffffff, +0x7505ffff, +0xffffffff, +0x0f5c741d, +0x3560c044, +0x44b56a8e, +0xffffffff, +0x928a6bff, +0x634a77ff, +0x9b77ffff, +0x05bd8c3b, +0x88886000, +0x4bb4ae96, +0xffffffff, +0xffffffff, +0x64505fff, +0xffffffff, +0x0c0e5c17, +0x1fc18c0a, +0xffffffff, +0x0e54741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x1dc18c13, +0x736fffff, +0x19bd8c00, +0xffffffff, +0xffffffff, +0x6a468c1d, +0xffffffff, +0x63485fff, +0x2253fc1a, +0x0c065c17, +0x3311fc1b, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7767ffff, +0x3468d002, +0xffffffff, +0x6b448bff, +0x94affc00, +0x28b475d5, +0x3660bc44, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0e44741d, +0x82754418, +0xffffffff, +0x4bb4aa96, +0xffffffff, +0xffffffff, +0xffffffff, +0x4ab5fed3, +0x04bc73ff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8c88600f, +0x5b55fc2a, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7357ffff, +0xffffffff, +0x7115fc17, +0x624dfc21, +0x43b569d3, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7015fc29, +0x24b45dd3, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3b54bc1c, +0xffffffff, +0xffffffff, +0x4bb4a696, +0x9bc1ffff, +0xffffffff, +0xffffffff, +0x070c701c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7847ffff, +0x49696800, +0xffffffff, +0x02627017, +0x95af4400, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x104a7417, +0xffffffff, +0xffffffff, +0x0704701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x08505c17, +0xffffffff, +0xffffffff, +0x1fc18c0b, +0x7f7a63ff, +0x7d87fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0x94b1ffff, +0x1dc18c14, +0x4f6ffc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x08485c17, +0xffffffff, +0xffffffff, +0xffffffff, +0x79133818, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9ba9ffff, +0x31ba6000, +0xffffffff, +0x27b45eb3, +0xffffffff, +0x69448817, +0x29b475d6, +0xffffffff, +0xffffffff, +0x6e4e9c17, +0x95af4000, +0xffffffff, +0x0066701c, +0x45b56ace, +0xffffffff, +0xffffffff, +0xffffffff, +0x9ba1ffff, +0xffffffff, +0xffffffff, +0x130c741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8c886010, +0xffffffff, +0x3852bfff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9999ffff, +0xffffffff, +0x5457fc17, +0x1304741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x187f3bff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0056701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x67448417, +0x7e91ffff, +0x25b45dd4, +0x0b405c00, +0x614ffc17, +0x46b56a75, +0x48b7681c, +0xffffffff, +0x2bb4726e, +0xffffffff, +0x9b17ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x33126fff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9089ffff, +0xffffffff, +0x6047fc17, +0x49696801, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x750fffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6a52a41d, +0xffffffff, +0x515477ff, +0x21526817, +0xffffffff, +0xffffffff, +0xffffffff, +0x1fc18c0c, +0xffffffff, +0x575a5fff, +0xffffffff, +0xffffffff, +0x7507ffff, +0x6d468fff, +0x1dc18c15, +0x9bb20000, +0xffffffff, +0xffffffff, +0xffffffff, +0x644c77ff, +0x9479ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6c64cbff, +0xffffffff, +0xffffffff, +0xffffffff, +0x33105c17, +0xffffffff, +0x425c73ff, +0x0e56741d, +0xffffffff, +0x27b45eb4, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x634a5fff, +0xffffffff, +0x0c085c17, +0x3313fc1b, +0xffffffff, +0x21526417, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8c886011, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0c005c17, +0xffffffff, +0xffffffff, +0x0e46741d, +0xffffffff, +0xffffffff, +0xffffffff, +0x8d894c0e, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x46b56a76, +0x4bb4ae75, +0xffffffff, +0x096a5c17, +0xffffffff, +0xffffffff, +0x624ffc21, +0x8f89fc0e, +0xffffffff, +0x20526017, +0xffffffff, +0x33106018, +0x159c6817, +0xffffffff, +0xffffffff, +0xffffffff, +0x49696802, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3e56bc1c, +0xffffffff, +0xffffffff, +0x9bc3ffff, +0x8d89480e, +0xffffffff, +0xffffffff, +0x070e701c, +0xffffffff, +0x1fc18c0d, +0xffffffff, +0x085a5c17, +0xffffffff, +0xffffffff, +0x69468c17, +0xffffffff, +0x1ec18c16, +0xffffffff, +0x6e50a017, +0xffffffff, +0x4bb4aa75, +0x104c7417, +0x4db6a81c, +0xffffffff, +0x0706701c, +0x5253fc1d, +0x6f64c817, +0x2db472ae, +0x08525c17, +0xffffffff, +0xffffffff, +0xffffffff, +0x065c7017, +0x8f89fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3953fc2f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x084a5c17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x1babffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x5e43fc1d, +0xffffffff, +0xffffffff, +0xffffffff, +0x08425c17, +0xffffffff, +0xffffffff, +0x4bb4a675, +0x4db6a41c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8e894c0f, +0xffffffff, +0xffffffff, +0x130e741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x44b56a6e, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7b846800, +0xffffffff, +0x8789fc06, +0x654e8417, +0x4bb4ae76, +0x9a9bffff, +0xffffffff, +0x1306741d, +0xffffffff, +0x8f89fc0f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0058701c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x9793ffff, +0xffffffff, +0x6151fc17, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6c66cfff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x1fc18c0e, +0x938bffff, +0xffffffff, +0x6149fc17, +0xffffffff, +0x3f56bc2f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7411ffff, +0x4bb4aa76, +0xffffffff, +0xffffffff, +0xffffffff, +0x4ab5feb3, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x415dfc1c, +0xffffffff, +0xffffffff, +0xffffffff, +0x8f89fc01, +0xffffffff, +0xffffffff, +0x7509ffff, +0x1aab5056, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x644e77ff, +0xffffffff, +0xffffffff, +0x3a55fc1c, +0x8275441c, +0xffffffff, +0xffffffff, +0x51545fff, +0xffffffff, +0x33125c17, +0x7501ffff, +0xffffffff, +0x0f58741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x8073ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x140bfc1d, +0x4bb4a676, +0x644c5fff, +0xffffffff, +0x0c0a5c17, +0xffffffff, +0x8e894c10, +0xffffffff, +0x2ab47695, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x736bffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0c025c17, +0x8789fc07, +0xffffffff, +0xffffffff, +0xffffffff, +0x26b45e6f, +0xffffffff, +0x8f89fc10, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x6e489017, +0xffffffff, +0xffffffff, +0xffffffff, +0x6952a417, +0xffffffff, +0xffffffff, +0xffffffff, +0x096c5c17, +0xffffffff, +0x2fb873ff, +0x6251fc21, +0x6f66cc17, +0x9ba3fc00, +0xffffffff, +0xffffffff, +0x33126018, +0xffffffff, +0x1fc18c0f, +0xffffffff, +0xffffffff, +0xffffffff, +0x4db4aa6e, +0x89893800, +0x6842881d, +0x08645c17, +0x45b56aae, +0x7353ffff, +0x6249fc21, +0xffffffff, +0xffffffff, +0x3e58bc1c, +0xffffffff, +0xffffffff, +0x9bc5ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0710701c, +0xffffffff, +0xffffffff, +0x373e7c00, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x104e7417, +0xffffffff, +0xffffffff, +0x0708701c, +0x5355fc1d, +0xffffffff, +0xffffffff, +0x08545c17, +0x7643ffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x4db4a66e, +0x4cb5ffff, +0x6a42841d, +0x3c55fc2f, +0xffffffff, +0x0700701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x084c5c17, +0x6a56ac1d, +0xffffffff, +0xffffffff, +0x8e894c11, +0x7a83fc00, +0xffffffff, +0xffffffff, +0xffffffff, +0x1cadffff, +0xffffffff, +0x4e6bfc17, +0xffffffff, +0x5f45fc1d, +0xffffffff, +0xffffffff, +0xffffffff, +0x08445c17, +0x5a54abff, +0x8789fc08, +0xffffffff, +0x375ebfff, +0x015e7044, +0xffffffff, +0x26b45e70, +0xffffffff, +0x8f89fc11, +0x9ba5ffff, +0xffffffff, +0x3310741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x962bffff, +0xffffffff, +0xffffffff, +0x0062701c, +0xffffffff, +0xffffffff, +0xffffffff, +0x65508417, +0xffffffff, +0xffffffff, +0x565bfc17, +0x1308741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x3211101b, +0xffffffff, +0xffffffff, +0x113e7400, +0xffffffff, +0xffffffff, +0xffffffff, +0x65488417, +0x9795ffff, +0xffffffff, +0x4e53fc17, +0x5954a7ff, +0x1300741d, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0052701c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x918dffff, +0xffffffff, +0x614bfc17, +0xffffffff, +0x3f58bc2f, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x7413ffff, +0x85894408, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x5e43fc17, +0xffffffff, +0xffffffff, +0x177e6017, +0xffffffff, +0x27b45ed3, +0xffffffff, +0x750bffff, +0x036873ff, +0xffffffff, +0xffffffff, +0x4db4aaae, +0xffffffff, +0xffffffff, +0x645077ff, +0xffffffff, +0xffffffff, +0x3d57fc1c, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0xffffffff, +0x0c145c17, +0x7503ffff, +0xffffffff, +0xffffffff +}; + +#define fold_hashkey(k) (lj_rol(lj_rol((k),21)-(k),1)%1001) + diff --git a/core/src/luajit/autogen/macosx/nojit/arm64/lj_libdef.h b/core/src/luajit/autogen/macosx/nojit/arm64/lj_libdef.h new file mode 100644 index 000000000..521de0174 --- /dev/null +++ b/core/src/luajit/autogen/macosx/nojit/arm64/lj_libdef.h @@ -0,0 +1,402 @@ +/* This is a generated file. DO NOT EDIT! */ + +#ifdef LJLIB_MODULE_base +#undef LJLIB_MODULE_base +static const lua_CFunction lj_lib_cf_base[] = { + lj_ffh_assert, + lj_ffh_next, + lj_ffh_pairs, + lj_ffh_ipairs_aux, + lj_ffh_ipairs, + lj_ffh_setmetatable, + lj_cf_getfenv, + lj_cf_setfenv, + lj_ffh_rawget, + lj_cf_rawset, + lj_cf_rawequal, + lj_cf_unpack, + lj_cf_select, + lj_ffh_tonumber, + lj_ffh_tostring, + lj_cf_error, + lj_ffh_pcall, + lj_cf_loadfile, + lj_cf_load, + lj_cf_loadstring, + lj_cf_dofile, + lj_cf_gcinfo, + lj_cf_collectgarbage, + lj_cf_newproxy, + lj_cf_print +}; +static const uint8_t lj_lib_init_base[] = { +2,0,28,70,97,115,115,101,114,116,195,110,105,108,199,98,111,111,108,101,97, +110,252,1,200,117,115,101,114,100,97,116,97,198,115,116,114,105,110,103,197, +117,112,118,97,108,198,116,104,114,101,97,100,197,112,114,111,116,111,200,102, +117,110,99,116,105,111,110,197,116,114,97,99,101,197,99,100,97,116,97,197,116, +97,98,108,101,252,9,198,110,117,109,98,101,114,132,116,121,112,101,68,110,101, +120,116,253,69,112,97,105,114,115,64,253,70,105,112,97,105,114,115,140,103, +101,116,109,101,116,97,116,97,98,108,101,76,115,101,116,109,101,116,97,116, +97,98,108,101,7,103,101,116,102,101,110,118,7,115,101,116,102,101,110,118,70, +114,97,119,103,101,116,6,114,97,119,115,101,116,8,114,97,119,101,113,117,97, +108,6,117,110,112,97,99,107,6,115,101,108,101,99,116,72,116,111,110,117,109, +98,101,114,72,116,111,115,116,114,105,110,103,5,101,114,114,111,114,69,112, +99,97,108,108,134,120,112,99,97,108,108,8,108,111,97,100,102,105,108,101,4, +108,111,97,100,10,108,111,97,100,115,116,114,105,110,103,6,100,111,102,105, +108,101,6,103,99,105,110,102,111,14,99,111,108,108,101,99,116,103,97,114,98, +97,103,101,252,2,8,110,101,119,112,114,111,120,121,200,116,111,115,116,114, +105,110,103,5,112,114,105,110,116,252,3,200,95,86,69,82,83,73,79,78,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_coroutine +#undef LJLIB_MODULE_coroutine +static const lua_CFunction lj_lib_cf_coroutine[] = { + lj_cf_coroutine_status, + lj_cf_coroutine_running, + lj_cf_coroutine_isyieldable, + lj_cf_coroutine_create, + lj_ffh_coroutine_yield, + lj_ffh_coroutine_resume, + lj_cf_coroutine_wrap +}; +static const uint8_t lj_lib_init_coroutine[] = { +30,13,7,6,115,116,97,116,117,115,7,114,117,110,110,105,110,103,11,105,115,121, +105,101,108,100,97,98,108,101,6,99,114,101,97,116,101,69,121,105,101,108,100, +70,114,101,115,117,109,101,254,4,119,114,97,112,255 +}; +#endif + +#ifdef LJLIB_MODULE_math +#undef LJLIB_MODULE_math +static const lua_CFunction lj_lib_cf_math[] = { + lj_ffh_math_abs, + lj_ffh_math_sqrt, + lj_ffh_math_log, + lj_ffh_math_atan2, + lj_ffh_math_ldexp, + lj_ffh_math_min, + lj_cf_math_random, + lj_cf_math_randomseed +}; +static const uint8_t lj_lib_init_math[] = { +38,16,30,67,97,98,115,133,102,108,111,111,114,132,99,101,105,108,68,115,113, +114,116,133,108,111,103,49,48,131,101,120,112,131,115,105,110,131,99,111,115, +131,116,97,110,132,97,115,105,110,132,97,99,111,115,132,97,116,97,110,132,115, +105,110,104,132,99,111,115,104,132,116,97,110,104,133,102,114,101,120,112,132, +109,111,100,102,67,108,111,103,249,3,100,101,103,0,1,2,0,0,1,2,24,1,0,0,76, +1,2,0,241,135,158,166,3,220,203,178,130,4,249,3,114,97,100,0,1,2,0,0,1,2,24, +1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,69,97,116,97,110,50,131, +112,111,119,132,102,109,111,100,69,108,100,101,120,112,67,109,105,110,131,109, +97,120,251,24,45,68,84,251,33,9,64,194,112,105,250,251,0,0,0,0,0,0,240,127, +196,104,117,103,101,250,252,2,6,114,97,110,100,111,109,252,2,10,114,97,110, +100,111,109,115,101,101,100,255 +}; +#endif + +#ifdef LJLIB_MODULE_bit +#undef LJLIB_MODULE_bit +static const lua_CFunction lj_lib_cf_bit[] = { + lj_ffh_bit_tobit, + lj_ffh_bit_bnot, + lj_ffh_bit_bswap, + lj_ffh_bit_lshift, + lj_ffh_bit_band, + lj_cf_bit_tohex +}; +static const uint8_t lj_lib_init_bit[] = { +64,40,12,69,116,111,98,105,116,68,98,110,111,116,69,98,115,119,97,112,70,108, +115,104,105,102,116,134,114,115,104,105,102,116,135,97,114,115,104,105,102, +116,131,114,111,108,131,114,111,114,68,98,97,110,100,131,98,111,114,132,98, +120,111,114,5,116,111,104,101,120,255 +}; +#endif + +#ifdef LJLIB_MODULE_string +#undef LJLIB_MODULE_string +static const lua_CFunction lj_lib_cf_string[] = { + lj_ffh_string_byte, + lj_ffh_string_char, + lj_ffh_string_sub, + lj_cf_string_rep, + lj_ffh_string_reverse, + lj_cf_string_dump, + lj_cf_string_find, + lj_cf_string_match, + lj_cf_string_gmatch, + lj_cf_string_gsub, + lj_cf_string_format +}; +static const uint8_t lj_lib_init_string[] = { +76,51,14,249,3,108,101,110,0,1,2,0,0,0,3,16,0,5,0,21,1,0,0,76,1,2,0,68,98,121, +116,101,68,99,104,97,114,67,115,117,98,3,114,101,112,71,114,101,118,101,114, +115,101,133,108,111,119,101,114,133,117,112,112,101,114,4,100,117,109,112,4, +102,105,110,100,5,109,97,116,99,104,254,6,103,109,97,116,99,104,4,103,115,117, +98,6,102,111,114,109,97,116,255 +}; +#endif + +#ifdef LJLIB_MODULE_table +#undef LJLIB_MODULE_table +static const lua_CFunction lj_lib_cf_table[] = { + lj_cf_table_maxn, + lj_cf_table_insert, + lj_cf_table_concat, + lj_cf_table_sort +}; +static const uint8_t lj_lib_init_table[] = { +90,57,9,249,8,102,111,114,101,97,99,104,105,0,2,10,0,0,0,15,16,0,12,0,16,1, +9,0,41,2,1,0,21,3,0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,8,5,0,59,9,5,0,66,6,3, +2,10,6,0,0,88,7,1,128,76,6,2,0,79,2,248,127,75,0,1,0,249,7,102,111,114,101, +97,99,104,0,2,11,0,0,0,16,16,0,12,0,16,1,9,0,43,2,0,0,18,3,0,0,41,4,0,0,88, +5,7,128,18,7,1,0,18,9,5,0,18,10,6,0,66,7,3,2,10,7,0,0,88,8,1,128,76,7,2,0,70, +5,3,3,82,5,247,127,75,0,1,0,249,4,103,101,116,110,0,1,2,0,0,0,3,16,0,12,0,21, +1,0,0,76,1,2,0,4,109,97,120,110,6,105,110,115,101,114,116,249,6,114,101,109, +111,118,101,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128,8,2,0,0, +88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14,0,41,3, +1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2,0,41,6, +1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4,2,0,76, +3,2,0,75,0,1,0,0,2,249,4,109,111,118,101,0,5,12,0,0,0,35,16,0,12,0,16,1,14, +0,16,2,14,0,16,3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88,5,24, +128,33,5,1,3,0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128,18,6, +1,0,18,7,2,0,41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252,127, +88,6,8,128,18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9,0,64, +11,10,4,79,6,252,127,76,4,2,0,6,99,111,110,99,97,116,4,115,111,114,116,254, +254,255 +}; +#endif + +#ifdef LJLIB_MODULE_io_method +#undef LJLIB_MODULE_io_method +static const lua_CFunction lj_lib_cf_io_method[] = { + lj_cf_io_method_close, + lj_cf_io_method_read, + lj_cf_io_method_write, + lj_cf_io_method_flush, + lj_cf_io_method_seek, + lj_cf_io_method_setvbuf, + lj_cf_io_method_lines, + lj_cf_io_method___gc, + lj_cf_io_method___tostring +}; +static const uint8_t lj_lib_init_io_method[] = { +96,57,10,5,99,108,111,115,101,4,114,101,97,100,5,119,114,105,116,101,5,102, +108,117,115,104,4,115,101,101,107,7,115,101,116,118,98,117,102,5,108,105,110, +101,115,4,95,95,103,99,10,95,95,116,111,115,116,114,105,110,103,252,1,199,95, +95,105,110,100,101,120,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_io +#undef LJLIB_MODULE_io +static const lua_CFunction lj_lib_cf_io[] = { + lj_cf_io_open, + lj_cf_io_popen, + lj_cf_io_tmpfile, + lj_cf_io_close, + lj_cf_io_read, + lj_cf_io_write, + lj_cf_io_flush, + lj_cf_io_input, + lj_cf_io_output, + lj_cf_io_lines, + lj_cf_io_type +}; +static const uint8_t lj_lib_init_io[] = { +105,57,12,252,2,192,250,4,111,112,101,110,5,112,111,112,101,110,7,116,109,112, +102,105,108,101,5,99,108,111,115,101,4,114,101,97,100,5,119,114,105,116,101, +5,102,108,117,115,104,5,105,110,112,117,116,6,111,117,116,112,117,116,5,108, +105,110,101,115,4,116,121,112,101,255 +}; +#endif + +#ifdef LJLIB_MODULE_os +#undef LJLIB_MODULE_os +static const lua_CFunction lj_lib_cf_os[] = { + lj_cf_os_execute, + lj_cf_os_remove, + lj_cf_os_rename, + lj_cf_os_tmpname, + lj_cf_os_getenv, + lj_cf_os_exit, + lj_cf_os_clock, + lj_cf_os_date, + lj_cf_os_time, + lj_cf_os_difftime, + lj_cf_os_setlocale +}; +static const uint8_t lj_lib_init_os[] = { +116,57,11,7,101,120,101,99,117,116,101,6,114,101,109,111,118,101,6,114,101, +110,97,109,101,7,116,109,112,110,97,109,101,6,103,101,116,101,110,118,4,101, +120,105,116,5,99,108,111,99,107,4,100,97,116,101,4,116,105,109,101,8,100,105, +102,102,116,105,109,101,9,115,101,116,108,111,99,97,108,101,255 +}; +#endif + +#ifdef LJLIB_MODULE_debug +#undef LJLIB_MODULE_debug +static const lua_CFunction lj_lib_cf_debug[] = { + lj_cf_debug_getregistry, + lj_cf_debug_getmetatable, + lj_cf_debug_setmetatable, + lj_cf_debug_getfenv, + lj_cf_debug_setfenv, + lj_cf_debug_getinfo, + lj_cf_debug_getlocal, + lj_cf_debug_setlocal, + lj_cf_debug_getupvalue, + lj_cf_debug_setupvalue, + lj_cf_debug_upvalueid, + lj_cf_debug_upvaluejoin, + lj_cf_debug_sethook, + lj_cf_debug_gethook, + lj_cf_debug_debug, + lj_cf_debug_traceback +}; +static const uint8_t lj_lib_init_debug[] = { +127,57,16,11,103,101,116,114,101,103,105,115,116,114,121,12,103,101,116,109, +101,116,97,116,97,98,108,101,12,115,101,116,109,101,116,97,116,97,98,108,101, +7,103,101,116,102,101,110,118,7,115,101,116,102,101,110,118,7,103,101,116,105, +110,102,111,8,103,101,116,108,111,99,97,108,8,115,101,116,108,111,99,97,108, +10,103,101,116,117,112,118,97,108,117,101,10,115,101,116,117,112,118,97,108, +117,101,9,117,112,118,97,108,117,101,105,100,11,117,112,118,97,108,117,101, +106,111,105,110,7,115,101,116,104,111,111,107,7,103,101,116,104,111,111,107, +5,100,101,98,117,103,9,116,114,97,99,101,98,97,99,107,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit +#undef LJLIB_MODULE_jit +static const lua_CFunction lj_lib_cf_jit[] = { + lj_cf_jit_on, + lj_cf_jit_off, + lj_cf_jit_flush, + lj_cf_jit_status, + lj_cf_jit_security, + lj_cf_jit_attach +}; +static const uint8_t lj_lib_init_jit[] = { +143,57,10,2,111,110,3,111,102,102,5,102,108,117,115,104,6,115,116,97,116,117, +115,8,115,101,99,117,114,105,116,121,6,97,116,116,97,99,104,252,5,194,111,115, +250,252,4,196,97,114,99,104,250,252,3,203,118,101,114,115,105,111,110,95,110, +117,109,250,252,2,199,118,101,114,115,105,111,110,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit_util +#undef LJLIB_MODULE_jit_util +static const lua_CFunction lj_lib_cf_jit_util[] = { + lj_cf_jit_util_funcinfo, + lj_cf_jit_util_funcbc, + lj_cf_jit_util_funck, + lj_cf_jit_util_funcuvname +}; +static const uint8_t lj_lib_init_jit_util[] = { +149,57,4,8,102,117,110,99,105,110,102,111,6,102,117,110,99,98,99,5,102,117, +110,99,107,10,102,117,110,99,117,118,110,97,109,101,255 +}; +#endif + +#ifdef LJLIB_MODULE_jit_profile +#undef LJLIB_MODULE_jit_profile +static const lua_CFunction lj_lib_cf_jit_profile[] = { + lj_cf_jit_profile_start, + lj_cf_jit_profile_stop, + lj_cf_jit_profile_dumpstack +}; +static const uint8_t lj_lib_init_jit_profile[] = { +153,57,3,5,115,116,97,114,116,4,115,116,111,112,9,100,117,109,112,115,116,97, +99,107,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi_meta +#undef LJLIB_MODULE_ffi_meta +static const lua_CFunction lj_lib_cf_ffi_meta[] = { + lj_cf_ffi_meta___index, + lj_cf_ffi_meta___newindex, + lj_cf_ffi_meta___eq, + lj_cf_ffi_meta___len, + lj_cf_ffi_meta___lt, + lj_cf_ffi_meta___le, + lj_cf_ffi_meta___concat, + lj_cf_ffi_meta___call, + lj_cf_ffi_meta___add, + lj_cf_ffi_meta___sub, + lj_cf_ffi_meta___mul, + lj_cf_ffi_meta___div, + lj_cf_ffi_meta___mod, + lj_cf_ffi_meta___pow, + lj_cf_ffi_meta___unm, + lj_cf_ffi_meta___tostring, + lj_cf_ffi_meta___pairs, + lj_cf_ffi_meta___ipairs +}; +static const uint8_t lj_lib_init_ffi_meta[] = { +156,57,19,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101, +120,4,95,95,101,113,5,95,95,108,101,110,4,95,95,108,116,4,95,95,108,101,8,95, +95,99,111,110,99,97,116,6,95,95,99,97,108,108,5,95,95,97,100,100,5,95,95,115, +117,98,5,95,95,109,117,108,5,95,95,100,105,118,5,95,95,109,111,100,5,95,95, +112,111,119,5,95,95,117,110,109,10,95,95,116,111,115,116,114,105,110,103,7, +95,95,112,97,105,114,115,8,95,95,105,112,97,105,114,115,195,102,102,105,203, +95,95,109,101,116,97,116,97,98,108,101,250,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi_clib +#undef LJLIB_MODULE_ffi_clib +static const lua_CFunction lj_lib_cf_ffi_clib[] = { + lj_cf_ffi_clib___index, + lj_cf_ffi_clib___newindex, + lj_cf_ffi_clib___gc +}; +static const uint8_t lj_lib_init_ffi_clib[] = { +174,57,3,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101,120, +4,95,95,103,99,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi_callback +#undef LJLIB_MODULE_ffi_callback +static const lua_CFunction lj_lib_cf_ffi_callback[] = { + lj_cf_ffi_callback_free, + lj_cf_ffi_callback_set +}; +static const uint8_t lj_lib_init_ffi_callback[] = { +177,57,3,4,102,114,101,101,3,115,101,116,252,1,199,95,95,105,110,100,101,120, +250,255 +}; +#endif + +#ifdef LJLIB_MODULE_ffi +#undef LJLIB_MODULE_ffi +static const lua_CFunction lj_lib_cf_ffi[] = { + lj_cf_ffi_cdef, + lj_cf_ffi_new, + lj_cf_ffi_cast, + lj_cf_ffi_typeof, + lj_cf_ffi_typeinfo, + lj_cf_ffi_istype, + lj_cf_ffi_sizeof, + lj_cf_ffi_alignof, + lj_cf_ffi_offsetof, + lj_cf_ffi_errno, + lj_cf_ffi_string, + lj_cf_ffi_copy, + lj_cf_ffi_fill, + lj_cf_ffi_abi, + lj_cf_ffi_metatype, + lj_cf_ffi_gc, + lj_cf_ffi_load +}; +static const uint8_t lj_lib_init_ffi[] = { +179,57,23,4,99,100,101,102,3,110,101,119,4,99,97,115,116,6,116,121,112,101, +111,102,8,116,121,112,101,105,110,102,111,6,105,115,116,121,112,101,6,115,105, +122,101,111,102,7,97,108,105,103,110,111,102,8,111,102,102,115,101,116,111, +102,5,101,114,114,110,111,6,115,116,114,105,110,103,4,99,111,112,121,4,102, +105,108,108,3,97,98,105,252,8,192,250,8,109,101,116,97,116,121,112,101,252, +7,192,250,2,103,99,252,5,192,250,4,108,111,97,100,252,4,193,67,250,252,3,194, +111,115,250,252,2,196,97,114,99,104,250,255 +}; +#endif + diff --git a/core/src/luajit/autogen/macosx/nojit/arm64/lj_recdef.h b/core/src/luajit/autogen/macosx/nojit/arm64/lj_recdef.h new file mode 100644 index 000000000..ea00647a6 --- /dev/null +++ b/core/src/luajit/autogen/macosx/nojit/arm64/lj_recdef.h @@ -0,0 +1,262 @@ +/* This is a generated file. DO NOT EDIT! */ + +static const uint16_t recff_idmap[] = { +0, +0x0100, +0x0200, +0x0300, +0, +0x0400+(0), +0x0500, +0x0400+(1), +0x0600, +0x0700, +0x0800, +0, +0x0900, +0x0a00, +0x0b00, +0, +0x0c00, +0x0d00, +0x0e00, +0, +0x0f00, +0x1000, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x1100, +0x1200+(IRFPM_FLOOR), +0x1200+(IRFPM_CEIL), +0x1300+(IRFPM_SQRT), +0x1400+(IRCALL_log10), +0x1400+(IRCALL_exp), +0x1400+(IRCALL_sin), +0x1400+(IRCALL_cos), +0x1400+(IRCALL_tan), +0x1400+(IRCALL_asin), +0x1400+(IRCALL_acos), +0x1400+(IRCALL_atan), +0x1400+(IRCALL_sinh), +0x1400+(IRCALL_cosh), +0x1400+(IRCALL_tanh), +0, +0, +0x1500, +0x1600, +0x1700, +0, +0x1800, +0x1900+(IR_MIN), +0x1900+(IR_MAX), +0x1a00, +0, +0x1b00, +0x1c00+(IR_BNOT), +0x1c00+(IR_BSWAP), +0x1d00+(IR_BSHL), +0x1d00+(IR_BSHR), +0x1d00+(IR_BSAR), +0x1d00+(IR_BROL), +0x1d00+(IR_BROR), +0x1e00+(IR_BAND), +0x1e00+(IR_BOR), +0x1e00+(IR_BXOR), +0x1f00, +0x2000+(0), +0x2100, +0x2000+(1), +0x2200, +0x2300+(IRCALL_lj_buf_putstr_reverse), +0x2300+(IRCALL_lj_buf_putstr_lower), +0x2300+(IRCALL_lj_buf_putstr_upper), +0, +0x2400, +0, +0, +0, +0, +0x2500, +0, +0x2600, +0x2700, +0, +0x2800, +0x2900, +0, +0, +0x2a00+(0), +0x2b00+(0), +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x2a00+(GCROOT_IO_OUTPUT), +0x2b00+(GCROOT_IO_OUTPUT), +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x2c00, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0x2d00+(0), +0x2d00+(1), +0x2e00+(MM_eq), +0x2e00+(MM_len), +0x2e00+(MM_lt), +0x2e00+(MM_le), +0x2e00+(MM_concat), +0x2f00, +0x2e00+(MM_add), +0x2e00+(MM_sub), +0x2e00+(MM_mul), +0x2e00+(MM_div), +0x2e00+(MM_mod), +0x2e00+(MM_pow), +0x2e00+(MM_unm), +0, +0, +0, +0x3000+(1), +0x3000+(0), +0, +0, +0, +0, +0x3100, +0x3100, +0x3200, +0, +0x3300, +0x3400+(FF_ffi_sizeof), +0x3400+(FF_ffi_alignof), +0x3400+(FF_ffi_offsetof), +0x3500, +0x3600, +0x3700, +0x3800, +0x3900, +0, +0x3a00 +}; + +static const RecordFunc recff_func[] = { +recff_nyi, +recff_c, +recff_assert, +recff_type, +recff_xpairs, +recff_ipairs_aux, +recff_getmetatable, +recff_setmetatable, +recff_getfenv, +recff_rawget, +recff_rawset, +recff_rawequal, +recff_select, +recff_tonumber, +recff_tostring, +recff_pcall, +recff_xpcall, +recff_math_abs, +recff_math_round, +recff_math_unary, +recff_math_call, +recff_math_log, +recff_math_atan2, +recff_math_pow, +recff_math_ldexp, +recff_math_minmax, +recff_math_random, +recff_bit_tobit, +recff_bit_unary, +recff_bit_shift, +recff_bit_nary, +recff_bit_tohex, +recff_string_range, +recff_string_char, +recff_string_rep, +recff_string_op, +recff_string_find, +recff_string_format, +recff_table_insert, +recff_table_concat, +recff_table_new, +recff_table_clear, +recff_io_write, +recff_io_flush, +recff_debug_getmetatable, +recff_cdata_index, +recff_cdata_arith, +recff_cdata_call, +recff_clib_index, +recff_ffi_new, +recff_ffi_typeof, +recff_ffi_istype, +recff_ffi_xof, +recff_ffi_errno, +recff_ffi_string, +recff_ffi_copy, +recff_ffi_fill, +recff_ffi_abi, +recff_ffi_gc +}; + diff --git a/core/src/luajit/autogen/macosx/nojit/arm64/lj_vm.S b/core/src/luajit/autogen/macosx/nojit/arm64/lj_vm.S new file mode 100644 index 000000000..6228bd812 --- /dev/null +++ b/core/src/luajit/autogen/macosx/nojit/arm64/lj_vm.S @@ -0,0 +1,1953 @@ + .file "buildvm_arm64.dasc" + .text + .align 4 + + .private_extern _lj_vm_asm_begin + .no_dead_strip _lj_vm_asm_begin +_lj_vm_asm_begin: + + .private_extern _lj_BC_ISLT + .no_dead_strip _lj_BC_ISLT +_lj_BC_ISLT: + .long 0xf87b7a60,0x794006b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95b235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x54011da3 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x54011d21 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x54011ca3 + .long 0x1e620000,0x1e612000,0x9a953235,0x17ffffed + + .private_extern _lj_BC_ISGE + .no_dead_strip _lj_BC_ISGE +_lj_BC_ISGE: + .long 0xf87b7a60,0x794006b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95a235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x540119a3 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x54011921 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x540118a3 + .long 0x1e620000,0x1e612000,0x9a952235,0x17ffffed + + .private_extern _lj_BC_ISLE + .no_dead_strip _lj_BC_ISLE +_lj_BC_ISLE: + .long 0xf87b7a60,0x794006b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95d235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x540115a3 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x54011521 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x540114a3 + .long 0x1e620000,0x1e612000,0x9a959235,0x17ffffed + + .private_extern _lj_BC_ISGT + .no_dead_strip _lj_BC_ISGT +_lj_BC_ISGT: + .long 0xf87b7a60,0x794006b1,0xf87c7a61,0x910012b5 + .long 0x8b110ab1,0xd1408231,0xeb40833f,0x54000161 + .long 0xeb41833f,0x54000221,0x6b01001f,0x9a95c235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7b7a60,0x540111a3 + .long 0xfc7c7a61,0xeb41833f,0x540000e8,0x54011121 + .long 0x1e620021,0x14000004,0xfc7c7a61,0x540110a3 + .long 0x1e620000,0x1e612000,0x9a958235,0x17ffffed + + .private_extern _lj_BC_ISEQV + .no_dead_strip _lj_BC_ISEQV +_lj_BC_ISEQV: + .long 0xf87b7a60,0x8b1c0e7c,0x794006b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0x936ffc4f + .long 0xb10039ff,0x54000ce9,0x936ffc08,0xb1002dff + .long 0xba4b1904,0x54011380,0xeb02001f,0x54000101 + .long 0xaa1103f5,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0xeb0801ff + .long 0xba4c09e2,0x54ffff08,0x9240b801,0xf940102a + .long 0xb4fffeaa,0x39402949,0x52800003,0x3727fe49 + .long 0x14000882 + + .private_extern _lj_BC_ISNEV + .no_dead_strip _lj_BC_ISNEV +_lj_BC_ISNEV: + .long 0xf87b7a60,0x8b1c0e7c,0x794006b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0x936ffc4f + .long 0xb10039ff,0x54000d29,0x936ffc08,0xb1002dff + .long 0xba4b1904,0x54010f60,0xeb02001f,0x540000e1 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xeb0801ff,0xba4c09e2 + .long 0x54fffae8,0x9240b801,0xf940102a,0xb4fffa8a + .long 0x39402949,0x52800023,0x3727fa29,0x14000862 + + .private_extern _lj_BC_ISEQS + .no_dead_strip _lj_BC_ISEQS +_lj_BC_ISEQS: + .long 0xf87b7a60,0xaa3c03fc,0x794006b1,0xf87c7a81 + .long 0x910012b5,0x92800088,0x936ffc0f,0x8b110ab1 + .long 0x8b08bc21,0xd1408231,0xb1002dff,0x54010ba0 + .long 0xeb01001f,0x9a950235,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISNES + .no_dead_strip _lj_BC_ISNES +_lj_BC_ISNES: + .long 0xf87b7a60,0xaa3c03fc,0x794006b1,0xf87c7a81 + .long 0x910012b5,0x92800088,0x936ffc0f,0x8b110ab1 + .long 0x8b08bc21,0xd1408231,0xb1002dff,0x54010920 + .long 0xeb01001f,0x9a951235,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISEQN + .no_dead_strip _lj_BC_ISEQN +_lj_BC_ISEQN: + .long 0xf87b7a60,0x8b1c0e9c,0x794006b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0xeb40833f + .long 0x54000161,0xeb42833f,0x54000221,0x6b02001f + .long 0x9a950235,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0x54000183 + .long 0xfc7b7a60,0xfd400381,0xeb42833f,0x54000041 + .long 0x1e620041,0x1e612000,0x17fffff2,0xfd400381 + .long 0x1e620000,0x1e612000,0x17ffffee,0x936ffc0f + .long 0xb1002dff,0x54fffd81,0x1400081e + + .private_extern _lj_BC_ISNEN + .no_dead_strip _lj_BC_ISNEN +_lj_BC_ISNEN: + .long 0xf87b7a60,0x8b1c0e9c,0x794006b1,0xf9400382 + .long 0x910012b5,0x8b110ab1,0xd1408231,0xeb40833f + .long 0x54000161,0xeb42833f,0x54000221,0x6b02001f + .long 0x9a951235,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0x54000183 + .long 0xfc7b7a60,0xfd400381,0xeb42833f,0x54000041 + .long 0x1e620041,0x1e612000,0x17fffff2,0xfd400381 + .long 0x1e620000,0x1e612000,0x17ffffee,0x936ffc0f + .long 0xb1002dff,0x54fffd61,0x140007fb + + .private_extern _lj_BC_ISEQP + .no_dead_strip _lj_BC_ISEQP +_lj_BC_ISEQP: + .long 0xf87b7a68,0x794006b1,0x910012b5,0x9100079c + .long 0x8b110ab1,0x936ffd0f,0xb1002dff,0x5400fe60 + .long 0xab0f039f,0xd1408231,0x9a950235,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_ISNEP + .no_dead_strip _lj_BC_ISNEP +_lj_BC_ISNEP: + .long 0xf87b7a68,0x794006b1,0x910012b5,0x9100079c + .long 0x8b110ab1,0x936ffd0f,0xb1002dff,0x5400fc40 + .long 0xab0f039f,0xd1408231,0x9a951235,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_ISTC + .no_dead_strip _lj_BC_ISTC +_lj_BC_ISTC: + .long 0x794006b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a9c337b + .long 0x9a953235,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISFC + .no_dead_strip _lj_BC_ISFC +_lj_BC_ISFC: + .long 0x794006b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a9c237b + .long 0x9a952235,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_IST + .no_dead_strip _lj_BC_IST +_lj_BC_IST: + .long 0x794006b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a953235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISF + .no_dead_strip _lj_BC_ISF +_lj_BC_ISF: + .long 0x794006b1,0xf87c7a68,0x910012b5,0x92d00009 + .long 0x8b110ab1,0xeb09011f,0xd1408231,0x9a952235 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_ISTYPE + .no_dead_strip _lj_BC_ISTYPE +_lj_BC_ISTYPE: + .long 0xf87b7a68,0xab88bf9f,0x5400f421,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_ISNUM + .no_dead_strip _lj_BC_ISNUM +_lj_BC_ISNUM: + .long 0xf87b6a68,0xeb48833f,0x5400f309,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_MOV + .no_dead_strip _lj_BC_MOV +_lj_BC_MOV: + .long 0xf87c7a68,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_NOT + .no_dead_strip _lj_BC_NOT +_lj_BC_NOT: + .long 0xf87c7a68,0x92d00009,0x92e0002a,0xeb09011f + .long 0x9a8a3128,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_UNM + .no_dead_strip _lj_BC_UNM +_lj_BC_UNM: + .long 0xf87c7a68,0x936ffd0f,0xb10039ff,0x5400f108 + .long 0xd2410108,0x540000a1,0x6b0803e8,0xd2e83c02 + .long 0x8b180108,0x9a827108,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_LEN + .no_dead_strip _lj_BC_LEN +_lj_BC_LEN: + .long 0xf87c7a60,0x936ffc0f,0xb10015ff,0x9240b800 + .long 0x54000141,0xb9401400,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xb10031ff,0x5400efa1 + bl _lj_tab_len + .long 0x17fffff5 + + .private_extern _lj_BC_ADDVN + .no_dead_strip _lj_BC_ADDVN +_lj_BC_ADDVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x2b010000,0x5400eb26,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a81 + .long 0xeb40833f,0x5400e9a9,0xeb41833f,0x5400e969 + .long 0x1e612800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_SUBVN + .no_dead_strip _lj_BC_SUBVN +_lj_BC_SUBVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x6b010000,0x5400e7c6,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a81 + .long 0xeb40833f,0x5400e649,0xeb41833f,0x5400e609 + .long 0x1e613800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_MULVN + .no_dead_strip _lj_BC_MULVN +_lj_BC_MULVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001e1,0xeb41833f,0x540001a1 + .long 0x9b217c00,0xeb20c01f,0x2a0003e0,0x5400e421 + .long 0x8b180000,0xf83b7a60,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xfc717a60,0xfc7c7a81,0xeb40833f,0x5400e2a9 + .long 0xeb41833f,0x5400e269,0x1e610800,0xfc3b7a60 + .long 0x17fffff2 + + .private_extern _lj_BC_DIVVN + .no_dead_strip _lj_BC_DIVVN +_lj_BC_DIVVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xfc717a60,0xfc7c7a81,0xeb40833f,0x5400e109 + .long 0xeb41833f,0x5400e0c9,0x1e611800,0xfc3b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_MODVN + .no_dead_strip _lj_BC_MODVN +_lj_BC_MODVN: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a81 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x3400dea1,0x94000b70,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a81 + .long 0xeb40833f,0x5400dd09,0xeb41833f,0x5400dcc9 + .long 0x1e611802,0x1e654042,0x1f418040,0xfc3b7a60 + .long 0x17fffff0 + + .private_extern _lj_BC_ADDNV + .no_dead_strip _lj_BC_ADDNV +_lj_BC_ADDNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x2b010000,0x5400db46,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7c7a80,0xfc717a61 + .long 0xeb40833f,0x5400d9c9,0xeb41833f,0x5400d989 + .long 0x1e612800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_SUBNV + .no_dead_strip _lj_BC_SUBNV +_lj_BC_SUBNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x6b010000,0x5400d7e6,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7c7a80,0xfc717a61 + .long 0xeb40833f,0x5400d669,0xeb41833f,0x5400d629 + .long 0x1e613800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_MULNV + .no_dead_strip _lj_BC_MULNV +_lj_BC_MULNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001e1,0xeb41833f,0x540001a1 + .long 0x9b217c00,0xeb20c01f,0x2a0003e0,0x5400d441 + .long 0x8b180000,0xf83b7a60,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xfc7c7a80,0xfc717a61,0xeb40833f,0x5400d2c9 + .long 0xeb41833f,0x5400d289,0x1e610800,0xfc3b7a60 + .long 0x17fffff2 + + .private_extern _lj_BC_DIVNV + .no_dead_strip _lj_BC_DIVNV +_lj_BC_DIVNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xfc7c7a80,0xfc717a61,0xeb40833f,0x5400d129 + .long 0xeb41833f,0x5400d0e9,0x1e611800,0xfc3b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_MODNV + .no_dead_strip _lj_BC_MODNV +_lj_BC_MODNV: + .long 0x92401f9c,0xd3587e11,0xf87c7a80,0xf8717a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x3400cec1,0x94000aee,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc7c7a80,0xfc717a61 + .long 0xeb40833f,0x5400cd29,0xeb41833f,0x5400cce9 + .long 0x1e611802,0x1e654042,0x1f418040,0xfc3b7a60 + .long 0x17fffff0 + + .private_extern _lj_BC_ADDVV + .no_dead_strip _lj_BC_ADDVV +_lj_BC_ADDVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x2b010000,0x5400cbc6,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a61 + .long 0xeb40833f,0x5400ca49,0xeb41833f,0x5400ca09 + .long 0x1e612800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_SUBVV + .no_dead_strip _lj_BC_SUBVV +_lj_BC_SUBVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x6b010000,0x5400c866,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a61 + .long 0xeb40833f,0x5400c6e9,0xeb41833f,0x5400c6a9 + .long 0x1e613800,0xfc3b7a60,0x17fffff2 + + .private_extern _lj_BC_MULVV + .no_dead_strip _lj_BC_MULVV +_lj_BC_MULVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001e1,0xeb41833f,0x540001a1 + .long 0x9b217c00,0xeb20c01f,0x2a0003e0,0x5400c4c1 + .long 0x8b180000,0xf83b7a60,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xfc717a60,0xfc7c7a61,0xeb40833f,0x5400c349 + .long 0xeb41833f,0x5400c309,0x1e610800,0xfc3b7a60 + .long 0x17fffff2 + + .private_extern _lj_BC_DIVVV + .no_dead_strip _lj_BC_DIVVV +_lj_BC_DIVVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xfc717a60,0xfc7c7a61,0xeb40833f,0x5400c1a9 + .long 0xeb41833f,0x5400c169,0x1e611800,0xfc3b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_MODVV + .no_dead_strip _lj_BC_MODVV +_lj_BC_MODVV: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xeb40833f,0x540001a1,0xeb41833f,0x54000161 + .long 0x3400bf41,0x94000a6c,0x8b180000,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xfc717a60,0xfc7c7a61 + .long 0xeb40833f,0x5400bda9,0xeb41833f,0x5400bd69 + .long 0x1e611802,0x1e654042,0x1f418040,0xfc3b7a60 + .long 0x17fffff0 + + .private_extern _lj_BC_POW + .no_dead_strip _lj_BC_POW +_lj_BC_POW: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a61 + .long 0xfc717a60,0xfc7c7a61,0xeb40833f,0x5400bbc9 + .long 0xeb41833f,0x5400bb89 + bl _pow + .long 0xfc3b7a60,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_CAT + .no_dead_strip _lj_BC_CAT +_lj_BC_CAT: + .long 0xd3587e11,0x92401f9c,0xf90012f3,0xcb110382 + .long 0x8b1c0e61,0xaa1703e0,0xf90057f5 + bl _lj_meta_cat + .long 0x385ff2b1,0xf94012f3,0xb500ba40,0xf8717a68 + .long 0xf83b7a68,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KSTR + .no_dead_strip _lj_BC_KSTR +_lj_BC_KSTR: + .long 0xaa3c03fc,0xf87c7a88,0x92800089,0x8b09bd08 + .long 0xf83b7a68,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KCDATA + .no_dead_strip _lj_BC_KCDATA +_lj_BC_KCDATA: + .long 0xaa3c03fc,0xf87c7a88,0x92800149,0x8b09bd08 + .long 0xf83b7a68,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KSHORT + .no_dead_strip _lj_BC_KSHORT +_lj_BC_KSHORT: + .long 0x13003f9c,0x8b180388,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_KNUM + .no_dead_strip _lj_BC_KNUM +_lj_BC_KNUM: + .long 0xf87c7a88,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KPRI + .no_dead_strip _lj_BC_KPRI +_lj_BC_KPRI: + .long 0xaa3cbfe8,0xf83b7a68,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_KNIL + .no_dead_strip _lj_BC_KNIL +_lj_BC_KNIL: + .long 0x8b1b0e7b,0x8b1c0e7c,0xf800877a,0xeb1c037f + .long 0xf800877a,0x54ffffcb,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_UGET + .no_dead_strip _lj_BC_UGET +_lj_BC_UGET: + .long 0xf85f0261,0x9100179c,0x9240b821,0xf87c7821 + .long 0xf9401021,0xf9400028,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_USETV + .no_dead_strip _lj_BC_USETV +_lj_BC_USETV: + .long 0xf85f0261,0x9100177b,0x9240b821,0xf87b7820 + .long 0xf87c7a62,0xf9401001,0x3940200a,0x39402808 + .long 0x936ffc4f,0xf9000022,0x910011ef,0x721e015f + .long 0x7a401904,0xba4a19e0,0x540000e8,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x9240b842,0x39402049,0x7200053f + .long 0x54fffee0,0xaa1603e0 + bl _lj_gc_barrieruv + .long 0x17fffff4 + + .private_extern _lj_BC_USETS + .no_dead_strip _lj_BC_USETS +_lj_BC_USETS: + .long 0xf85f0261,0x9100177b,0xaa3c03fc,0x9240b821 + .long 0xf87b7820,0xf87c7a82,0x92800088,0xf9401001 + .long 0x3940200a,0x8b08bc48,0x39402049,0xf9000028 + .long 0x371000ea,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0x39402808 + .long 0x7200053f,0x7a401904,0x54fffee0,0xaa1603e0 + bl _lj_gc_barrieruv + .long 0x17fffff4 + + .private_extern _lj_BC_USETN + .no_dead_strip _lj_BC_USETN +_lj_BC_USETN: + .long 0xf85f0261,0x9100177b,0x9240b821,0xf87b7821 + .long 0xf87c7a88,0xf9401021,0xf9000028,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_USETP + .no_dead_strip _lj_BC_USETP +_lj_BC_USETP: + .long 0xf85f0261,0x9100177b,0x9240b821,0xf87b7821 + .long 0xaa3cbfe8,0xf9401021,0xf9000028,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_UCLO + .no_dead_strip _lj_BC_UCLO +_lj_BC_UCLO: + .long 0xf94022e2,0x8b1c0abc,0xf90012f3,0xd1408395 + .long 0xb40000a2,0xaa1703e0,0x8b1b0e61 + bl _lj_func_closeuv + .long 0xf94012f3,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_FNEW + .no_dead_strip _lj_BC_FNEW +_lj_BC_FNEW: + .long 0xaa3c03fc,0xf90012f3,0xf85f0262,0xf90057f5 + .long 0xf87c7a81,0xaa1703e0,0x9240b842 + bl _lj_func_newL_gc + .long 0xf94012f3,0x92800108,0x8b08bc00,0xf83b7a60 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_TNEW + .no_dead_strip _lj_BC_TNEW +_lj_BC_TNEW: + .long 0xa9410ec2,0xf90012f3,0xf90057f5,0xaa1703e0 + .long 0xeb03005f,0x54000202,0x92402b81,0xd34bff82 + .long 0xf11ffc3f,0x52810028,0x9a881021 + bl _lj_tab_new + .long 0xf94012f3,0xf2ffff40,0xf83b7a60,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + bl _lj_gc_step_fixtop + .long 0xaa1703e0,0x17ffffef + + .private_extern _lj_BC_TDUP + .no_dead_strip _lj_BC_TDUP +_lj_BC_TDUP: + .long 0xa9410ec2,0xf90012f3,0xf90057f5,0xaa1703e0 + .long 0xeb03005f,0x540001a2,0xaa3c03fc,0xf87c7a81 + bl _lj_tab_dup + .long 0xf94012f3,0xf2ffff40,0xf83b7a60,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + bl _lj_gc_step_fixtop + .long 0xaa1703e0,0x17fffff2 + + .private_extern _lj_BC_GGET + .no_dead_strip _lj_BC_GGET +_lj_BC_GGET: + .long 0xf85f0260,0xaa3c03fc,0x9240b800,0xf9400801 + .long 0xf87c7a9c,0x14000033 + + .private_extern _lj_BC_GSET + .no_dead_strip _lj_BC_GSET +_lj_BC_GSET: + .long 0xf85f0260,0xaa3c03fc,0x9240b800,0xf9400801 + .long 0xf87c7a9c,0x140000ab + + .private_extern _lj_BC_TGETV + .no_dead_strip _lj_BC_TGETV +_lj_BC_TGETV: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xf87c7a69 + .long 0x936ffc2f,0xb10031ff,0x9240b821,0x54008781 + .long 0xeb49833f,0x540002a1,0xf9400822,0xb9403020 + .long 0x8b294c42,0x6b00013f,0x540086a2,0xf9400048 + .long 0xeb1a011f,0x54000100,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xf9401020,0xb4ffff00,0x39402809 + .long 0x3707fec9,0x14000426,0x936ffd2f,0xb10015ff + .long 0x54008461,0x9240b93c,0x1400000a + + .private_extern _lj_BC_TGETS + .no_dead_strip _lj_BC_TGETS +_lj_BC_TGETS: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xaa3c03fc + .long 0xf87c7a9c,0x936ffc2f,0xb10031ff,0x9240b821 + .long 0x54008121,0xb9403429,0xb9400f8a,0xf9401422 + .long 0x0a0a0129,0x8b090529,0x92800083,0x8b090c42 + .long 0x8b03bf83,0xa9400048,0xf9400842,0xeb03001f + .long 0x54000141,0xeb1a011f,0x54000140,0xf83b7a68 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xb5fffe62,0xaa1a03e8 + .long 0xf9401020,0xb4fffec0,0x39402809,0x3707fe89 + .long 0x140003f1 + + .private_extern _lj_BC_TGETB + .no_dead_strip _lj_BC_TGETB +_lj_BC_TGETB: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0x936ffc2f + .long 0xb10031ff,0x9240b821,0x54007e01,0xf9400822 + .long 0xb9403020,0x8b1c0c42,0x6b00039f,0x54007d62 + .long 0xf9400048,0xeb1a011f,0x54000100,0xf83b7a68 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xf9401020,0xb4ffff00 + .long 0x39402809,0x3707fec9,0x140003dc + + .private_extern _lj_BC_TGETR + .no_dead_strip _lj_BC_TGETR +_lj_BC_TGETR: + .long 0xd3587e11,0x92401f9c,0xf8717a60,0xf87c7a69 + .long 0x9240b800,0xf9400802,0xb940300a,0x8b294c42 + .long 0x6b0a013f,0x54007dc2,0xf9400048,0xf83b7a68 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_TSETV + .no_dead_strip _lj_BC_TSETV +_lj_BC_TSETV: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xf87c7a69 + .long 0x936ffc2f,0xb10031ff,0x9240b821,0x54007e61 + .long 0xeb49833f,0x540003c1,0xf9400822,0xb9403020 + .long 0x8b294c42,0x6b00013f,0x54007d82,0xf9400049 + .long 0xf87b7a68,0x3940202a,0xeb1a013f,0x54000120 + .long 0xf9000048,0x3710018a,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xf9401020,0xb4fffee0,0x39402809,0x370ffea9 + .long 0x140003da,0xf94022c9,0x121d794a,0xf90022c1 + .long 0x3900202a,0xf9000c29,0x17fffff0,0x936ffd2f + .long 0xb10015ff,0x54007a21,0x9240b93c,0x1400000a + + .private_extern _lj_BC_TSETS + .no_dead_strip _lj_BC_TSETS +_lj_BC_TSETS: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xaa3c03fc + .long 0xf87c7a9c,0x936ffc2f,0xb10031ff,0x9240b821 + .long 0x540076e1,0xb9403429,0xb9400f8a,0xf9401422 + .long 0x0a0a0129,0x8b090529,0x92800083,0x8b090c42 + .long 0x8b03bf83,0x3900283f,0xa9400049,0xf940084b + .long 0x3940202a,0xeb03001f,0x54000221,0xf87b7a68 + .long 0xeb1a013f,0x54000120,0xf9000048,0x371003ca + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xf9401020,0xb4fffee0 + .long 0x39402809,0x370ffea9,0x1400039d,0xaa0b03e2 + .long 0xb5fffd4b,0xf9401020,0xb4000060,0x39402809 + .long 0x360872e9,0x92800089,0xf90057f5,0x8b09bf88 + .long 0xf90012f3,0xaa1703e0,0xf9005fe8,0x9102e3e2 + bl _lj_tab_newkey + .long 0xf94012f3,0xf87b7a68,0xf9000008,0x17ffffe4 + .long 0xf94022c9,0x121d794a,0xf90022c1,0x3900202a + .long 0xf9000c29,0x17ffffde + + .private_extern _lj_BC_TSETB + .no_dead_strip _lj_BC_TSETB +_lj_BC_TSETB: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0x936ffc2f + .long 0xb10031ff,0x9240b821,0x54007081,0xf9400822 + .long 0xb9403020,0x8b1c0c42,0x6b00039f,0x54006fe2 + .long 0xf9400049,0xf87b7a68,0x3940202a,0xeb1a013f + .long 0x54000120,0xf9000048,0x3710018a,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xf9401020,0xb4fffee0,0x39402809 + .long 0x370ffea9,0x1400036d,0xf94022c9,0x121d794a + .long 0xf90022c1,0x3900202a,0xf9000c29,0x17fffff0 + + .private_extern _lj_BC_TSETM + .no_dead_strip _lj_BC_TSETM +_lj_BC_TSETM: + .long 0x8b1b0e7b,0xb940c3f1,0xf85f8361,0xf87c7a89 + .long 0xd1002231,0xb40001f1,0x9240b821,0xb9403020 + .long 0x0b510d22,0xf9400823,0xeb00005f,0x8b110371 + .long 0x540001c8,0x8b294c69,0x3940202a,0xf8408768 + .long 0xf8008528,0xeb11037f,0x54ffffa3,0x3710018a + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_tab_reasize + .long 0x17ffffe3,0xf94022c9,0x121d794a,0xf90022c1 + .long 0x3900202a,0xf9000c29,0x17fffff0 + + .private_extern _lj_BC_TSETR + .no_dead_strip _lj_BC_TSETR +_lj_BC_TSETR: + .long 0xd3587e11,0x92401f9c,0xf8717a61,0xf87c7a69 + .long 0x9240b821,0xf9400820,0x3940202a,0xb9403023 + .long 0x8b294c00,0x3710016a,0x6b03013f,0x54006a62 + .long 0xf87b7a68,0xf9000008,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xf94022c8,0x121d794a,0xf90022c1,0x3900202a + .long 0xf9000c28,0x17fffff1 + + .private_extern _lj_BC_CALLM + .no_dead_strip _lj_BC_CALLM +_lj_BC_CALLM: + .long 0xb940c3e8,0xd37d1f9c,0x8b08039c,0x14000002 + + .private_extern _lj_BC_CALL + .no_dead_strip _lj_BC_CALL +_lj_BC_CALL: + .long 0xd37d1f9c,0xaa1303f1,0x8b1b0e73,0xf9400262 + .long 0xd100239c,0x91004273,0x936ffc4f,0xb10025ff + .long 0x9240b842,0x54007261,0xf81f8275,0xf9401055 + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_BC_CALLMT + .no_dead_strip _lj_BC_CALLMT +_lj_BC_CALLMT: + .long 0xb940c3e8,0x8b1c0d1c,0x14000002 + + .private_extern _lj_BC_CALLT + .no_dead_strip _lj_BC_CALLT +_lj_BC_CALLT: + .long 0xd37df39c,0x8b1b0e7b,0xf9400369,0xd100239c + .long 0x9100437b,0x936ffd2f,0xb10025ff,0x9240b922 + .long 0x54007201,0xf85f8275,0x52800011,0x3940284a + .long 0xf24006bf,0x54000321,0xf81f0269,0xb40000fc + .long 0xf8716b68,0x91002229,0xeb1c013f,0xf8316a68 + .long 0xaa0903f1,0x54ffff61,0xf100055f,0x54000108 + .long 0xf9401055,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0x8b1b0e7b,0xd61f0100,0x385fd2bb + .long 0xcb1b0e60,0xf85e0000,0x9240b800,0xf9401000 + .long 0xf85b8014,0x17fffff3,0xd24006b5,0xf2400abf + .long 0x9a8a122a,0x54fffca1,0xcb150273,0xf85f8275 + .long 0xf24006bf,0x9a8a122a,0x17ffffe0 + + .private_extern _lj_BC_ITERC + .no_dead_strip _lj_BC_ITERC +_lj_BC_ITERC: + .long 0x8b1b0e7b,0xf85e8362,0xaa1303f1,0xa97f0760 + .long 0x91004373,0x5280021c,0xf9000362,0xa9010760 + .long 0x936ffc4f,0xb10025ff,0x9240b842,0x540069a1 + .long 0xf81f8275,0xf9401055,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_BC_ITERN + .no_dead_strip _lj_BC_ITERN +_lj_BC_ITERN: + .long 0x8b1b0e7b,0xf85f0371,0x794006ab,0xb85f8360 + .long 0x910012b5,0x8b0b0aab,0x9240ba31,0xd140816b + .long 0xb9403229,0xf9400a21,0xeb09001c,0x8b000c22 + .long 0x54000202,0xf9400048,0xeb1a011f,0x9a801400 + .long 0x54ffff40,0x8b180000,0xa9002360,0x91000400 + .long 0xb81f8360,0xaa0b03f5,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0xb940362a,0xf9401631,0x8b1c0780,0xeb0a039f + .long 0x8b000e22,0x54fffea8,0xa9400048,0xeb1a011f + .long 0x9100079c,0x54ffff20,0xa9002360,0x8b090380 + .long 0x17ffffec + + .private_extern _lj_BC_VARG + .no_dead_strip _lj_BC_VARG +_lj_BC_VARG: + .long 0xd3587e11,0x92401f9c,0xf85f8269,0x8b1c0e7c + .long 0x8b1b0e7b,0x91000f9c,0x8b110f6a,0xcb09039c + .long 0xd100426b,0xb40001d1,0xd100414a,0xeb0b039f + .long 0xf8408788,0x9a9a3108,0xeb0a037f,0xf8008768 + .long 0x54ffff63,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0xf9401ae8 + .long 0xeb1c016a,0x9a8ad3f1,0x91002231,0x8b0a0369 + .long 0xb900c3f1,0x54fffe8d,0xeb08013f,0x540000c8 + .long 0xf8408788,0xf8008768,0xeb0b039f,0x54ffffa3 + .long 0x17ffffed,0xd343fd41,0xa9026ef3,0xaa1703e0 + .long 0xcb13039c,0xf90057f5 + bl _lj_state_growstack + .long 0xa9426ef3,0x8b1c027c,0xd100426b,0x17fffff2 + + .private_extern _lj_BC_ISNEXT + .no_dead_strip _lj_BC_ISNEXT +_lj_BC_ISNEXT: + .long 0x8b1b0e7b,0xf85e8360,0x8b1c0abc,0xa97f0f62 + .long 0xd140839c,0x936ffc0f,0xb10025ff,0x9240b800 + .long 0x54000221,0x936ffc48,0x39402809,0xb100311f + .long 0xfa5a0060,0x7a440920,0x54000161,0x320f77e8 + .long 0xd3607d08,0xf81f8368,0xaa1c03f5,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x52800b08,0x528008a9,0x381fc2a8 + .long 0x39000389,0x17fffff5 + + .private_extern _lj_BC_RETM + .no_dead_strip _lj_BC_RETM +_lj_BC_RETM: + .long 0xb940c3e8,0xf85f8275,0x8b1b0e7b,0x8b1c0d1c + .long 0x14000004 + + .private_extern _lj_BC_RET + .no_dead_strip _lj_BC_RET +_lj_BC_RET: + .long 0xf85f8275,0xd37df39c,0x8b1b0e7b,0xb900c3fc + .long 0xf24006a0,0xd24006a1,0x540003e1,0xb85fc2b0 + .long 0xf1002389,0xd1004262,0x540000c0,0xf8408768 + .long 0x91002273,0xd1002129,0xf81e8268,0xb5ffff89 + .long 0xd3483e1b,0xcb1b0c43,0xd3587e11,0xf85f0060 + .long 0xeb110f9f,0x54000163,0x9240b800,0xaa0303f3 + .long 0xf9401001,0xf85b8034,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0x91002273,0x9100239c,0xf81e827a,0x17fffff1 + .long 0x8b1b0e7b,0xf240083f,0x54001fa1,0xcb010273 + .long 0xf85f8275,0x17ffffdb + + .private_extern _lj_BC_RET0 + .no_dead_strip _lj_BC_RET0 +_lj_BC_RET0: + .long 0xf85f8275,0xd37df39c,0xb900c3fc,0xf24006a0 + .long 0xd24006a1,0x54fffea1,0xb85fc2b0,0xd1004263 + .long 0xd3483e1b,0xcb1b0c73,0xd3587e11,0xf85f0260 + .long 0xeb110f9f,0x54000143,0x9240b800,0xf9401001 + .long 0xf85b8034,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0xd3507e1c,0xd61f0100,0x9100239c + .long 0xf800847a,0x17fffff3 + + .private_extern _lj_BC_RET1 + .no_dead_strip _lj_BC_RET1 +_lj_BC_RET1: + .long 0xf85f8275,0xd37df39c,0xb900c3fc,0xf24006a0 + .long 0xd24006a1,0x54fffb61,0xb85fc2b0,0xf87b7a68 + .long 0xd1004263,0xd3483e1b,0xcb1b0c73,0xf8008468 + .long 0xd3587e11,0xf85f0260,0xeb110f9f,0x54000143 + .long 0x9240b800,0xf9401001,0xf85b8034,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x9100239c,0xf800847a,0x17fffff3 + + .private_extern _lj_BC_FORI + .no_dead_strip _lj_BC_FORI +_lj_BC_FORI: + .long 0x8b1b0e7b,0xa9400760,0xf9400b62,0x8b1c0abc + .long 0xd140839c,0xeb40833f,0x54000221,0xeb41833f + .long 0x54004fa1,0xeb42833f,0x54004f61,0x37f80142 + .long 0x6b01001f,0x9a95c395,0xf9000f60,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x6b00003f,0x17fffff7,0x6d400760 + .long 0x54004da3,0xeb41833f,0x54004d69,0xeb42833f + .long 0x54004d29,0xfd000f60,0xb7f80082,0x1e612000 + .long 0x9a958395,0x17ffffee,0x1e602020,0x17fffffd + + .private_extern _lj_BC_FORL + .no_dead_strip _lj_BC_FORL +_lj_BC_FORL: + .long 0x8b1b0e7b,0xa9400760,0xf9400b62,0x8b1c0abc + .long 0xd140839c,0xeb40833f,0x54000221,0x2b020000 + .long 0x540000e6,0x8b180008,0x37f80162,0x6b01001f + .long 0x9a95d395,0xf9000368,0xf9000f68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0x6b00003f,0x17fffff6,0x6d400760 + .long 0x54004923,0xfd400b62,0x1e622800,0xb7f800c2 + .long 0x1e612000,0xfd000360,0xfd000f60,0x9a959395 + .long 0x17ffffef,0x1e602020,0x17fffffb + + .private_extern _lj_BC_ITERL + .no_dead_strip _lj_BC_ITERL +_lj_BC_ITERL: + .long 0xf87b7a60,0x8b1b0e69,0xeb1a001f,0x54000080 + .long 0x8b1c0aa8,0xd1408115,0xf81f8120,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100 + + .private_extern _lj_BC_LOOP + .no_dead_strip _lj_BC_LOOP +_lj_BC_LOOP: + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_JMP + .no_dead_strip _lj_BC_JMP +_lj_BC_JMP: + .long 0x8b1c0abc,0xd1408395,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + + .private_extern _lj_BC_FUNCF + .no_dead_strip _lj_BC_FUNCF +_lj_BC_FUNCF: + + .private_extern _lj_BC_IFUNCF + .no_dead_strip _lj_BC_IFUNCF +_lj_BC_IFUNCF: + .long 0xf9401ae0,0x3859e2a9,0xf85b42b4,0xeb00037f + .long 0x540014a8,0xeb090f9f,0x540000e3,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xf83c6a7a,0x9100239c,0x17fffff6 + + .private_extern _lj_BC_JFUNCF + .no_dead_strip _lj_BC_JFUNCF +_lj_BC_JFUNCF: + + .private_extern _lj_BC_FUNCV + .no_dead_strip _lj_BC_FUNCV +_lj_BC_FUNCV: + + .private_extern _lj_BC_IFUNCV + .no_dead_strip _lj_BC_IFUNCV +_lj_BC_IFUNCV: + .long 0xf9401ae0,0x92800108,0x8b1c026a,0x8b08bc42 + .long 0x8b1c037b,0x91004f88,0xf8008542,0xf85b42b4 + .long 0xeb00037f,0xf8008548,0x540011e2,0xd100415c + .long 0x3859e2a9,0xaa1303fb,0xaa0a03f3,0xb4000109 + .long 0xeb1c037f,0x54000182,0xf9400368,0xd1000529 + .long 0xf800877a,0xf8008548,0xb5ffff49,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xd1000529,0xf800855a,0xb4ffff09 + .long 0x17fffffd + + .private_extern _lj_BC_JFUNCV + .no_dead_strip _lj_BC_JFUNCV +_lj_BC_JFUNCV: + + .private_extern _lj_BC_FUNCC + .no_dead_strip _lj_BC_FUNCC +_lj_BC_FUNCC: + .long 0xf9401443,0x8b1c0361,0xf9401ae0,0x8b1c027c + .long 0xeb00003f,0xa90272f3,0x12800028,0xaa1703e0 + .long 0x54000dc8,0xb900bac8,0xd63f0060,0xa94226f3 + .long 0xf900bad7,0x937d7c1c,0xb900bada,0xf85f8275 + .long 0xcb1c013b,0x14000019 + + .private_extern _lj_BC_FUNCCW + .no_dead_strip _lj_BC_FUNCCW +_lj_BC_FUNCCW: + .long 0xf940aec3,0x8b1c0361,0xf9401ae0,0x8b1c027c + .long 0xeb00003f,0xa90272f3,0xf9401441,0x12800028 + .long 0xaa1703e0,0x54000b68,0xb900bac8,0xd63f0060 + .long 0xa94226f3,0xf900bad7,0x937d7c1c,0xb900bada + .long 0xf85f8275,0xcb1c013b,0x14000006 + + .private_extern _lj_vm_returnp + .no_dead_strip _lj_vm_returnp +_lj_vm_returnp: + .long 0x36101c75,0xf85f8235,0x92e00028,0xaa1103f3 + .long 0xf81f8f68 + + .private_extern _lj_vm_returnc + .no_dead_strip _lj_vm_returnc +_lj_vm_returnc: + .long 0xb100239c,0x52800020,0x540006e0,0xb900c3fc + .long 0xf24006a0,0x54ffdca0 + + .private_extern _lj_vm_return + .no_dead_strip _lj_vm_return +_lj_vm_return: + .long 0x927df2b1,0xf100041f,0xcb110271,0x54fffe41 + .long 0xf90012f1,0xb980cbe1,0x12800028,0xd1004273 + .long 0xf100238a,0xb900bac8,0x540000a0,0xf100214a + .long 0xf8408768,0xf8008668,0x54ffffa1,0xeb010f9f + .long 0x54000201,0xf90016f3 + + .private_extern _lj_vm_leave_cp + .no_dead_strip _lj_vm_leave_cp +_lj_vm_leave_cp: + .long 0xf94053fc,0x52800000,0xf9002afc + + .private_extern _lj_vm_leave_unw + .no_dead_strip _lj_vm_leave_unw +_lj_vm_leave_unw: + .long 0xa94153f3,0x6d4627e8,0xa9425bf5,0x6d472fea + .long 0xa94363f7,0x6d4837ec,0xa9446bf9,0x6d493fee + .long 0xa94573fb,0xa8cd7bfd,0xd65f03c0,0x540000ec + .long 0xf9401ae2,0xeb02027f,0x54000102,0xf800867a + .long 0x9100239c,0x17ffffe9,0xb4fffd41,0xcb010f80 + .long 0xcb000273,0x17ffffe7,0xf90016f3,0xaa1703e0 + bl _lj_state_growstack + .long 0xf94016f3,0xb980cbe1,0x17ffffdf + + .private_extern _lj_vm_unwind_c + .no_dead_strip _lj_vm_unwind_c +_lj_vm_unwind_c: + .long 0x9100001f,0xaa0103e0 + + .private_extern _lj_vm_unwind_c_eh + .no_dead_strip _lj_vm_unwind_c_eh +_lj_vm_unwind_c_eh: + .long 0xf9405bf7,0x12800028,0xf9400af6,0xb900bac8 + .long 0x17ffffde + + .private_extern _lj_vm_unwind_ff + .no_dead_strip _lj_vm_unwind_ff +_lj_vm_unwind_ff: + .long 0x927ef41f + + .private_extern _lj_vm_unwind_ff_eh + .no_dead_strip _lj_vm_unwind_ff_eh +_lj_vm_unwind_ff_eh: + .long 0xf9405bf7,0xd2ffff38,0xd2bfff39,0x9280001a + .long 0x5280021c,0xf94012f3,0xf9400af6,0x92d00008 + .long 0xd100227b,0xf85f8275,0xf81f8268,0xb900bada + .long 0x17ffffb5 + + .private_extern _lj_vm_growstack_c + .no_dead_strip _lj_vm_growstack_c +_lj_vm_growstack_c: + .long 0x52800281,0x14000007 + + .private_extern _lj_vm_growstack_l + .no_dead_strip _lj_vm_growstack_l +_lj_vm_growstack_l: + .long 0x8b1c027c,0xcb13037b,0xaa1703e0,0xa90272f3 + .long 0x910012b5,0xd343ff61,0xf90057f5 + bl _lj_state_growstack + .long 0xa94272f3,0xf85f0262,0xcb13039c,0x9240b842 + .long 0xf9401055,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_vm_resume + .no_dead_strip _lj_vm_resume +_lj_vm_resume: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0xaa0003f7 + .long 0xf9400af6,0xaa0103f3,0xf9005bf7,0x528000b5 + .long 0xb900cbff,0x910007e8,0x39402ee9,0xb900c7ff + .long 0xf90057f7,0xf90053ff,0xf9002ae8,0x34000669 + .long 0xf900bad7,0xaa1303fb,0xa94202f3,0xd2ffff38 + .long 0xd2bfff39,0xf85f8275,0x39002eff,0x9280001a + .long 0xcb13001c,0xf24006a0,0x9100239c,0xb900bada + .long 0xb900c3fc,0x54ffcc80,0x17ffff7f + + .private_extern _lj_vm_pcall + .no_dead_strip _lj_vm_pcall +_lj_vm_pcall: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0x528000b5 + .long 0xb900c7e3,0x1400000d + + .private_extern _lj_vm_call + .no_dead_strip _lj_vm_call +_lj_vm_call: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0x52800035 + .long 0xf940281c,0xb900cbe2,0xaa0003f7,0xf9005be0 + .long 0xf9400af6,0xaa0103f3,0xf90057e0,0xf90053fc + .long 0xf9002afd,0xf900bad7,0xa94202f1,0xd2ffff38 + .long 0xd2bfff39,0x8b1302b5,0x9280001a,0xcb1102b5 + .long 0xcb13001c,0xb900bada + + .private_extern _lj_vm_call_dispatch + .no_dead_strip _lj_vm_call_dispatch +_lj_vm_call_dispatch: + .long 0xf85f0262,0x936ffc4f,0xb10025ff,0x9240b842 + .long 0x54001e81 + + .private_extern _lj_vm_call_dispatch_f + .no_dead_strip _lj_vm_call_dispatch_f +_lj_vm_call_dispatch_f: + .long 0xf81f8275,0xf9401055,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_vm_cpcall + .no_dead_strip _lj_vm_cpcall +_lj_vm_cpcall: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0xaa0003f7 + .long 0xf9401c1b,0xf9005be0,0xf9400af6,0xf94016f1 + .long 0xf90057e0,0xf9402afc,0xcb11037b,0xb900cbfb + .long 0xb900c7ff,0xf90053fc,0xf9002afd,0xf900bad7 + .long 0xd63f0060,0xaa0003f3,0x528000b5,0xb5fff9f3 + .long 0x17ffff3b + + .private_extern _lj_cont_dispatch + .no_dead_strip _lj_cont_dispatch +_lj_cont_dispatch: + .long 0xf85f0222,0xf85e0260,0xaa1303e3,0xaa1103f3 + .long 0x9240b842,0xf100041f,0xf85e8075,0xf9401042 + .long 0x8b1c0368,0xf81f811a,0x54000069,0xf85b8054 + .long 0xd61f0000,0x5400ab40,0xd1008063,0xcb13007c + .long 0x140004d1 + + .private_extern _lj_cont_cat + .no_dead_strip _lj_cont_cat +_lj_cont_cat: + .long 0xb85fc2b0,0xd1008061,0xf9400368,0xf90012f3 + .long 0xd3587e11,0xd3483e1b,0x8b110e69,0xeb090029 + .long 0x54000080,0xf9000028,0xd343fd22,0x17fffacf + .long 0xf83b7a68,0x14000069 + + .private_extern _lj_vmeta_tgets1 + .no_dead_strip _lj_vmeta_tgets1 +_lj_vmeta_tgets1: + .long 0x92800083,0x8b110e61,0x8b03bf83,0x14000004 + + .private_extern _lj_vmeta_tgets + .no_dead_strip _lj_vmeta_tgets +_lj_vmeta_tgets: + .long 0xf2ffff41,0xf90076c1,0x9103a2c1,0x9102e3e2 + .long 0xf9005fe3,0x14000008 + + .private_extern _lj_vmeta_tgetb + .no_dead_strip _lj_vmeta_tgetb +_lj_vmeta_tgetb: + .long 0x8b18039c,0x8b110e61,0x9102e3e2,0xf9005ffc + .long 0x14000003 + + .private_extern _lj_vmeta_tgetv + .no_dead_strip _lj_vmeta_tgetv +_lj_vmeta_tgetv: + .long 0x8b110e61,0x8b1c0e62,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_meta_tget + .long 0xb4000120,0xf9400008,0xf83b7a68,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xd1000a69,0xf94016f3,0x5280021c + .long 0xf85f0262,0xf81e8275,0xcb090275,0x9240b842 + .long 0x17ffff97 + + .private_extern _lj_vmeta_tgetr + .no_dead_strip _lj_vmeta_tgetr +_lj_vmeta_tgetr: + .long 0x93407d21 + bl _lj_tab_getinth + .long 0xaa1a03e8,0xb4ff8220,0xf9400008,0x17fffc0f + + .private_extern _lj_vmeta_tsets1 + .no_dead_strip _lj_vmeta_tsets1 +_lj_vmeta_tsets1: + .long 0x92800083,0x8b110e61,0x8b03bf83,0x14000004 + + .private_extern _lj_vmeta_tsets + .no_dead_strip _lj_vmeta_tsets +_lj_vmeta_tsets: + .long 0xf2ffff41,0xf90076c1,0x9103a2c1,0x9102e3e2 + .long 0xf9005fe3,0x14000008 + + .private_extern _lj_vmeta_tsetb + .no_dead_strip _lj_vmeta_tsetb +_lj_vmeta_tsetb: + .long 0x8b18039c,0x8b110e61,0x9102e3e2,0xf9005ffc + .long 0x14000003 + + .private_extern _lj_vmeta_tsetv + .no_dead_strip _lj_vmeta_tsetv +_lj_vmeta_tsetv: + .long 0x8b110e61,0x8b1c0e62,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_meta_tset + .long 0xf87b7a68,0xb4000100,0xf9000008,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0xd3507e1c + .long 0xd61f0100,0xd1000a69,0xf94016f3,0x5280031c + .long 0xf85f0262,0xf9000a68,0xf81e8275,0xcb090275 + .long 0x9240b842,0x17ffff6a + + .private_extern _lj_vmeta_tsetr + .no_dead_strip _lj_vmeta_tsetr +_lj_vmeta_tsetr: + .long 0x93407d22,0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_tab_setinth + .long 0x17fffca9 + + .private_extern _lj_vmeta_comp + .no_dead_strip _lj_vmeta_comp +_lj_vmeta_comp: + .long 0x8b1b0e61,0xd10012b5,0x8b1c0e62,0xf90012f3 + .long 0xaa1703e0,0xf90057f5,0x53001e03 + bl _lj_meta_comp + .long 0xf100041f,0x54000828,0x794006b1,0x910012b5 + .long 0x8b110ab1,0xd1408231,0x9a9132b5 + + .private_extern _lj_cont_nop + .no_dead_strip _lj_cont_nop +_lj_cont_nop: + .long 0xb84046b0,0x8b300ec9,0xd3483e1b,0xf9416d28 + .long 0xd3507e1c,0xd61f0100 + + .private_extern _lj_cont_ra + .no_dead_strip _lj_cont_ra +_lj_cont_ra: + .long 0xb85fc2b0,0xf9400368,0xd3483e09,0xf8297a68 + .long 0x17fffff6 + + .private_extern _lj_cont_condt + .no_dead_strip _lj_cont_condt +_lj_cont_condt: + .long 0xf9400368,0x92e00029,0xeb08013f,0x17ffffed + + .private_extern _lj_cont_condf + .no_dead_strip _lj_cont_condf +_lj_cont_condf: + .long 0xf9400368,0x92d00009,0xeb09011f,0x17ffffe9 + + .private_extern _lj_vmeta_equal + .no_dead_strip _lj_vmeta_equal +_lj_vmeta_equal: + .long 0x9240b842,0xd10012b5,0xf90012f3,0xaa1703e0 + .long 0xf90057f5 + bl _lj_meta_equal + .long 0x17ffffe0 + + .private_extern _lj_vmeta_equal_cd + .no_dead_strip _lj_vmeta_equal_cd +_lj_vmeta_equal_cd: + .long 0xd10012b5,0xf90012f3,0xaa1703e0,0xaa1003e1 + .long 0xf90057f5 + bl _lj_meta_equal_cd + .long 0x17ffffd9 + + .private_extern _lj_vmeta_istype + .no_dead_strip _lj_vmeta_istype +_lj_vmeta_istype: + .long 0xd10012b5,0xf90012f3,0xaa1703e0,0xaa1b03e1 + .long 0xaa1c03e2,0xf90057f5 + bl _lj_meta_istype + .long 0x17ffffd8 + + .private_extern _lj_vmeta_arith_vn + .no_dead_strip _lj_vmeta_arith_vn +_lj_vmeta_arith_vn: + .long 0x8b110e62,0x8b1c0e83,0x14000009 + + .private_extern _lj_vmeta_arith_nv + .no_dead_strip _lj_vmeta_arith_nv +_lj_vmeta_arith_nv: + .long 0x8b110e63,0x8b1c0e82,0x14000006 + + .private_extern _lj_vmeta_unm + .no_dead_strip _lj_vmeta_unm +_lj_vmeta_unm: + .long 0x8b1c0e62,0xaa0203e3,0x14000003 + + .private_extern _lj_vmeta_arith_vv + .no_dead_strip _lj_vmeta_arith_vv +_lj_vmeta_arith_vv: + .long 0x8b110e62,0x8b1c0e63,0x53001e04,0x8b1b0e61 + .long 0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_meta_arith + .long 0xb4fff8c0 + + .private_extern _lj_vmeta_binop + .no_dead_strip _lj_vmeta_binop +_lj_vmeta_binop: + .long 0xcb130009,0xf81e8015,0x91000935,0xaa0003f3 + .long 0x5280021c,0x17ffff0f + + .private_extern _lj_vmeta_len + .no_dead_strip _lj_vmeta_len +_lj_vmeta_len: + .long 0x8b1c0e61,0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_meta_len + .long 0x17fffff5 + + .private_extern _lj_vmeta_call + .no_dead_strip _lj_vmeta_call +_lj_vmeta_call: + .long 0xaa1703e0,0xf90012f1,0xd1004261,0xf90057f5 + .long 0x8b1c0262 + bl _lj_meta_call + .long 0xf85f0262,0x9100239c,0x9240b842,0xf81f8275 + .long 0xf9401055,0xb84046b0,0x8b300ec9,0xd3483e1b + .long 0xf9416d28,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_vmeta_callt + .no_dead_strip _lj_vmeta_callt +_lj_vmeta_callt: + .long 0xaa1703e0,0xf90012f3,0xd1004361,0xf90057f5 + .long 0x8b1c0362 + bl _lj_meta_call + .long 0xf85f0369,0xf85f8275,0x9100239c,0x9240b922 + .long 0x17fffc68 + + .private_extern _lj_vmeta_for + .no_dead_strip _lj_vmeta_for +_lj_vmeta_for: + .long 0xaa1703e0,0xf90012f3,0xaa1b03e1,0xf90057f5 + bl _lj_meta_for + .long 0xb85fc2b0,0xd3483e1b,0xd3507e1c,0x17fffd73 + + .private_extern _lj_ff_assert + .no_dead_strip _lj_ff_assert +_lj_ff_assert: + .long 0xf9400260,0xf100239f,0x540079e3,0xf85f8275 + .long 0x92d00009,0xeb09001f,0x54007962,0xf81f0260 + .long 0xd1002271,0xf100239b,0x9100239c,0xb40032fb + .long 0xf9400a20,0xd100237b,0xf8008620,0xb5ffffbb + .long 0x14000192 + + .private_extern _lj_ff_type + .no_dead_strip _lj_ff_type +_lj_ff_type: + .long 0xf9400260,0xf100239f,0x540077c3,0x528001a8 + .long 0x936ffc0f,0xb10035ff,0xda8f3109,0x91001929 + .long 0xf8697840,0x14000185 + + .private_extern _lj_ff_getmetatable + .no_dead_strip _lj_ff_getmetatable +_lj_ff_getmetatable: + .long 0xf9400260,0xf100239f,0x54007683,0x936ffc0f + .long 0xb10031ff,0xba4d19e4,0x9240b800,0x54000301 + .long 0xf9401011,0xaa1a03e0,0xf9411adc,0xb4002f31 + .long 0xb9403629,0xb9400f8a,0xf9401622,0x0a0a0129 + .long 0x8b090529,0x92800083,0x8b090c42,0x8b03bf83 + .long 0xa9402040,0xf9400842,0xeb03011f,0x540000a0 + .long 0xb5ffff82,0xaa1103e0,0xf2ffff40,0x14000169 + .long 0xeb1a011f,0x54002ce1,0x17fffffb,0x928001a8 + .long 0xeb0801ff,0x9a8821ef,0xcb0f0ec9,0xf9412931 + .long 0x17ffffe5 + + .private_extern _lj_ff_setmetatable + .no_dead_strip _lj_ff_setmetatable +_lj_ff_setmetatable: + .long 0xa9400660,0xf100439f,0x540071e3,0x936ffc0f + .long 0xb10031ff,0x9240b809,0x54007161,0xf9401128 + .long 0x936ffc2f,0x3940212a,0xb10031ff,0x9240b821 + .long 0xfa400900,0x54007081,0xf9001121,0x36102a0a + .long 0xf94022c8,0x121d794a,0xf90022c9,0x3900212a + .long 0xf9000d28,0x1400014a + + .private_extern _lj_ff_rawget + .no_dead_strip _lj_ff_rawget +_lj_ff_rawget: + .long 0xf9400261,0xf100439f,0x54006f23,0x936ffc2f + .long 0xb10031ff,0x9240b821,0x54006ea1,0xaa1703e0 + .long 0x91002262 + bl _lj_tab_get + .long 0xf9400000,0x1400013e + + .private_extern _lj_ff_tonumber + .no_dead_strip _lj_ff_tonumber +_lj_ff_tonumber: + .long 0xf9400260,0xf100239f,0x54006da1,0xeb40833f + .long 0x54006d63,0x14000138 + + .private_extern _lj_ff_tostring + .no_dead_strip _lj_ff_tostring +_lj_ff_tostring: + .long 0xf9400260,0xf100239f,0x54006ce3,0x936ffc0f + .long 0xb10015ff,0x54002640,0xf94162c9,0xf90012f3 + .long 0xb10039ff,0xfa409920,0xf90057f5,0x54006bc1 + .long 0xa94106c0,0xeb01001f,0x5400004b,0x94000384 + .long 0xaa1703e0,0xaa1303e1 + bl _lj_strfmt_number + .long 0x92800089,0xf94012f3,0x8b09bc00,0x14000121 + + .private_extern _lj_ff_next + .no_dead_strip _lj_ff_next +_lj_ff_next: + .long 0xf9400260,0xf100239f,0x54006a03,0x936ffc0f + .long 0xb10031ff,0x9240b801,0x54006981,0xf83c6a7a + .long 0xf85f8275,0xa9024ef3,0xaa1703e0,0x91002262 + .long 0xf90057f5 + bl _lj_tab_next + .long 0xf81f027a,0xb4002260,0xa9408660,0x5280031c + .long 0xa93f0660,0x14000110 + + .private_extern _lj_ff_pairs + .no_dead_strip _lj_ff_pairs +_lj_ff_pairs: + .long 0xf9400260,0xf100239f,0x54006783,0x936ffc0f + .long 0xb10031ff,0x9240b809,0x54006701,0xf9401843 + .long 0xf85f8275,0x5280041c,0xa93fea60,0xf81f0263 + .long 0x14000103 + + .private_extern _lj_ff_ipairs_aux + .no_dead_strip _lj_ff_ipairs_aux +_lj_ff_ipairs_aux: + .long 0xa9400660,0xf100439f,0x540065e3,0x936ffc0f + .long 0xb10031ff,0x9240b800,0x54006561,0xeb41833f + .long 0x54006521,0xb9403009,0xf9400802,0xb9403408 + .long 0x11000421,0x6b09003f,0xf85f8275,0x8b18002a + .long 0x5280011c,0xf81f026a,0x540000e2,0xf8617848 + .long 0x52800309,0xeb1a011f,0xf81f8268,0x9a89039c + .long 0x140000ea,0x34001d28 + bl _lj_tab_getinth + .long 0xb4001ce0,0xf9400008,0x17fffff7 + + .private_extern _lj_ff_ipairs + .no_dead_strip _lj_ff_ipairs +_lj_ff_ipairs: + .long 0xf9400260,0xf100239f,0x54006223,0x936ffc0f + .long 0xb10031ff,0x9240b809,0x540061a1,0xf9401843 + .long 0xf85f8275,0x5280041c,0xa93fe260,0xf81f0263 + .long 0x140000d8 + + .private_extern _lj_ff_pcall + .no_dead_strip _lj_ff_pcall +_lj_ff_pcall: + .long 0x394246c8,0xf100239c,0x54006083,0xaa1303f1 + .long 0x91004273,0x53041108,0x91005915,0x54ffc220 + .long 0x8b1c026a,0xf85f0148,0xf81f8d48,0xeb13015f + .long 0x54ffffa1,0x17fffe0b + + .private_extern _lj_ff_xpcall + .no_dead_strip _lj_ff_xpcall +_lj_ff_xpcall: + .long 0xa9400660,0x394246c8,0xf1004389,0x54005ea3 + .long 0xaa1303f1,0x936ffc2f,0x53041108,0xb10025ff + .long 0x91007915,0x54005de1,0xaa0903fc,0x91006273 + .long 0xa9000221,0xb4ffbfbc,0x17ffffec + + .private_extern _lj_ff_coroutine_resume + .no_dead_strip _lj_ff_coroutine_resume +_lj_ff_coroutine_resume: + .long 0xf9400260,0xf100239f,0x54005ce3,0x936ffc0f + .long 0xb1001dff,0x9240b800,0x54005c61,0xf85f8275 + .long 0xf90012f3,0xa9420411,0x39402c09,0x8b090028 + .long 0xf90057f5,0xeb11011f,0x54005b60,0xf100053f + .long 0x91002028,0x9a882021,0xf9401803,0x8b1c0022 + .long 0xf9402811,0xfa439042,0xfa409a22,0x54005a48 + .long 0xd1002042,0x91002273,0xd100239c,0xf9001402 + .long 0xf90016f3,0xb40000dc,0xf8716a68,0xeb1c023f + .long 0xf8316828,0x91002231,0x54ffff81,0x52800002 + .long 0xaa0003fb,0x52800003,0x97fffd82,0xa9420f62 + .long 0xf100041f,0xf94012f3,0xf900bad7,0xb900bada + .long 0x54000308,0xcb02007c,0xf9401ae0,0x8b1c0261 + .long 0xb400017c,0xeb00003f,0x52800011,0x540002e8 + .long 0xd1002383,0xf9001762,0xf8716848,0xeb03023f + .long 0xf8316a68,0x91002231,0x54ffff81,0x92e00029 + .long 0x9100439c,0xf81f8269,0xd100227b,0xf24006a0 + .long 0xf90057f5,0xb900c3fc,0x54ff7de0,0x17fffd0a + .long 0xf85f8c68,0x92d00009,0x5280031c,0xf9001763 + .long 0xf9000268,0x17fffff4,0xaa1703e0,0xd343ff81 + bl _lj_state_growstack + .long 0x52800000,0x17ffffd9 + + .private_extern _lj_ff_coroutine_wrap_aux + .no_dead_strip _lj_ff_coroutine_wrap_aux +_lj_ff_coroutine_wrap_aux: + .long 0xf9401840,0x9240b800,0xf85f8275,0xf90012f3 + .long 0xa9420411,0x39402c09,0x8b090028,0xf90057f5 + .long 0xeb11011f,0x54005220,0xf100053f,0x91002028 + .long 0x9a882021,0xf9401803,0x8b1c0022,0xf9402811 + .long 0xfa439042,0xfa409a22,0x54005108,0xf9001402 + .long 0xf90016f3,0xb40000dc,0xf8716a68,0xeb1c023f + .long 0xf8316828,0x91002231,0x54ffff81,0x52800002 + .long 0xaa0003fb,0x52800003,0x97fffd3b,0xa9420f62 + .long 0xf100041f,0xf94012f3,0xf900bad7,0xb900bada + .long 0x540002c8,0xcb02007c,0xf9401ae0,0x8b1c0261 + .long 0xb400017c,0xeb00003f,0x52800011,0x54000248 + .long 0xd1002383,0xf9001762,0xf8716848,0xeb03023f + .long 0xf8316a68,0x91002231,0x54ffff81,0xaa1303fb + .long 0x9100239c,0xf24006a0,0xf90057f5,0xb900c3fc + .long 0x54ff7540,0x17fffcc5,0xaa1703e0,0xaa1b03e1 + bl _lj_ffh_coroutine_wrap_err + .long 0xaa1703e0,0xd343ff81 + bl _lj_state_growstack + .long 0x52800000,0x17ffffde + + .private_extern _lj_ff_coroutine_yield + .no_dead_strip _lj_ff_coroutine_yield +_lj_ff_coroutine_yield: + .long 0xf9402ae8,0x8b1c0269,0x52800020,0xa90226f3 + .long 0x36004a88,0xf9002aff,0x39002ee0,0x17fffcca + + .private_extern _lj_ff_math_floor + .no_dead_strip _lj_ff_math_floor +_lj_ff_math_floor: + .long 0xf9400260,0xf100239f,0xfd400260,0x540049a3 + .long 0xeb40833f,0x54000320,0x54004943,0x1e654000 + .long 0x14000034 + + .private_extern _lj_ff_math_ceil + .no_dead_strip _lj_ff_math_ceil +_lj_ff_math_ceil: + .long 0xf9400260,0xf100239f,0xfd400260,0x54004883 + .long 0xeb40833f,0x54000200,0x54004823,0x1e64c000 + .long 0x1400002b + + .private_extern _lj_ff_math_abs + .no_dead_strip _lj_ff_math_abs +_lj_ff_math_abs: + .long 0xf9400260,0xf100239f,0x54004783,0xeb40833f + .long 0x54004743,0x9240f800,0x540000c1,0x4a807c01 + .long 0xd2e83c02,0x6b807c20,0x8b180000,0x9a825000 + + .private_extern _lj_fff_restv + .no_dead_strip _lj_fff_restv +_lj_fff_restv: + .long 0xf85f8275,0xf81f0260 + + .private_extern _lj_fff_res1 + .no_dead_strip _lj_fff_res1 +_lj_fff_res1: + .long 0x5280021c + + .private_extern _lj_fff_res + .no_dead_strip _lj_fff_res +_lj_fff_res: + .long 0xf24006a0,0xb900c3fc,0xd100427b,0x54ff9201 + .long 0xb85fc2b0,0xd3587e11,0xeb110f9f,0x54000123 + .long 0xd3483e09,0xcb090f73,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0xd3507e1c,0xd61f0100 + .long 0x8b1c0369,0x9100239c,0xf81f813a,0x17fffff3 + + .private_extern _lj_ff_math_sqrt + .no_dead_strip _lj_ff_math_sqrt +_lj_ff_math_sqrt: + .long 0xf9400260,0xf100239f,0xfd400260,0x54004303 + .long 0xeb40833f,0x540042c9,0x1e61c000 + + .private_extern _lj_fff_resn + .no_dead_strip _lj_fff_resn +_lj_fff_resn: + .long 0xf85f8275,0xfc1f0260,0x17ffffe2 + + .private_extern _lj_ff_math_log + .no_dead_strip _lj_ff_math_log +_lj_ff_math_log: + .long 0xf9400260,0xf100239f,0xfd400260,0x540041c1 + .long 0xeb40833f,0x54004189 + bl _log + .long 0x17fffff6 + + .private_extern _lj_ff_math_log10 + .no_dead_strip _lj_ff_math_log10 +_lj_ff_math_log10: + .long 0xf9400260,0xf100239f,0xfd400260,0x540040c3 + .long 0xeb40833f,0x54004089 + bl _log10 + .long 0x17ffffee + + .private_extern _lj_ff_math_exp + .no_dead_strip _lj_ff_math_exp +_lj_ff_math_exp: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003fc3 + .long 0xeb40833f,0x54003f89 + bl _exp + .long 0x17ffffe6 + + .private_extern _lj_ff_math_sin + .no_dead_strip _lj_ff_math_sin +_lj_ff_math_sin: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003ec3 + .long 0xeb40833f,0x54003e89 + bl _sin + .long 0x17ffffde + + .private_extern _lj_ff_math_cos + .no_dead_strip _lj_ff_math_cos +_lj_ff_math_cos: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003dc3 + .long 0xeb40833f,0x54003d89 + bl _cos + .long 0x17ffffd6 + + .private_extern _lj_ff_math_tan + .no_dead_strip _lj_ff_math_tan +_lj_ff_math_tan: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003cc3 + .long 0xeb40833f,0x54003c89 + bl _tan + .long 0x17ffffce + + .private_extern _lj_ff_math_asin + .no_dead_strip _lj_ff_math_asin +_lj_ff_math_asin: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003bc3 + .long 0xeb40833f,0x54003b89 + bl _asin + .long 0x17ffffc6 + + .private_extern _lj_ff_math_acos + .no_dead_strip _lj_ff_math_acos +_lj_ff_math_acos: + .long 0xf9400260,0xf100239f,0xfd400260,0x54003ac3 + .long 0xeb40833f,0x54003a89 + bl _acos + .long 0x17ffffbe + + .private_extern _lj_ff_math_atan + .no_dead_strip _lj_ff_math_atan +_lj_ff_math_atan: + .long 0xf9400260,0xf100239f,0xfd400260,0x540039c3 + .long 0xeb40833f,0x54003989 + bl _atan + .long 0x17ffffb6 + + .private_extern _lj_ff_math_sinh + .no_dead_strip _lj_ff_math_sinh +_lj_ff_math_sinh: + .long 0xf9400260,0xf100239f,0xfd400260,0x540038c3 + .long 0xeb40833f,0x54003889 + bl _sinh + .long 0x17ffffae + + .private_extern _lj_ff_math_cosh + .no_dead_strip _lj_ff_math_cosh +_lj_ff_math_cosh: + .long 0xf9400260,0xf100239f,0xfd400260,0x540037c3 + .long 0xeb40833f,0x54003789 + bl _cosh + .long 0x17ffffa6 + + .private_extern _lj_ff_math_tanh + .no_dead_strip _lj_ff_math_tanh +_lj_ff_math_tanh: + .long 0xf9400260,0xf100239f,0xfd400260,0x540036c3 + .long 0xeb40833f,0x54003689 + bl _tanh + .long 0x17ffff9e + + .private_extern _lj_ff_math_pow + .no_dead_strip _lj_ff_math_pow +_lj_ff_math_pow: + .long 0xa9400660,0xf100439f,0x6d400660,0x540035c3 + .long 0xeb40833f,0x54003589,0xeb41833f,0x54003549 + bl _pow + .long 0x17ffff94 + + .private_extern _lj_ff_math_atan2 + .no_dead_strip _lj_ff_math_atan2 +_lj_ff_math_atan2: + .long 0xa9400660,0xf100439f,0x6d400660,0x54003483 + .long 0xeb40833f,0x54003449,0xeb41833f,0x54003409 + bl _atan2 + .long 0x17ffff8a + + .private_extern _lj_ff_math_fmod + .no_dead_strip _lj_ff_math_fmod +_lj_ff_math_fmod: + .long 0xa9400660,0xf100439f,0x6d400660,0x54003343 + .long 0xeb40833f,0x54003309,0xeb41833f,0x540032c9 + bl _fmod + .long 0x17ffff80 + + .private_extern _lj_ff_math_ldexp + .no_dead_strip _lj_ff_math_ldexp +_lj_ff_math_ldexp: + .long 0xa9400660,0xf100439f,0x54003223,0xfd400260 + .long 0xeb40833f,0x540031c9,0xeb41833f,0x54003181 + .long 0x93407c20 + bl _ldexp + .long 0x17ffff75 + + .private_extern _lj_ff_math_frexp + .no_dead_strip _lj_ff_math_frexp +_lj_ff_math_frexp: + .long 0xf9400260,0xf100239f,0xfd400260,0x540030a3 + .long 0xeb40833f,0x54003069,0x9102e3e0 + bl _frexp + .long 0xb940bbe1,0xf85f8275,0xfc1f0260,0x5280031c + .long 0x8b180021,0xf81f8261,0x17ffff4b + + .private_extern _lj_ff_math_modf + .no_dead_strip _lj_ff_math_modf +_lj_ff_math_modf: + .long 0xf9400260,0xf100239f,0xfd400260,0x54002ec3 + .long 0xeb40833f,0x54002e89,0xd1004260,0xf85f8275 + bl _modf + .long 0x5280031c,0xfc1f8260,0x17ffff3f + + .private_extern _lj_ff_math_min + .no_dead_strip _lj_ff_math_min +_lj_ff_math_min: + .long 0xf9400260,0xf100239f,0x54002d63,0x8b1c0271 + .long 0x9100227b,0xeb40833f,0x540001c1,0xf9400361 + .long 0xeb11037f,0x54ffe642,0xeb41833f,0x540000a1 + .long 0x6b01001f,0x9100237b,0x9a80c020,0x17fffff8 + .long 0x1e620000,0x54002b83,0xfd400361,0x14000009 + .long 0xfd400260,0x54002b03,0xf9400361,0xfd400361 + .long 0xeb11037f,0x54ffe802,0xeb41833f,0x540000a9 + .long 0x1e612000,0x9100237b,0x1e605c20,0x17fffff7 + .long 0x1e620021,0x54002983,0x17fffffa + + .private_extern _lj_ff_math_max + .no_dead_strip _lj_ff_math_max +_lj_ff_math_max: + .long 0xf9400260,0xf100239f,0x54002903,0x8b1c0271 + .long 0x9100227b,0xeb40833f,0x540001c1,0xf9400361 + .long 0xeb11037f,0x54ffe1e2,0xeb41833f,0x540000a1 + .long 0x6b01001f,0x9100237b,0x9a80b020,0x17fffff8 + .long 0x1e620000,0x54002723,0xfd400361,0x14000009 + .long 0xfd400260,0x540026a3,0xf9400361,0xfd400361 + .long 0xeb11037f,0x54ffe3a2,0xeb41833f,0x540000a9 + .long 0x1e612000,0x9100237b,0x1e60dc20,0x17fffff7 + .long 0x1e620021,0x54002523,0x17fffffa + + .private_extern _lj_ff_string_byte + .no_dead_strip _lj_ff_string_byte +_lj_ff_string_byte: + .long 0xa97f8275,0xf100239f,0x936ffc0f,0xba4509e0 + .long 0x9240b800,0x54002441,0x39406008,0xb9401402 + .long 0x8b180108,0xf81f0268,0x5280011c,0xb4ffdda2 + .long 0x17fffeeb + + .private_extern _lj_ff_string_char + .no_dead_strip _lj_ff_string_char +_lj_ff_string_char: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x94000141 + .long 0xa97f8275,0x7103fc1f,0xfa489b80,0x54002261 + .long 0xeb40833f,0x54002221,0x52800022,0xaa1303e1 + + .private_extern _lj_fff_newstr + .no_dead_strip _lj_fff_newstr +_lj_fff_newstr: + .long 0xf90012f3,0xaa1703e0,0xf90057f5 + bl _lj_str_new + + .private_extern _lj_fff_resstr + .no_dead_strip _lj_fff_resstr +_lj_fff_resstr: + .long 0xf94012f3,0x92800089,0x8b09bc00,0x17fffed5 + + .private_extern _lj_ff_string_sub + .no_dead_strip _lj_ff_string_sub +_lj_ff_string_sub: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x9400012d + .long 0xf9400260,0xf9400a62,0xf100439f,0x92800011 + .long 0x540000a0,0x54001fa3,0xeb42833f,0x54001f61 + .long 0x93407c51,0xf9400661,0x936ffc0f,0xb10015ff + .long 0x9240b800,0x54001ea1,0xb9401409,0xeb41833f + .long 0x54001e41,0x93407c21,0x8b09022a,0xf100023f + .long 0x8b090028,0x9a8aa631,0xf100003f,0x9a88a421 + .long 0xf100023f,0x9a9fa231,0xf100043f,0x9a9fa421 + .long 0xeb09023f,0x9a89d231,0x91005c00,0xeb010222 + .long 0x8b010001,0x91000442,0x54fffa4a,0x9101e2c0 + .long 0x92800089,0x8b09bc00,0x17fffeaa + + .private_extern _lj_ff_string_reverse + .no_dead_strip _lj_ff_string_reverse +_lj_ff_string_reverse: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x94000102 + .long 0xf9400261,0xf100239f,0x936ffc2f,0xba4529e0 + .long 0x9240b821,0x54001a41,0xf9406ec8,0x910322c0 + .long 0xf90012f3,0xf90057f5,0xf90072d7,0xf90066c8 + bl _lj_buf_putstr_reverse + bl _lj_buf_tostr + .long 0x17ffffbf + + .private_extern _lj_ff_string_lower + .no_dead_strip _lj_ff_string_lower +_lj_ff_string_lower: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x940000ef + .long 0xf9400261,0xf100239f,0x936ffc2f,0xba4529e0 + .long 0x9240b821,0x540017e1,0xf9406ec8,0x910322c0 + .long 0xf90012f3,0xf90057f5,0xf90072d7,0xf90066c8 + bl _lj_buf_putstr_lower + bl _lj_buf_tostr + .long 0x17ffffac + + .private_extern _lj_ff_string_upper + .no_dead_strip _lj_ff_string_upper +_lj_ff_string_upper: + .long 0xa94106c0,0xeb01001f,0x5400004b,0x940000dc + .long 0xf9400261,0xf100239f,0x936ffc2f,0xba4529e0 + .long 0x9240b821,0x54001581,0xf9406ec8,0x910322c0 + .long 0xf90012f3,0xf90057f5,0xf90072d7,0xf90066c8 + bl _lj_buf_putstr_upper + bl _lj_buf_tostr + .long 0x17ffff99 + + .private_extern _lj_vm_tobit_fb + .no_dead_strip _lj_vm_tobit_fb +_lj_vm_tobit_fb: + .long 0x54001449,0x8b000001,0x52808682,0xcb41d442 + .long 0xf100d45f,0x540000e8,0x9240d021,0xb24b0021 + .long 0xf100001f,0x9ac22421,0x5a815420,0xd61f03c0 + .long 0x52800000,0xd61f03c0 + + .private_extern _lj_ff_bit_band + .no_dead_strip _lj_ff_bit_band +_lj_ff_bit_band: + .long 0xf9400260,0xf100239f,0x54001243,0x1000007e + .long 0xeb40833f,0x54fffda1,0x5280011b,0x2a0003e8 + .long 0x100000fe,0xf87b6a60,0xeb1c037f,0x9100237b + .long 0x540005ca,0xeb40833f,0x54fffc81,0x0a000108 + .long 0x17fffff9 + + .private_extern _lj_ff_bit_bor + .no_dead_strip _lj_ff_bit_bor +_lj_ff_bit_bor: + .long 0xf9400260,0xf100239f,0x54001023,0x1000007e + .long 0xeb40833f,0x54fffb81,0x5280011b,0x2a0003e8 + .long 0x100000fe,0xf87b6a60,0xeb1c037f,0x9100237b + .long 0x540003aa,0xeb40833f,0x54fffa61,0x2a000108 + .long 0x17fffff9 + + .private_extern _lj_ff_bit_bxor + .no_dead_strip _lj_ff_bit_bxor +_lj_ff_bit_bxor: + .long 0xf9400260,0xf100239f,0x54000e03,0x1000007e + .long 0xeb40833f,0x54fff961,0x5280011b,0x2a0003e8 + .long 0x100000fe,0xf87b6a60,0xeb1c037f,0x9100237b + .long 0x5400018a,0xeb40833f,0x54fff841,0x4a000108 + .long 0x17fffff9 + + .private_extern _lj_ff_bit_tobit + .no_dead_strip _lj_ff_bit_tobit +_lj_ff_bit_tobit: + .long 0xf9400260,0xf100239f,0x54000be3,0x1000007e + .long 0xeb40833f,0x54fff741,0x2a0003e8,0x8b180100 + .long 0x17fffe27 + + .private_extern _lj_ff_bit_bswap + .no_dead_strip _lj_ff_bit_bswap +_lj_ff_bit_bswap: + .long 0xf9400260,0xf100239f,0x54000ac3,0x1000007e + .long 0xeb40833f,0x54fff621,0x5ac00808,0x8b180100 + .long 0x17fffe1e + + .private_extern _lj_ff_bit_bnot + .no_dead_strip _lj_ff_bit_bnot +_lj_ff_bit_bnot: + .long 0xf9400260,0xf100239f,0x540009a3,0x1000007e + .long 0xeb40833f,0x54fff501,0x2a2003e8,0x8b180100 + .long 0x17fffe15 + + .private_extern _lj_ff_bit_lshift + .no_dead_strip _lj_ff_bit_lshift +_lj_ff_bit_lshift: + .long 0xa9400268,0xf100439f,0x54000883,0x1000007e + .long 0xeb40833f,0x54fff3e1,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54fff341,0x1ac92008 + .long 0x8b180100,0x17fffe07 + + .private_extern _lj_ff_bit_rshift + .no_dead_strip _lj_ff_bit_rshift +_lj_ff_bit_rshift: + .long 0xa9400268,0xf100439f,0x540006c3,0x1000007e + .long 0xeb40833f,0x54fff221,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54fff181,0x1ac92408 + .long 0x8b180100,0x17fffdf9 + + .private_extern _lj_ff_bit_arshift + .no_dead_strip _lj_ff_bit_arshift +_lj_ff_bit_arshift: + .long 0xa9400268,0xf100439f,0x54000503,0x1000007e + .long 0xeb40833f,0x54fff061,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54ffefc1,0x1ac92808 + .long 0x8b180100,0x17fffdeb + + .private_extern _lj_ff_bit_rol + .no_dead_strip _lj_ff_bit_rol +_lj_ff_bit_rol: + .long 0xa9400268,0xf100439f,0x54000343,0x1000007e + .long 0xeb40833f,0x54ffeea1,0xcb0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54ffee01,0x1ac92c08 + .long 0x8b180100,0x17fffddd + + .private_extern _lj_ff_bit_ror + .no_dead_strip _lj_ff_bit_ror +_lj_ff_bit_ror: + .long 0xa9400268,0xf100439f,0x54000183,0x1000007e + .long 0xeb40833f,0x54ffece1,0xaa0003e9,0xaa0803e0 + .long 0x1000007e,0xeb40833f,0x54ffec41,0x1ac92c08 + .long 0x8b180100,0x17fffdcf + + .private_extern _lj_fff_fallback + .no_dead_strip _lj_fff_fallback +_lj_fff_fallback: + .long 0xa97f5662,0xf9401aea,0x8b1c0269,0xa90226f3 + .long 0x9240b842,0x91028129,0xf9401442,0xf90057f5 + .long 0xeb0a013f,0xaa1703e0,0x54000368,0xd63f0040 + .long 0xf94012f3,0x7100001f,0xd37df01c,0xd100427b + .long 0x54ffb82c,0xf94016e0,0xf85f0262,0xcb13001c + .long 0x54000121,0x9240b842,0xf9401055,0xb84046b0 + .long 0x8b300ec9,0xd3483e1b,0xf9416d28,0x8b1b0e7b + .long 0xd61f0100 + + .private_extern _lj_vm_call_tail + .no_dead_strip _lj_vm_call_tail +_lj_vm_call_tail: + .long 0xf24006a8,0x927df2a9,0x54000081,0x385fd2bb + .long 0xd37df37b,0x91004369,0xcb090271,0x17fffaee + .long 0x52800281 + bl _lj_state_growstack + .long 0xf94012f3,0xeb00001f,0x17ffffe8 + + .private_extern _lj_fff_gcstep + .no_dead_strip _lj_fff_gcstep +_lj_fff_gcstep: + .long 0x8b1c0261,0xaa1e03fb,0xa90206f3,0xf90057f5 + .long 0xaa1703e0 + bl _lj_gc_step + .long 0xa94206f3,0xf85f0262,0xaa1b03fe,0xcb13003c + .long 0x9240b842,0xd65f03c0 + + .private_extern _lj_vm_record + .no_dead_strip _lj_vm_record +_lj_vm_record: + + .private_extern _lj_vm_rethook + .no_dead_strip _lj_vm_rethook +_lj_vm_rethook: + .long 0x394246ca,0x3620018a,0xf943d528,0xd61f0100 + + .private_extern _lj_vm_inshook + .no_dead_strip _lj_vm_inshook +_lj_vm_inshook: + .long 0x394246ca,0xb9414acb,0x3727ff8a,0x721e055f + .long 0x54ffff40,0x5100056b,0xb9014acb,0x3400004b + .long 0x3617feca,0xaa1703e0,0xf90012f3,0xaa1503e1 + bl _lj_dispatch_ins + .long 0xf94012f3,0xb85fc2b0,0x8b300ec9,0xd3483e1b + .long 0xf943d528,0xd3507e1c,0xd61f0100 + + .private_extern _lj_cont_hook + .no_dead_strip _lj_cont_hook +_lj_cont_hook: + .long 0xf85d8060,0x910012b5,0xb900c3e0,0x17fffff7 + + .private_extern _lj_vm_hotloop + .no_dead_strip _lj_vm_hotloop +_lj_vm_hotloop: + + .private_extern _lj_vm_callhook + .no_dead_strip _lj_vm_callhook +_lj_vm_callhook: + .long 0xaa1503e1 + + .private_extern _lj_vm_hotcall + .no_dead_strip _lj_vm_hotcall +_lj_vm_hotcall: + .long 0x8b1c0269,0xf90057f5,0xaa1703e0,0xcb13037b + .long 0xa90226f3 + bl _lj_dispatch_call + .long 0xa94226f3,0xf90057ff,0xf85f0262,0x8b1b027b + .long 0xcb13013c,0xb85fc2b0,0x9240b842,0xd61f0000 + + .private_extern _lj_cont_stitch + .no_dead_strip _lj_cont_stitch +_lj_cont_stitch: + + .private_extern _lj_vm_profhook + .no_dead_strip _lj_vm_profhook +_lj_vm_profhook: + .long 0xaa1703e0,0xf90012f3,0xaa1503e1 + bl _lj_dispatch_profile + .long 0xf94012f3,0xd10012b5,0x17fffb5c + + .private_extern _lj_vm_exit_handler + .no_dead_strip _lj_vm_exit_handler +_lj_vm_exit_handler: + + .private_extern _lj_vm_exit_interp + .no_dead_strip _lj_vm_exit_interp +_lj_vm_exit_interp: + + .private_extern _lj_vm_modi + .no_dead_strip _lj_vm_modi +_lj_vm_modi: + .long 0x4a010003,0x7100007f,0x4a807c02,0x4a817c23 + .long 0x4b807c42,0x4b817c63,0x1ac30840,0x1b038800 + .long 0x7a404804,0x4b030002,0x1a820000,0x4a010002 + .long 0x7100005f,0x5a805400,0xd65f03c0 + + .private_extern _lj_vm_ffi_callback + .no_dead_strip _lj_vm_ffi_callback +_lj_vm_ffi_callback: + .long 0xa9b37bfd,0x910003fd,0xa90153f3,0x6d0627e8 + .long 0xa9025bf5,0x6d072fea,0xa90363f7,0x6d0837ec + .long 0xa9046bf9,0x6d093fee,0xa90573fb,0xf940c155 + .long 0xaa0a03f6,0x910343ea,0xb900d2a9,0xa90706a0 + .long 0x6d0306a0,0xa9080ea2,0x6d040ea2,0xa90916a4 + .long 0x6d0516a4,0xa90a1ea6,0x6d061ea6,0xf9005aaa + .long 0xaa1503e0,0xf90057f5,0x910003e1 + bl _lj_ccallback_enter + .long 0xa9427013,0xd2ffff38,0xd2bfff39,0x9280001a + .long 0xaa0003f7,0xf85f0262,0xcb13039c,0xb900bada + .long 0x9240b842,0xf9401055,0xb84046b0,0x8b300ec9 + .long 0xd3483e1b,0xf9416d28,0x8b1b0e7b,0xd61f0100 + + .private_extern _lj_cont_ffi_callback + .no_dead_strip _lj_cont_ffi_callback +_lj_cont_ffi_callback: + .long 0xf940c2d5,0xa9020ef3,0xf9000ab7,0xaa1503e0 + .long 0xaa1b03e1 + bl _lj_ccallback_leave + .long 0xa94706a0,0x6d4306a0,0x17fff9ce + + .private_extern _lj_vm_ffi_call + .no_dead_strip _lj_vm_ffi_call +_lj_vm_ffi_call: + .long 0xa9be7bfd,0x910003fd,0xf9000bf3,0xaa0003f3 + .long 0xb9400808,0x39403269,0x9102626a,0xf1000529 + .long 0xf940026b,0xcb2863bf,0x540000a4,0xf8697948 + .long 0xf8297be8,0xf1000529,0x54ffffa5,0xa9458660 + .long 0x6d418660,0xa9468e62,0x6d428e62,0xa9479664 + .long 0x6d439664,0xa9489e66,0x6d449e66,0xf9400a68 + .long 0xd63f0160,0x910003bf,0xa9058660,0x6d018660 + .long 0x6d028e62,0xf9400bf3,0xa8c27bfd,0xd65f03c0 + + .cstring + .ascii "DynASM 1.4.0\0" + diff --git a/core/src/luajit/autogen/macosx/nojit/arm64/lj_vmdef.h b/core/src/luajit/autogen/macosx/nojit/arm64/lj_vmdef.h new file mode 100644 index 000000000..db4fcd74a --- /dev/null +++ b/core/src/luajit/autogen/macosx/nojit/arm64/lj_vmdef.h @@ -0,0 +1,360 @@ +-- This is a generated file. DO NOT EDIT! + +return { + +bcnames = "ISLT ISGE ISLE ISGT ISEQV ISNEV ISEQS ISNES ISEQN ISNEN ISEQP ISNEP ISTC ISFC IST ISF ISTYPEISNUM MOV NOT UNM LEN ADDVN SUBVN MULVN DIVVN MODVN ADDNV SUBNV MULNV DIVNV MODNV ADDVV SUBVV MULVV DIVVV MODVV POW CAT KSTR KCDATAKSHORTKNUM KPRI KNIL UGET USETV USETS USETN USETP UCLO FNEW TNEW TDUP GGET GSET TGETV TGETS TGETB TGETR TSETV TSETS TSETB TSETM TSETR CALLM CALL CALLMTCALLT ITERC ITERN VARG ISNEXTRETM RET RET0 RET1 FORI JFORI FORL IFORL JFORL ITERL IITERLJITERLLOOP ILOOP JLOOP JMP FUNCF IFUNCFJFUNCFFUNCV IFUNCVJFUNCVFUNCC FUNCCW", + +irnames = "LT GE LE GT ULT UGE ULE UGT EQ NE ABC RETF NOP BASE PVAL GCSTEPHIOP LOOP USE PHI RENAMEPROF KPRI KINT KGC KPTR KKPTR KNULL KNUM KINT64KSLOT BNOT BSWAP BAND BOR BXOR BSHL BSHR BSAR BROL BROR ADD SUB MUL DIV MOD POW NEG ABS LDEXP MIN MAX FPMATHADDOV SUBOV MULOV AREF HREFK HREF NEWREFUREFO UREFC FREF STRREFLREF ALOAD HLOAD ULOAD FLOAD XLOAD SLOAD VLOAD ALEN ASTOREHSTOREUSTOREFSTOREXSTORESNEW XSNEW TNEW TDUP CNEW CNEWI BUFHDRBUFPUTBUFSTRTBAR OBAR XBAR CONV TOBIT TOSTR STRTO CALLN CALLA CALLL CALLS CALLXSCARG ", + +irfpm = { [0]="floor", "ceil", "trunc", "sqrt", "log", "log2", "other", }, + +irfield = { [0]="str.len", "func.env", "func.pc", "func.ffid", "thread.env", "tab.meta", "tab.array", "tab.node", "tab.asize", "tab.hmask", "tab.nomm", "udata.meta", "udata.udtype", "udata.file", "cdata.ctypeid", "cdata.ptr", "cdata.int", "cdata.int64", "cdata.int64_4", }, + +ircall = { +[0]="lj_str_cmp", +"lj_str_find", +"lj_str_new", +"lj_strscan_num", +"lj_strfmt_int", +"lj_strfmt_num", +"lj_strfmt_char", +"lj_strfmt_putint", +"lj_strfmt_putnum", +"lj_strfmt_putquoted", +"lj_strfmt_putfxint", +"lj_strfmt_putfnum_int", +"lj_strfmt_putfnum_uint", +"lj_strfmt_putfnum", +"lj_strfmt_putfstr", +"lj_strfmt_putfchar", +"lj_buf_putmem", +"lj_buf_putstr", +"lj_buf_putchar", +"lj_buf_putstr_reverse", +"lj_buf_putstr_lower", +"lj_buf_putstr_upper", +"lj_buf_putstr_rep", +"lj_buf_puttab", +"lj_buf_tostr", +"lj_tab_new_ah", +"lj_tab_new1", +"lj_tab_dup", +"lj_tab_clear", +"lj_tab_newkey", +"lj_tab_len", +"lj_tab_len_hint", +"lj_gc_step_jit", +"lj_gc_barrieruv", +"lj_mem_newgco", +"lj_prng_u64d", +"lj_vm_modi", +"log10", +"exp", +"sin", +"cos", +"tan", +"asin", +"acos", +"atan", +"sinh", +"cosh", +"tanh", +"fputc", +"fwrite", +"fflush", +"lj_vm_floor", +"lj_vm_ceil", +"lj_vm_trunc", +"sqrt", +"log", +"lj_vm_log2", +"lj_vm_powi", +"pow", +"atan2", +"ldexp", +"lj_vm_tobit", +"softfp_add", +"softfp_sub", +"softfp_mul", +"softfp_div", +"softfp_cmp", +"softfp_i2d", +"softfp_d2i", +"lj_vm_sfmin", +"lj_vm_sfmax", +"lj_vm_tointg", +"softfp_ui2d", +"softfp_f2d", +"softfp_d2ui", +"softfp_d2f", +"softfp_i2f", +"softfp_ui2f", +"softfp_f2i", +"softfp_f2ui", +"fp64_l2d", +"fp64_ul2d", +"fp64_l2f", +"fp64_ul2f", +"fp64_d2l", +"fp64_d2ul", +"fp64_f2l", +"fp64_f2ul", +"lj_carith_divi64", +"lj_carith_divu64", +"lj_carith_modi64", +"lj_carith_modu64", +"lj_carith_powi64", +"lj_carith_powu64", +"lj_cdata_newv", +"lj_cdata_setfin", +"strlen", +"memcpy", +"memset", +"lj_vm_errno", +"lj_carith_mul64", +"lj_carith_shl64", +"lj_carith_shr64", +"lj_carith_sar64", +"lj_carith_rol64", +"lj_carith_ror64", +}, + +traceerr = { +[0]="error thrown or hook called during recording", +"trace too short", +"trace too long", +"trace too deep", +"too many snapshots", +"blacklisted", +"retry recording", +"NYI: bytecode %d", +"leaving loop in root trace", +"inner loop in root trace", +"loop unroll limit reached", +"bad argument type", +"JIT compilation disabled for function", +"call unroll limit reached", +"down-recursion, restarting", +"NYI: unsupported variant of FastFunc %s", +"NYI: return to lower frame", +"store with nil or NaN key", +"missing metamethod", +"looping index lookup", +"NYI: mixed sparse/dense table", +"symbol not in cache", +"NYI: unsupported C type conversion", +"NYI: unsupported C function type", +"guard would always fail", +"too many PHIs", +"persistent type instability", +"failed to allocate mcode memory", +"machine code too long", +"hit mcode limit (retrying)", +"too many spill slots", +"inconsistent register allocation", +"NYI: cannot assemble IR instruction %d", +"NYI: PHI shuffling too complex", +"NYI: register coalescing too complex", +}, + +ffnames = { +[0]="Lua", +"C", +"assert", +"type", +"next", +"pairs", +"ipairs_aux", +"ipairs", +"getmetatable", +"setmetatable", +"getfenv", +"setfenv", +"rawget", +"rawset", +"rawequal", +"unpack", +"select", +"tonumber", +"tostring", +"error", +"pcall", +"xpcall", +"loadfile", +"load", +"loadstring", +"dofile", +"gcinfo", +"collectgarbage", +"newproxy", +"print", +"coroutine.status", +"coroutine.running", +"coroutine.isyieldable", +"coroutine.create", +"coroutine.yield", +"coroutine.resume", +"coroutine.wrap_aux", +"coroutine.wrap", +"math.abs", +"math.floor", +"math.ceil", +"math.sqrt", +"math.log10", +"math.exp", +"math.sin", +"math.cos", +"math.tan", +"math.asin", +"math.acos", +"math.atan", +"math.sinh", +"math.cosh", +"math.tanh", +"math.frexp", +"math.modf", +"math.log", +"math.atan2", +"math.pow", +"math.fmod", +"math.ldexp", +"math.min", +"math.max", +"math.random", +"math.randomseed", +"bit.tobit", +"bit.bnot", +"bit.bswap", +"bit.lshift", +"bit.rshift", +"bit.arshift", +"bit.rol", +"bit.ror", +"bit.band", +"bit.bor", +"bit.bxor", +"bit.tohex", +"string.byte", +"string.char", +"string.sub", +"string.rep", +"string.reverse", +"string.lower", +"string.upper", +"string.dump", +"string.find", +"string.match", +"string.gmatch_aux", +"string.gmatch", +"string.gsub", +"string.format", +"table.maxn", +"table.insert", +"table.concat", +"table.sort", +"table.new", +"table.clear", +"io.method.close", +"io.method.read", +"io.method.write", +"io.method.flush", +"io.method.seek", +"io.method.setvbuf", +"io.method.lines", +"io.method.__gc", +"io.method.__tostring", +"io.open", +"io.popen", +"io.tmpfile", +"io.close", +"io.read", +"io.write", +"io.flush", +"io.input", +"io.output", +"io.lines", +"io.type", +"os.execute", +"os.remove", +"os.rename", +"os.tmpname", +"os.getenv", +"os.exit", +"os.clock", +"os.date", +"os.time", +"os.difftime", +"os.setlocale", +"debug.getregistry", +"debug.getmetatable", +"debug.setmetatable", +"debug.getfenv", +"debug.setfenv", +"debug.getinfo", +"debug.getlocal", +"debug.setlocal", +"debug.getupvalue", +"debug.setupvalue", +"debug.upvalueid", +"debug.upvaluejoin", +"debug.sethook", +"debug.gethook", +"debug.debug", +"debug.traceback", +"jit.on", +"jit.off", +"jit.flush", +"jit.status", +"jit.security", +"jit.attach", +"jit.util.funcinfo", +"jit.util.funcbc", +"jit.util.funck", +"jit.util.funcuvname", +"jit.profile.start", +"jit.profile.stop", +"jit.profile.dumpstack", +"ffi.meta.__index", +"ffi.meta.__newindex", +"ffi.meta.__eq", +"ffi.meta.__len", +"ffi.meta.__lt", +"ffi.meta.__le", +"ffi.meta.__concat", +"ffi.meta.__call", +"ffi.meta.__add", +"ffi.meta.__sub", +"ffi.meta.__mul", +"ffi.meta.__div", +"ffi.meta.__mod", +"ffi.meta.__pow", +"ffi.meta.__unm", +"ffi.meta.__tostring", +"ffi.meta.__pairs", +"ffi.meta.__ipairs", +"ffi.clib.__index", +"ffi.clib.__newindex", +"ffi.clib.__gc", +"ffi.callback.free", +"ffi.callback.set", +"ffi.cdef", +"ffi.new", +"ffi.cast", +"ffi.typeof", +"ffi.typeinfo", +"ffi.istype", +"ffi.sizeof", +"ffi.alignof", +"ffi.offsetof", +"ffi.errno", +"ffi.string", +"ffi.copy", +"ffi.fill", +"ffi.abi", +"ffi.metatype", +"ffi.gc", +"ffi.load", +}, + +} + diff --git a/core/src/luajit/makefile b/core/src/luajit/makefile index fa63cc67c..f2a2563bf 100644 --- a/core/src/luajit/makefile +++ b/core/src/luajit/makefile @@ -137,6 +137,13 @@ luajit_CXFLAGS += -fPIE endif endif +# use given system library? +luajit_C_FILES := $(if $(findstring luajit,$(base_LIBNAMES)),,$(luajit_C_FILES)) +luajit_ASM_FILES := $(if $(findstring luajit,$(base_LIBNAMES)),,$(luajit_ASM_FILES)) +luajit_INC_FILES := $(if $(findstring luajit,$(base_LIBNAMES)),,$(luajit_INC_FILES)) +luajit_OBJ_FILES := $(if $(findstring luajit,$(base_LIBNAMES)),,$(luajit_OBJ_FILES)) + + # suffix include $(PRO_DIR)/suffix.mak diff --git a/core/src/luajit/xmake.lua b/core/src/luajit/xmake.lua index aa5c1d7a2..cfee1f76e 100644 --- a/core/src/luajit/xmake.lua +++ b/core/src/luajit/xmake.lua @@ -2,9 +2,11 @@ local jit = true local plat = "$(plat)" local arch = "$(arch)" -if is_plat("msys", "cygwin") then +if is_plat("msys", "mingw", "cygwin") then plat = "windows" arch = is_arch("x86_64") and "x64" or "x86" +elseif is_plat("android") then + plat = "linux" end if is_arch("arm64", "arm64-v8a") then arch = "arm64" @@ -44,7 +46,7 @@ target("luajit") add_files("luajit/src/*.c|ljamalg.c|luajit.c") if is_plat("windows") then add_files(autogendir .. "/lj_vm.obj") - elseif is_plat("msys", "cygwin") then + elseif is_plat("msys", "cygwin", "mingw") then add_files(autogendir .. "/lj_vm.o") else add_files(autogendir .. "/*.S") @@ -73,4 +75,4 @@ target("luajit") add_cflags("-Wno-error=unused-function") end]] - + diff --git a/core/src/sv/makefile b/core/src/sv/makefile index e1197c612..9d265d6b0 100644 --- a/core/src/sv/makefile +++ b/core/src/sv/makefile @@ -23,7 +23,10 @@ sv_C_FILES += \ # includes sv_INC_DIRS += sv/include - +# use system tbox library? +sv_C_FILES := $(if $(findstring sv,$(base_LIBNAMES)),,$(sv_C_FILES)) +sv_INC_DIRS := $(if $(findstring sv,$(base_LIBNAMES)),,$(sv_INC_DIRS)) + # suffix include $(PRO_DIR)/suffix.mak diff --git a/core/src/tbox/inc/iphoneos/tbox.config.h b/core/src/tbox/inc/iphoneos/tbox.config.h new file mode 100755 index 000000000..2545b1625 --- /dev/null +++ b/core/src/tbox/inc/iphoneos/tbox.config.h @@ -0,0 +1,233 @@ +#ifndef TB_CONFIG_H +#define TB_CONFIG_H + +// version +#define TB_CONFIG_VERSION "1.6.6" +#define TB_CONFIG_VERSION_MAJOR 1 +#define TB_CONFIG_VERSION_MINOR 6 +#define TB_CONFIG_VERSION_ALTER 6 +#define TB_CONFIG_VERSION_BUILD 202103241707 + +// defines +#define TB_CONFIG_OS_IOS 1 +#define _GNU_SOURCE 1 +#define _REENTRANT 1 +#define TB_CONFIG_SMALL 1 +/* #undef TB_CONFIG_MICRO_ENABLE */ +/* #undef TB_CONFIG_TYPE_HAVE_WCHAR */ +#define TB_CONFIG_TYPE_HAVE_FLOAT 1 +/* #undef TB_CONFIG_FORCE_UTF8 */ +/* #undef TB_CONFIG_API_HAVE_DEPRECATED */ +/* #undef TB_CONFIG_EXCEPTION_ENABLE */ + +// keywords +#define TB_CONFIG_KEYWORD_HAVE__thread 1 +#define TB_CONFIG_KEYWORD_HAVE_Thread_local 1 + +// features +#define TB_CONFIG_FEATURE_HAVE_ANONYMOUS_UNION 1 + +// modules +/* #undef TB_CONFIG_MODULE_HAVE_XML */ +/* #undef TB_CONFIG_MODULE_HAVE_ZIP */ +#define TB_CONFIG_MODULE_HAVE_HASH 1 +/* #undef TB_CONFIG_MODULE_HAVE_REGEX */ +/* #undef TB_CONFIG_MODULE_HAVE_OBJECT */ +#define TB_CONFIG_MODULE_HAVE_CHARSET 1 +/* #undef TB_CONFIG_MODULE_HAVE_DATABASE */ +/* #undef TB_CONFIG_MODULE_HAVE_COROUTINE */ + +// packages +/* #undef TB_CONFIG_PACKAGE_HAVE_ZLIB */ +/* #undef TB_CONFIG_PACKAGE_HAVE_MYSQL */ +/* #undef TB_CONFIG_PACKAGE_HAVE_SQLITE3 */ +/* #undef TB_CONFIG_PACKAGE_HAVE_OPENSSL */ +/* #undef TB_CONFIG_PACKAGE_HAVE_POLARSSL */ +/* #undef TB_CONFIG_PACKAGE_HAVE_MBEDTLS */ +/* #undef TB_CONFIG_PACKAGE_HAVE_PCRE2 */ +/* #undef TB_CONFIG_PACKAGE_HAVE_PCRE */ + +// libc functions +#define TB_CONFIG_LIBC_HAVE_MEMCPY 1 +#define TB_CONFIG_LIBC_HAVE_MEMSET 1 +#define TB_CONFIG_LIBC_HAVE_MEMMOVE 1 +#define TB_CONFIG_LIBC_HAVE_MEMCMP 1 +#define TB_CONFIG_LIBC_HAVE_MEMMEM 1 +#define TB_CONFIG_LIBC_HAVE_STRCAT 1 +#define TB_CONFIG_LIBC_HAVE_STRNCAT 1 +#define TB_CONFIG_LIBC_HAVE_STRCPY 1 +#define TB_CONFIG_LIBC_HAVE_STRNCPY 1 +#define TB_CONFIG_LIBC_HAVE_STRLCPY 1 +#define TB_CONFIG_LIBC_HAVE_STRLEN 1 +#define TB_CONFIG_LIBC_HAVE_STRNLEN 1 +#define TB_CONFIG_LIBC_HAVE_STRCHR 1 +#define TB_CONFIG_LIBC_HAVE_STRRCHR 1 +#define TB_CONFIG_LIBC_HAVE_STRSTR 1 +#define TB_CONFIG_LIBC_HAVE_STRCASESTR 1 +#define TB_CONFIG_LIBC_HAVE_STRCMP 1 +#define TB_CONFIG_LIBC_HAVE_STRCASECMP 1 +#define TB_CONFIG_LIBC_HAVE_STRNCMP 1 +#define TB_CONFIG_LIBC_HAVE_STRNCASECMP 1 + +#define TB_CONFIG_LIBC_HAVE_WCSCAT 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCAT 1 +#define TB_CONFIG_LIBC_HAVE_WCSCPY 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCPY 1 +#define TB_CONFIG_LIBC_HAVE_WCSLCPY 1 +#define TB_CONFIG_LIBC_HAVE_WCSLEN 1 +#define TB_CONFIG_LIBC_HAVE_WCSNLEN 1 +#define TB_CONFIG_LIBC_HAVE_WCSSTR 1 +/* #undef TB_CONFIG_LIBC_HAVE_WCSCASESTR */ +#define TB_CONFIG_LIBC_HAVE_WCSCMP 1 +#define TB_CONFIG_LIBC_HAVE_WCSCASECMP 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCMP 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCASECMP 1 +#define TB_CONFIG_LIBC_HAVE_WCSTOMBS 1 +#define TB_CONFIG_LIBC_HAVE_MBSTOWCS 1 + +#define TB_CONFIG_LIBC_HAVE_GMTIME 1 +#define TB_CONFIG_LIBC_HAVE_MKTIME 1 +#define TB_CONFIG_LIBC_HAVE_LOCALTIME 1 +#define TB_CONFIG_LIBC_HAVE_GETTIMEOFDAY 1 +#define TB_CONFIG_LIBC_HAVE_SIGNAL 1 +#define TB_CONFIG_LIBC_HAVE_SETJMP 1 +#define TB_CONFIG_LIBC_HAVE_SIGSETJMP 1 +#define TB_CONFIG_LIBC_HAVE_KILL 1 +#define TB_CONFIG_LIBC_HAVE_BACKTRACE 1 +#define TB_CONFIG_LIBC_HAVE_SETLOCALE 1 +#define TB_CONFIG_LIBC_HAVE_FPUTC 1 +#define TB_CONFIG_LIBC_HAVE_FGETC 1 +#define TB_CONFIG_LIBC_HAVE_UNGETC 1 +#define TB_CONFIG_LIBC_HAVE_FPUTS 1 +#define TB_CONFIG_LIBC_HAVE_FGETS 1 +#define TB_CONFIG_LIBC_HAVE_FREAD 1 +#define TB_CONFIG_LIBC_HAVE_FWRITE 1 +#define TB_CONFIG_LIBC_HAVE_SRANDOM 1 +#define TB_CONFIG_LIBC_HAVE_RANDOM 1 + +// libm functions +/* #undef TB_CONFIG_LIBM_HAVE_SINCOS */ +/* #undef TB_CONFIG_LIBM_HAVE_SINCOSF */ +#define TB_CONFIG_LIBM_HAVE_LOG2 1 +#define TB_CONFIG_LIBM_HAVE_LOG2F 1 +#define TB_CONFIG_LIBM_HAVE_SQRT 1 +#define TB_CONFIG_LIBM_HAVE_SQRTF 1 +#define TB_CONFIG_LIBM_HAVE_ACOS 1 +#define TB_CONFIG_LIBM_HAVE_ACOSF 1 +#define TB_CONFIG_LIBM_HAVE_ASIN 1 +#define TB_CONFIG_LIBM_HAVE_ASINF 1 +#define TB_CONFIG_LIBM_HAVE_POW 1 +#define TB_CONFIG_LIBM_HAVE_POWF 1 +#define TB_CONFIG_LIBM_HAVE_FMOD 1 +#define TB_CONFIG_LIBM_HAVE_FMODF 1 +#define TB_CONFIG_LIBM_HAVE_TAN 1 +#define TB_CONFIG_LIBM_HAVE_TANF 1 +#define TB_CONFIG_LIBM_HAVE_ATAN 1 +#define TB_CONFIG_LIBM_HAVE_ATANF 1 +#define TB_CONFIG_LIBM_HAVE_ATAN2 1 +#define TB_CONFIG_LIBM_HAVE_ATAN2F 1 +#define TB_CONFIG_LIBM_HAVE_COS 1 +#define TB_CONFIG_LIBM_HAVE_COSF 1 +#define TB_CONFIG_LIBM_HAVE_SIN 1 +#define TB_CONFIG_LIBM_HAVE_SINF 1 +#define TB_CONFIG_LIBM_HAVE_EXP 1 +#define TB_CONFIG_LIBM_HAVE_EXPF 1 + +// posix functions +#define TB_CONFIG_POSIX_HAVE_POLL 1 +#define TB_CONFIG_POSIX_HAVE_SELECT 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_MUTEX_INIT 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_CREATE 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_SETSPECIFIC 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_GETSPECIFIC 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_KEY_CREATE 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_KEY_DELETE 1 +/* #undef TB_CONFIG_POSIX_HAVE_PTHREAD_SETAFFINITY_NP */ +#define TB_CONFIG_POSIX_HAVE_SOCKET 1 +#define TB_CONFIG_POSIX_HAVE_OPENDIR 1 +#define TB_CONFIG_POSIX_HAVE_DLOPEN 1 +#define TB_CONFIG_POSIX_HAVE_OPEN 1 +/* #undef TB_CONFIG_POSIX_HAVE_STAT64 */ +#define TB_CONFIG_POSIX_HAVE_GETHOSTNAME 1 +#define TB_CONFIG_POSIX_HAVE_GETIFADDRS 1 +/* #undef TB_CONFIG_POSIX_HAVE_SEM_INIT */ +#define TB_CONFIG_POSIX_HAVE_GETPAGESIZE 1 +#define TB_CONFIG_POSIX_HAVE_SYSCONF 1 +#define TB_CONFIG_POSIX_HAVE_SCHED_YIELD 1 +/* #undef TB_CONFIG_POSIX_HAVE_SCHED_SETAFFINITY */ +#define TB_CONFIG_POSIX_HAVE_REGCOMP 1 +#define TB_CONFIG_POSIX_HAVE_REGEXEC 1 +#define TB_CONFIG_POSIX_HAVE_READV 1 +#define TB_CONFIG_POSIX_HAVE_WRITEV 1 +/* #undef TB_CONFIG_POSIX_HAVE_PREADV */ +/* #undef TB_CONFIG_POSIX_HAVE_PWRITEV */ +/* #undef TB_CONFIG_POSIX_HAVE_PREAD64 */ +/* #undef TB_CONFIG_POSIX_HAVE_PWRITE64 */ +/* #undef TB_CONFIG_POSIX_HAVE_FDATASYNC */ +#define TB_CONFIG_POSIX_HAVE_COPYFILE 1 +/* #undef TB_CONFIG_POSIX_HAVE_SENDFILE */ +/* #undef TB_CONFIG_POSIX_HAVE_EPOLL_CREATE */ +/* #undef TB_CONFIG_POSIX_HAVE_EPOLL_WAIT */ +#define TB_CONFIG_POSIX_HAVE_POSIX_SPAWNP 1 +/* #undef TB_CONFIG_POSIX_HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP */ +#if (defined(__MACH__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 101400) +# undef TB_CONFIG_POSIX_HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP // only for macOS >=10.15 +#endif +#define TB_CONFIG_POSIX_HAVE_EXECVP 1 +/* #undef TB_CONFIG_POSIX_HAVE_EXECVPE */ +#define TB_CONFIG_POSIX_HAVE_FORK 1 +#define TB_CONFIG_POSIX_HAVE_VFORK 1 +#define TB_CONFIG_POSIX_HAVE_WAITPID 1 +#define TB_CONFIG_POSIX_HAVE_GETDTABLESIZE 1 +#define TB_CONFIG_POSIX_HAVE_GETRLIMIT 1 +#define TB_CONFIG_POSIX_HAVE_GETADDRINFO 1 +#define TB_CONFIG_POSIX_HAVE_GETNAMEINFO 1 +#define TB_CONFIG_POSIX_HAVE_GETHOSTBYNAME 1 +#define TB_CONFIG_POSIX_HAVE_GETHOSTBYADDR 1 +#define TB_CONFIG_POSIX_HAVE_FCNTL 1 +#define TB_CONFIG_POSIX_HAVE_PIPE 1 +/* #undef TB_CONFIG_POSIX_HAVE_PIPE2 */ +#define TB_CONFIG_POSIX_HAVE_MKFIFO 1 +#define TB_CONFIG_POSIX_HAVE_MMAP 1 + +// windows functions +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE_NF */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE_ACQ */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE_REL */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE8 */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE8_NF */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE8_ACQ */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGE8_REL */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDOR8 */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDOR8_NF */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDOR8_ACQ */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDOR8_REL */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD_NF */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD_ACQ */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD_REL */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD64 */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD64_NF */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD64_ACQ */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDEXCHANGEADD64_REL */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE_NF */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE_ACQ */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE_REL */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE64 */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE64_NF */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE64_ACQ */ +/* #undef TB_CONFIG_WINDOWS_HAVE__INTERLOCKEDCOMPAREEXCHANGE64_REL */ + +// bsd functions +#define TB_CONFIG_BSD_HAVE_FLOCK 1 + +// systemv functions +#define TB_CONFIG_SYSTEMV_HAVE_SEMGET 1 +/* #undef TB_CONFIG_SYSTEMV_HAVE_SEMTIMEDOP */ + +// valgrind functions +/* #undef TB_CONFIG_SYSTEMV_HAVE_VALGRIND_STACK_REGISTER */ + +#endif diff --git a/core/src/tbox/inc/macosx/tbox.config.h b/core/src/tbox/inc/macosx/tbox.config.h index f7e64654a..c1e9c7454 100755 --- a/core/src/tbox/inc/macosx/tbox.config.h +++ b/core/src/tbox/inc/macosx/tbox.config.h @@ -143,7 +143,11 @@ #define TB_CONFIG_POSIX_HAVE_OPENDIR 1 #define TB_CONFIG_POSIX_HAVE_DLOPEN 1 #define TB_CONFIG_POSIX_HAVE_OPEN 1 -#define TB_CONFIG_POSIX_HAVE_STAT64 1 +#if !defined(__arm64__) && !defined(__aarch64__) +# define TB_CONFIG_POSIX_HAVE_STAT64 1 +#else +/* #undef TB_CONFIG_POSIX_HAVE_STAT64 */ +#endif #define TB_CONFIG_POSIX_HAVE_GETHOSTNAME 1 #define TB_CONFIG_POSIX_HAVE_GETIFADDRS 1 #define TB_CONFIG_POSIX_HAVE_SEM_INIT 1 diff --git a/core/src/tbox/makefile b/core/src/tbox/makefile index 3aeb5c1ed..f24303eb1 100644 --- a/core/src/tbox/makefile +++ b/core/src/tbox/makefile @@ -263,7 +263,7 @@ tbox_C_FILES += \ tbox/src/tbox/charset/utf32 \ tbox/src/tbox/charset/ucs2 \ tbox/src/tbox/charset/ucs4 \ - tbox/src/tbox/charset/iso8859 + tbox/src/tbox/charset/iso8859 iswin = ifeq ($(PLAT),windows) @@ -290,7 +290,11 @@ tbox_C_FILES += \ tbox/src/tbox/platform/windows/interface/mswsock \ tbox/src/tbox/platform/windows/interface/kernel32 \ tbox/src/tbox/platform/windows/interface/iphlpapi \ - tbox/src/tbox/platform/windows/interface/interface + tbox/src/tbox/platform/windows/interface/interface +endif +ifeq ($(PLAT),iphoneos) +tbox_M_FILES += \ + tbox/src/tbox/platform/mach/ios/directory endif # includes @@ -298,7 +302,12 @@ tbox_INC_DIRS += \ tbox/src \ inc/$(PLAT) - +# use system tbox library? +tbox_C_FILES := $(if $(findstring tbox,$(base_LIBNAMES)),,$(tbox_C_FILES)) +tbox_M_FILES := $(if $(findstring tbox,$(base_LIBNAMES)),,$(tbox_M_FILES)) +tbox_INC_FILES := $(if $(findstring tbox,$(base_LIBNAMES)),,$(tbox_INC_FILES)) + + # suffix include $(PRO_DIR)/suffix.mak diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox -Subproject d80f8d11356e1cdb7465278ecd7ad4e3478c3c4 +Subproject 5ef932750ede0b90867fd4afdcf1deed2464c82 diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 71b202689..6a401a486 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -33,7 +33,7 @@ # include <windows.h> # include <io.h> # include <fcntl.h> -#elif defined(TB_CONFIG_OS_MACOSX) +#elif defined(TB_CONFIG_OS_MACOSX) || defined(TB_CONFIG_OS_IOS) # include <unistd.h> # include <mach-o/dyld.h> #elif defined(TB_CONFIG_OS_LINUX) || defined(TB_CONFIG_OS_BSD) || defined(TB_CONFIG_OS_ANDROID) @@ -483,7 +483,7 @@ static tb_size_t xm_engine_get_program_file(xm_engine_t* engine, tb_char_t* path // ok ok = tb_true; -#elif defined(TB_CONFIG_OS_MACOSX) +#elif defined(TB_CONFIG_OS_MACOSX) || defined(TB_CONFIG_OS_IOS) /* * _NSGetExecutablePath() copies the path of the main executable into the buffer. The bufsize parameter * should initially be the size of the buffer. The function returns 0 if the path was successfully copied, @@ -552,7 +552,7 @@ static tb_bool_t xm_engine_get_program_directory(xm_engine_t* engine, tb_char_t* if (programfile) { // get real program file path from the symbol link -#ifndef TB_CONFIG_OS_WINDOWS +#if !defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_CONFIG_OS_IOS) tb_char_t programpath[TB_PATH_MAXN]; tb_long_t size = readlink(programfile, programpath, sizeof(programpath)); if (size >= 0 && size < sizeof(programpath)) diff --git a/core/src/xmake/io/file_close.c b/core/src/xmake/io/file_close.c index 45dea00a9..2390b7fd4 100644 --- a/core/src/xmake/io/file_close.c +++ b/core/src/xmake/io/file_close.c @@ -65,6 +65,12 @@ tb_int_t xm_io_file_close(lua_State* lua) } #endif + // flush filter stream cache, TODO we should fix it in tbox/stream + if ((file->mode & TB_FILE_MODE_RW) == TB_FILE_MODE_RW && file->fstream) + { + if (!tb_stream_sync(file->file_ref, tb_false)) return tb_false; + } + // close file tb_stream_clos(file->file_ref); file->file_ref = tb_null; diff --git a/core/src/xmake/io/file_open.c b/core/src/xmake/io/file_open.c index 6ccba9b62..c92380207 100644 --- a/core/src/xmake/io/file_open.c +++ b/core/src/xmake/io/file_open.c @@ -207,6 +207,14 @@ tb_int_t xm_io_file_open(lua_State* lua) encoding = TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_BE; else if (tb_strstr(modestr, "utf16") || tb_strstr(modestr, "utf-16")) encoding = TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_NE; + else if (tb_strstr(modestr, "ansi")) + encoding = TB_CHARSET_TYPE_ANSI; + else if (tb_strstr(modestr, "gbk")) + encoding = TB_CHARSET_TYPE_GBK; + else if (tb_strstr(modestr, "gb2312")) + encoding = TB_CHARSET_TYPE_GB2312; + else if (tb_strstr(modestr, "iso8859")) + encoding = TB_CHARSET_TYPE_ISO8859; else if (modestr[0] == 'w' || modestr[0] == 'a') // set to utf-8 if not specified for the writing mode encoding = TB_CHARSET_TYPE_UTF8; else if (modestr[0] == 'r') // detect encoding if not specified for the reading mode diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index 5421a907d..2c45588b4 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -144,7 +144,7 @@ endif xmake_CXFLAGS += -D__tb_prefix__=\"xmake\" xmake_CXFLAGS += $(if $(findstring readline,$(base_LIBNAMES)),-DXM_CONFIG_API_HAVE_READLINE,) xmake_CXFLAGS += $(if $(findstring curses,$(base_LIBNAMES)),-DXM_CONFIG_API_HAVE_CURSES,) - + # includes xmake_INC_DIRS += \ ../tbox/tbox/src \ @@ -152,7 +152,7 @@ xmake_INC_DIRS += \ ../luajit/luajit/src \ ../sv/sv/include - + # suffix include $(PRO_DIR)/suffix.mak diff --git a/core/src/xmake/os/args.c b/core/src/xmake/os/args.c index adfe843a9..4f1c89f7f 100644 --- a/core/src/xmake/os/args.c +++ b/core/src/xmake/os/args.c @@ -38,43 +38,35 @@ static tb_void_t tb_os_args_append(tb_string_ref_t result, tb_char_t const* cstr // check tb_assert_and_check_return(size < TB_PATH_MAXN); - // wrap and escape characters + // need wrap quote? tb_char_t ch; - tb_size_t n = 0; tb_char_t const* p = cstr; tb_bool_t wrap_quote = tb_false; - tb_char_t buff[TB_PATH_MAXN]; - tb_size_t m = tb_arrayn(buff); - while ((ch = *p) && n < m) + if (!nowrap) { - // escape '"' or '\\' - if (ch == '\"' || (escape && ch == '\\')) + while ((ch = *p)) { - if (n < m) buff[n++] = '\\'; + if (ch == ' ' || ch == '(' || ch == ')') wrap_quote = tb_true; + p++; } - else if (ch == ' ' || ch == '(' || ch == ')') wrap_quote = tb_true; - if (n < m) buff[n++] = ch; - p++; } - tb_assert_and_check_return(n < m); - buff[n] = '\0'; - // wrap "" if exists escape characters and spaces? - if (wrap_quote && !nowrap) + // wrap begin quote + if (wrap_quote) tb_string_chrcat(result, '\"'); + + // escape characters + p = cstr; + while ((ch = *p)) { - tb_string_chrcat(result, '\"'); - tb_size_t i = 0; - tb_char_t ch; - for (i = 0; i < n; i++) - { - ch = buff[i]; - if (ch == '\\') // escape the '\\' characters in "" - tb_string_chrcat(result, '\\'); - tb_string_chrcat(result, ch); - } - tb_string_chrcat(result, '\"'); + // escape '"' or '\\' + if (ch == '\"' || ((escape || wrap_quote) && ch == '\\')) + tb_string_chrcat(result, '\\'); + tb_string_chrcat(result, ch); + p++; } - else if (n) tb_string_cstrncat(result, buff, n); + + // wrap end quote + if (wrap_quote) tb_string_chrcat(result, '\"'); } /* ////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/src/xmake/os/argv.c b/core/src/xmake/os/argv.c index f484fc6cf..980be8863 100644 --- a/core/src/xmake/os/argv.c +++ b/core/src/xmake/os/argv.c @@ -42,7 +42,17 @@ tb_int_t xm_os_argv(lua_State* lua) tb_char_t const* args = luaL_checkstring(lua, 1); tb_check_return_val(args, 0); - // done + // split only? do not escape + tb_bool_t splitonly = tb_false; + if (lua_istable(lua, 2)) + { + lua_pushstring(lua, "splitonly"); + lua_gettable(lua, 2); + splitonly = lua_toboolean(lua, -1); + lua_pop(lua, 1); + } + + // parse argument list tb_string_t arg; do { @@ -88,7 +98,7 @@ tb_int_t xm_os_argv(lua_State* lua) } // save this charactor to argument - if (!skip) tb_string_chrcat(&arg, ch); + if (splitonly || !skip) tb_string_chrcat(&arg, ch); // step and cancel escape if (escape == 1) escape++; @@ -114,7 +124,5 @@ tb_int_t xm_os_argv(lua_State* lua) // exit arg tb_string_exit(&arg); - - // ok return 1; } diff --git a/core/src/xmake/os/setenv.c b/core/src/xmake/os/setenv.c index 8240c872b..82a5fd48c 100644 --- a/core/src/xmake/os/setenv.c +++ b/core/src/xmake/os/setenv.c @@ -47,7 +47,5 @@ tb_int_t xm_os_setenv(lua_State* lua) // set it lua_pushboolean(lua, value? tb_environment_set(name, value) : tb_false); - - // ok return 1; } diff --git a/core/src/xmake/process/open.c b/core/src/xmake/process/open.c index e13cf05b8..82ea5b94f 100644 --- a/core/src/xmake/process/open.c +++ b/core/src/xmake/process/open.c @@ -200,23 +200,23 @@ tb_int_t xm_process_open(lua_State* lua) if (inpath) { // redirect stdin to file - attr.inpath = inpath; - attr.inmode = TB_FILE_MODE_RO; - attr.intype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; + attr.in.path = inpath; + attr.inmode = TB_FILE_MODE_RO; + attr.intype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; } else if (infile && xm_io_file_is_file(infile)) { tb_file_ref_t rawfile = tb_null; if (tb_stream_ctrl(infile->stream, TB_STREAM_CTRL_FILE_GET_FILE, &rawfile) && rawfile) { - attr.infile = rawfile; - attr.intype = TB_PROCESS_REDIRECT_TYPE_FILE; + attr.in.file = rawfile; + attr.intype = TB_PROCESS_REDIRECT_TYPE_FILE; } } else if (inpipe) { - attr.inpipe = inpipe; - attr.intype = TB_PROCESS_REDIRECT_TYPE_PIPE; + attr.in.pipe = inpipe; + attr.intype = TB_PROCESS_REDIRECT_TYPE_PIPE; } @@ -224,46 +224,46 @@ tb_int_t xm_process_open(lua_State* lua) if (outpath) { // redirect stdout to file - attr.outpath = outpath; - attr.outmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT; - attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; + attr.out.path = outpath; + attr.outmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT; + attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; } else if (outfile && xm_io_file_is_file(outfile)) { tb_file_ref_t rawfile = tb_null; if (tb_stream_ctrl(outfile->stream, TB_STREAM_CTRL_FILE_GET_FILE, &rawfile) && rawfile) { - attr.outfile = rawfile; - attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILE; + attr.out.file = rawfile; + attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILE; } } else if (outpipe) { - attr.outpipe = outpipe; - attr.outtype = TB_PROCESS_REDIRECT_TYPE_PIPE; + attr.out.pipe = outpipe; + attr.outtype = TB_PROCESS_REDIRECT_TYPE_PIPE; } // redirect stderr? if (errpath) { // redirect stderr to file - attr.errpath = errpath; - attr.errmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT; - attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; + attr.err.path = errpath; + attr.errmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT; + attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; } else if (errfile && xm_io_file_is_file(errfile)) { tb_file_ref_t rawfile = tb_null; if (tb_stream_ctrl(errfile->stream, TB_STREAM_CTRL_FILE_GET_FILE, &rawfile) && rawfile) { - attr.errfile = rawfile; - attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILE; + attr.err.file = rawfile; + attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILE; } } else if (errpipe) { - attr.errpipe = errpipe; - attr.errtype = TB_PROCESS_REDIRECT_TYPE_PIPE; + attr.err.pipe = errpipe; + attr.errtype = TB_PROCESS_REDIRECT_TYPE_PIPE; } // set the new environments diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c index 58d8bdfb5..02ccb49e7 100644 --- a/core/src/xmake/process/openv.c +++ b/core/src/xmake/process/openv.c @@ -242,69 +242,69 @@ tb_int_t xm_process_openv(lua_State* lua) if (inpath) { // redirect stdin to file - attr.inpath = inpath; - attr.inmode = TB_FILE_MODE_RO; - attr.intype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; + attr.in.path = inpath; + attr.inmode = TB_FILE_MODE_RO; + attr.intype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; } else if (infile && xm_io_file_is_file(infile)) { tb_file_ref_t rawfile = tb_null; if (tb_stream_ctrl(infile->stream, TB_STREAM_CTRL_FILE_GET_FILE, &rawfile) && rawfile) { - attr.infile = rawfile; - attr.intype = TB_PROCESS_REDIRECT_TYPE_FILE; + attr.in.file = rawfile; + attr.intype = TB_PROCESS_REDIRECT_TYPE_FILE; } } else if (inpipe) { - attr.inpipe = inpipe; - attr.intype = TB_PROCESS_REDIRECT_TYPE_PIPE; + attr.in.pipe = inpipe; + attr.intype = TB_PROCESS_REDIRECT_TYPE_PIPE; } // redirect stdout? if (outpath) { // redirect stdout to file - attr.outpath = outpath; - attr.outmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT; - attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; + attr.out.path = outpath; + attr.outmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT; + attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; } else if (outfile && xm_io_file_is_file(outfile)) { tb_file_ref_t rawfile = tb_null; if (tb_stream_ctrl(outfile->stream, TB_STREAM_CTRL_FILE_GET_FILE, &rawfile) && rawfile) { - attr.outfile = rawfile; - attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILE; + attr.out.file = rawfile; + attr.outtype = TB_PROCESS_REDIRECT_TYPE_FILE; } } else if (outpipe) { - attr.outpipe = outpipe; - attr.outtype = TB_PROCESS_REDIRECT_TYPE_PIPE; + attr.out.pipe = outpipe; + attr.outtype = TB_PROCESS_REDIRECT_TYPE_PIPE; } // redirect stderr? if (errpath) { // redirect stderr to file - attr.errpath = errpath; - attr.errmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT; - attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; + attr.err.path = errpath; + attr.errmode = TB_FILE_MODE_RW | TB_FILE_MODE_TRUNC | TB_FILE_MODE_CREAT; + attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILEPATH; } else if (errfile && xm_io_file_is_file(errfile)) { tb_file_ref_t rawfile = tb_null; if (tb_stream_ctrl(errfile->stream, TB_STREAM_CTRL_FILE_GET_FILE, &rawfile) && rawfile) { - attr.errfile = rawfile; - attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILE; + attr.err.file = rawfile; + attr.errtype = TB_PROCESS_REDIRECT_TYPE_FILE; } } else if (errpipe) { - attr.errpipe = errpipe; - attr.errtype = TB_PROCESS_REDIRECT_TYPE_PIPE; + attr.err.pipe = errpipe; + attr.errtype = TB_PROCESS_REDIRECT_TYPE_PIPE; } // set the new environments diff --git a/core/src/xmake/semver/select.c b/core/src/xmake/semver/select.c index e4f109f62..221baf46d 100644 --- a/core/src/xmake/semver/select.c +++ b/core/src/xmake/semver/select.c @@ -33,7 +33,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * private implementation */ -static tb_bool_t xm_semver_select_from_versions_tags(lua_State* lua, tb_int_t fromidx, semver_t* semver, semver_range_t const* range, semvers_t* matches) +static tb_bool_t xm_semver_select_from_versions_tags1(lua_State* lua, tb_int_t fromidx, semver_t* semver, semver_range_t const* range, semvers_t* matches) { // clear matches semvers_pclear(matches); @@ -77,6 +77,28 @@ static tb_bool_t xm_semver_select_from_versions_tags(lua_State* lua, tb_int_t fr // ok return tb_true; } +static tb_bool_t xm_semver_select_from_versions_tags2(lua_State* lua, tb_int_t fromidx, semver_t* semver, tb_char_t const* version_str, tb_size_t version_len) +{ + lua_Integer i = 0; + luaL_checktype(lua, fromidx, LUA_TTABLE); + for (i = lua_objlen(lua, fromidx); i > 0; --i) + { + lua_pushinteger(lua, i); + lua_gettable(lua, fromidx); + + tb_char_t const* source_str = luaL_checkstring(lua, -1); + if (source_str && tb_strncmp(source_str, version_str, version_len) == 0) + { + lua_createtable(lua, 0, 2); + lua_pushstring(lua, source_str); + lua_setfield(lua, -2, "version"); + lua_pushstring(lua, fromidx == 2? "versions" : "tags"); + lua_setfield(lua, -2, "source"); + return tb_true; + } + } + return tb_false; +} static tb_bool_t xm_semver_select_from_branches(lua_State* lua, tb_int_t fromidx, tb_char_t const* range_str, tb_size_t range_len) { lua_Integer i = 0; @@ -185,14 +207,30 @@ tb_int_t xm_semver_select(lua_State* lua) if (is_range) { // attempt to select version from the versions list first - if (xm_semver_select_from_versions_tags(lua, 2, &semver, &range, &matches)) + if (xm_semver_select_from_versions_tags1(lua, 2, &semver, &range, &matches)) + { + ok = tb_true; + break; + } + + // attempt to select version from the tags list + if (xm_semver_select_from_versions_tags1(lua, 3, &semver, &range, &matches)) + { + ok = tb_true; + break; + } + } + else + { + // attempt to select version from the versions list first + if (xm_semver_select_from_versions_tags2(lua, 2, &semver, range_str, range_len)) { ok = tb_true; break; } // attempt to select version from the tags list - if (xm_semver_select_from_versions_tags(lua, 3, &semver, &range, &matches)) + if (xm_semver_select_from_versions_tags2(lua, 3, &semver, range_str, range_len)) { ok = tb_true; break; diff --git a/core/src/xmake/winos/registry_query.c b/core/src/xmake/winos/registry_query.c index f507bbaab..aadb65b2e 100644 --- a/core/src/xmake/winos/registry_query.c +++ b/core/src/xmake/winos/registry_query.c @@ -102,9 +102,10 @@ tb_int_t xm_winos_registry_query(lua_State* lua) value = (tb_char_t*)tb_malloc0(valuesize + 1); tb_assert_and_check_break(value); - // get value result + // get value result, we attempt to do not expand value if get failed type = 0; - if (s_RegGetValueA(key, rootdir, valuename, RRF_RT_ANY, &type, (PVOID)value, &valuesize) != ERROR_SUCCESS) + if (s_RegGetValueA(key, rootdir, valuename, RRF_RT_ANY, &type, (PVOID)value, &valuesize) != ERROR_SUCCESS && + s_RegGetValueA(key, rootdir, valuename, RRF_RT_ANY | RRF_NOEXPAND, &type, (PVOID)value, &valuesize) != ERROR_SUCCESS) { lua_pushnil(lua); lua_pushfstring(lua, "get registry value failed: %s\\%s;%s", rootkey, rootdir, valuename); diff --git a/core/src/xmake/xmake.lua b/core/src/xmake/xmake.lua index eb2cc62b9..7a604301a 100644 --- a/core/src/xmake/xmake.lua +++ b/core/src/xmake/xmake.lua @@ -1,4 +1,3 @@ --- add target target("xmake") -- make as a static library @@ -40,5 +39,5 @@ target("xmake") if is_plat("windows") then add_defines("UNICODE", "_UNICODE") end - + diff --git a/core/suffix.mak b/core/suffix.mak index 7b5eec615..7f9446943 100644 --- a/core/suffix.mak +++ b/core/suffix.mak @@ -5,6 +5,11 @@ # append names NAMES += $(NAMES-y) +# verbose +ifneq ($(VERBOSE),y) +VECHO = @ +endif + # ccache hook compiler for optimizating make ifneq ($(CCACHE),) CC := $(CCACHE) $(CC) @@ -206,37 +211,37 @@ $(foreach name, $(NAMES), $(eval $(call MAKE_OBJS_AND_SRCS_FILES,$(name)))) define MAKE_OBJ_C $(1)$(OBJ_SUFFIX) : $(1).c @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).c - @$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).c $(OUT) $(TMP_DIR)/$(PRO_NAME).out + $(VECHO)$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).c $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_CC $(1)$(OBJ_SUFFIX) : $(1).cc @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).cc - @$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).cc $(OUT) $(TMP_DIR)/$(PRO_NAME).out + $(VECHO)$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).cc $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_CPP $(1)$(OBJ_SUFFIX) : $(1).cpp @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).cpp - @$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).cpp $(OUT) $(TMP_DIR)/$(PRO_NAME).out + $(VECHO)$(CC) $(2) $(3) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).cpp $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_M $(1)$(OBJ_SUFFIX) : $(1).m @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).m - @$(MM) -x objective-c $(2) $(3) $(MXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).m $(OUT) $(TMP_DIR)/$(PRO_NAME).out + $(VECHO)$(MM) -x objective-c $(2) $(3) $(MXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).m $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_MM $(1)$(OBJ_SUFFIX) : $(1).mm @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1).mm - @$(MM) -x objective-c++ $(2) $(3) $(MXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).mm $(OUT) $(TMP_DIR)/$(PRO_NAME).out + $(VECHO)$(MM) -x objective-c++ $(2) $(3) $(MXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1).mm $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_ASM_WITH_CC $(1)$(OBJ_SUFFIX) : $(1)$(ASM_SUFFIX) @echo $(CCACHE) $(DISTCC) compile.$(DTYPE) $(1)$(ASM_SUFFIX) - @$(CC) $(2) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1)$(ASM_SUFFIX) $(OUT) $(TMP_DIR)/$(PRO_NAME).out + $(VECHO)$(CC) $(2) $(CXFLAGS-o)$(1)$(OBJ_SUFFIX) $(1)$(ASM_SUFFIX) $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_OBJ_ASM_WITH_AS @@ -267,32 +272,32 @@ $(if $(AS) $(BIN_PREFIX)$(1)$(BIN_SUFFIX): $($(1)_OBJS) $(addsuffix $(OBJ_SUFFIX), $($(1)_OBJ_FILES)) @echo link $$@ - -@$(RM) $$@ - @$(LD) $(LDFLAGS-o)$$@ $$^ $($(1)_LDFLAGS) $(OUT) $(TMP_DIR)/$(PRO_NAME).out + -$(VECHO)$(RM) $$@ + $(VECHO)$(LD) $(LDFLAGS-o)$$@ $$^ $($(1)_LDFLAGS) $(OUT) $(TMP_DIR)/$(PRO_NAME).out $(LIB_PREFIX)$(1)$(LIB_SUFFIX): $($(1)_OBJS) $(addsuffix $(OBJ_SUFFIX), $($(1)_OBJ_FILES)) @echo link $$@ - -@$(RM) $$@ - @$(AR) $($(1)_ARFLAGS) $(ARFLAGS-o)$$@ $$^ $(OUT) $(TMP_DIR)/$(PRO_NAME).out + -$(VECHO)$(RM) $$@ + $(VECHO)$(AR) $($(1)_ARFLAGS) $(ARFLAGS-o)$$@ $$^ $(OUT) $(TMP_DIR)/$(PRO_NAME).out $(if $(RANLIB),@$(RANLIB) $$@,) $(DLL_PREFIX)$(1)$(DLL_SUFFIX): $($(1)_OBJS) $(addsuffix $(OBJ_SUFFIX), $($(1)_OBJ_FILES)) @echo link $$@ - -@$(RM) $$@ - @$(LD) $(LDFLAGS-o)$$@ $$^ $($(1)_SHFLAGS) $(OUT) $(TMP_DIR)/$(PRO_NAME).out + -$(VECHO)$(RM) $$@ + $(VECHO)$(LD) $(LDFLAGS-o)$$@ $$^ $($(1)_SHFLAGS) $(OUT) $(TMP_DIR)/$(PRO_NAME).out endef define MAKE_ALL_SUB_PROS SUB_PROS_$(1)_all: $(foreach pro, $(DEP_PROS), DEP_PROS_$(pro)_all) @echo make $(1) - +@$(MAKE) --no-print-directory -C $(1) + +$(VECHO)$(MAKE) --no-print-directory -C $(1) endef define MAKE_ALL_DEP_PROS DEP_PROS_$(1)_all: @echo make $(1) - +@$(MAKE) --no-print-directory -C $(1) + +$(VECHO)$(MAKE) --no-print-directory -C $(1) endef all: \ @@ -364,31 +369,31 @@ $(foreach name, $(NAMES), $(eval $(call MAKE_INSTALL_FILES,$(name)))) define MAKE_INSTALL_INC_FILES $(1)_install: - -@$(MKDIR) $($(1)_INC_DIRS_) - -@$(CP) $(1) $($(1)_INC_DIRS_) + -$(VECHO)$(MKDIR) $($(1)_INC_DIRS_) + -$(VECHO)$(CP) $(1) $($(1)_INC_DIRS_) endef define MAKE_INSTALL_LIB_FILES $(1)_install: - -@$(MKDIR) $($(1)_LIB_DIRS_) - -@$(CP) $(1) $($(1)_LIB_DIRS_) + -$(VECHO)$(MKDIR) $($(1)_LIB_DIRS_) + -$(VECHO)$(CP) $(1) $($(1)_LIB_DIRS_) endef define MAKE_INSTALL_DLL_FILES $(1)_install: - -@$(MKDIR) $($(1)_DLL_DIRS_) - -@$(CP) $(1) $($(1)_DLL_DIRS_) + -$(VECHO)$(MKDIR) $($(1)_DLL_DIRS_) + -$(VECHO)$(CP) $(1) $($(1)_DLL_DIRS_) endef define MAKE_INSTALL_BIN_FILES $(1)_install: - -@$(MKDIR) $($(1)_BIN_DIRS_) - -@$(CP) $(1) $($(1)_BIN_DIRS_) + -$(VECHO)$(MKDIR) $($(1)_BIN_DIRS_) + -$(VECHO)$(CP) $(1) $($(1)_BIN_DIRS_) endef $(CFG_FILE)_install: - -@$(MKDIR) $($(CFG_FILE)_DIRS_) - -@$(CP) $(CFG_FILE) $($(CFG_FILE)_DIRS_) + -$(VECHO)$(MKDIR) $($(CFG_FILE)_DIRS_) + -$(VECHO)$(CP) $(CFG_FILE) $($(CFG_FILE)_DIRS_) # make install define MAKE_INSTALL @@ -410,14 +415,14 @@ install: $(foreach file, $(INSTALL_FILES), $(file)_install) $(foreach pro, $(SUB define MAKE_INSTALL_SUB_PROS SUB_PROS_$(1)_install: @echo install $(1) - @$(MAKE) --no-print-directory -C $(1) install + $(VECHO)$(MAKE) --no-print-directory -C $(1) install endef # make dep-projects define MAKE_INSTALL_DEP_PROS DEP_PROS_$(1)_install: $(foreach pro, $(DEP_PROS), DEP_PROS_$(pro)_install) @echo install $(1) - @$(MAKE) --no-print-directory -C $(1) install + $(VECHO)$(MAKE) --no-print-directory -C $(1) install endef $(foreach pro, $(SUB_PROS), $(eval $(call MAKE_INSTALL_SUB_PROS,$(pro)))) $(foreach pro, $(DEP_PROS), $(eval $(call MAKE_INSTALL_DEP_PROS,$(pro)))) @@ -427,21 +432,21 @@ $(foreach pro, $(DEP_PROS), $(eval $(call MAKE_INSTALL_DEP_PROS,$(pro)))) # # define MAKE_CLEAN $(1)_$(2)_clean: - -@$(RM) $($(2)_PREFIX)$(1)$($(2)_SUFFIX) - -@$(RM) $($(1)_OBJS) - -@$(RM) *.ilk *.manifest *.pdb *.idb *.dmp + -$(VECHO)$(RM) $($(2)_PREFIX)$(1)$($(2)_SUFFIX) + -$(VECHO)$(RM) $($(1)_OBJS) + -$(VECHO)$(RM) *.ilk *.manifest *.pdb *.idb *.dmp endef define MAKE_CLEAN_SUB_PROS SUB_PROS_$(1)_clean: $(foreach pro, $(DEP_PROS), DEP_PROS_$(pro)_clean) @echo clean $(1) - +@$(MAKE) --no-print-directory -C $(1) clean + +$(VECHO)$(MAKE) --no-print-directory -C $(1) clean endef define MAKE_CLEAN_DEP_PROS DEP_PROS_$(1)_clean: @echo clean $(1) - +@$(MAKE) --no-print-directory -C $(1) clean + +$(VECHO)$(MAKE) --no-print-directory -C $(1) clean endef clean: \ @@ -459,17 +464,17 @@ $(foreach pro, $(DEP_PROS), $(eval $(call MAKE_CLEAN_DEP_PROS,$(pro)))) define MAKE_UPDATE_SUB_PROS SUB_PROS_$(1)_update: $(foreach pro, $(DEP_PROS), DEP_PROS_$(pro)_update) @echo update $(1) - @$(MAKE) --no-print-directory -C $(1) update + $(VECHO)$(MAKE) --no-print-directory -C $(1) update endef define MAKE_UPDATE_DEP_PROS DEP_PROS_$(1)_update: @echo update $(1) - @$(MAKE) --no-print-directory -C $(1) update + $(VECHO)$(MAKE) --no-print-directory -C $(1) update endef update: .null $(foreach pro, $(SUB_PROS), SUB_PROS_$(pro)_update) - -@$(RM) *.b *.a *.so *.exe *.dll *.lib *.pdb *.ilk + -$(VECHO)$(RM) *.b *.a *.so *.exe *.dll *.lib *.pdb *.ilk $(foreach pro, $(SUB_PROS), $(eval $(call MAKE_UPDATE_SUB_PROS,$(pro)))) $(foreach pro, $(DEP_PROS), $(eval $(call MAKE_UPDATE_DEP_PROS,$(pro)))) diff --git a/core/xmake.lua b/core/xmake.lua index c3728eec2..23d807ffe 100644 --- a/core/xmake.lua +++ b/core/xmake.lua @@ -2,7 +2,7 @@ set_project("xmake") -- version -set_version("2.3.9", {build = "%Y%m%d%H%M"}) +set_version("2.5.5", {build = "%Y%m%d%H%M"}) -- set xmake min version set_xmakever("2.2.3") @@ -29,7 +29,7 @@ add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno- add_defines("_GNU_SOURCE=1", "_FILE_OFFSET_BITS=64", "_LARGEFILE_SOURCE") -- for the windows platform (msvc) -if is_plat("windows") then +if is_plat("windows") then add_cxflags("-MT") add_ldflags("-nodefaultlib:msvcrt.lib") add_links("kernel32", "user32", "gdi32") @@ -1,9 +1,10 @@ # is debug? debug :=n -verbose := -#debug :=y -#verbose :=-v +# verbose +ifneq ($(VERBOSE),y) +VECHO = @ +endif # prefix ifeq ($(prefix),) # compatible with brew script (make install PREFIX=xxx DESTDIR=/xxx) @@ -42,10 +43,10 @@ endif BUILD_ARCH :=$(if $(findstring windows,$(PLAT)),x86,$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring msys,$(PLAT)),$(MSYSARCH),$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring cygwin,$(PLAT)),x$(shell getconf LONG_BIT),$(BUILD_ARCH)) -BUILD_ARCH :=$(if $(findstring macosx,$(PLAT)),x$(shell getconf LONG_BIT),$(BUILD_ARCH)) +BUILD_ARCH :=$(if $(findstring macosx,$(PLAT)),$(shell uname -m),$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring linux,$(PLAT)),$(shell uname -m),$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring bsd,$(PLAT)),x$(shell getconf LONG_BIT),$(BUILD_ARCH)) -BUILD_ARCH :=$(if $(findstring iphoneos,$(PLAT)),armv7,$(BUILD_ARCH)) +BUILD_ARCH :=$(if $(findstring iphoneos,$(PLAT)),arm64,$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring android,$(PLAT)),armv7,$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring i686,$(BUILD_ARCH)),i386,$(BUILD_ARCH)) BUILD_ARCH :=$(if $(findstring x32,$(BUILD_ARCH)),i386,$(BUILD_ARCH)) diff --git a/scripts/get.ps1 b/scripts/get.ps1 index 4ec3df140..a189b2ba2 100755 --- a/scripts/get.ps1 +++ b/scripts/get.ps1 @@ -153,7 +153,7 @@ param ( $content = [System.Text.RegularExpressions.Regex]::Replace($content, "\n*(# PowerShell parameter completion shim for xmake)?\s*Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock\s*{.+?\n}\s*", "`n", [System.Text.RegularExpressions.RegexOptions]::Singleline) } try { - $appendcontent = (Invoke-Webrequest 'https://raw.githubusercontent.com/xmake-io/xmake/master/scripts/register-completions.ps1' -UseBasicParsing).Content + $appendcontent = (Invoke-Webrequest 'https://xmake.io/assets/scripts/pscompletions.text' -UseBasicParsing).Content } catch { writeErrorTip 'Download failed!' writeErrorTip 'Check your network or... the news of S3 break' diff --git a/scripts/get.sh b/scripts/get.sh index 3c0562aba..8363b4499 100755 --- a/scripts/get.sh +++ b/scripts/get.sh @@ -50,7 +50,7 @@ get_host_speed() { if [ `uname` == "Darwin" ]; then ping -c 1 -t 1 $1 2>/dev/null | egrep -o 'time=\d+' | egrep -o "\d+" || echo "65535" else - ping -c 1 -W 1 $1 2>/dev/null | egrep -o 'time=\d+' | egrep -o "\d+" || echo "65535" + ping -c 1 -W 1 $1 2>/dev/null | grep -P -o 'time=\d+' | grep -P -o "\d+" || echo "65535" fi } @@ -153,11 +153,12 @@ install_tools() { yum --version >/dev/null 2>&1 && $sudoprefix yum install -y git readline-devel ccache && $sudoprefix yum groupinstall -y 'Development Tools'; } || { zypper --version >/dev/null 2>&1 && $sudoprefix zypper --non-interactive install git readline-devel ccache && $sudoprefix zypper --non-interactive install -t pattern devel_C_C++; } || { pacman -V >/dev/null 2>&1 && $sudoprefix pacman -S --noconfirm --needed git base-devel ccache; } || + { emerge -V >/dev/null 2>&1 && $sudoprefix emerge -atv dev-vcs/git ccache; } || { pkg list-installed >/dev/null 2>&1 && $sudoprefix pkg install -y git getconf build-essential readline ccache; } || # termux { pkg help >/dev/null 2>&1 && $sudoprefix pkg install -y git readline ccache ncurses; } || # freebsd { apk --version >/dev/null 2>&1 && $sudoprefix apk add git gcc g++ make readline-dev ncurses-dev libc-dev linux-headers; } } -test_tools || { install_tools && test_tools; } || my_exit "$(echo -e 'Dependencies Installation Fail\nThe getter currently only support these package managers\n\t* apt\n\t* yum\n\t* zypper\n\t* pacman\nPlease install following dependencies manually:\n\t* git\n\t* build essential like `make`, `gcc`, etc\n\t* libreadline-dev (readline-devel)\n\t* ccache (optional)')" 1 +test_tools || { install_tools && test_tools; } || my_exit "$(echo -e 'Dependencies Installation Fail\nThe getter currently only support these package managers\n\t* apt\n\t* yum\n\t* zypper\n\t* pacman\n\t* portage\nPlease install following dependencies manually:\n\t* git\n\t* build essential like `make`, `gcc`, etc\n\t* libreadline-dev (readline-devel)\n\t* ccache (optional)')" 1 projectdir=$tmpdir if [ 'x__local__' = "x$branch" ]; then if [ -d '.git' ]; then diff --git a/scripts/installer.nsi b/scripts/installer.nsi index 4f12aebea..a01b6feea 100644 --- a/scripts/installer.nsi +++ b/scripts/installer.nsi @@ -237,6 +237,7 @@ Section "XMake (required)" InstallExeutable File "..\*.md" File "..\core\build\xmake.exe" File "..\scripts\xrepo.bat" + File "..\scripts\xrepo.ps1" File /r /x ".DS_Store" "..\winenv" WriteUninstaller "uninstall.exe" diff --git a/scripts/makeppa b/scripts/makeppa index 0af565bc9..3f447958d 100755 --- a/scripts/makeppa +++ b/scripts/makeppa @@ -67,7 +67,7 @@ cat debian/changelog # build package echo "building package .." -debuild -S -k2C0C68C9 +debuild -S -k02713554FA2CE4AADA20AB23167A22F22C0C68C9 # check package echo "checking package .." @@ -117,3 +117,6 @@ rm -rf xmake-ppa # gpg --keyserver keyserver.ubuntu.com --recv 2C0C68C9 # gpg --export --armor 2C0C68C9 | sudo apt-key add - # +# show long key +# gpg --keyid-format long --list-keys [email protected] +# diff --git a/scripts/man/xmake.1 b/scripts/man/xmake.1 new file mode 100644 index 000000000..eca67ddca --- /dev/null +++ b/scripts/man/xmake.1 @@ -0,0 +1,214 @@ +.TH "xmake" "1" +.SH NAME +xmake \- cross-platform build utility based on Lua + + +.SH SYNOPSIS +.B xmake +.RI [ task "] [" options "] [" target ] + + +.SH DESCRIPTION +.B xmake +is a lightweight cross-platform build utility based on Lua. It uses +.I xmake.lua +to maintain project builds. Compared with +.IR makefile / CMakeLists.txt , +the configuration syntax is more concise and intuitive. It is very friendly to +novices and can quickly get started in a short time. Let users focus more on +actual project development. + + +.SH ACTIONS + +.TP +.B b, build +Build targets if no given tasks. + +.TP +.B u, uninstall +Uninstall the project binary files. + +.TP +.B p, package +Package target. + +.TP +.B r, run +Run the project target. + +.TP +.B g, global +Configure the global options for xmake. + +.TP +.B i, install +Package and install the target binary files. + +.TP +.B c, clean +Remove all binary and temporary files. + +.TP +.B create +Create a new project. + +.TP +.B q, require +Install and update required packages. + +.TP +.B update +Update and uninstall the xmake program. + +.TP +.B f, config +Configure the project. + + +.SH PLUGINS + +.TP +.B plugin +Manage plugins of xmake. + +.TP +.B m, macro +Run the given macro. + +.TP +.B doxygen +Generate the doxygen document. + +.TP +.B l, lua +Run the lua script. + +.TP +.B repo +Manage package repositories. + +.TP +.B service +Start service for remote or distributed compilation and etc. (Experimental, still in development) + +.TP +.B project +Generate the project file. + +.TP +.B show +Show the given project information. + + +.SH OPTIONS + +.TP +.B \-q, \-\-quiet +Quiet operation. + +.TP +.B \-y, \-\-yes +Input yes by default if need user confirm. + +.TP +.BR \-\-confirm =\fICONFIRM +Input the given result if need user confirm. + \- yes + \- no + \- def + +.TP +.B \-v, \-\-verbose +Print lots of verbose information for users. + +.TP +.B \-\-root +Allow to run xmake as root. + +.TP +.B \-D, \-\-diagnosis +Print lots of diagnosis information (backtrace, check info ..) only for developers. +And we can append \fB\-v\fR to get more whole information. + e.g. $ xmake \-vD + +.TP +.B \-\-version +Print the version number and exit. + +.TP +.B \-h, \-\-help +Print this help message and exit. + +.TP +.BI \-F " FILE" ", \-\-file\fR=" FILE +Read a given +.B xmake.lua +file. + +.TP +.BI \-P " PROJECT" ", \-\-project\fR=" PROJECT +Change to the given project directory. +Search priority: + 1. The Given Command Argument + 2. The Envirnoment Variable: \fBXMAKE_PROJECT_DIR\fR + 3. The Current Directory + + +.SH BUILD OPTIONS + +.TP +.B \-b, \-\-build +Build target. This is default building mode and optional. + +.TP +.B \-r, \-\-rebuild +Rebuild the target. + +.TP +.B \-a, \-\-all +Build all targets. + +.TP +.B \-\-dry\-run +Dry run to build target. + +.TP +.BI \-j " JOBS" ", \-\-jobs\fR=" JOBS +Specifies the number of jobs to build simultaneously. (default: 6) + +.TP +.B \-w, \-\-warning +Enable the warnings output. + +.TP +.BI \-\-files= FILES +Build the given source files. + +e.g. +.RS +.EX + \- xmake \-\-files=src/main.c + \- xmake \-\-files='src/*.c' [target] + \- xmake \-\-files='src/**c|excluded_file.c' + \- xmake \-\-files='src/main.c:src/test.c' +.EE +.RE + +.TP +.B target +The target name. It will build all default targets if this parameter is not specified. + + +.SH AUTHOR +.B xmake +is written by +.MT waruqi@\:gmail.com +ruki +.ME . + +This manual page was written by +.MT mmyangfl@\:gmail.com +Yangfl +.ME +for the Debian Project (and may be used by others). diff --git a/scripts/man/xrepo.1 b/scripts/man/xrepo.1 new file mode 100644 index 000000000..7106ea830 --- /dev/null +++ b/scripts/man/xrepo.1 @@ -0,0 +1,123 @@ +.TH "xrepo" "1" +.SH NAME +xrepo \- cross-platform build utility based on Lua + + +.SH SYNOPSIS +.B xrepo +.RI [ action "] [" options ] + + +.SH DESCRIPTION +.B xrepo +is a lightweight cross-platform build utility based on Lua. It uses +.I xrepo.lua +to maintain project builds. Compared with +.IR makefile / CMakeLists.txt , +the configuration syntax is more concise and intuitive. It is very friendly to +novices and can quickly get started in a short time. Let users focus more on +actual project development. + + +.SH ACTIONS + +.TP +.B clean +Clear all package caches and remove all not\-referenced packages. + +.TP +.B env +Set environment and execute command, or print environment. + +.TP +.B export +Export the given packages. + +.TP +.B fetch +Fetch library information of the given installed packages. + +.TP +.B import +Import the given packages. + +.TP +.B info +Show information of the given packages. + +.TP +.B install +Install the given packages. + +.TP +.B remove +Remove the given packages. + +.TP +.B scan +Scan the given or all installed packages. + +.TP +.B search +Search the given packages. + +.TP +.B add\-repo +Add the given remote repository url. + +.TP +.B list\-repo +List all remote repositories. + +.TP +.B rm\-repo +Remove the given remote repository. + +.TP +.B update\-repo +Update all local repositories from remote. + + +.SH OPTIONS + +.TP +.B \-q, \-\-quiet +Quiet operation. + +.TP +.B \-y, \-\-yes +Input yes by default if need user confirm. + +.TP +.B \-\-root +Allow to run xrepo as root. + +.TP +.B \-v, \-\-verbose +Print lots of verbose information for users. + +.TP +.B \-D, \-\-diagnosis +Print lots of diagnosis information. + +.TP +.B \-\-version +Print the version number and exit. + +.TP +.B \-h, \-\-help +Print this help message and exit. + + +.SH AUTHOR +.B xrepo +is written by +.MT waruqi@\:gmail.com +ruki +.ME . + +This manual page was written by +.MT mmyangfl@\:gmail.com +Yangfl +.ME +for the Debian Project (and may be used by others). diff --git a/scripts/rpmbuild/SPECS/xmake.spec b/scripts/rpmbuild/SPECS/xmake.spec index 5dce75406..9887176bc 100644 --- a/scripts/rpmbuild/SPECS/xmake.spec +++ b/scripts/rpmbuild/SPECS/xmake.spec @@ -1,5 +1,5 @@ -%define xmake_revision a1d830ffded196bd9af49376f4b50e374c4470ec -%define tbox_revision d27f2807173dbc787582b6169e8e854a0ef396fc +%define xmake_revision c44aea875ce6bde152a1bd2d92fec3fd9ca6b223 +%define tbox_revision 5ef932750ede0b90867fd4afdcf1deed2464c82b %define sv_revision 9a3cf7c8e589de4f70378824329882c4a047fffc %define lua_cjson_revision 515bab6d6d80b164b94db73af69609ea02f3a798 %define luajit_revision e9af1abec542e6f9851ff2368e7f196b6382a44c @@ -7,7 +7,7 @@ %undefine _disable_source_fetch Name: xmake -Version: 2.3.9 +Version: 2.5.5 Release: 1%{?dist} Summary: A cross-platform build utility based on Lua BuildArch: noarch diff --git a/scripts/xrepo.bat b/scripts/xrepo.bat index ff95b722a..c8714a11c 100755 --- a/scripts/xrepo.bat +++ b/scripts/xrepo.bat @@ -1,2 +1,67 @@ -@echo off -xmake lua private.xrepo %* +@set "XMAKE_EXE=xmake" + +@if [%1]==[env] ( + if [%2]==[quit] ( + if defined XMAKE_PROMPT_BACKUP ( + call %XMAKE_ENV_BACKUP% + setlocal EnableDelayedExpansion + if !errorlevel! neq 0 exit /B !errorlevel! + endlocal + set PROMPT=%XMAKE_PROMPT_BACKUP% + set XMAKE_ENV_BACKUP= + set XMAKE_PROMPT_BACKUP= + ) + goto :ENDXREPO + ) + if [%2]==[shell] ( + if defined XMAKE_PROMPT_BACKUP ( + call %XMAKE_ENV_BACKUP% + setlocal EnableDelayedExpansion + if !errorlevel! neq 0 exit /B !errorlevel! + %XMAKE_EXE% lua private.xrepo.action.env.info config + if !errorlevel! neq 0 ( + exit /B !errorlevel! + ) + @%XMAKE_EXE% lua private.xrepo.action.env.info prompt 1>nul + if !errorlevel! neq 0 ( + echo error: xmake.lua not found^^! + exit /B !errorlevel! + ) + endlocal + set PROMPT=%XMAKE_PROMPT_BACKUP% + set XMAKE_ENV_BACKUP= + set XMAKE_PROMPT_BACKUP= + echo Please rerun `xrepo env shell` to enter the environment. + exit /B 1 + ) else ( + setlocal EnableDelayedExpansion + %XMAKE_EXE% lua private.xrepo.action.env.info config + if !errorlevel! neq 0 ( + exit /B !errorlevel! + ) + @%XMAKE_EXE% lua private.xrepo.action.env.info prompt 1>nul + if !errorlevel! neq 0 ( + echo error: xmake.lua not found^^! + exit /B !errorlevel! + ) + endlocal + for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info prompt') do @( + @set "PROMPT=%%i %PROMPT%" + ) + @set XMAKE_PROMPT_BACKUP=%PROMPT% + ) + for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info envfile') do @( + @set "XMAKE_ENV_BACKUP=%%i.bat" + @"%XMAKE_EXE%" lua private.xrepo.action.env.info backup.cmd 1>"%%i.bat" + ) + for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info envfile') do @( + @"%XMAKE_EXE%" lua private.xrepo.action.env.info script.cmd 1>"%%i.bat" + call "%%i.bat" + ) + goto :ENDXREPO + ) +) + +@call %XMAKE_EXE% lua private.xrepo %* + +:ENDXREPO diff --git a/scripts/xrepo.ps1 b/scripts/xrepo.ps1 new file mode 100644 index 000000000..a821d8057 --- /dev/null +++ b/scripts/xrepo.ps1 @@ -0,0 +1,33 @@ +$script:SCRIPT_PATH = $myinvocation.mycommand.path +$script:BASE_DIR = Split-Path $SCRIPT_PATH -Parent +$Env:XMAKE_EXE = Join-Path $BASE_DIR xmake.exe + + +if ($Args.Count -eq 0) { + # No args, just call the underlying xmake executable. + & $Env:XMAKE_EXE lua private.xrepo; +} else { + $Command = $Args[0]; + if (($Command -eq "env") -and ($Args.Count -ge 2)) { + switch ($Args[1]) { + "shell" { + if (-not (Test-Path 'Env:XMAKE_ROOTDIR')) { + $Env:XMAKE_ROOTDIR = $BASE_DIR; + Import-Module "$Env:XMAKE_ROOTDIR\scripts\xrepo-hook.psm1"; + Add-XrepoEnvironmentToPrompt; + } + if ((Test-Path 'Env:XMAKE_PROMPT_MODIFIER') -and ($Env:XMAKE_PROMPT_MODIFIER -ne "")) { + Exit-XrepoEnvironment; + } + Enter-XrepoEnvironment; + return; + } + "quit" { + Exit-XrepoEnvironment; + return; + } + } + } + + & $Env:XMAKE_EXE lua private.xrepo $Args; +} diff --git a/tests/actions/package/localpkg/bar/.gitignore b/tests/actions/package/localpkg/bar/.gitignore new file mode 100644 index 000000000..152105761 --- /dev/null +++ b/tests/actions/package/localpkg/bar/.gitignore @@ -0,0 +1,8 @@ +# Xmake cache +.xmake/ +build/ + +# MacOS Cache +.DS_Store + + diff --git a/tests/actions/package/localpkg/bar/src/main.cpp b/tests/actions/package/localpkg/bar/src/main.cpp new file mode 100644 index 000000000..0102fba75 --- /dev/null +++ b/tests/actions/package/localpkg/bar/src/main.cpp @@ -0,0 +1,10 @@ +#include "foo.h" +#include <iostream> + +using namespace std; + +int main(int argc, char** argv) +{ + cout << "foo(1, 2) = " << foo(1, 2) << endl; + return 0; +} diff --git a/tests/actions/package/localpkg/bar/xmake.lua b/tests/actions/package/localpkg/bar/xmake.lua new file mode 100644 index 000000000..9024b2065 --- /dev/null +++ b/tests/actions/package/localpkg/bar/xmake.lua @@ -0,0 +1,11 @@ +add_rules("mode.debug", "mode.release") + +add_repositories("local-repo build") +add_requires("foo") + +target("bar") + set_kind("binary") + add_files("src/*.cpp") + add_packages("foo") + + diff --git a/tests/actions/package/localpkg/libfoo/.gitignore b/tests/actions/package/localpkg/libfoo/.gitignore new file mode 100644 index 000000000..152105761 --- /dev/null +++ b/tests/actions/package/localpkg/libfoo/.gitignore @@ -0,0 +1,8 @@ +# Xmake cache +.xmake/ +build/ + +# MacOS Cache +.DS_Store + + diff --git a/tests/projects/c/shared_library/src/interface.c b/tests/actions/package/localpkg/libfoo/src/add.cpp index 598d07560..e73473e0f 100644 --- a/tests/projects/c/shared_library/src/interface.c +++ b/tests/actions/package/localpkg/libfoo/src/add.cpp @@ -1,4 +1,4 @@ -#include "interface.h" +#include "add.h" int add(int a, int b) { diff --git a/tests/actions/package/localpkg/libfoo/src/add.h b/tests/actions/package/localpkg/libfoo/src/add.h new file mode 100644 index 000000000..62a39427c --- /dev/null +++ b/tests/actions/package/localpkg/libfoo/src/add.h @@ -0,0 +1,16 @@ +#ifdef __cplusplus +extern "C" { +#endif + +/*! calculate add(a, b) + * + * @param a the first argument + * @param b the second argument + * + * @return the result + */ +int add(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/tests/actions/package/localpkg/libfoo/src/foo.cpp b/tests/actions/package/localpkg/libfoo/src/foo.cpp new file mode 100644 index 000000000..b13e8e761 --- /dev/null +++ b/tests/actions/package/localpkg/libfoo/src/foo.cpp @@ -0,0 +1,8 @@ +#include "add.h" +#include "sub.h" +#include "foo.h" + +int foo(int a, int b) +{ + return add(sub(a, b), sub(b, a)); +} diff --git a/tests/actions/package/localpkg/libfoo/src/foo.h b/tests/actions/package/localpkg/libfoo/src/foo.h new file mode 100644 index 000000000..d53be3150 --- /dev/null +++ b/tests/actions/package/localpkg/libfoo/src/foo.h @@ -0,0 +1,16 @@ +#ifdef __cplusplus +extern "C" { +#endif + +/*! calculate foo(a, b) + * + * @param a the first argument + * @param b the second argument + * + * @return the result + */ +int foo(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/tests/actions/package/localpkg/libfoo/src/sub.cpp b/tests/actions/package/localpkg/libfoo/src/sub.cpp new file mode 100644 index 000000000..a65acd40f --- /dev/null +++ b/tests/actions/package/localpkg/libfoo/src/sub.cpp @@ -0,0 +1,6 @@ +#include "sub.h" + +int sub(int a, int b) +{ + return a - b; +} diff --git a/tests/actions/package/localpkg/libfoo/src/sub.h b/tests/actions/package/localpkg/libfoo/src/sub.h new file mode 100644 index 000000000..1bda92bc5 --- /dev/null +++ b/tests/actions/package/localpkg/libfoo/src/sub.h @@ -0,0 +1,16 @@ +#ifdef __cplusplus +extern "C" { +#endif + +/*! calculate sub(a, b) + * + * @param a the first argument + * @param b the second argument + * + * @return the result + */ +int sub(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/tests/actions/package/localpkg/libfoo/xmake.lua b/tests/actions/package/localpkg/libfoo/xmake.lua new file mode 100644 index 000000000..a6e5c7cb0 --- /dev/null +++ b/tests/actions/package/localpkg/libfoo/xmake.lua @@ -0,0 +1,19 @@ +add_rules("mode.debug", "mode.release") +set_license("Apache-2.0") + +target("sub") + set_kind("static") + add_files("src/sub.cpp") + add_headerfiles("src/sub.h") + +target("add") + set_kind("static") + add_files("src/add.cpp") + add_headerfiles("src/add.h") + +target("foo") + add_deps("add", "sub") + set_kind("static") + add_files("src/foo.cpp") + add_headerfiles("src/foo.h") + diff --git a/tests/actions/package/localpkg/test.lua b/tests/actions/package/localpkg/test.lua new file mode 100644 index 000000000..a1f03b215 --- /dev/null +++ b/tests/actions/package/localpkg/test.lua @@ -0,0 +1,10 @@ +function main(t) + if (os.subarch():startswith("x") or os.subarch() == "i386") and not is_host("bsd") then + os.cd("libfoo") + os.exec("xmake package -D -o ../bar/build") + os.cd("../bar") + os.exec("xmake f -c -D") + os.exec("xmake -D") + os.exec("xmake run") + end +end diff --git a/tests/apis/add_defines/.gitignore b/tests/apis/add_defines/.gitignore new file mode 100644 index 000000000..152105761 --- /dev/null +++ b/tests/apis/add_defines/.gitignore @@ -0,0 +1,8 @@ +# Xmake cache +.xmake/ +build/ + +# MacOS Cache +.DS_Store + + diff --git a/tests/apis/add_defines/src/main.cpp b/tests/apis/add_defines/src/main.cpp new file mode 100644 index 000000000..d16b296dc --- /dev/null +++ b/tests/apis/add_defines/src/main.cpp @@ -0,0 +1,14 @@ +#include <iostream> + +using namespace std; + +int main(int argc, char** argv) +{ + cout << TEST1 << endl; + cout << TEST2 << endl; + cout << TEST3 << endl; + cout << TEST4 << endl; + cout << TEST5 << endl; + cout << TEST6 << endl; + return 0; +} diff --git a/tests/apis/add_defines/test.lua b/tests/apis/add_defines/test.lua new file mode 100644 index 000000000..a4a38b0ce --- /dev/null +++ b/tests/apis/add_defines/test.lua @@ -0,0 +1,3 @@ +function main() + os.exec("xmake") +end diff --git a/tests/apis/add_defines/xmake.lua b/tests/apis/add_defines/xmake.lua new file mode 100644 index 000000000..1e00f4f62 --- /dev/null +++ b/tests/apis/add_defines/xmake.lua @@ -0,0 +1,10 @@ +add_rules("mode.debug", "mode.release") + +target("test") + set_kind("binary") + add_files("src/*.cpp") + add_defines("TEST1=\"hello\"") + add_defines("TEST2=\"hello xmake\"") + add_defines("TEST3=3") + add_cxflags("-DTEST4=\"hello\"") + add_cxflags("-DTEST5=\"hello xmake\" -DTEST6=3") diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua index 407421a5c..2b26cd939 100644 --- a/tests/modules/os/test.lua +++ b/tests/modules/os/test.lua @@ -63,25 +63,51 @@ end function test_argv(t) t:are_equal(os.argv(""), {}) + -- $cli aa bb cc t:are_equal(os.argv("aa bb cc"), {"aa", "bb", "cc"}) + -- $cli aa --bb=bbb -c t:are_equal(os.argv("aa --bb=bbb -c"), {"aa", "--bb=bbb", "-c"}) - t:are_equal(os.argv("\"aa bb cc\" dd"), {"aa bb cc", "dd"}) - t:are_equal(os.argv("\"aa(bb)cc\" dd"), {"aa(bb)cc", "dd"}) - t:are_equal(os.argv("aa\\bb/cc dd"), {"aa\\bb/cc", "dd"}) - t:are_equal(os.argv("\"aa\\\\bb/cc dd\" ee"), {"aa\\bb/cc dd", "ee"}) - t:are_equal(os.argv("\"aa\\\\bb/cc (dd)\" ee"), {"aa\\bb/cc (dd)", "ee"}) - t:are_equal(os.argv("-D__prefix__=\\\"tbox\\\""), {"-D__prefix__=\"tbox\""}) + -- $cli "aa bb cc" dd + t:are_equal(os.argv('"aa bb cc" dd'), {"aa bb cc", "dd"}) + -- $cli aa(bb)cc dd + t:are_equal(os.argv('"aa(bb)cc" dd'), {"aa(bb)cc", "dd"}) + -- $cli aa\\bb/cc dd + t:are_equal(os.argv('aa\\bb/cc dd'), {"aa\\bb/cc", "dd"}) + -- $cli "aa\\bb/cc dd" ee + t:are_equal(os.argv('"aa\\\\bb/cc dd" ee'), {"aa\\bb/cc dd", "ee"}) + -- $cli "aa\\bb/cc (dd)" ee + t:are_equal(os.argv('"aa\\\\bb/cc (dd)" ee'), {"aa\\bb/cc (dd)", "ee"}) + -- $cli -DTEST=\"hello\" + t:are_equal(os.argv('-DTEST=\\"hello\\"'), {'-DTEST="hello"'}) + -- $cli -DTEST=\"hello\" -DTEST=\"hello\" + t:are_equal(os.argv('-DTEST=\\"hello\\" -DTEST2=\\"hello\\"'), {'-DTEST="hello"', '-DTEST2="hello"'}) + -- $cli -DTEST="hello" + t:are_equal(os.argv('-DTEST="hello"'), {'-DTEST=hello'}) + -- $cli -DTEST="hello world" + t:are_equal(os.argv('-DTEST="hello world"'), {'-DTEST=hello world'}) + -- $cli -DTEST=\"hello world\" + t:are_equal(os.argv('-DTEST=\\"hello world\\"'), {'-DTEST="hello', 'world\"'}) + -- $cli "-DTEST=\"hello world\"" "-DTEST2="\hello world2\"" + t:are_equal(os.argv('"-DTEST=\\\"hello world\\\"" "-DTEST2=\\\"hello world2\\\""'), {'-DTEST="hello world"', '-DTEST2="hello world2"'}) + -- $cli '-DTEST="hello world"' '-DTEST2="hello world2"' + t:are_equal(os.argv("'-DTEST=\"hello world\"' '-DTEST2=\"hello world2\"'"), {'-DTEST="hello world"', '-DTEST2="hello world2"'}) + -- only split + t:are_equal(os.argv('-DTEST="hello world"', {splitonly = true}), {'-DTEST="hello world"'}) + t:are_equal(os.argv('-DTEST="hello world" -DTEST2="hello world2"', {splitonly = true}), {'-DTEST="hello world"', '-DTEST2="hello world2"'}) end function test_args(t) t:are_equal(os.args({}), "") t:are_equal(os.args({"aa", "bb", "cc"}), "aa bb cc") t:are_equal(os.args({"aa", "--bb=bbb", "-c"}), "aa --bb=bbb -c") - t:are_equal(os.args({"aa bb cc", "dd"}), "\"aa bb cc\" dd") - t:are_equal(os.args({"aa(bb)cc", "dd"}), "\"aa(bb)cc\" dd") + t:are_equal(os.args({"aa bb cc", "dd"}), '"aa bb cc" dd') + t:are_equal(os.args({"aa(bb)cc", "dd"}), '"aa(bb)cc" dd') t:are_equal(os.args({"aa\\bb/cc", "dd"}), "aa\\bb/cc dd") - t:are_equal(os.args({"aa\\bb/cc dd", "ee"}), "\"aa\\\\bb/cc dd\" ee") - t:are_equal(os.args({"aa\\bb/cc (dd)", "ee"}), "\"aa\\\\bb/cc (dd)\" ee") - t:are_equal(os.args("-D__prefix__=\"tbox\""), "-D__prefix__=\\\"tbox\\\"") + t:are_equal(os.args({"aa\\bb/cc dd", "ee"}), '"aa\\\\bb/cc dd" ee') + t:are_equal(os.args({"aa\\bb/cc (dd)", "ee"}), '"aa\\\\bb/cc (dd)" ee') t:are_equal(os.args({"aa\\bb/cc", "dd"}, {escape = true}), "aa\\\\bb/cc dd") + t:are_equal(os.args('-DTEST="hello"'), '-DTEST=\\"hello\\"') + t:are_equal(os.args({'-DTEST="hello"', '-DTEST2="hello"'}), '-DTEST=\\"hello\\" -DTEST2=\\"hello\\"') + t:are_equal(os.args('-DTEST=hello'), '-DTEST=hello') -- irreversible + t:are_equal(os.args({'-DTEST="hello world"', '-DTEST2="hello world2"'}), '"-DTEST=\\\"hello world\\\"" "-DTEST2=\\\"hello world2\\\""') end diff --git a/tests/modules/scheduler/runjobs.lua b/tests/modules/scheduler/runjobs.lua index 8659ef6ef..aea365241 100644 --- a/tests/modules/scheduler/runjobs.lua +++ b/tests/modules/scheduler/runjobs.lua @@ -28,11 +28,11 @@ function main() for i = 1, 3 do local job = jobs:addjob("job/" .. i, function (idx, total) _jobfunc(idx, total) - end, root) + end, {rootjob = root}) for j = 1, 50 do jobs:addjob("job/" .. i .. "/" .. j, function (idx, total) _jobfunc(idx, total) - end, job) + end, {rootjob = job}) end end t = os.mclock() diff --git a/tests/projects/bpf/minimal/src/minimal.bpf.c b/tests/projects/bpf/minimal/src/minimal.bpf.c new file mode 100644 index 000000000..ea1eeefbb --- /dev/null +++ b/tests/projects/bpf/minimal/src/minimal.bpf.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* Copyright (c) 2020 Facebook */ +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> + +char LICENSE[] SEC("license") = "Dual BSD/GPL"; + +int my_pid = 0; + +SEC("tp/syscalls/sys_enter_write") +int handle_tp(void *ctx) +{ + int pid = bpf_get_current_pid_tgid() >> 32; + + if (pid != my_pid) + return 0; + + bpf_printk("BPF triggered from PID %d.\n", pid); + + return 0; +} diff --git a/tests/projects/bpf/minimal/src/minimal.c b/tests/projects/bpf/minimal/src/minimal.c new file mode 100644 index 000000000..4b6ec3181 --- /dev/null +++ b/tests/projects/bpf/minimal/src/minimal.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +/* Copyright (c) 2020 Facebook */ +#include <stdio.h> +#include <unistd.h> +#include <sys/resource.h> +#include <bpf/libbpf.h> +#include "minimal.skel.h" + +static int libbpf_print_fn(enum libbpf_print_level level, const char *format, va_list args) +{ + return vfprintf(stderr, format, args); +} + +static void bump_memlock_rlimit(void) +{ + struct rlimit rlim_new = { + .rlim_cur = RLIM_INFINITY, + .rlim_max = RLIM_INFINITY, + }; + + if (setrlimit(RLIMIT_MEMLOCK, &rlim_new)) { + fprintf(stderr, "Failed to increase RLIMIT_MEMLOCK limit!\n"); + exit(1); + } +} + +int main(int argc, char **argv) +{ + struct minimal_bpf *skel; + int err; + + /* Set up libbpf errors and debug info callback */ + libbpf_set_print(libbpf_print_fn); + + /* Bump RLIMIT_MEMLOCK to allow BPF sub-system to do anything */ + bump_memlock_rlimit(); + + /* Open BPF application */ + skel = minimal_bpf__open(); + if (!skel) { + fprintf(stderr, "Failed to open BPF skeleton\n"); + return 1; + } + + /* ensure BPF program only handles write() syscalls from our process */ + skel->bss->my_pid = getpid(); + + /* Load & verify BPF programs */ + err = minimal_bpf__load(skel); + if (err) { + fprintf(stderr, "Failed to load and verify BPF skeleton\n"); + goto cleanup; + } + + /* Attach tracepoint handler */ + err = minimal_bpf__attach(skel); + if (err) { + fprintf(stderr, "Failed to attach BPF skeleton\n"); + goto cleanup; + } + + printf("Successfully started!\n"); + + for (;;) { + /* trigger our BPF program */ + fprintf(stderr, "."); + sleep(1); + } + +cleanup: + minimal_bpf__destroy(skel); + return -err; +} diff --git a/tests/projects/bpf/minimal/test.lua b/tests/projects/bpf/minimal/test.lua new file mode 100644 index 000000000..2856a3831 --- /dev/null +++ b/tests/projects/bpf/minimal/test.lua @@ -0,0 +1,6 @@ +function main(t) + if is_host("linux") and os.arch() == "x86_64" then + os.vrun("xmake f -y -p android -vD") + os.vrun("xmake -y -vD") + end +end diff --git a/tests/projects/bpf/minimal/xmake.lua b/tests/projects/bpf/minimal/xmake.lua new file mode 100644 index 000000000..8507b8aa1 --- /dev/null +++ b/tests/projects/bpf/minimal/xmake.lua @@ -0,0 +1,19 @@ +add_rules("mode.release", "mode.debug") +add_rules("platform.linux.bpf") + +add_requires("linux-tools", {configs = {bpftool = true}}) +add_requires("libbpf") +if is_plat("android") then + add_requires("ndk >=22.x") + set_toolchains("@ndk", {sdkver = "23"}) +else + add_requires("llvm >=10.x") + set_toolchains("@llvm") + add_requires("linux-headers") +end + +target("minimal") + set_kind("binary") + add_files("src/*.c") + add_packages("linux-tools", "linux-headers", "libbpf") + set_license("GPL-2.0") diff --git a/tests/projects/c++/capnproto/proto/message.capnp b/tests/projects/c++/capnproto/proto/message.capnp new file mode 100644 index 000000000..7109294ed --- /dev/null +++ b/tests/projects/c++/capnproto/proto/message.capnp @@ -0,0 +1,8 @@ +@0xd30600b3651feef7; + +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("test::proto"); + +struct Message { + text @0 :Text; +} diff --git a/tests/projects/c++/capnproto/src/main.cc b/tests/projects/c++/capnproto/src/main.cc new file mode 100644 index 000000000..8145c6cba --- /dev/null +++ b/tests/projects/c++/capnproto/src/main.cc @@ -0,0 +1,7 @@ +#include <capnp/message.h> +#include "message.capnp.h" + +int main() { + capnp::MallocMessageBuilder builder; + // test::proto::Message msg; +} diff --git a/tests/projects/c++/capnproto/xmake.lua b/tests/projects/c++/capnproto/xmake.lua new file mode 100644 index 000000000..d4859dabb --- /dev/null +++ b/tests/projects/c++/capnproto/xmake.lua @@ -0,0 +1,9 @@ +add_rules("mode.debug", "mode.release") +add_requires("capnproto") + +target("test") + set_kind("binary") + set_languages("c++14") + add_packages("capnproto") + add_files("src/**.cc") + add_files("proto/*.capnp", {rules = "capnproto.cpp", capnp_rootdir = "proto"}) diff --git a/tests/projects/c++/manifest/src/main.cpp b/tests/projects/c++/manifest/src/main.cpp new file mode 100644 index 000000000..db2361659 --- /dev/null +++ b/tests/projects/c++/manifest/src/main.cpp @@ -0,0 +1,9 @@ +#include <iostream> + +using namespace std; + +int main(int argc, char** argv) +{ + cout << "hello world!" << endl; + return 0; +} diff --git a/tests/projects/c++/manifest/src/main.manifest b/tests/projects/c++/manifest/src/main.manifest new file mode 100644 index 000000000..1c06b6190 --- /dev/null +++ b/tests/projects/c++/manifest/src/main.manifest @@ -0,0 +1,10 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
+<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level='asInvoker' uiAccess='false' />
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+</assembly>
diff --git a/tests/projects/c++/manifest/xmake.lua b/tests/projects/c++/manifest/xmake.lua new file mode 100644 index 000000000..121530a0c --- /dev/null +++ b/tests/projects/c++/manifest/xmake.lua @@ -0,0 +1,6 @@ +add_rules("mode.debug", "mode.release") +target("test") + set_kind("binary") + add_files("src/*.cpp") + add_files("src/*.manifest") + diff --git a/tests/projects/c++/shared_library_export_all/src/foo.cpp b/tests/projects/c++/shared_library_export_all/src/foo.cpp new file mode 100644 index 000000000..3ab50856c --- /dev/null +++ b/tests/projects/c++/shared_library_export_all/src/foo.cpp @@ -0,0 +1,6 @@ +#include "foo.h" + +int test::add(int a, int b) +{ + return a + b; +} diff --git a/tests/projects/c++/shared_library_export_all/src/foo.h b/tests/projects/c++/shared_library_export_all/src/foo.h new file mode 100644 index 000000000..f671c7d32 --- /dev/null +++ b/tests/projects/c++/shared_library_export_all/src/foo.h @@ -0,0 +1,5 @@ +class test +{ +public: + static int add(int a, int b); +}; diff --git a/tests/projects/c++/shared_library_export_all/src/main.cpp b/tests/projects/c++/shared_library_export_all/src/main.cpp new file mode 100644 index 000000000..e48f4730e --- /dev/null +++ b/tests/projects/c++/shared_library_export_all/src/main.cpp @@ -0,0 +1,10 @@ +#include "foo.h" +#include <iostream> + +using namespace std; + +int main(int argc, char** argv) +{ + cout << "add(1, 2) = " << test::add(1, 2) << endl; + return 0; +} diff --git a/tests/projects/c++/shared_library_export_all/test.lua b/tests/projects/c++/shared_library_export_all/test.lua new file mode 100644 index 000000000..b76241be2 --- /dev/null +++ b/tests/projects/c++/shared_library_export_all/test.lua @@ -0,0 +1,6 @@ +-- main entry +function main(t) + + -- build project + t:build() +end diff --git a/tests/projects/c++/shared_library_export_all/xmake.lua b/tests/projects/c++/shared_library_export_all/xmake.lua new file mode 100644 index 000000000..fa25fac50 --- /dev/null +++ b/tests/projects/c++/shared_library_export_all/xmake.lua @@ -0,0 +1,13 @@ +add_rules("mode.debug", "mode.release") + +target("foo") + set_kind("shared") + add_files("src/foo.cpp") + add_rules("utils.symbols.export_all", {export_classes = true}) + +target("demo") + set_kind("binary") + add_deps("foo") + add_files("src/main.cpp") + + diff --git a/tests/projects/c/Unicode 测试/test.lua b/tests/projects/c/Unicode 测试/test.lua Binary files differindex fecba70e1..b9209fbf4 100644 --- a/tests/projects/c/Unicode 测试/test.lua +++ b/tests/projects/c/Unicode 测试/test.lua diff --git a/tests/projects/c/Unicode 测试/xmake.lua b/tests/projects/c/Unicode 测试/xmake.lua Binary files differindex b34cdfd3d..224b17d0a 100644 --- a/tests/projects/c/Unicode 测试/xmake.lua +++ b/tests/projects/c/Unicode 测试/xmake.lua diff --git a/tests/projects/c/shared_library/src/foo.c b/tests/projects/c/shared_library/src/foo.c new file mode 100644 index 000000000..08054d059 --- /dev/null +++ b/tests/projects/c/shared_library/src/foo.c @@ -0,0 +1,6 @@ +#include "foo.h" + +int add(int a, int b) +{ + return a + b; +} diff --git a/tests/projects/c/shared_library/src/interface.h b/tests/projects/c/shared_library/src/foo.h index ef24ba3ce..073fb68d7 100644 --- a/tests/projects/c/shared_library/src/interface.h +++ b/tests/projects/c/shared_library/src/foo.h @@ -10,13 +10,6 @@ extern "C" { # define __export #endif -/*! calculate add(a, b) - * - * @param a the first argument - * @param b the second argument - * - * @return the result - */ __export int add(int a, int b); #ifdef __cplusplus diff --git a/tests/projects/c/shared_library/src/test.c b/tests/projects/c/shared_library/src/main.c index 9505a2f75..1e52e7a81 100644 --- a/tests/projects/c/shared_library/src/test.c +++ b/tests/projects/c/shared_library/src/main.c @@ -1,4 +1,4 @@ -#include "interface.h" +#include "foo.h" #include <stdio.h> int main(int argc, char** argv) diff --git a/tests/projects/c/shared_library/test.lua b/tests/projects/c/shared_library/test.lua index b76241be2..b57362078 100644 --- a/tests/projects/c/shared_library/test.lua +++ b/tests/projects/c/shared_library/test.lua @@ -1,6 +1,3 @@ --- main entry function main(t) - - -- build project t:build() end diff --git a/tests/projects/c/shared_library/xmake.lua b/tests/projects/c/shared_library/xmake.lua index 6507658c6..664e2d4eb 100644 --- a/tests/projects/c/shared_library/xmake.lua +++ b/tests/projects/c/shared_library/xmake.lua @@ -1,12 +1,12 @@ add_rules("mode.release", "mode.debug") -target("shared_library_c") +target("foo") set_kind("shared") - add_files("src/interface.c") + add_files("src/foo.c") target("test") set_kind("binary") - add_deps("shared_library_c") - add_files("src/test.c") + add_deps("foo") + add_files("src/main.c") diff --git a/tests/projects/c/shared_library_export_all/src/bar.cpp b/tests/projects/c/shared_library_export_all/src/bar.cpp new file mode 100644 index 000000000..9fdeca569 --- /dev/null +++ b/tests/projects/c/shared_library_export_all/src/bar.cpp @@ -0,0 +1,13 @@ +#include <stdio.h> + +class bar +{ + bar() {} + ~bar() {} + void test() {} +}; + +void test(bar& b) +{ + printf("test\n"); +} diff --git a/tests/projects/c/shared_library_export_all/src/foo.c b/tests/projects/c/shared_library_export_all/src/foo.c new file mode 100644 index 000000000..08054d059 --- /dev/null +++ b/tests/projects/c/shared_library_export_all/src/foo.c @@ -0,0 +1,6 @@ +#include "foo.h" + +int add(int a, int b) +{ + return a + b; +} diff --git a/tests/projects/c/shared_library_export_all/src/foo.h b/tests/projects/c/shared_library_export_all/src/foo.h new file mode 100644 index 000000000..d2506bca9 --- /dev/null +++ b/tests/projects/c/shared_library_export_all/src/foo.h @@ -0,0 +1,9 @@ +#ifdef __cplusplus +extern "C" { +#endif + +int add(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/tests/projects/c/shared_library_export_all/src/main.c b/tests/projects/c/shared_library_export_all/src/main.c new file mode 100644 index 000000000..1e52e7a81 --- /dev/null +++ b/tests/projects/c/shared_library_export_all/src/main.c @@ -0,0 +1,8 @@ +#include "foo.h" +#include <stdio.h> + +int main(int argc, char** argv) +{ + printf("add(1, 2) = %d\n", add(1, 2)); + return 0; +} diff --git a/tests/projects/c/shared_library_export_all/test.lua b/tests/projects/c/shared_library_export_all/test.lua new file mode 100644 index 000000000..b57362078 --- /dev/null +++ b/tests/projects/c/shared_library_export_all/test.lua @@ -0,0 +1,3 @@ +function main(t) + t:build() +end diff --git a/tests/projects/c/shared_library_export_all/xmake.lua b/tests/projects/c/shared_library_export_all/xmake.lua new file mode 100644 index 000000000..6466a16fc --- /dev/null +++ b/tests/projects/c/shared_library_export_all/xmake.lua @@ -0,0 +1,13 @@ +add_rules("mode.release", "mode.debug") + +target("foo") + set_kind("shared") + add_files("src/foo.c", "src/bar.cpp") + add_rules("utils.symbols.export_all", {class = true}) + +target("test") + set_kind("binary") + add_deps("foo") + add_files("src/main.c") + + diff --git a/tests/projects/c/static library with spaces/s r c/interface.h b/tests/projects/c/static library with spaces/i n c/interface.h index 10ec0f856..10ec0f856 100644 --- a/tests/projects/c/static library with spaces/s r c/interface.h +++ b/tests/projects/c/static library with spaces/i n c/interface.h diff --git a/tests/projects/c/static library with spaces/i n c/stdafx.h b/tests/projects/c/static library with spaces/i n c/stdafx.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/projects/c/static library with spaces/i n c/stdafx.h diff --git a/tests/projects/c/static library with spaces/xmake.lua b/tests/projects/c/static library with spaces/xmake.lua index 3febc19f3..ac93d8441 100644 --- a/tests/projects/c/static library with spaces/xmake.lua +++ b/tests/projects/c/static library with spaces/xmake.lua @@ -3,11 +3,12 @@ add_rules("mode.release", "mode.debug") target("test") set_kind("static") add_files("s r c/interface.c") - add_includedirs("$(projectdir)/s r c", {public = true}) + add_sysincludedirs("$(projectdir)/i n c", {public = true}) target("demo") set_kind("binary") add_deps("test") add_files("s r c/test.c") + set_pcheader("$(projectdir)/i n c/stdafx.h") diff --git a/tests/projects/dlang/console/test.lua b/tests/projects/dlang/console/test.lua index c1bac30ee..92168a8c1 100644 --- a/tests/projects/dlang/console/test.lua +++ b/tests/projects/dlang/console/test.lua @@ -2,7 +2,7 @@ function main(t) -- build project - if os.host() == "macosx" then + if is_host("macosx") and os.arch() ~= "arm64" then t:build() else return t:skip("wrong host platform") diff --git a/tests/projects/dlang/shared_library/test.lua b/tests/projects/dlang/shared_library/test.lua index c1bac30ee..92168a8c1 100644 --- a/tests/projects/dlang/shared_library/test.lua +++ b/tests/projects/dlang/shared_library/test.lua @@ -2,7 +2,7 @@ function main(t) -- build project - if os.host() == "macosx" then + if is_host("macosx") and os.arch() ~= "arm64" then t:build() else return t:skip("wrong host platform") diff --git a/tests/projects/dlang/static_library/test.lua b/tests/projects/dlang/static_library/test.lua index c1bac30ee..92168a8c1 100644 --- a/tests/projects/dlang/static_library/test.lua +++ b/tests/projects/dlang/static_library/test.lua @@ -2,7 +2,7 @@ function main(t) -- build project - if os.host() == "macosx" then + if is_host("macosx") and os.arch() ~= "arm64" then t:build() else return t:skip("wrong host platform") diff --git a/tests/projects/go/console/test.lua b/tests/projects/go/console/test.lua index c1bac30ee..92168a8c1 100644 --- a/tests/projects/go/console/test.lua +++ b/tests/projects/go/console/test.lua @@ -2,7 +2,7 @@ function main(t) -- build project - if os.host() == "macosx" then + if is_host("macosx") and os.arch() ~= "arm64" then t:build() else return t:skip("wrong host platform") diff --git a/tests/projects/go/static_library/test.lua b/tests/projects/go/static_library/test.lua index c1bac30ee..92168a8c1 100644 --- a/tests/projects/go/static_library/test.lua +++ b/tests/projects/go/static_library/test.lua @@ -2,7 +2,7 @@ function main(t) -- build project - if os.host() == "macosx" then + if is_host("macosx") and os.arch() ~= "arm64" then t:build() else return t:skip("wrong host platform") diff --git a/tests/projects/hybrid/static_library/test.lua b/tests/projects/hybrid/static_library/test.lua index b76241be2..5cad49b73 100644 --- a/tests/projects/hybrid/static_library/test.lua +++ b/tests/projects/hybrid/static_library/test.lua @@ -1,6 +1,6 @@ --- main entry function main(t) - - -- build project + if is_host("macosx") and os.arch() == "arm64" then + return + end t:build() end diff --git a/tests/projects/other/multiplats_vs/test.lua b/tests/projects/other/multiplats_vs/test.lua index 795df5c95..e0f60487b 100644 --- a/tests/projects/other/multiplats_vs/test.lua +++ b/tests/projects/other/multiplats_vs/test.lua @@ -1,6 +1,6 @@ function test_multivs(t) if is_subhost("windows") then - t:build() + t:build() else return t:skip("wrong host platform") end diff --git a/tests/projects/package/basic/src/main.c b/tests/projects/package/basic/src/main.c index 9ae580511..740b34694 100755 --- a/tests/projects/package/basic/src/main.c +++ b/tests/projects/package/basic/src/main.c @@ -1,7 +1,12 @@ #include <stdio.h> +#include <pcre2.h> + +int test(); int main(int argc, char** argv) { printf("hello world!\n"); + pcre2_compile(0, 0, 0, 0, 0, 0); + test(); return 0; } diff --git a/tests/projects/package/basic/src/test.c b/tests/projects/package/basic/src/test.c new file mode 100644 index 000000000..e711dd197 --- /dev/null +++ b/tests/projects/package/basic/src/test.c @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <pcre2.h> + +int test() +{ + printf("hello world!\n"); + pcre2_compile(0, 0, 0, 0, 0, 0); + return 0; +} + diff --git a/tests/projects/package/basic/test.lua b/tests/projects/package/basic/test.lua index a4b905689..4964fecaa 100644 --- a/tests/projects/package/basic/test.lua +++ b/tests/projects/package/basic/test.lua @@ -1,7 +1,12 @@ --- main entry function main(t) - -- TODO - -- build project --- t:build() + -- freebsd ci is slower + if is_host("bsd") then + return + end + + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end end diff --git a/tests/projects/package/basic/xmake.lua b/tests/projects/package/basic/xmake.lua index b71a22c1d..0cf08600c 100644 --- a/tests/projects/package/basic/xmake.lua +++ b/tests/projects/package/basic/xmake.lua @@ -1,11 +1,17 @@ add_requires("tbox master", {debug = true}) add_requires("zlib >=1.2.11") -add_requires("pcre2", "luajit", {system = false, optional = true}) +add_requires("pcre2", {system = false, optional = true}) add_rules("mode.debug", "mode.release") +target("test") + set_kind("static") + add_files("src/test.c") + add_packages("pcre2", {public = true}) + target("console") set_kind("binary") - add_files("src/*.c") - add_packages("tbox", "zlib", "pcre2", "luajit") + add_deps("test") + add_files("src/main.c") + add_packages("tbox", "zlib") diff --git a/tests/projects/package/depconfigs/src/main.c b/tests/projects/package/depconfigs/src/main.c new file mode 100755 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/package/depconfigs/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/depconfigs/test.lua b/tests/projects/package/depconfigs/test.lua new file mode 100644 index 000000000..a6690754b --- /dev/null +++ b/tests/projects/package/depconfigs/test.lua @@ -0,0 +1,10 @@ +function main(t) + -- freebsd ci is slower + if is_host("bsd") then + return + end + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end +end diff --git a/tests/projects/package/depconfigs/xmake.lua b/tests/projects/package/depconfigs/xmake.lua new file mode 100644 index 000000000..c76e92df5 --- /dev/null +++ b/tests/projects/package/depconfigs/xmake.lua @@ -0,0 +1,55 @@ +add_requires("libpng", "libtiff", {system = false, configs = {vs_runtime = "MD"}}) +add_requires("libwebp") + +add_requireconfs("libwebp", {system = false, configs = {shared = true, vs_runtime = "MD"}}) +add_requireconfs("libpng.zlib", {system = false, override = true, configs = {cxflags = "-DTEST1"}, version = "1.2.10"}) +add_requireconfs("libtiff.*|cmake", {system = false, configs = {cxflags = "-DTEST2"}}) +add_requireconfs("libwebp.**|cmake", {system = false, configs = {cxflags = "-DTEST3"}}) + +target("test") + set_kind("binary") + add_files("src/*.c") + add_packages("libpng") + before_build(function (target) + if target:pkg("libpng") then + local found + for _, linkdir in ipairs(target:pkg("libpng"):get("linkdirs")) do + if linkdir:find("zlib[/\\]1%.2%.10") then + found = true + end + end + assert(found, "package(zlib 1.2.10) not found!") + end + end) + +target("test2") + set_kind("binary") + add_files("src/*.c") + add_packages("libtiff") + before_build(function (target) + if target:pkg("libtiff") then + local found + for _, linkdir in ipairs(target:pkg("libtiff"):get("linkdirs")) do + if linkdir:find("zlib", 1, true) then + found = true + end + end + assert(found, "package(zlib) not found!") + end + end) + +target("test3") + set_kind("binary") + add_files("src/*.c") + add_packages("libwebp") + before_build(function (target) + if target:pkg("libwebp") then + local found + for _, linkdir in ipairs(target:pkg("libwebp"):get("linkdirs")) do + if linkdir:find("zlib", 1, true) then + found = true + end + end + assert(found, "package(zlib) not found!") + end + end) diff --git a/tests/projects/package/multiconfig/test.lua b/tests/projects/package/multiconfig/test.lua index a4b905689..a6690754b 100644 --- a/tests/projects/package/multiconfig/test.lua +++ b/tests/projects/package/multiconfig/test.lua @@ -1,7 +1,10 @@ --- main entry function main(t) - - -- TODO - -- build project --- t:build() + -- freebsd ci is slower + if is_host("bsd") then + return + end + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end end diff --git a/tests/projects/package/multiconfig/xmake.lua b/tests/projects/package/multiconfig/xmake.lua index 48d64da13..09121e8d2 100644 --- a/tests/projects/package/multiconfig/xmake.lua +++ b/tests/projects/package/multiconfig/xmake.lua @@ -11,7 +11,7 @@ target("test1") target("test2") set_kind("binary") add_files("src/*.c") - add_packages("zlib#debug") + add_packages("zlib~debug") target("test3") set_kind("binary") diff --git a/tests/projects/package/rootconfigs/src/main.c b/tests/projects/package/rootconfigs/src/main.c new file mode 100755 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/package/rootconfigs/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/rootconfigs/test.lua b/tests/projects/package/rootconfigs/test.lua new file mode 100644 index 000000000..a6690754b --- /dev/null +++ b/tests/projects/package/rootconfigs/test.lua @@ -0,0 +1,10 @@ +function main(t) + -- freebsd ci is slower + if is_host("bsd") then + return + end + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end +end diff --git a/tests/projects/package/rootconfigs/xmake.lua b/tests/projects/package/rootconfigs/xmake.lua new file mode 100644 index 000000000..3e395ab7b --- /dev/null +++ b/tests/projects/package/rootconfigs/xmake.lua @@ -0,0 +1,7 @@ +add_requireconfs("*", {system = false, configs = {debug = false}}) +add_requires("zlib", {system = false, debug = true}) + +target("test") + set_kind("binary") + add_files("src/*.c") + add_packages("zlib") diff --git a/tests/projects/package/toolchain_gnu_rm/src/main.c b/tests/projects/package/toolchain_gnu_rm/src/main.c new file mode 100644 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/package/toolchain_gnu_rm/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_gnu_rm/xmake.lua b/tests/projects/package/toolchain_gnu_rm/xmake.lua new file mode 100644 index 000000000..0857f6b90 --- /dev/null +++ b/tests/projects/package/toolchain_gnu_rm/xmake.lua @@ -0,0 +1,7 @@ +add_rules("mode.debug", "mode.release") +add_requires("gnu-rm") + +target("test") + set_kind("binary") + add_files("src/*.c") + set_toolchains("@gnu-rm") diff --git a/tests/projects/package/toolchain_llvm/src/main.c b/tests/projects/package/toolchain_llvm/src/main.c new file mode 100644 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/package/toolchain_llvm/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_llvm/xmake.lua b/tests/projects/package/toolchain_llvm/xmake.lua new file mode 100644 index 000000000..974430856 --- /dev/null +++ b/tests/projects/package/toolchain_llvm/xmake.lua @@ -0,0 +1,7 @@ +add_rules("mode.debug", "mode.release") +add_requires("llvm 11.0.0", {alias = "llvm-11"}) + +target("test") + set_kind("binary") + add_files("src/*.c") + set_toolchains("llvm@llvm-11") diff --git a/tests/projects/package/toolchain_llvm_mingw/src/main.c b/tests/projects/package/toolchain_llvm_mingw/src/main.c new file mode 100644 index 000000000..9ae580511 --- /dev/null +++ b/tests/projects/package/toolchain_llvm_mingw/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_llvm_mingw/xmake.lua b/tests/projects/package/toolchain_llvm_mingw/xmake.lua new file mode 100644 index 000000000..da5c71225 --- /dev/null +++ b/tests/projects/package/toolchain_llvm_mingw/xmake.lua @@ -0,0 +1,7 @@ +add_rules("mode.debug", "mode.release") +add_requires("llvm-mingw") + +target("test") + set_kind("binary") + add_files("src/*.c") + set_toolchains("mingw@llvm-mingw") diff --git a/tests/projects/package/toolchain_muslcc/src/main.c b/tests/projects/package/toolchain_muslcc/src/main.c new file mode 100644 index 000000000..6331557e6 --- /dev/null +++ b/tests/projects/package/toolchain_muslcc/src/main.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdint.h> +#include <zlib.h> +#include <ogg/ogg.h> +#ifdef HAVE_LIBPLIST +# include <plist/plist.h> +#endif + +int main(int argc, char** argv) +{ + printf("hello world!\n"); + inflate(0, 0); + ogg_sync_init(0); +#ifdef HAVE_LIBPLIST + plist_new_dict(); +#endif + return 0; +} diff --git a/tests/projects/package/toolchain_muslcc/test.lua b/tests/projects/package/toolchain_muslcc/test.lua new file mode 100644 index 000000000..4964fecaa --- /dev/null +++ b/tests/projects/package/toolchain_muslcc/test.lua @@ -0,0 +1,12 @@ +function main(t) + + -- freebsd ci is slower + if is_host("bsd") then + return + end + + -- only for x86/x64, because it will take too long time on ci with arm/mips + if os.subarch():startswith("x") or os.subarch() == "i386" then + t:build() + end +end diff --git a/tests/projects/package/toolchain_muslcc/xmake.lua b/tests/projects/package/toolchain_muslcc/xmake.lua new file mode 100644 index 000000000..bf5e98e8c --- /dev/null +++ b/tests/projects/package/toolchain_muslcc/xmake.lua @@ -0,0 +1,26 @@ +add_rules("mode.debug", "mode.release") + +-- set cross-compliation platform +set_plat("cross") +set_arch("arm") + +-- add library packages +-- for testing zlib/xmake, libplist/autoconf, libogg/cmake +add_requires("zlib", "libogg", {system = false}) +if is_host("macosx", "linux", "bsd") then + add_requires("libplist", {system = false}) +end + +-- add toolchains package +add_requires("muslcc") + +-- set global toolchains for target and packages +set_toolchains("@muslcc") + +target("test") + set_kind("binary") + add_files("src/*.c") + add_packages("zlib", "libplist", "libogg") + if has_package("libplist") then + add_defines("HAVE_LIBPLIST") + end 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/tests/projects/package/toolchain_zig/src/main.zig b/tests/projects/package/toolchain_zig/src/main.zig new file mode 100644 index 000000000..56b206650 --- /dev/null +++ b/tests/projects/package/toolchain_zig/src/main.zig @@ -0,0 +1,6 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + try stdout.print("Hello, {}!\n", .{"world"}); +} diff --git a/tests/projects/package/toolchain_zig/xmake.lua b/tests/projects/package/toolchain_zig/xmake.lua new file mode 100644 index 000000000..330c09640 --- /dev/null +++ b/tests/projects/package/toolchain_zig/xmake.lua @@ -0,0 +1,8 @@ +add_rules("mode.debug", "mode.release") +add_requires("zig 0.7.x") + +target("test") + set_kind("binary") + add_files("src/*.zig") + set_toolchains("@zig") + diff --git a/tests/projects/rust/console/test.lua b/tests/projects/rust/console/test.lua index c1bac30ee..92168a8c1 100644 --- a/tests/projects/rust/console/test.lua +++ b/tests/projects/rust/console/test.lua @@ -2,7 +2,7 @@ function main(t) -- build project - if os.host() == "macosx" then + if is_host("macosx") and os.arch() ~= "arm64" then t:build() else return t:skip("wrong host platform") diff --git a/tests/projects/rust/static_library/test.lua b/tests/projects/rust/static_library/test.lua index c1bac30ee..92168a8c1 100644 --- a/tests/projects/rust/static_library/test.lua +++ b/tests/projects/rust/static_library/test.lua @@ -2,7 +2,7 @@ function main(t) -- build project - if os.host() == "macosx" then + if is_host("macosx") and os.arch() ~= "arm64" then t:build() else return t:skip("wrong host platform") diff --git a/tests/projects/zig/console/src/main.zig b/tests/projects/zig/console/src/main.zig index fcfd5e0fa..56b206650 100644 --- a/tests/projects/zig/console/src/main.zig +++ b/tests/projects/zig/console/src/main.zig @@ -1,6 +1,6 @@ const std = @import("std"); pub fn main() !void { - const stdout = std.io.getStdOut().outStream(); + const stdout = std.io.getStdOut().writer(); try stdout.print("Hello, {}!\n", .{"world"}); } diff --git a/tests/projects/zig/shared_library/src/main.zig b/tests/projects/zig/shared_library/src/main.zig index cee64b6b7..2675d4326 100644 --- a/tests/projects/zig/shared_library/src/main.zig +++ b/tests/projects/zig/shared_library/src/main.zig @@ -3,6 +3,6 @@ const std = @import("std"); extern fn add(a: i32, b: i32) i32; pub fn main() !void { - const stdout = std.io.getStdOut().outStream(); + const stdout = std.io.getStdOut().writer(); try stdout.print("Hello, {} - {}!\n", .{"world", add(1, 1)}); } diff --git a/tests/projects/zig/static_library/src/main.zig b/tests/projects/zig/static_library/src/main.zig index cee64b6b7..2675d4326 100644 --- a/tests/projects/zig/static_library/src/main.zig +++ b/tests/projects/zig/static_library/src/main.zig @@ -3,6 +3,6 @@ const std = @import("std"); extern fn add(a: i32, b: i32) i32; pub fn main() !void { - const stdout = std.io.getStdOut().outStream(); + const stdout = std.io.getStdOut().writer(); try stdout.print("Hello, {} - {}!\n", .{"world", add(1, 1)}); } diff --git a/tests/test_utils/test_build.lua b/tests/test_utils/test_build.lua index 44026200b..2a42e67d8 100644 --- a/tests/test_utils/test_build.lua +++ b/tests/test_utils/test_build.lua @@ -9,7 +9,7 @@ function test_build:build(argv) os.exec("xmake g -c") -- generic? - os.exec("xmake f -c") + os.exec("xmake f -c -D -y") os.exec("xmake") os.exec("xmake p -D") if not is_host("windows") then @@ -17,7 +17,7 @@ function test_build:build(argv) os.exec("xmake uninstall --installdir=$(tmpdir) -D") end os.exec("xmake c -D") - os.exec("xmake f --mode=debug -D") + os.exec("xmake f --mode=debug -D -y") os.exec("xmake m -b") os.exec("xmake -r -a -D") os.exec("xmake m -e buildtest") diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua index a5df6dec7..0fc15fd81 100644 --- a/xmake/actions/build/build.lua +++ b/xmake/actions/build/build.lua @@ -28,7 +28,8 @@ import("core.base.hashset") -- clean target for rebuilding function _clean_target(target) - if not target:isphony() then + local targetkind = target:kind() + if targetkind ~= "phony" and targetkind ~= "object" then os.tryrm(target:symbolfile()) os.tryrm(target:targetfile()) end @@ -47,14 +48,14 @@ function _add_batchjobs_builtin(batchjobs, rootjob, target) else job = batchjobs:addjob("rule/" .. r:name() .. "/build", function (index, total) script(target, {progress = (index * 100) / total}) - end, job or rootjob) + end, {rootjob = job or rootjob}) end end end -- uses the builtin target script - if not job and not target:isphony() then - job, job_leaf = import("kinds." .. target:targetkind(), {anonymous = true})(batchjobs, rootjob, target) + if not job and not target:is_phony() then + job, job_leaf = import("kinds." .. target:kind(), {anonymous = true})(batchjobs, rootjob, target) end job = job or rootjob return job, job_leaf or job @@ -75,7 +76,7 @@ function _add_batchjobs(batchjobs, rootjob, target) -- on_build(function (target, batchjobs, opt) -- return batchjobs:addjob("test", function (idx, total) -- print("build it") - -- end, opt.rootjob) + -- end, {rootjob = opt.rootjob}) -- end, {batch = true}) -- job, job_leaf = assert(script(target, batchjobs, {rootjob = rootjob}), "target(%s):on_build(): no returned job!", target:name()) @@ -90,7 +91,7 @@ function _add_batchjobs(batchjobs, rootjob, target) -- job = batchjobs:addjob(target:name() .. "/build", function (index, total) script(target, {progress = (index * 100) / total}) - end, rootjob) + end, {rootjob = rootjob}) end return job, job_leaf or job end @@ -99,12 +100,12 @@ end function _add_batchjobs_for_target(batchjobs, rootjob, target) -- has been disabled? - if target:get("enabled") == false then + if not target:is_enabled() then return end -- add after_build job for target - local oldenvs = {} + local oldenvs local job_after_build = batchjobs:addjob(target:name() .. "/after_build", function (index, total) -- do after_build @@ -120,11 +121,12 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target) end end - -- leave the environments of the target packages - for name, values in pairs(oldenvs) do - os.setenv(name, values) + -- restore environments + if oldenvs then + os.setenvs(oldenvs) end - end, rootjob) + + end, {rootjob = rootjob}) -- add batch jobs for target, @note only on_build script support batch jobs local job_build, job_build_leaf = _add_batchjobs(batchjobs, job_after_build, target) @@ -132,11 +134,8 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target) -- add before_build job for target local job_build_before = batchjobs:addjob(target:name() .. "/before_build", function (index, total) - -- enter the environments of the target packages - for name, values in pairs(target:pkgenvs()) do - oldenvs[name] = os.getenv(name) - os.addenv(name, unpack(values)) - end + -- enter package environments + oldenvs = os.addenvs(target:pkgenvs()) -- clean target if rebuild if option.get("rebuild") and not option.get("dry-run") then @@ -155,7 +154,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target) before_build(target, {progress = progress}) end end - end, job_build_leaf) + end, {rootjob = job_build_leaf}) -- we need do build_before after all dependent targets if across_targets_in_parallel is disabled return target:policy("build.across_targets_in_parallel") == false and job_build_before or job_build, job_after_build @@ -188,8 +187,7 @@ function get_batchjobs(targetname) local depset = hashset.new() local targets = {} for _, target in pairs(project.targets()) do - local default = target:get("default") - if default == nil or default == true or option.get("all") then + if target:is_default() or option.get("all") then for _, depname in ipairs(target:get("deps")) do depset:insert(depname) end diff --git a/xmake/actions/build/build_files.lua b/xmake/actions/build/build_files.lua index 3d0a48e75..dd89ea311 100644 --- a/xmake/actions/build/build_files.lua +++ b/xmake/actions/build/build_files.lua @@ -89,7 +89,7 @@ end function _add_batchjobs_for_target(batchjobs, rootjob, target, filepatterns) -- has been disabled? - if target:get("enabled") == false then + if not target:is_enabled() then return end @@ -124,8 +124,7 @@ function _get_batchjobs(targetname, filepatterns) local depset = hashset.new() local targets = {} for _, target in pairs(project.targets()) do - local default = target:get("default") - if default == nil or default == true or option.get("all") then + if target:is_default() or option.get("all") then for _, depname in ipairs(target:get("deps")) do depset:insert(depname) end @@ -163,11 +162,7 @@ function _get_file_patterns(sourcefiles) local _excludes = {} for _, exclude in ipairs(excludes) do exclude = path.translate(exclude) - exclude = exclude:gsub("([%+%.%-%^%$%(%)%%])", "%%%1") - exclude = exclude:gsub("%*%*", "\001") - exclude = exclude:gsub("%*", "\002") - exclude = exclude:gsub("\001", ".*") - exclude = exclude:gsub("\002", "[^/]*") + exclude = path.pattern(exclude) table.insert(_excludes, exclude) end excludes = _excludes @@ -208,6 +203,8 @@ function main(targetname, sourcefiles) local curdir = os.curdir() runjobs("build_files", batchjobs, {comax = option.get("jobs") or 1, curdir = curdir, count_as_index = true}) os.cd(curdir) + else + wprint("%s not found!", sourcefiles) end end diff --git a/xmake/actions/build/cleaner.lua b/xmake/actions/build/cleaner.lua index 97231e819..0f47ffeb3 100644 --- a/xmake/actions/build/cleaner.lua +++ b/xmake/actions/build/cleaner.lua @@ -26,7 +26,6 @@ import("core.project.config") import("core.project.project") import("core.package.package") import("core.platform.platform") -import("core.platform.environment") -- clean up temporary files once a day function cleanup() @@ -55,7 +54,7 @@ function cleanup() try { function () - process.openv("xmake", argv, {stdout = path.join(os.tmpdir(), "cleaner.log")}, {detach = true}):close() + process.openv("xmake", argv, {stdout = path.join(os.tmpdir(), "cleaner.log"), detach = true}):close() end } end @@ -86,7 +85,7 @@ function main() end -- clean up the previous month package cache files, @see package.cachedir() - local cachedir = path.join(global.cachedir(), "packages", os.date("%y%m", os.time() - 31 * 24 * 3600)) + local cachedir = path.join(package.cachedir({rootonly = true}), os.date("%y%m", os.time() - 31 * 24 * 3600)) if os.isdir(cachedir) and cachedir ~= package.cachedir() then print("cleanup %s ..", cachedir) os.tryrm(cachedir) diff --git a/xmake/actions/build/kinds/binary.lua b/xmake/actions/build/kinds/binary.lua index 45b97a706..dd72fc21a 100644 --- a/xmake/actions/build/kinds/binary.lua +++ b/xmake/actions/build/kinds/binary.lua @@ -31,7 +31,7 @@ import("object", {alias = "add_batchjobs_for_object"}) function _do_link_target(target, opt) -- load linker instance - local linkinst = linker.load(target:targetkind(), target:sourcekinds(), {target = target}) + local linkinst = linker.load(target:kind(), target:sourcekinds(), {target = target}) -- get link flags local linkflags = linkinst:linkflags({target = target}) @@ -42,7 +42,7 @@ function _do_link_target(target, opt) -- need build this target? local depfiles = objectfiles for _, dep in ipairs(target:orderdeps()) do - if dep:targetkind() == "static" then + if dep:kind() == "static" then if depfiles == objectfiles then depfiles = table.copy(objectfiles) end @@ -135,7 +135,7 @@ function main(batchjobs, rootjob, target) -- add link job local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total) _link_target(target, {progress = (index * 100) / total}) - end, rootjob) + end, {rootjob = rootjob}) -- we need only return and depend the link job for each target, -- so we can compile the source files for each target in parallel diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua index baf2d2f11..742311370 100644 --- a/xmake/actions/build/kinds/object.lua +++ b/xmake/actions/build/kinds/object.lua @@ -24,6 +24,7 @@ import("core.project.rule") import("core.project.config") import("core.project.project") import("private.async.runjobs") +import("private.utils.batchcmds") -- add batch jobs for the custom rule function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix) @@ -32,7 +33,7 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix local rulename = assert(sourcebatch.rulename, "unknown rule for sourcebatch!") local ruleinst = assert(project.rule(rulename) or rule.rule(rulename), "unknown rule: %s", rulename) - -- add batch jobs + -- add batch jobs for xx_build_files local scriptname = "build_files" .. (suffix and ("_" .. suffix) or "") local script = ruleinst:script(scriptname) if script then @@ -41,9 +42,12 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix else batchjobs:addjob("rule/" .. rulename .. "/" .. scriptname, function (index, total) script(target, sourcebatch, {progress = (index * 100) / total}) - end, rootjob) + end, {rootjob = rootjob}) end - else + end + + -- add batch jobs for xx_build_file + if not script then scriptname = "build_file" .. (suffix and ("_" .. suffix) or "") script = ruleinst:script(scriptname) if script then @@ -51,7 +55,36 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix for _, sourcefile in ipairs(sourcebatch.sourcefiles) do batchjobs:addjob(sourcefile, function (index, total) script(target, sourcefile, {sourcekind = sourcekind, progress = (index * 100) / total}) - end, rootjob) + end, {rootjob = rootjob}) + end + end + end + + -- add batch jobs for xx_buildcmd_files + if not script then + scriptname = "buildcmd_files" .. (suffix and ("_" .. suffix) or "") + script = ruleinst:script(scriptname) + if script then + batchjobs:addjob("rule/" .. rulename .. "/" .. scriptname, function (index, total) + local batchcmds_ = batchcmds.new({target = target}) + script(target, batchcmds_, sourcebatch, {progress = (index * 100) / total}) + batchcmds_:runcmds({dryrun = option.get("dry-run")}) + end, {rootjob = rootjob}) + end + end + + -- add batch jobs for xx_buildcmd_file + if not script then + scriptname = "buildcmd_file" .. (suffix and ("_" .. suffix) or "") + script = ruleinst:script(scriptname) + if script then + local sourcekind = sourcebatch.sourcekind + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + batchjobs:addjob(sourcefile, function (index, total) + local batchcmds_ = batchcmds.new({target = target}) + script(target, batchcmds_, sourcefile, {sourcekind = sourcekind, progress = (index * 100) / total}) + batchcmds_:runcmds({dryrun = option.get("dry-run")}) + end, {rootjob = rootjob}) end end end @@ -69,7 +102,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target, sourcebatch, suff else batchjobs:addjob(target:name() .. "/" .. scriptname, function (index, total) script(target, sourcebatch, {progress = (index * 100) / total}) - end, rootjob) + end, {rootjob = rootjob}) end return true else @@ -80,7 +113,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target, sourcebatch, suff for _, sourcefile in ipairs(sourcebatch.sourcefiles) do batchjobs:addjob(sourcefile, function (index, total) script(target, sourcefile, {sourcekind = sourcekind, progress = (index * 100) / total}) - end, rootjob) + end, {rootjob = rootjob}) end return true end diff --git a/xmake/actions/build/kinds/shared.lua b/xmake/actions/build/kinds/shared.lua index 821e775ce..2d2d9e507 100644 --- a/xmake/actions/build/kinds/shared.lua +++ b/xmake/actions/build/kinds/shared.lua @@ -31,7 +31,7 @@ import("object", {alias = "add_batchjobs_for_object"}) function _do_link_target(target, opt) -- load linker instance - local linkinst = linker.load(target:targetkind(), target:sourcekinds(), {target = target}) + local linkinst = linker.load(target:kind(), target:sourcekinds(), {target = target}) -- get link flags local linkflags = linkinst:linkflags({target = target}) @@ -42,7 +42,7 @@ function _do_link_target(target, opt) -- need build this target? local depfiles = objectfiles for _, dep in ipairs(target:orderdeps()) do - if dep:targetkind() == "static" then + if dep:kind() == "static" then if depfiles == objectfiles then depfiles = table.copy(objectfiles) end @@ -150,7 +150,7 @@ function main(batchjobs, rootjob, target) -- add link job local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total) _link_target(target, {progress = (index * 100) / total}) - end, rootjob) + end, {rootjob = rootjob}) -- we need only return and depend the link job for each target, -- so we can compile the source files for each target in parallel diff --git a/xmake/actions/build/kinds/static.lua b/xmake/actions/build/kinds/static.lua index b058ba875..91fba6ed5 100644 --- a/xmake/actions/build/kinds/static.lua +++ b/xmake/actions/build/kinds/static.lua @@ -31,7 +31,7 @@ import("object", {alias = "add_batchjobs_for_object"}) function _do_link_target(target, opt) -- load linker instance - local linkinst = linker.load(target:targetkind(), target:sourcekinds(), {target = target}) + local linkinst = linker.load(target:kind(), target:sourcekinds(), {target = target}) -- get link flags local linkflags = linkinst:linkflags({target = target}) @@ -42,7 +42,7 @@ function _do_link_target(target, opt) -- need build this target? local depfiles = objectfiles for _, dep in ipairs(target:orderdeps()) do - if dep:targetkind() == "static" then + if dep:kind() == "static" then if depfiles == objectfiles then depfiles = table.copy(objectfiles) end @@ -150,7 +150,7 @@ function main(batchjobs, rootjob, target) -- add link job local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total) _link_target(target, {progress = (index * 100) / total}) - end, rootjob) + end, {rootjob = rootjob}) -- we need only return and depend the link job for each target, -- so we can compile the source files for each target in parallel diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index 253f4a45d..864f88185 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -22,10 +22,10 @@ import("core.base.option") import("core.base.global") import("core.base.task") +import("core.project.rule") import("core.project.config") import("core.project.project") import("core.platform.platform") -import("core.platform.environment") import("core.theme.theme") import("private.utils.progress") import("build") @@ -79,6 +79,19 @@ function _try_build() end end +-- do global project rules +function _do_project_rules(scriptname, opt) + for _, rulename in ipairs(project.get("target.rules")) do + local r = project.rule(rulename) or rule.rule(rulename) + if r and r:kind() == "project" then + local buildscript = r:script(scriptname) + if buildscript then + buildscript(opt) + end + end + end +end + -- main function main() @@ -105,10 +118,14 @@ function main() -- clean up temporary files once a day cleaner.cleanup() - -- build it try { function () + + -- do rules before building + _do_project_rules("build_before") + + -- do build local sourcefiles = option.get("files") if sourcefiles then build_files(targetname, sourcefiles) @@ -120,6 +137,11 @@ function main() catch { function (errors) + + -- do rules after building + _do_project_rules("build_after", {errors = errors}) + + -- raise if errors then raise(errors) elseif targetname then @@ -131,6 +153,9 @@ function main() } } + -- do rules after building + _do_project_rules("build_after") + -- unlock the whole project project.unlock() diff --git a/xmake/actions/build/statistics.lua b/xmake/actions/build/statistics.lua index 3ad6de99e..9a4c196c5 100644 --- a/xmake/actions/build/statistics.lua +++ b/xmake/actions/build/statistics.lua @@ -23,9 +23,8 @@ import("core.base.option") import("core.base.process") import("core.project.config") import("core.platform.platform") -import("core.platform.environment") import("private.action.update.fetch_version") -import("private.action.require.packagenv") +import("private.action.require.impl.packagenv") -- statistics is enabled? function _is_enabled() @@ -89,7 +88,7 @@ function post() try { function () - process.openv("xmake", argv, {stdout = path.join(os.tmpdir(), projectname .. ".stats.log")}, {detach = true}):close() + process.openv("xmake", argv, {stdout = path.join(os.tmpdir(), projectname .. ".stats.log"), detach = true}):close() end } @@ -111,11 +110,8 @@ function main() -- load platform platform.load(config.plat()) - -- enter environment - environment.enter("toolchains") - -- enter the environments of git - packagenv.enter("git") + local oldenvs = packagenv.enter("git") -- get the project directory name local projectname = path.basename(os.projectdir()) @@ -143,8 +139,5 @@ function main() end -- leave the environments of git - packagenv.leave("git") - - -- leave environment - environment.leave("toolchains") + os.setenvs(oldenvs) end diff --git a/xmake/actions/build/xmake.lua b/xmake/actions/build/xmake.lua index c92e7fb39..3323ac5b1 100644 --- a/xmake/actions/build/xmake.lua +++ b/xmake/actions/build/xmake.lua @@ -48,7 +48,8 @@ task("build") , {} , {'j', "jobs", "kv", tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)), - "Specifies the number of jobs to build simultaneously." } + "Set the number of parallel compilation jobs." } + , {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs." } , {'w', "warning", "k", false , "Enable the warnings output." } , {nil, "files", "kv", nil , "Build the given source files.", "e.g. ", diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua index a8b8016e4..e9e574545 100644 --- a/xmake/actions/clean/main.lua +++ b/xmake/actions/clean/main.lua @@ -26,7 +26,6 @@ import("core.project.config") import("core.base.global") import("core.project.project") import("core.platform.platform") -import("core.platform.environment") import("private.action.clean.remove_files") import("target.action.clean", {alias = "_do_clean_target"}) @@ -52,16 +51,12 @@ end function _clean_target(target) -- has been disabled? - if target:get("enabled") == false then + if not target:is_enabled() then return end -- enter the environments of the target packages - local oldenvs = {} - for name, values in pairs(target:pkgenvs()) do - oldenvs[name] = os.getenv(name) - os.addenv(name, unpack(values)) - end + local oldenvs = os.addenvs(target:pkgenvs()) -- the target scripts local scripts = @@ -96,9 +91,7 @@ function _clean_target(target) end -- leave the environments of the target packages - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end + os.setenvs(oldenvs) end -- clean the given targets diff --git a/xmake/actions/config/configfiles.lua b/xmake/actions/config/configfiles.lua index b7bb17d25..33a44c1a8 100644 --- a/xmake/actions/config/configfiles.lua +++ b/xmake/actions/config/configfiles.lua @@ -24,12 +24,13 @@ import("core.base.semver") import("core.project.config") import("core.project.project") import("core.platform.platform") +import("lib.detect.find_tool") -- get all configuration files function _get_configfiles() local configfiles = {} for _, target in pairs(project.targets()) do - if target:get("enabled") ~= false then + if target:is_enabled() then -- get configuration files for target local srcfiles, dstfiles, fileinfos = target:configfiles() @@ -86,6 +87,34 @@ function _get_builtinvars_target(target) return builtinvars end +-- get the git builtin variables +function _get_builtinvars_git(builtinvars) + local cmds = + { + GIT_TAG = {"describe", "--tags"}, + GIT_TAG_LONG = {"describe", "--tags", "--long"}, + GIT_BRANCH = {"rev-parse", "--abbrev-ref", "HEAD"}, + GIT_COMMIT = {"rev-parse", "--short", "HEAD"}, + GIT_COMMIT_LONG = {"rev-parse", "HEAD"}, + GIT_COMMIT_DATE = {"log", "-1", "--date=format:%Y%m%d%H%M%S", "--format=%ad"} + } + for name, argv in pairs(cmds) do + builtinvars[name] = function () + local result + local git = find_tool("git") + if git then + result = try {function () + return os.iorunv(git.program, argv) + end} + end + if not result then + result = "none" + end + return result:trim() + end + end +end + -- get the global builtin variables function _get_builtinvars_global() local builtinvars = _g.builtinvars_global @@ -104,6 +133,7 @@ function _get_builtinvars_global() builtinvars_upper[name:upper()] = type(value) == "string" and value:upper() or value end table.join2(builtinvars, builtinvars_upper) + _get_builtinvars_git(builtinvars) _g.builtinvars_global = builtinvars end return builtinvars @@ -161,6 +191,9 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets) -- get the builtin variables from the target for name, value in pairs(_get_builtinvars_target(target)) do + if type(value) == "function" then + value = value() + end if variables[name] == nil then variables[name] = value end @@ -168,6 +201,9 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets) end -- get the global builtin variables for name, value in pairs(_get_builtinvars_global()) do + if type(value) == "function" then + value = value() + end if variables[name] == nil then variables[name] = value end diff --git a/xmake/actions/config/configheader.lua b/xmake/actions/config/configheader.lua index e693d0b3e..f57e3efaf 100644 --- a/xmake/actions/config/configheader.lua +++ b/xmake/actions/config/configheader.lua @@ -69,48 +69,6 @@ function _make_for_target(target) file:print("") end - -- make the defines - local defines = table.copy(target:get("defines_h")) - - -- make the undefines - local undefines = table.copy(target:get("undefines_h")) - - -- make the defines for options - for _, opt in ipairs(target:orderopts()) do - table.join2(defines, opt:get("defines_h")) - table.join2(defines, opt:get("defines_h_if_ok")) -- deprecated - table.join2(undefines, opt:get("undefines_h")) - table.join2(undefines, opt:get("undefines_h_if_ok")) -- deprecated - end - - -- make the defines for packages - for _, pkg in ipairs(target:orderpkgs()) do - table.join2(defines, pkg:get("defines_h")) - table.join2(undefines, pkg:get("undefines_h")) - end - - -- make the defines - if #defines ~= 0 then - file:print("// defines") - for _, define in ipairs(defines) do - if define:find("=") then - file:print("#define %s", define:gsub("=", " "):gsub("%$%((.-)%)", function (w) if w == "prefix" then return configprefix end end)) - else - file:print("#define %s 1", define:gsub("%$%((.-)%)", function (w) if w == "prefix" then return configprefix end end)) - end - end - file:print("") - end - - -- make the undefines - if #undefines ~= 0 then - file:print("// undefines") - for _, undefine in ipairs(undefines) do - file:print("#undef %s", undefine:gsub("%$%((.-)%)", function (w) if w == "prefix" then return configprefix end end)) - end - file:print("") - end - -- make the tail file:print("#endif") @@ -120,16 +78,12 @@ end -- make the configure file for the given target and dependents function _make_for_target_with_deps(targetname) - - -- the target local target = project.target(targetname) - - -- make configure for the target - _make_for_target(target) - - -- make configure for the dependent targets? - for _, dep in ipairs(target:get("deps")) do - _make_for_target_with_deps(dep) + if target then + _make_for_target(target) + for _, dep in ipairs(target:get("deps")) do + _make_for_target_with_deps(dep) + end end end diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 6acdf7999..68f8ab531 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -31,7 +31,8 @@ import("scangen") import("menuconf", {alias = "menuconf_show"}) import("configfiles", {alias = "generate_configfiles"}) import("configheader", {alias = "generate_configheader"}) -import("actions.require.install", {alias = "install_requires", rootdir = os.programdir()}) +import("private.action.require.check", {alias = "check_packages"}) +import("private.action.require.install", {alias = "install_packages"}) -- filter option function _option_filter(name) @@ -47,6 +48,8 @@ function _option_filter(name) , verbose = true , diagnosis = true , require = true + , export = true + , import = true } return not options[name] end @@ -64,17 +67,12 @@ function _need_check(changed) changed = option.get("clean") end - -- get the current mtimes + -- check for all project files local mtimes = project.mtimes() - - -- get the previous mtimes if not changed then local mtimes_prev = localcache.get("config", "mtimes") if mtimes_prev then - - -- check for all project files for file, mtime in pairs(mtimes) do - -- modified? reconfig and rebuild it local mtime_prev = mtimes_prev[file] if not mtime_prev or mtime > mtime_prev then @@ -85,6 +83,11 @@ function _need_check(changed) end end + -- unfinished config/recheck + if not changed and localcache.get("config", "recheck") then + changed = true + end + -- xmake has been updated? force to check config again -- we need clean the dirty config cache of the old version if not changed then @@ -92,46 +95,30 @@ function _need_check(changed) changed = true end end - - -- update mtimes - localcache.set("config", "mtimes", mtimes) - - -- changed? return changed end --- check dependent target -function _check_target_deps(target) - - -- check +-- check target +function _check_target(target) for _, depname in ipairs(target:get("deps")) do - - -- check dependent target name assert(depname ~= target:name(), "the target(%s) cannot depend self!", depname) - - -- get dependent target local deptarget = project.target(depname) - - -- check dependent target name assert(deptarget, "unknown target(%s) for %s.deps!", depname, target:name()) - - -- check the dependent targets - _check_target_deps(deptarget) + _check_target(deptarget) end end --- check target -function _check_target(targetname) - assert(targetname) +-- check targets +function _check_targets(targetname) assert(not project.is_loaded(), "project and targets may have been loaded early!") if targetname == "all" then for _, target in pairs(project.targets()) do - _check_target_deps(target) + _check_target(target) end else local target = project.target(targetname) assert(target, "unknown target: %s", targetname) - _check_target_deps(target) + _check_target(target) end end @@ -140,9 +127,9 @@ function _check_target_toolchains() -- check toolchains configuration for all target in the current project -- @note we must check targets after loading options for _, target in pairs(project.targets()) do - if target:get("enabled") ~= false and (target:get("toolchains") or - not target:is_plat(config.get("plat")) or - not target:is_arch(config.get("arch"))) then + if target:is_enabled() and (target:get("toolchains") or + not target:is_plat(config.get("plat")) or + not target:is_arch(config.get("arch"))) then local target_toolchains = target:get("toolchains") if target_toolchains then target_toolchains = hashset.from(table.wrap(target_toolchains)) @@ -159,7 +146,56 @@ function _check_target_toolchains() raise(errors) end end + elseif not target:get("toolset") then + -- we only abort it when we know that toolchains of platform and target do not found + local toolchain_found + for _, toolchain_inst in pairs(target:toolchains()) do + if toolchain_inst:is_standalone() then + toolchain_found = true + end + end + assert(toolchain_found, "target(%s): toolchain not found!", target:name()) + end + end +end + +-- config target +function _config_target(target) + for _, rule in ipairs(target:orderules()) do + local on_config = rule:script("config") + if on_config then + on_config(target) + end + end + local on_config = target:script("config") + if on_config then + on_config(target) + end +end + +-- config targets +function _config_targets(targetname) + if targetname == "all" then + for _, target in ipairs(project.ordertargets()) do + if target:is_enabled() then + _config_target(target) + end end + else + local target = project.target(targetname) + assert(target, "unknown target: %s", targetname) + for _, dep in ipairs(target:orderdeps()) do + _config_target(dep) + end + _config_target(target) + end +end + +-- export configs +function _export_configs() + local exportfile = option.get("export") + if exportfile then + config.save(exportfile, {public = true}) end end @@ -203,7 +239,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) -- the target name local targetname = option.get("target") or "all" - -- load the project configure + -- load the project configuration -- -- priority: option > option_cache > global > option_default > config_check > project_check > config_cache -- @@ -217,7 +253,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) end end - -- override configure from the options or cache + -- override configuration from the options or cache local options_history = {} if not option.get("clean") and not autogen then options_history = localcache.get("config", "options") or {} @@ -232,7 +268,15 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) config.set(name, value, {readonly = true}) end - -- merge the cached configure + -- merge configuration from the given import file + local importfile = option.get("import") + if importfile and os.isfile(importfile) then + if config.load(importfile) then + options_changed = true + end + end + + -- merge the cached configuration -- -- @note we cannot load cache config when switching platform, arch .. -- so we need known whether options have been changed @@ -242,7 +286,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) configcache_loaded = config.load() end - -- merge the global configure + -- merge the global configuration for name, value in pairs(global.options()) do if config.get(name) == nil then config.set(name, value) @@ -273,7 +317,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) -- load platform instance local instance_plat = platform.load(plat, arch) - -- merge the checked configure + -- merge the checked configuration local recheck = _need_check(options_changed or not configcache_loaded or autogen) if recheck then @@ -283,6 +327,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) localcache.clear("option") localcache.clear("package") localcache.clear("toolchain") + localcache.set("config", "recheck", true) localcache.save() -- check platform @@ -303,15 +348,19 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) -- only config for building project using third-party buildsystem if not trybuild then - -- install and update requires + -- install and update packages local require_enable = option.boolean(option.get("require")) - if (recheck or require_enable) and require_enable ~= false then - install_requires() + if (recheck or require_enable) then + if require_enable ~= false then + install_packages() + else + check_packages() + end end -- check target and ensure to load all targets, @note we must load targets after installing required packages, -- otherwise has_package() will be invalid. - _check_target(targetname) + _check_targets(targetname) -- update the config files if recheck then @@ -323,6 +372,9 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) if recheck then _check_target_toolchains() end + + -- config targets + _config_targets(targetname) end -- dump config @@ -330,7 +382,14 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) config.dump() end + -- export configs + if option.get("export") then + _export_configs() + end + -- save options and config cache + localcache.set("config", "recheck", false) + localcache.set("config", "mtimes", project.mtimes()) config.save() localcache.set("config", "options", options) localcache.save("config") diff --git a/xmake/actions/config/menuconf.lua b/xmake/actions/config/menuconf.lua index 5d06e007f..5657b30db 100644 --- a/xmake/actions/config/menuconf.lua +++ b/xmake/actions/config/menuconf.lua @@ -93,6 +93,8 @@ function app:_filter_option(name) , help = true , clean = true , menu = true + , import = true + , export = true } return not options[name] and not project.option(name) end @@ -358,9 +360,13 @@ end -- load configs from options function app:load(cache) - -- load config from cache - if cache then - cache = config.load(option.get("target") or "all") + -- merge configuration from the given import file or cache + local loaded = false + local importfile = option.get("import") + if importfile and os.isfile(importfile) then + loaded = config.load(importfile) + elseif cache then + loaded = config.load() end -- clear configs first @@ -374,7 +380,7 @@ function app:load(cache) self:mconfdialog():load(configs) -- the previous config is only for loading menuconf, so clear config now - if cache then + if loaded then config.clear() end end diff --git a/xmake/actions/config/scangen.lua b/xmake/actions/config/scangen.lua index a249b73c0..ef447c228 100644 --- a/xmake/actions/config/scangen.lua +++ b/xmake/actions/config/scangen.lua @@ -54,7 +54,7 @@ function main() -- add targetkinds if filecount > 0 then - for targetkind, _ in pairs(instance:targetkinds()) do + for targetkind, _ in pairs(instance:kinds()) do targetkinds[targetkind] = true end end @@ -90,24 +90,14 @@ function main() cprint("target(${magenta}%s${clear}): %s", targetname, targetkind) -- add rules - file:print("-- add rules: debug/release") file:print("add_rules(\"mode.debug\", \"mode.release\")") file:print("") -- add target - file:print("-- define target") file:print("target(\"%s\")", targetname) - file:print("") - file:print(" -- set kind") file:print(" set_kind(\"%s\")", targetkind) - file:print("") - file:print(" -- add files") for _, sourcefile in ipairs(sourcefiles) do - - -- trace cprint(" ${green}[+]: ${clear}%s", sourcefile) - - -- add file file:print(" add_files(\"%s\")", sourcefile) end file:print("") @@ -125,19 +115,13 @@ function main() cprint(" ${green}[+]: ${clear}%s", sourcefile) -- add target - file:print("-- define target") file:print("target(\"%s\")", name) - file:print("") - file:print(" -- set kind") file:print(" set_kind(\"binary\")") - file:print("") - file:print(" -- add files") file:print(" add_files(\"%s\")", sourcefile) file:print("") -- add deps if #sourcefiles > 0 then - file:print(" -- add deps") file:print(" add_deps(\"%s\")", targetname) file:print("") end diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua index 1be74b3f2..6b58698d6 100644 --- a/xmake/actions/config/xmake.lua +++ b/xmake/actions/config/xmake.lua @@ -42,6 +42,12 @@ task("config") , options = { {'c', "clean", "k", nil , "Clean the cached configure and configure all again." } + , {nil, "export", "kv", nil , "Export the current configuration to the given file." + , " e.g." + , " - xmake f -m debug -xxx=y --export=build/config.txt" } + , {nil, "import", "kv", nil , "Import configuration from the given file." + , " e.g." + , " - xmake f -import=build/config.txt" } , {nil, "menu", "k", nil , "Configure project with a menu-driven user interface." } , {category = "."} , {'p', "plat", "kv", "auto" , "Compile for the given platform." diff --git a/xmake/actions/install/install.lua b/xmake/actions/install/install.lua index 1f990a1b9..b4b0a6628 100644 --- a/xmake/actions/install/install.lua +++ b/xmake/actions/install/install.lua @@ -49,7 +49,7 @@ end function _install_target(target) -- has been disabled? - if target:get("enabled") == false then + if not target:is_enabled() then return end @@ -57,11 +57,7 @@ function _install_target(target) local oldir = os.cd(project.directory()) -- enter the environments of the target packages - local oldenvs = {} - for name, values in pairs(target:pkgenvs()) do - oldenvs[name] = os.getenv(name) - os.addenv(name, unpack(values)) - end + local oldenvs = os.addenvs(target:pkgenvs()) -- the target scripts local scripts = @@ -96,9 +92,7 @@ function _install_target(target) end -- leave the environments of the target packages - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end + os.setenvs(oldenvs) -- leave project directory os.cd(oldir) @@ -122,8 +116,7 @@ function main(targetname) else -- install default or all targets for _, target in ipairs(project.ordertargets()) do - local default = target:get("default") - if default == nil or default == true or targetname == "__all" then + if target:is_default() or targetname == "__all" then _install_target(target) end end diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua index 62bd9210b..40ba15cc3 100644 --- a/xmake/actions/install/main.lua +++ b/xmake/actions/install/main.lua @@ -37,8 +37,7 @@ function _check_targets(targetname) else -- install default or all targets for _, target in pairs(project.targets()) do - local default = target:get("default") - if default == nil or default == true or targetname == "__all" then + if target:is_default() or targetname == "__all" then table.insert(targets, target) end end @@ -47,7 +46,7 @@ function _check_targets(targetname) -- filter and check targets with builtin-install script local targetnames = {} for _, target in ipairs(targets) do - if not target:isphony() and target:get("enabled") ~= false and not target:script("install") then + if not target:is_phony() and target:is_enabled() and not target:script("install") then local targetfile = target:targetfile() if targetfile and not os.isfile(targetfile) then table.insert(targetnames, target:name()) @@ -79,7 +78,7 @@ function main() function () -- install target - install(targetname or ifelse(option.get("all"), "__all", "__def")) + install(targetname or (option.get("all") and "__all" or "__def")) -- trace cprint("${color.success}install ok!") @@ -95,22 +94,14 @@ function main() local ok = try { function () - - -- install target - install(targetname or ifelse(option.get("all"), "__all", "__def")) - - -- trace + install(targetname or (option.get("all") and "__all" or "__def")) cprint("${color.success}install ok!") - - -- ok return true end } -- release privilege privilege.store() - - -- ok? if ok then return end end @@ -119,9 +110,7 @@ function main() if sudo.has() and option.get("admin") then -- install target with administrator permission - sudo.runl(path.join(os.scriptdir(), "install_admin.lua"), {targetname or ifelse(option.get("all"), "__all", "__def"), option.get("installdir"), option.get("prefix")}) - - -- trace + sudo.runl(path.join(os.scriptdir(), "install_admin.lua"), {targetname or (option.get("all") and "__all" or "__def"), option.get("installdir"), option.get("prefix")}) cprint("${color.success}install ok!") ok = true end diff --git a/xmake/actions/package/local/main.lua b/xmake/actions/package/local/main.lua new file mode 100644 index 000000000..beaaa8862 --- /dev/null +++ b/xmake/actions/package/local/main.lua @@ -0,0 +1,288 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file main.lua +-- + +-- imports +import("core.base.option") +import("core.base.task") +import("core.project.rule") +import("core.project.config") +import("core.project.project") +import("lib.luajit.bit") + +-- package binary +function _package_binary(target) + + -- get the output directory + local outputdir = option.get("outputdir") or config.buildir() + local packagename = target:name():lower() + if #packagename > 1 and bit.band(packagename:byte(2), 0xc0) == 0x80 then + wprint("package(%s): cannot generate package, becauese it contains unicode characters!", packagename) + return + end + local packagedir = path.join(outputdir, "packages", packagename:sub(1, 1), packagename) + local binarydir = path.join(packagedir, target:plat(), target:arch(), config.mode(), "bin") + + -- copy the binary file to the output directory + local targetfile = target:targetfile() + os.mkdir(binarydir) + os.vcp(targetfile, binarydir) + os.trycp(target:symbolfile(), binarydir) + + -- generate xmake.lua + local file = io.open(path.join(packagedir, "xmake.lua"), "w") + if file then + local deps = {} + for _, dep in ipairs(target:orderdeps()) do + table.insert(deps, dep:name()) + end + file:print("package(\"%s\")", packagename) + local homepage = option.get("homepage") + if homepage then + file:print(" set_homepage(\"%s\")", homepage) + end + local description = option.get("description") or ("The " .. packagename .. " package") + file:print(" set_description(\"%s\")", description) + if target:license() then + file:print(" set_license(\"%s\")", target:license()) + end + if #deps > 0 then + file:print(" add_deps(\"%s\")", table.concat(deps, "\", \"")) + end + file:print("") + file:print([[ + on_load(function (package) + package:set("installdir", path.join(os.scriptdir(), package:plat(), package:arch(), package:mode())) + end) + + on_fetch(function (package) + return {program = path.join(package:installdir("bin"), "%s")} + end)]], #deps > 0 and ("add_deps(\"" .. table.concat(deps, "\", \"") .. "\")") or "", + path.filename(targetfile)) + file:close() + end + + -- show tips + print("package(%s): %s generated", packagename, packagedir) +end + +-- package library +function _package_library(target) + + -- get the output directory + local outputdir = option.get("outputdir") or config.buildir() + local packagename = target:name():lower() + if #packagename > 1 and bit.band(packagename:byte(2), 0xc0) == 0x80 then + wprint("package(%s): cannot generate package, becauese it contains unicode characters!", packagename) + return + end + local packagedir = path.join(outputdir, "packages", packagename:sub(1, 1), packagename) + local binarydir = path.join(packagedir, target:plat(), target:arch(), config.mode(), "bin") + local librarydir = path.join(packagedir, target:plat(), target:arch(), config.mode(), "lib") + local headerdir = path.join(packagedir, target:plat(), target:arch(), config.mode(), "include") + + -- copy the library file to the output directory + local targetfile = target:targetfile() + if target:is_shared() and target:is_plat("windows", "mingw") then + os.mkdir(binarydir) + os.vcp(targetfile, binarydir) + os.trycp(target:symbolfile(), binarydir) + local targetfile_lib = path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib") + if os.isfile(targetfile_lib) then + os.mkdir(librarydir) + os.vcp(targetfile_lib, librarydir) + end + else + os.mkdir(librarydir) + os.vcp(targetfile, librarydir) + os.trycp(target:symbolfile(), librarydir) + end + + -- copy headers + local srcheaders, dstheaders = target:headerfiles(headerdir) + if srcheaders and dstheaders then + local i = 1 + for _, srcheader in ipairs(srcheaders) do + local dstheader = dstheaders[i] + if dstheader then + os.vcp(srcheader, dstheader) + end + i = i + 1 + end + end + + -- generate xmake.lua + local file = io.open(path.join(packagedir, "xmake.lua"), "w") + if file then + local deps = {} + for _, dep in ipairs(target:orderdeps()) do + table.insert(deps, dep:name()) + end + file:print("package(\"%s\")", packagename) + local homepage = option.get("homepage") + if homepage then + file:print(" set_homepage(\"%s\")", homepage) + end + local description = option.get("description") or ("The " .. packagename .. " package") + file:print(" set_description(\"%s\")", description) + if target:license() then + file:print(" set_license(\"%s\")", target:license()) + end + if #deps > 0 then + file:print(" add_deps(\"%s\")", table.concat(deps, "\", \"")) + end + file:print("") + file:print([[ + on_load(function (package) + package:set("installdir", path.join(os.scriptdir(), package:plat(), package:arch(), package:mode())) + end) + + on_fetch(function (package) + local result = {} + result.links = "%s" + result.linkdirs = package:installdir("lib") + result.includedirs = package:installdir("include") + return result + end)]], target:linkname(), + path.filename(targetfile)) + file:close() + end + + -- show tips + print("package(%s): %s generated", packagename, packagedir) +end + +-- do package target +function _do_package_target(target) + if not target:is_phony() then + local scripts = + { + binary = _package_binary + , static = _package_library + , shared = _package_library + } + local kind = target:kind() + assert(scripts[kind], "this target(%s) with kind(%s) can not be packaged!", target:name(), kind) + scripts[kind](target) + end +end + +-- package target +function _on_package_target(target) + local done = false + for _, r in ipairs(target:orderules()) do + local on_package = r:script("package") + if on_package then + on_package(target) + done = true + end + end + if done then return end + _do_package_target(target) +end + +-- package the given target +function _package_target(target) + + -- has been disabled? + if not target:is_enabled() then + return + end + + -- enter project directory + local oldir = os.cd(project.directory()) + + -- enter the environments of the target packages + local oldenvs = os.addenvs(target:pkgenvs()) + + -- the target scripts + local scripts = + { + target:script("package_before") + , function (target) + for _, r in ipairs(target:orderules()) do + local before_package = r:script("package_before") + if before_package then + before_package(target) + end + end + end + , target:script("package", _on_package_target) + , function (target) + for _, r in ipairs(target:orderules()) do + local after_package = r:script("package_after") + if after_package then + after_package(target) + end + end + end + , target:script("package_after") + } + + -- package the target scripts + for i = 1, 5 do + local script = scripts[i] + if script ~= nil then + script(target) + end + end + + -- leave the environments of the target packages + os.setenvs(oldenvs) + + -- leave project directory + os.cd(oldir) +end + +-- package the given targets +function _package_targets(targets) + for _, target in ipairs(targets) do + _package_target(target) + end +end + +-- main +function main() + + -- lock the whole project + project.lock() + + -- get the target name + local targetname = option.get("target") + + -- build it first + task.run("build", {target = targetname, all = option.get("all")}) + + -- package the given target? + if targetname then + local target = project.target(targetname) + _package_targets(target:orderdeps()) + _package_target(target) + else + -- package default or all targets + for _, target in ipairs(project.ordertargets()) do + if target:is_default() or option.get("all") then + _package_target(target) + end + end + end + + -- unlock the whole project + project.unlock() +end diff --git a/xmake/actions/package/main.lua b/xmake/actions/package/main.lua index 7977d3b23..78835bb61 100644 --- a/xmake/actions/package/main.lua +++ b/xmake/actions/package/main.lua @@ -20,224 +20,8 @@ -- imports import("core.base.option") -import("core.base.task") -import("core.base.global") -import("core.project.rule") -import("core.project.config") -import("core.project.project") -import("core.platform.platform") --- package library -function _package_library(target) - - -- the output directory - local outputdir = option.get("outputdir") or config.buildir() - - -- the target name - local targetname = target:name() - - -- copy the library file to the output directory - os.vcp(target:targetfile(), format("%s/%s.pkg/$(plat)/$(arch)/lib/$(mode)/%s", outputdir, targetname, path.filename(target:targetfile()))) - - -- copy the symbol file to the output directory - local symbolfile = target:symbolfile() - if os.isfile(symbolfile) then - os.vcp(symbolfile, format("%s/%s.pkg/$(plat)/$(arch)/lib/$(mode)/%s", outputdir, targetname, path.filename(symbolfile))) - end - - -- copy *.lib for shared/windows (*.dll) target - -- @see https://github.com/xmake-io/xmake/issues/787 - if target:targetkind() == "shared" and is_plat("windows", "mingw") then - local targetfile = target:targetfile() - local targetfile_lib = path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib") - if os.isfile(targetfile_lib) then - os.vcp(targetfile_lib, format("%s/%s.pkg/$(plat)/$(arch)/lib/$(mode)/", outputdir, targetname)) - end - end - - -- copy the config.h to the output directory (deprecated) - local configheader = target:configheader() - if configheader then - os.vcp(configheader, format("%s/%s.pkg/$(plat)/$(arch)/include/%s", outputdir, targetname, path.filename(configheader))) - end - - -- copy headers - local srcheaders, dstheaders = target:headerfiles(format("%s/%s.pkg/$(plat)/$(arch)/include", outputdir, targetname)) - if srcheaders and dstheaders then - local i = 1 - for _, srcheader in ipairs(srcheaders) do - local dstheader = dstheaders[i] - if dstheader then - os.vcp(srcheader, dstheader) - end - i = i + 1 - end - end - - -- make xmake.lua - local file = io.open(format("%s/%s.pkg/xmake.lua", outputdir, targetname), "w") - if file then - file:print("option(\"%s\")", targetname) - file:print(" set_showmenu(true)") - file:print(" set_category(\"package\")") - file:print(" add_links(\"%s\")", target:basename()) - file:write(" add_linkdirs(\"$(plat)/$(arch)/lib/$(mode)\")\n") - file:write(" add_includedirs(\"$(plat)/$(arch)/include\")\n") - local languages = target:get("languages") - if languages then - file:print(" set_languages(\"%s\")", table.concat(table.wrap(languages), "\", \"")) - end - file:close() - end -end - --- do package target -function _do_package_target(target) - - -- is phony target? - if target:isphony() then - return - end - - -- get kind - local kind = target:targetkind() - - -- get script - local scripts = - { - binary = function (target) end - , static = _package_library - , shared = _package_library - } - - -- check - assert(scripts[kind], "this target(%s) with kind(%s) can not be packaged!", target:name(), kind) - - -- package it - scripts[kind](target) -end - --- package target -function _on_package_target(target) - - -- has been disabled? - if target:get("enabled") == false then - return - end - - -- build target with rules - local done = false - for _, r in ipairs(target:orderules()) do - local on_package = r:script("package") - if on_package then - on_package(target) - done = true - end - end - if done then return end - - -- do package - _do_package_target(target) -end - --- package the given target -function _package_target(target) - - -- enter project directory - local oldir = os.cd(project.directory()) - - -- enter the environments of the target packages - local oldenvs = {} - for name, values in pairs(target:pkgenvs()) do - oldenvs[name] = os.getenv(name) - os.addenv(name, unpack(values)) - end - - -- the target scripts - local scripts = - { - target:script("package_before") - , function (target) - for _, r in ipairs(target:orderules()) do - local before_package = r:script("package_before") - if before_package then - before_package(target) - end - end - end - , target:script("package", _on_package_target) - , function (target) - for _, r in ipairs(target:orderules()) do - local after_package = r:script("package_after") - if after_package then - after_package(target) - end - end - end - , target:script("package_after") - } - - -- package the target scripts - for i = 1, 5 do - local script = scripts[i] - if script ~= nil then - script(target) - end - end - - -- leave the environments of the target packages - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end - - -- leave project directory - os.cd(oldir) -end - --- package the given targets -function _package_targets(targets) - for _, target in ipairs(targets) do - _package_target(target) - end -end - --- main +-- main entry function main() - - -- --archs? deprecated - if option.get("archs") then - - -- load config - config.load() - - -- deprecated - raise("please run \"xmake m package %s\" instead of \"xmake p --archs=%s\"", config.get("plat"), option.get("archs")) - end - - -- lock the whole project - project.lock() - - -- get the target name - local targetname = option.get("target") - - -- build it first - task.run("build", {target = targetname, all = option.get("all")}) - - -- package the given target? - if targetname then - local target = project.target(targetname) - _package_targets(target:orderdeps()) - _package_target(target) - else - -- package default or all targets - for _, target in ipairs(project.ordertargets()) do - local default = target:get("default") - if default == nil or default == true or option.get("all") then - _package_target(target) - end - end - end - - -- unlock the whole project - project.lock() + import(option.get("format") or "local")() end diff --git a/xmake/actions/package/oldpkg/main.lua b/xmake/actions/package/oldpkg/main.lua new file mode 100644 index 000000000..d47d8d474 --- /dev/null +++ b/xmake/actions/package/oldpkg/main.lua @@ -0,0 +1,209 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file main.lua +-- + +-- imports +import("core.base.option") +import("core.base.task") +import("core.project.rule") +import("core.project.config") +import("core.project.project") + +-- package library +function _package_library(target) + + -- the output directory + local outputdir = option.get("outputdir") or config.buildir() + + -- the target name + local targetname = target:name() + + -- copy the library file to the output directory + os.vcp(target:targetfile(), format("%s/%s.pkg/$(plat)/$(arch)/lib/$(mode)/%s", outputdir, targetname, path.filename(target:targetfile()))) + + -- copy the symbol file to the output directory + local symbolfile = target:symbolfile() + if os.isfile(symbolfile) then + os.vcp(symbolfile, format("%s/%s.pkg/$(plat)/$(arch)/lib/$(mode)/%s", outputdir, targetname, path.filename(symbolfile))) + end + + -- copy *.lib for shared/windows (*.dll) target + -- @see https://github.com/xmake-io/xmake/issues/787 + if target:is_shared() and target:is_plat("windows", "mingw") then + local targetfile = target:targetfile() + local targetfile_lib = path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib") + if os.isfile(targetfile_lib) then + os.vcp(targetfile_lib, format("%s/%s.pkg/$(plat)/$(arch)/lib/$(mode)/", outputdir, targetname)) + end + end + + -- copy the config.h to the output directory (deprecated) + local configheader = target:configheader() + if configheader then + os.vcp(configheader, format("%s/%s.pkg/$(plat)/$(arch)/include/%s", outputdir, targetname, path.filename(configheader))) + end + + -- copy headers + local srcheaders, dstheaders = target:headerfiles(format("%s/%s.pkg/$(plat)/$(arch)/include", outputdir, targetname)) + if srcheaders and dstheaders then + local i = 1 + for _, srcheader in ipairs(srcheaders) do + local dstheader = dstheaders[i] + if dstheader then + os.vcp(srcheader, dstheader) + end + i = i + 1 + end + end + + -- make xmake.lua + local file = io.open(format("%s/%s.pkg/xmake.lua", outputdir, targetname), "w") + if file then + file:print("option(\"%s\")", targetname) + file:print(" set_showmenu(true)") + file:print(" set_category(\"package\")") + file:print(" add_links(\"%s\")", target:basename()) + file:write(" add_linkdirs(\"$(plat)/$(arch)/lib/$(mode)\")\n") + file:write(" add_includedirs(\"$(plat)/$(arch)/include\")\n") + local languages = target:get("languages") + if languages then + file:print(" set_languages(\"%s\")", table.concat(table.wrap(languages), "\", \"")) + end + file:close() + end +end + +-- do package target +function _do_package_target(target) + if not target:is_phony() then + local scripts = + { + binary = function (target) end + , static = _package_library + , shared = _package_library + } + local kind = target:kind() + assert(scripts[kind], "this target(%s) with kind(%s) can not be packaged!", target:name(), kind) + scripts[kind](target) + end +end + +-- package target +function _on_package_target(target) + local done = false + for _, r in ipairs(target:orderules()) do + local on_package = r:script("package") + if on_package then + on_package(target) + done = true + end + end + if done then return end + _do_package_target(target) +end + +-- package the given target +function _package_target(target) + + -- has been disabled? + if not target:is_enabled() then + return + end + + -- enter project directory + local oldir = os.cd(project.directory()) + + -- enter the environments of the target packages + local oldenvs = os.addenvs(target:pkgenvs()) + + -- the target scripts + local scripts = + { + target:script("package_before") + , function (target) + for _, r in ipairs(target:orderules()) do + local before_package = r:script("package_before") + if before_package then + before_package(target) + end + end + end + , target:script("package", _on_package_target) + , function (target) + for _, r in ipairs(target:orderules()) do + local after_package = r:script("package_after") + if after_package then + after_package(target) + end + end + end + , target:script("package_after") + } + + -- package the target scripts + for i = 1, 5 do + local script = scripts[i] + if script ~= nil then + script(target) + end + end + + -- leave the environments of the target packages + os.setenvs(oldenvs) + + -- leave project directory + os.cd(oldir) +end + +-- package the given targets +function _package_targets(targets) + for _, target in ipairs(targets) do + _package_target(target) + end +end + +-- main +function main() + + -- lock the whole project + project.lock() + + -- get the target name + local targetname = option.get("target") + + -- build it first + task.run("build", {target = targetname, all = option.get("all")}) + + -- package the given target? + if targetname then + local target = project.target(targetname) + _package_targets(target:orderdeps()) + _package_target(target) + else + -- package default or all targets + for _, target in ipairs(project.ordertargets()) do + if target:is_default() or option.get("all") then + _package_target(target) + end + end + end + + -- unlock the whole project + project.unlock() +end diff --git a/xmake/actions/package/remote/main.lua b/xmake/actions/package/remote/main.lua new file mode 100644 index 000000000..064141b56 --- /dev/null +++ b/xmake/actions/package/remote/main.lua @@ -0,0 +1,137 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file main.lua +-- + +-- imports +import("core.base.option") +import("core.base.task") +import("core.project.rule") +import("core.project.config") +import("core.project.project") +import("lib.luajit.bit") + +-- package remote +function _package_remote(target) + + -- get the output directory + local outputdir = option.get("outputdir") or config.buildir() + local packagename = target:name():lower() + if #packagename > 1 and bit.band(packagename:byte(2), 0xc0) == 0x80 then + wprint("package(%s): cannot generate package, becauese it contains unicode characters!", packagename) + return + end + local packagedir = path.join(outputdir, "packages", packagename:sub(1, 1), packagename) + + -- generate xmake.lua + local file = io.open(path.join(packagedir, "xmake.lua"), "w") + if file then + local deps = {} + for _, dep in ipairs(target:orderdeps()) do + table.insert(deps, dep:name()) + end + file:print("package(\"%s\")", packagename) + if target:is_binary() then + file:print(" set_kind(\"binary\")") + end + local homepage = option.get("homepage") + if homepage then + file:print(" set_homepage(\"%s\")", homepage) + end + local description = option.get("description") or ("The " .. packagename .. " package") + file:print(" set_description(\"%s\")", description) + if target:license() then + file:print(" set_license(\"%s\")", target:license()) + end + if #deps > 0 then + file:print(" add_deps(\"%s\")", table.concat(deps, "\", \"")) + end + file:print("") + local url = option.get("url") or "https://github.com/myrepo/foo.git" + local version = option.get("version") or target:version() and (target:version()) or "1.0" + local shasum = option.get("shasum") or "<shasum256 or gitcommit>" + file:print(" add_urls(\"%s\")", url) + file:print(" add_versions(\"%s\", \"%s\")", version, shasum) + file:print("") + file:print([[ + on_install(function (package) + local configs = {} + if package:config("shared") then + configs.kind = "shared" + end + import("package.tools.xmake").install(package, configs) + end) + + on_test(function (package) + -- TODO check includes and interfaces + -- assert(package:has_cfuncs("foo", {includes = "foo.h"}) + end)]]) + file:close() + end + + -- show tips + print("package(%s): %s generated", packagename, packagedir) +end + +-- package target +function _package_target(target) + if not target:is_phony() then + local scripts = + { + binary = _package_remote + , static = _package_remote + , shared = _package_remote + } + local kind = target:kind() + assert(scripts[kind], "this target(%s) with kind(%s) can not be packaged!", target:name(), kind) + scripts[kind](target) + end +end + +-- package the given targets +function _package_targets(targets) + for _, target in ipairs(targets) do + _package_target(target) + end +end + +-- main +function main() + + -- lock the whole project + project.lock() + + -- package the given target? + local targetname = option.get("target") + if targetname then + local target = project.target(targetname) + _package_targets(target:orderdeps()) + _package_target(target) + else + -- package default or all targets + for _, target in ipairs(project.ordertargets()) do + if target:is_default() or option.get("all") then + _package_target(target) + end + end + end + + -- unlock the whole project + project.unlock() +end + diff --git a/xmake/actions/package/xmake.lua b/xmake/actions/package/xmake.lua index d30815a98..dd7b1846f 100644 --- a/xmake/actions/package/xmake.lua +++ b/xmake/actions/package/xmake.lua @@ -18,36 +18,31 @@ -- @file xmake.lua -- --- define task task("package") - - -- set category set_category("action") - - -- on run on_run("main") - - -- set menu set_menu { - -- usage - usage = "xmake package|p [options] [target]" - - -- description - , description = "Package target." - - -- xmake p - , shortname = 'p' - - -- options - , options = - { - {'o', "outputdir", "kv", nil , "Set the output directory." } - , {'a', "all", "k", nil , "Package all targets." } - , {} - , {nil, "target", "v", nil , "The target name. It will package all default targets if this parameter is not specified." - , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end } - } - } + usage = "xmake package|p [options] [target]", + description = "Package target.", + shortname = 'p', + options = { + {'o', "outputdir", "kv", nil, "Set the output directory."}, + {'a', "all", "k", nil, "Package all targets."}, + {}, + {'f', "format", "kv", "local", "Set the package format.", + values = {"oldpkg", "local", "remote"}}, + {nil, "homepage", "kv", nil, "Set the homepage of package."}, + {nil, "description","kv", nil, "Set the description of package."}, + {nil, "url", "kv", nil, "Set the url of remote package."}, + {nil, "version", "kv", nil, "Set the version of remove package."}, + {nil, "shasum", "kv", nil, "Set the sha256 or commit of remote package."}, + {}, + {nil, "target", "v", nil, "The target name. It will package all default targets if this parameter is not specified.", + values = function (complete, opt) + return import("private.utils.complete_helper.targets")(complete, opt) + end } + } + } diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua deleted file mode 100644 index a63c948dc..000000000 --- a/xmake/actions/require/impl/package.lua +++ /dev/null @@ -1,903 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file package.lua --- - --- imports -import("core.base.semver") -import("core.base.option") -import("core.base.global") -import("core.base.hashset") -import("core.base.scheduler") -import("core.base.tty") -import("private.async.runjobs") -import("private.utils.progress") -import("core.cache.memcache") -import("core.cache.localcache") -import("core.project.project") -import("core.package.package", {alias = "core_package"}) -import("actions.install", {alias = "action_install"}) -import("actions.download", {alias = "action_download"}) -import("devel.git") -import("net.fasturl") -import("repository") - --- get memcache -function _memcache() - return memcache.cache("require.impl.package") -end - --- --- parse require string --- --- basic --- - add_requires("zlib") --- --- semver --- - add_requires("tbox >=1.5.1", "zlib >=1.2.11") --- --- git branch/tag --- - add_requires("zlib master") --- --- with the given repository --- - add_requires("xmake-repo@tbox >=1.5.1") --- --- with the given configs --- - add_requires("aaa_bbb_ccc >=1.5.1 <1.6.0", {optional = true, alias = "mypkg", debug = true}) --- - add_requires("tbox", {config = {coroutine = true, abc = "xxx"}}) --- --- with namespace and the 3rd package manager --- - add_requires("xmake::xmake-repo@tbox >=1.5.1") --- - add_requires("vcpkg::ffmpeg") --- - add_requires("conan::OpenSSL/1.0.2n@conan/stable") --- - add_requires("conan::openssl/1.1.1g") -- new --- - add_requires("brew::pcre2/libpcre2-8 10.x", {alias = "pcre2"}) --- --- clone as a standalone package with the different configs --- we can install and use these three packages at the same time. --- - add_requires("zlib") --- - add_requires("zlib~debug", {debug = true}) --- - add_requires("zlib~shared", {configs = {shared = true}, alias = "zlib_shared"}) --- --- {system = nil/true/false}: --- nil: get local or system packages --- true: only get system package --- false: only get local packages --- -function _parse_require(require_str, requires_extra, parentinfo) - - -- get it from cache first - local requires = _memcache():get("requires") or {} - local required = requires[require_str] - if required then - return required.packagename, required.requireinfo - end - - -- split package and version info - local splitinfo = require_str:split('%s+') - assert(splitinfo and #splitinfo > 0, "require(\"%s\"): invalid!", require_str) - - -- get package info - local packageinfo = splitinfo[1] - - -- get version - -- - -- e.g. - -- - -- latest - -- >=1.5.1 <1.6.0 - -- master || >1.4 - -- ~1.2.3 - -- ^1.1 - -- - local version = "latest" - if #splitinfo > 1 then - version = table.concat(table.slice(splitinfo, 2), " ") - end - assert(version, "require(\"%s\"): unknown version!", require_str) - - -- require third-party packages? e.g. brew::pcre2/libpcre2-8 - local reponame = nil - local packagename = nil - if require_str:find("::", 1, true) then - packagename = packageinfo - else - - -- get repository name, package name and package url - local pos = packageinfo:lastof('@', true) - if pos then - - -- get package name - packagename = packageinfo:sub(pos + 1) - - -- get reponame - reponame = packageinfo:sub(1, pos - 1) - else - packagename = packageinfo - end - end - - -- check package name - assert(packagename, "require(\"%s\"): the package name not found!", require_str) - - -- get require extra - local require_extra = {} - if requires_extra then - require_extra = requires_extra[require_str] or {} - end - - -- get required building configurations - local require_build_configs = require_extra.configs or require_extra.config - if require_extra.debug then - require_build_configs = require_build_configs or {} - require_build_configs.debug = true - end - - -- require packge in the current host platform - if require_extra.host then - require_extra.plat = os.host() - require_extra.arch = os.arch() - end - - -- init required item - local required = {} - parentinfo = parentinfo or {} - required.packagename = packagename - required.requireinfo = - { - originstr = require_str, - reponame = reponame, - version = version, - plat = require_extra.plat, -- require package in the given platform - arch = require_extra.arch, -- require package in the given architecture - ["os"] = require_extra.os, -- require package in the given target os - kind = require_extra.kind, -- default: library, set package kind, e.g. binary, library, we can set `kind = "binary"` to only detect binary program and ignore library. - alias = require_extra.alias, -- set package alias name - group = require_extra.group, -- only uses the first package in same group - system = require_extra.system, -- default: true, we can set it to disable system package manually - option = require_extra.option, -- set and attach option - configs = require_build_configs, -- the required building configurations - default = require_extra.default, -- default: true, we can set it to disable package manually - optional = parentinfo.optional or require_extra.optional, -- default: false, inherit parentinfo.optional - verify = require_extra.verify, -- default: true, we can set false to ignore sha256sum and select any version - external = require_extra.external -- default: true, we use sysincludedirs/-isystem instead of -I/xxx - } - - -- save this required item to cache - requires[require_str] = required - _memcache():set("requires", requires) - - -- ok - return required.packagename, required.requireinfo -end - --- load package package from system -function _load_package_from_system(packagename) - return core_package.load_from_system(packagename) -end - --- load package package from project -function _load_package_from_project(packagename) - return core_package.load_from_project(packagename) -end - --- load package package from repositories -function _load_package_from_repository(packagename, reponame) - local packagedir, repo = repository.packagedir(packagename, reponame) - if packagedir then - return core_package.load_from_repository(packagename, repo, packagedir) - end -end - --- search packages from repositories -function _search_packages(name) - - local packages = {} - for _, packageinfo in ipairs(repository.searchdirs(name)) do - local package = core_package.load_from_repository(packageinfo.name, packageinfo.repo, packageinfo.packagedir) - if package then - table.insert(packages, package) - end - end - return packages -end - --- sort package deps --- --- e.g. --- --- a.deps = b --- b.deps = c --- --- orderdeps: c -> b -> a --- -function _sort_packagedeps(package) - local orderdeps = {} - for _, dep in pairs(package:deps()) do - table.join2(orderdeps, _sort_packagedeps(dep)) - table.insert(orderdeps, dep) - end - return orderdeps -end - --- add some builtin configurations to package -function _add_package_configurations(package) - local vs_runtime = project.get("target.runtimes") or get_config("vs_runtime") or "MT" - package:add("configs", "debug", {builtin = true, description = "Enable debug symbols.", default = false, type = "boolean"}) - package:add("configs", "shared", {builtin = true, description = "Enable shared library.", default = false, type = "boolean"}) - package:add("configs", "cflags", {builtin = true, description = "Set the C compiler flags."}) - package:add("configs", "cxflags", {builtin = true, description = "Set the C/C++ compiler flags."}) - package:add("configs", "cxxflags", {builtin = true, description = "Set the C++ compiler flags."}) - package:add("configs", "asflags", {builtin = true, description = "Set the assembler flags."}) - package:add("configs", "vs_runtime", {builtin = true, description = "Set vs compiler runtime.", default = vs_runtime, values = {"MT", "MTd", "MD", "MDd"}}) -end - --- select package version -function _select_package_version(package, requireinfo) - - -- exists urls? otherwise be phony package (only as package group) - if #package:urls() > 0 then - - -- has git url? - local has_giturl = false - for _, url in ipairs(package:urls()) do - if git.checkurl(url) then - has_giturl = true - break - end - end - - -- select package version - local source = nil - local version = nil - local require_version = requireinfo.version - local require_verify = requireinfo.verify - if (not package:get("versions") or require_verify == false) and semver.is_valid(require_version) then - -- no version list in package() or need not verify sha256sum? try selecting this version directly - -- @see https://github.com/xmake-io/xmake/issues/930 - -- https://github.com/xmake-io/xmake/issues/1009 - version = require_version - source = "versions" - elseif #package:versions() > 0 and (require_version == "latest" or require_version:find('.', 1, true)) then -- select version? - version, source = semver.select(require_version, package:versions()) - elseif has_giturl then -- select branch? - version, source = require_version ~= "latest" and require_version or "master", "branches" - else - raise("package(%s %s): not found!", package:name(), require_version) - end - return version, source - end -end - --- check the configurations of packages --- --- package("pcre2") --- add_configs("bitwidth", {description = "Set the code unit width.", default = "8", values = {"8", "16", "32"}}) --- add_configs("bitwidth", {type = "number", values = {8, 16, 32}}) --- add_configs("bitwidth", {restrict = function(value) if tonumber(value) < 100 then return true end}) --- -function _check_package_configurations(package) - local configs_defined = {} - for _, name in ipairs(package:get("configs")) do - configs_defined[name] = package:extraconf("configs", name) or {} - end - for name, value in pairs(package:configs()) do - local conf = configs_defined[name] - if conf then - local config_type = conf.type - if config_type ~= nil and type(value) ~= config_type then - raise("package(%s %s): invalid type(%s) for config(%s), need type(%s)!", package:name(), package:version_str(), type(value), name, config_type) - end - if conf.values then - local found = false - for _, config_value in ipairs(conf.values) do - if tostring(value) == tostring(config_value) then - found = true - break - end - end - if not found then - raise("package(%s %s): invalid value(%s) for config(%s), please run `xmake require --info %s` to get all valid values!", package:name(), package:version_str(), value, name, package:name()) - end - end - if conf.restrict then - if not conf.restrict(value) then - raise("package(%s %s): invalid value(%s) for config(%s)!", package:name(), package:version_str(), value, name) - end - end - else - raise("package(%s %s): invalid config(%s), please run `xmake require --info %s` to get all configurations!", package:name(), package:version_str(), name, package:name()) - end - end -end - --- load required packages -function _load_package(packagename, requireinfo, opt) - - -- attempt to get it from cache first - opt = opt or {} - local packages = _memcache():get("packages") or {} - local package = packages[packagename] - if package then - - -- satisfy required version? - local version_required = _select_package_version(package, requireinfo) - if version_required and version_required ~= package:version_str() then - raise("package(%s): version conflict, '%s' does not satisfy '%s'!", packagename, package:version_str(), requireinfo.version) - end - return package - end - - -- load package from project first - if os.isfile(os.projectfile()) then - package = _load_package_from_project(packagename) - end - - -- load package from repositories - if not package then - package = _load_package_from_repository(packagename, requireinfo.reponame) - end - - -- load package from system - if not package and opt.system ~= false then - package = _load_package_from_system(packagename) - end - - -- check - assert(package, "package(%s) not found!", packagename) - - -- select package version - local version, source = _select_package_version(package, requireinfo) - if version then - package:version_set(version, source) - end - - -- save require info to package - package:requireinfo_set(requireinfo) - - -- add some builtin configurations to package - _add_package_configurations(package) - - -- check package configurations - _check_package_configurations(package) - - -- do load for package - local on_load = package:script("load") - if on_load then - on_load(package) - end - - -- load environments from the manifest to enable the environments of on_install() - package:envs_load() - - -- save this package package to cache - packages[packagename] = package - _memcache():set("packages", packages) - return package -end - --- load all required packages -function _load_packages(requires, opt) - - -- no requires? - if not requires or #requires == 0 then - return {} - end - - -- load packages - local packages = {} - for _, requireinfo in ipairs(load_requires(requires, opt.requires_extra, opt.parentinfo)) do - - -- load package - local package = _load_package(requireinfo.name, requireinfo.info, opt) - - -- maybe package not found and optional - if package then - - -- load dependent packages and save them first of this package - if not package._DEPS then - local deps = package:get("deps") - if deps and opt.nodeps ~= true then - - -- get the extra configs dependent packages and inherit some builtin configs - local extraconfs = package:extraconf("deps") or {} - if not package:config("shared") then - for _, depstr in ipairs(deps) do - local depconf = extraconfs[depstr] - if not depconf then - depconf = {} - extraconfs[depstr] = depconf - end - depconf.configs = depconf.configs or {} - if depconf.configs.vs_runtime == nil then - depconf.configs.vs_runtime = package:config("vs_runtime") - end - end - end - - -- load dependent packages and do not load system packages for package/deps() - local packagedeps = {} - for _, dep in ipairs(_load_packages(deps, {requires_extra = extraconfs, parentinfo = requireinfo.info, nodeps = opt.nodeps, system = false})) do - dep:parents_add(package) - table.insert(packages, dep) - packagedeps[dep:name()] = dep - end - package._DEPS = packagedeps - package._ORDERDEPS = table.unique(_sort_packagedeps(package)) - end - end - - -- save this package package - table.insert(packages, package) - end - end - return packages -end - --- sort packages urls -function _sort_packages_urls(packages) - - -- add all urls to fasturl and prepare to sort them together - for _, package in pairs(packages) do - fasturl.add(package:urls()) - end - - -- sort and update urls - for _, package in pairs(packages) do - package:urls_set(fasturl.sort(package:urls())) - end -end - --- get package status string -function _get_package_status_str(package) - local status = {} - if package:debug() then - table.insert(status, "debug") - end - if package:optional() then - table.insert(status, "optional") - end - return #status > 0 and "(" .. table.concat(status, ", ") .. ")" or "" -end - --- get user confirm -function _get_confirm(packages) - - -- no confirmed packages? - if #packages == 0 then - return true - end - - -- get confirm - local confirm = utils.confirm({default = true, description = function () - - -- get packages for each repositories - local packages_repo = {} - local packages_group = {} - for _, package in ipairs(packages) do - -- achive packages by repository - local reponame = package:repo() and package:repo():name() or (package:isSys() and "system" or "") - if package:is3rd() then - reponame = package:name():lower():split("::")[1] - end - packages_repo[reponame] = packages_repo[reponame] or {} - table.insert(packages_repo[reponame], package) - - -- achive packages by group - local group = package:group() - if group then - packages_group[group] = packages_group[group] or {} - table.insert(packages_group[group], package) - end - end - - -- show tips - cprint("${bright color.warning}note: ${clear}try installing these packages (pass -y to skip confirm)?") - for reponame, packages in pairs(packages_repo) do - if reponame ~= "" then - print("in %s:", reponame) - end - local packages_showed = {} - for _, package in ipairs(packages) do - if not packages_showed[tostring(package)] then - local group = package:group() - if group and packages_group[group] and #packages_group[group] > 1 then - for idx, package_in_group in ipairs(packages_group[group]) do - cprint(" ${yellow}%s${clear} %s %s %s", idx == 1 and "->" or " or", package_in_group:name(), package_in_group:version_str() or "", _get_package_status_str(package_in_group)) - packages_showed[tostring(package_in_group)] = true - end - packages_group[group] = nil - else - cprint(" ${yellow}->${clear} %s %s %s", package:name(), package:version_str() or "", _get_package_status_str(package)) - packages_showed[tostring(package)] = true - end - end - end - end - end}) - return confirm -end - --- patch some builtin dependent packages -function _patch_packages(packages_install, packages_download) - - -- @NOTE use git.apply instead of patch - -- we can add some builtin packages like this - --[[ - -- add package(patch) - local patched_package = nil - for _, package in ipairs(packages_install) do - if package:patches() then - patched_package = package - break - end - end - if patched_package then - local packages = load_packages("patch") - if packages and #packages > 0 then - -- install patch package - local package = packages[1] - if not package:fetch() then - packages_download[tostring(package)] = package - table.insert(packages_install, 1, package) - end - -- add dependences to ensure to be installed first - patched_package:deps_add(package) - end - end - ]] -end - --- install packages -function _install_packages(packages_install, packages_download) - - -- we need hide wait characters if is not a tty - local show_wait = io.isatty() - - -- do install - local progress_helper = show_wait and progress.new() or nil - local packages_installing = {} - local packages_downloading = {} - local packages_pending = table.copy(packages_install) - local packages_in_group = {} - local installing_count = 0 - local parallelize = true - runjobs("install_packages", function (index) - - -- fetch a new package - local package = nil - while package == nil and #packages_pending > 0 do - for idx, pkg in ipairs(packages_pending) do - - -- all dependences has been installed? we install it now - local ready = true - for _, dep in ipairs(pkg:orderdeps()) do - if not dep:exists() then - ready = false - end - end - local group = pkg:group() - if ready and group then - -- this group has been installed? skip it - local group_status = packages_in_group[group] - if group_status == 1 then - table.remove(packages_pending, idx) - break - -- this group is installing? wait it - elseif group_status == 0 then - ready = false - end - end - - -- get a package with the ready status - if ready then - package = pkg - table.remove(packages_pending, idx) - break - end - end - if package == nil and #packages_pending > 0 then - scheduler.co_yield() - end - end - if package then - - -- only install the first package in same group - local group = package:group() - if not group or not packages_in_group[group] then - - -- disable parallelize? - if not package:parallelize() then - parallelize = false - end - if not parallelize then - while installing_count > 0 do - scheduler.co_yield() - end - end - installing_count = installing_count + 1 - - -- mark this group as 'installing' - if group then - packages_in_group[group] = 0 - end - - -- download this package first - local downloaded = true - if packages_download[tostring(package)] then - packages_downloading[index] = package - downloaded = action_download(package) - packages_downloading[index] = nil - end - - -- install this package - packages_installing[index] = package - if downloaded then - action_install(package) - end - packages_installing[index] = nil - - -- mark this group as 'installed' or 'failed' - if group then - packages_in_group[group] = package:exists() and 1 or -1 - end - - -- enable parallelize - parallelize = true - installing_count = installing_count - 1 - end - end - packages_installing[index] = nil - packages_downloading[index] = nil - - end, {total = #packages_install, comax = (option.get("verbose") or option.get("diagnosis")) and 1 or 4, on_timer = function (running_jobs_indices) - - -- do not print progress info if be verbose - if option.get("verbose") or not show_wait then - return - end - - -- make installing and downloading packages list - local installing = {} - local downloading = {} - for _, index in ipairs(running_jobs_indices) do - local package = packages_installing[index] - if package then - table.insert(installing, package:name()) - end - local package = packages_downloading[index] - if package then - table.insert(downloading, package:name()) - end - end - - -- get waitobjs tips - local tips = nil - local waitobjs = scheduler.co_group_waitobjs("install_packages") - if waitobjs:size() > 0 then - local names = {} - for _, obj in waitobjs:keys() do - if obj:otype() == scheduler.OT_PROC then - table.insert(names, obj:name()) - elseif obj:otype() == scheduler.OT_SOCK then - table.insert(names, "sock") - elseif obj:otype() == scheduler.OT_PIPE then - table.insert(names, "pipe") - end - end - names = table.unique(names) - if #names > 0 then - names = table.concat(names, ",") - if #names > 16 then - names = names:sub(1, 16) .. ".." - end - tips = string.format("(%d/%s)", waitobjs:size(), names) - end - end - - -- trace - progress_helper:clear() - tty.erase_line_to_start().cr() - cprintf("${yellow} => ") - if #downloading > 0 then - cprintf("downloading ${magenta}%s", table.concat(downloading, ", ")) - end - if #installing > 0 then - cprintf("%sinstalling ${magenta}%s", #downloading > 0 and ", " or "", table.concat(installing, ", ")) - end - cprintf(" .. %s", tips and ("${dim}" .. tips .. "${clear} ") or "") - progress_helper:write() - end, exit = function(errors) - if errors then - tty.erase_line_to_start().cr() - io.flush() - end - end}) -end - --- the cache directory -function cachedir() - return path.join(global.directory(), "cache", "packages") -end - --- load requires -function load_requires(requires, requires_extra, parentinfo) - local requireinfos = {} - for _, require_str in ipairs(requires) do - local packagename, requireinfo = _parse_require(require_str, requires_extra, parentinfo) - table.insert(requireinfos, {name = packagename, info = requireinfo}) - end - return requireinfos -end - --- load all required packages -function load_packages(requires, opt) - opt = opt or {} - local unique = {} - local packages = {} - for _, package in ipairs(_load_packages(requires, opt)) do - -- remove repeat packages with same the package name and version - local key = package:name() .. (package:version_str() or "") - if not unique[key] then - table.insert(packages, package) - unique[key] = true - end - end - return packages -end - --- install packages -function install_packages(requires, opt) - - -- init options - opt = opt or {} - - -- load packages - local packages = load_packages(requires, opt) - - -- fetch packages (with system) from local first - runjobs("fetch_packages", function (index) - local package = packages[index] - if package and (not option.get("force") or (option.get("shallow") and package:parents())) then - package:envs_enter() - package:fetch() - package:envs_leave() - end - end, {total = #packages}) - - -- filter packages - local packages_install = {} - local packages_download = {} - local packages_unsupported = {} - for _, package in ipairs(packages) do - if not package:exists() and (#package:urls() > 0 or package:script("install")) then - if package:supported() then - if #package:urls() > 0 then - packages_download[tostring(package)] = package - end - table.insert(packages_install, package) - elseif not package:optional() then - table.insert(packages_unsupported, package) - end - end - end - - -- exists unsupported packages? - if #packages_unsupported > 0 then - -- show tips - cprint("${bright color.warning}note: ${clear}the following packages are unsupported for $(plat)/$(arch)!") - for _, package in ipairs(packages_unsupported) do - print(" -> %s %s", package:name(), package:version_str() or "") - end - raise() - end - - -- patch some dependent builtin packages - _patch_packages(packages_install, packages_download) - - -- get user confirm - if not _get_confirm(packages_install) then - local packages_must = {} - for _, package in ipairs(packages_install) do - if not package:optional() then - table.insert(packages_must, package:name()) - end - end - if #packages_must > 0 then - raise("packages(%s): must be installed!", table.concat(packages_must, ", ")) - else - -- continue other actions - return - end - end - - -- sort package urls - _sort_packages_urls(packages_download) - - -- install all required packages from repositories - _install_packages(packages_install, packages_download) - - -- ok - return packages -end - --- uninstall packages -function uninstall_packages(requires, opt) - - -- init options - opt = opt or {} - - -- do not remove dependent packages - opt.nodeps = true - - -- clear the local cache - localcache.clear() - - -- remove all packages - local packages = {} - for _, instance in ipairs(load_packages(requires, opt)) do - if os.isfile(instance:manifest_file()) then - table.insert(packages, instance) - end - os.tryrm(instance:installdir()) - end - return packages -end - --- export packages -function export_packages(requires, opt) - - -- init options - opt = opt or {} - - -- get the export directory - local exportdir = assert(opt.exportdir) - - -- export all packages - local packages = {} - for _, instance in ipairs(load_packages(requires, opt)) do - - -- get the exported name - local name = instance:name():lower():gsub("::", "_") - if instance:version_str() then - name = name .. "_" .. instance:version_str() - end - name = name .. "_" .. instance:buildhash() - - -- export this package - if instance:fetch() then - os.cp(instance:installdir(), path.join(exportdir, name)) - table.insert(packages, instance) - end - end - return packages -end - --- search packages -function search_packages(names) - - -- search all names - local results = {} - for _, name in ipairs(names) do - local packages = _search_packages(name) - if packages then - results[name] = packages - end - end - return results -end diff --git a/xmake/actions/require/install.lua b/xmake/actions/require/install.lua deleted file mode 100644 index cedc3e434..000000000 --- a/xmake/actions/require/install.lua +++ /dev/null @@ -1,201 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file package.lua --- - --- imports -import("core.base.option") -import("core.base.task") -import("core.project.project") -import("lib.detect.find_tool") -import("impl.package") -import("impl.repository") -import("impl.environment") -import("impl.utils.get_requires") - --- register required package environments --- envs: bin path for *.dll, program .. -function _register_required_package_envs(instance, envs) - for name, values in pairs(instance:envs()) do - if name == "PATH" or name == "LD_LIBRARY_PATH" or name == "DYLD_LIBRARY_PATH" then - for _, value in ipairs(values) do - envs[name] = envs[name] or {} - if path.is_absolute(value) then - table.insert(envs[name], value) - else - table.insert(envs[name], path.join(instance:installdir(), value)) - end - end - else - envs[name] = envs[name] or {} - table.join2(envs[name], values) - end - end -end - --- register required package libraries --- libs: includedirs, links, linkdirs ... -function _register_required_package_libs(instance, requireinfo, is_deps) - if instance:kind() ~= "binary" then - local fetchinfo = instance:fetch() - if fetchinfo then - fetchinfo.name = nil - if is_deps then - -- we need only reserve license for root package - -- - -- @note the license compatibility between the root package and - -- its dependent packages is guaranteed by the root package itself - -- - fetchinfo.license = nil - - -- we need only some infos for root package - fetchinfo.version = nil - fetchinfo.static = nil - fetchinfo.shared = nil - end - requireinfo:add(fetchinfo) - end - end -end - --- register the required local package -function _register_required_package(instance, requireinfo) - - -- disable it if this package is optional and missing - if _g.optional_missing[instance:name()] then - requireinfo:enable(false) - else - -- clear require info first - requireinfo:clear() - - -- add packages info with all dependencies - local envs = {} - _register_required_package_libs(instance, requireinfo) - _register_required_package_envs(instance, envs) - local orderdeps = instance:orderdeps() - if orderdeps then - local total = #orderdeps - for idx, _ in ipairs(orderdeps) do - local dep = orderdeps[total + 1 - idx] - if dep then - _register_required_package_libs(dep, requireinfo, true) - _register_required_package_envs(dep, envs) - end - end - end - if #table.keys(envs) > 0 then - requireinfo:add({envs = envs}) - end - - -- enable this require info - requireinfo:enable(true) - end - - -- save this require info and flush the whole cache file - requireinfo:save() -end - --- register all required local packages -function _register_required_packages(packages) - local registered_in_group = {} - for _, instance in ipairs(packages) do - - -- only register the first package in same group - local group = instance:group() - if not group or not registered_in_group[group] then - - -- do not register binary package - local requireinfo = project.require(instance:alias() or instance:name()) - if requireinfo then - _register_required_package(instance, requireinfo) - end - - -- mark as registered in group - if group then - registered_in_group[group] = true - end - end - end -end - --- check missing packages -function _check_missing_packages(packages) - - -- get all missing packages - local packages_missing = {} - local optional_missing = {} - for _, instance in ipairs(packages) do - if not instance:exists() and (#instance:urls() > 0 or instance:isSys()) then - if instance:optional() then - optional_missing[instance:name()] = instance - else - table.insert(packages_missing, instance:name()) - end - end - end - - -- raise tips - if #packages_missing > 0 then - local cmd = "xmake repo -u" - if os.getenv("XREPO_WORKING") then - cmd = "xrepo update-repo" - end - raise("The packages(%s) not found, please run `%s` first!", table.concat(packages_missing, ", "), cmd) - end - - -- save the optional missing packages - _g.optional_missing = optional_missing -end - --- install packages -function main(requires_raw) - - -- get requires and extra config - local requires_extra = nil - local requires, requires_extra = get_requires(requires_raw) - if not requires or #requires == 0 then - return - end - - -- find git - environment.enter() - local git = find_tool("git") - environment.leave() - - -- pull all repositories first if not exists - -- - -- attempt to install git from the builtin-packages first if git not found - -- - if git and not repository.pulled() then - task.run("repo", {update = true}) - end - - -- install packages - environment.enter() - local packages = package.install_packages(requires, {requires_extra = requires_extra}) - if packages then - - -- check missing packages - _check_missing_packages(packages) - - -- register all required local packages - _register_required_packages(packages) - end - environment.leave() -end - diff --git a/xmake/actions/require/main.lua b/xmake/actions/require/main.lua index bdac48cdf..eb0e2014e 100644 --- a/xmake/actions/require/main.lua +++ b/xmake/actions/require/main.lua @@ -24,15 +24,16 @@ import("core.base.task") import("core.project.config") import("core.project.project") import("core.platform.platform") -import("list") -import("scan") -import("info") -import("fetch") -import("clean") -import("search") -import("export") -import("install") -import("uninstall") +import("private.action.require.list") +import("private.action.require.scan") +import("private.action.require.info") +import("private.action.require.fetch") +import("private.action.require.clean") +import("private.action.require.search") +import("private.action.require.export") +import("private.action.require.import", {alias = "import_packages"}) +import("private.action.require.install") +import("private.action.require.uninstall") -- -- the default repositories: @@ -92,6 +93,11 @@ function main() export(option.get("requires")) + -- import the installed packages + elseif option.get("import") then + + import_packages(option.get("requires")) + -- show the given package info elseif option.get("info") then diff --git a/xmake/actions/require/xmake.lua b/xmake/actions/require/xmake.lua index ca44d9e62..a9d4db32c 100644 --- a/xmake/actions/require/xmake.lua +++ b/xmake/actions/require/xmake.lua @@ -46,7 +46,11 @@ task("require") " $ xmake require --clean", " $ xmake require --clean zlib tbox pcr*" } , {'f', "force", "k", nil, "Force to reinstall all package dependencies." } + , {'j', "jobs", "kv", tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)), + "Set the number of parallel compilation jobs." } + , {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs." } , {nil, "shallow", "k", nil, "Does not install dependent packages." } + , {nil, "build", "k", nil, "Always build and install packages from source." } , {'l', "list", "k", nil, "List all package dependencies in project.", "e.g.", " $ xmake require --list" } @@ -77,9 +81,15 @@ task("require") "e.g.", " $ xmake require --export", " $ xmake require --export tbox zlib", - " $ xmake require --export --exportdir=packagesdir zlib", + " $ xmake require --export --packagedir=packagesdir zlib", " $ xmake require --export --extra=\"{debug=true}\" tbox" } - , {nil, "exportdir", "kv", "packages","Set the exported packages directory." } + , {nil, "import", "k", nil, "Import the installed packages and their dependencies.", + "e.g.", + " $ xmake require --import", + " $ xmake require --import tbox zlib", + " $ xmake require --import --packagedir=packagesdir zlib", + " $ xmake require --import --extra=\"{debug=true}\" tbox" } + , {nil, "packagedir", "kv", "packages","Set the packages directory for exporting and importing." } , {nil, "extra", "kv", nil, "Set the extra info of packages." } , { } , {nil, "requires", "vs", nil, "The package requires.", diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index a9a838651..a74845f95 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -25,7 +25,6 @@ import("core.project.config") import("core.base.global") import("core.project.project") import("core.platform.platform") -import("core.platform.environment") import("devel.debugger") import("private.action.run.make_runenvs") @@ -33,7 +32,7 @@ import("private.action.run.make_runenvs") function _do_run_target(target) -- only for binary program - if target:targetkind() ~= "binary" then + if not target:is_binary() then return end @@ -69,11 +68,6 @@ end -- run target function _on_run_target(target) - -- has been disabled? - if target:get("enabled") == false then - return - end - -- build target with rules local done = false for _, r in ipairs(target:orderules()) do @@ -89,28 +83,35 @@ function _on_run_target(target) _do_run_target(target) end +-- recursively target add env +function _add_target_pkgenvs(target, targets_added) + if targets_added[target:name()] then + return + end + targets_added[target:name()] = true + os.addenvs(target:pkgenvs()) + for _, dep in ipairs(target:orderdeps()) do + _add_target_pkgenvs(dep, targets_added) + end +end + -- run the given target function _run(target) - -- enter the environments of the target packages - local oldenvs = {} - for name, values in pairs(target:pkgenvs()) do - oldenvs[name] = os.getenv(name) - os.addenv(name, unpack(values)) + -- has been disabled? + if not target:is_enabled() then + return end + -- enter the environments of the target packages + local oldenvs = os.getenvs() + _add_target_pkgenvs(target, {}) + -- the target scripts local scripts = { target:script("run_before") , function (target) - - -- has been disabled? - if target:get("enabled") == false then - return - end - - -- run rules for _, r in ipairs(target:orderules()) do local before_run = r:script("run_before") if before_run then @@ -120,13 +121,6 @@ function _run(target) end , target:script("run", _on_run_target) , function (target) - - -- has been disabled? - if target:get("enabled") == false then - return - end - - -- run rules for _, r in ipairs(target:orderules()) do local after_run = r:script("run_after") if after_run then @@ -146,9 +140,7 @@ function _run(target) end -- leave the environments of the target packages - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end + os.setenvs(oldenvs) end -- check targets @@ -161,8 +153,7 @@ function _check_targets(targetname) else -- install default or all targets for _, target in ipairs(project.ordertargets()) do - local default = target:get("default") - if (default == nil or default == true or option.get("all")) and target:targetkind() == "binary" then + if (target:is_default() or option.get("all")) and target:is_binary() then table.insert(targets, target) end end @@ -171,7 +162,7 @@ function _check_targets(targetname) -- filter and check targets with builtin-run script local targetnames = {} for _, target in ipairs(targets) do - if not target:isphony() and target:get("enabled") ~= false and not target:script("run") then + if not target:is_phony() and target:is_enabled() and not target:script("run") then local targetfile = target:targetfile() if targetfile and not os.isfile(targetfile) then table.insert(targetnames, target:name()) @@ -200,25 +191,18 @@ function main() -- enter project directory local oldir = os.cd(project.directory()) - -- enter the running environment - environment.enter("run") - -- run the given target? if targetname then _run(project.target(targetname)) else -- run default or all binary targets for _, target in ipairs(project.ordertargets()) do - local default = target:get("default") - if (default == nil or default == true or option.get("all")) and target:targetkind() == "binary" then + if (target:is_default() or option.get("all")) and target:is_binary() then _run(target) end end end - -- leave the running environment - environment.leave("run") - -- leave project directory os.cd(oldir) end diff --git a/xmake/actions/uninstall/uninstall.lua b/xmake/actions/uninstall/uninstall.lua index bc7468030..8ce5346a6 100644 --- a/xmake/actions/uninstall/uninstall.lua +++ b/xmake/actions/uninstall/uninstall.lua @@ -49,7 +49,7 @@ end function _uninstall_target(target) -- has been disabled? - if target:get("enabled") == false then + if not target:is_enabled() then return end @@ -57,11 +57,7 @@ function _uninstall_target(target) local oldir = os.cd(project.directory()) -- enter the environments of the target packages - local oldenvs = {} - for name, values in pairs(target:pkgenvs()) do - oldenvs[name] = os.getenv(name) - os.addenv(name, unpack(values)) - end + local oldenvs = os.addenvs(target:pkgenvs()) -- the target scripts local scripts = @@ -96,9 +92,7 @@ function _uninstall_target(target) end -- leave the environments of the target packages - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end + os.setenvs(oldenvs) -- leave project directory os.cd(oldir) diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua index f25e76330..4bd4389cd 100644 --- a/xmake/actions/update/main.lua +++ b/xmake/actions/update/main.lua @@ -30,7 +30,7 @@ import("net.fasturl") import("core.base.privilege") import("privilege.sudo") import("private.async.runjobs") -import("actions.require.impl.environment", {rootdir = os.programdir()}) +import("private.action.require.impl.environment") import("private.action.update.fetch_version") import("utils.archive") import("lib.detect.find_file") @@ -173,7 +173,7 @@ function _install(sourcedir) end else os.vrun("make build") - process.openv("./scripts/get.sh", {"__local__", "__install_only__"}, {stdout = os.tmpfile(), stderr = os.tmpfile()}, {detach = true}):close() + process.openv("./scripts/get.sh", {"__local__", "__install_only__"}, {stdout = os.tmpfile(), stderr = os.tmpfile(), detach = true}):close() end return true end, @@ -223,7 +223,7 @@ function _install_script(sourcedir) local script_original = path.join(os.programdir(), "scripts", "update-script.bat") local script = os.tmpfile() .. ".bat" os.cp(script_original, script) - local params = { "/c", script, os.programdir(), source } + local params = { "/c", script, os.programdir(), source } os.tryrm(script_original .. ".bak") local access = os.trymv(script_original, script_original .. ".bak") _run_win_v("cmd", params, not access) @@ -309,15 +309,19 @@ function main() raise("not support to update from unofficial source on windows, missing '--scriptonly' flag?") end + local winarch = os.arch() == "x64" and "win64" or "win32" if version:find('.', 1, true) then - local winarch = os.arch() == "x64" and "win64" or "win32" mainurls = {format("https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?tag=%s&pr=false&job=Image%%3A+Visual+Studio+2017%%3B+Platform%%3A+%s", version, os.arch()), format("https://github.com/xmake-io/xmake/releases/download/%s/xmake-%s.%s.exe", version, version, winarch), format("https://cdn.jsdelivr.net/gh/xmake-mirror/xmake-releases@%s/xmake-%s.%s.exe.zip", version, version, winarch), format("https://gitlab.com/xmake-mirror/xmake-releases/raw/%s/xmake-%s.%s.exe.zip", version, version, winarch)} else -- regard as a git branch, fetch from ci - mainurls = {format("https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=%s&pr=false&job=Image%%3A+Visual+Studio+2017%%3B+Platform%%3A+%s", version, os.arch())} + local tags = fetchinfo.tags + table.sort(tags) + local latest_version = tags[#tags] or ("v" .. xmake.version():shortstr()) + mainurls = {format("https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=%s&pr=false&job=Image%%3A+Visual+Studio+2017%%3B+Platform%%3A+%s", version, os.arch()), + format("https://github.com/xmake-io/xmake/releases/download/%s/xmake-%s.%s.exe", latest_version, version, winarch)} end -- re-sort mainurls diff --git a/xmake/core/base/colors.lua b/xmake/core/base/colors.lua index 36846bab2..942f1f081 100644 --- a/xmake/core/base/colors.lua +++ b/xmake/core/base/colors.lua @@ -22,6 +22,7 @@ local colors = colors or {} -- load modules +local tty -- lazy loading it local emoji = require("base/emoji") -- the color8 keys @@ -141,83 +142,6 @@ colors._keys24 = -- the escape string colors._ESC = '\x1b[%sm' --- get colorterm setting --- --- COLORTERM: color8, color256, truecolor, nocolor --- -function colors._colorterm() - local colorterm = colors._COLORTERM - if colorterm == nil then - colorterm = os.getenv("XMAKE_COLORTERM") or os.getenv("COLORTERM") or "" - colors._COLORTERM = colorterm - end - return colorterm -end - --- support 8 colors? -function colors.color8() - - -- no color? - local colorterm = colors._colorterm() - if colorterm == "nocolor" then - return false - end - - -- has 8 colors? - if colorterm == "color8" or os.subhost() ~= "windows" then - return true - end - - -- this is supported if exists ANSICON envirnoment variable on windows - colors._ANSICON = colors._ANSICON or os.getenv("ANSICON") or "" - return colors._ANSICON ~= "" -end - --- support 256 colors? -function colors.color256() - - -- no color? - local colorterm = colors._colorterm() - if colorterm == "nocolor" then - return false - end - - -- has 256 colors? - return colorterm == "color256" or os.subhost() ~= "windows" -end - --- support 24bits true color --- --- There's no reliable way, and ncurses/terminfo's maintainer expressed he has no intent on introducing support. --- S-Lang author added a check for $COLORTERM containing either "truecolor" or "24bit" (case sensitive). --- In turn, VTE, Konsole and iTerm2 set this variable to "truecolor" (it's been there in VTE for a while, --- it's relatively new and maybe still git-only in Konsole and iTerm2). --- --- This is obviously not a reliable method, and is not forwarded via sudo, ssh etc. However, whenever it errs, --- it errs on the safe side: does not advertise support whereas it's actually supported. --- App developers can freely choose to check for this same variable, or introduce their own method --- (e.g. an option in their config file), whichever matches better the overall design of the given app. --- Checking $COLORTERM is recommended though, since that would lead to a more unique desktop experience --- where the user has to set one variable only and it takes effect across all the apps, rather than something --- separately for each app. --- -function colors.truecolor() - - -- support true color? - local colorterm = colors._colorterm() - return colorterm:find("truecolor", 1, true) or colorterm:find("24bit", 1, true) -end - --- support emoji? -function colors.emoji() - local emoji = colors._EMOJI - if emoji == nil then - emoji = not os.getenv("XMAKE_COLORTERM_NOEMOJI") - colors._EMOJI = emoji - end - return emoji -end - -- make rainbow truecolor code by the index of characters -- -- @param index the index of characters @@ -327,24 +251,29 @@ function colors.translate(str, opt) end -- translate color blocks, e.g. ${red}, ${color.xxx}, ${emoji} + tty = tty or require("base/tty") + local has_color8 = tty.has_color8() + local has_color256 = tty.has_color256() + local has_color24 = tty.has_color24() + local has_emoji = tty.has_emoji() str = str:gsub("(%${(.-)})", function(_, word) -- not supported? ignore it local nocolors = false - if not colors.color8() and not colors.color256() and not colors.truecolor() then + if not has_color8 and not has_color256 and not has_color24 then nocolors = true end -- is plain theme? no colors and no emoji - local noemoji = not colors.emoji() + local noemoji = not has_emoji if opt.plain or (theme and theme:name() == "plain") then nocolors = true noemoji = true end -- get keys - local keys = colors.color256() and colors._keys256 or colors._keys8 - if colors.truecolor() then + local keys = has_color256 and colors._keys256 or colors._keys8 + if has_color24 then keys = colors._keys24 end @@ -384,13 +313,13 @@ function colors.translate(str, opt) -- get the color code local code = keys[block] if not code then - if colors.truecolor() and block:find(";", 1, true) then + if has_color24 and block:find(";", 1, true) then if block:startswith("on;") then code = block:gsub("on;", "48;2;") else code = "38;2;" .. block end - elseif colors.color256() and block:find("#", 1, true) then + elseif has_color256 and block:find("#", 1, true) then if block:startswith("on#") then code = block:gsub("on#", "48;5;") else diff --git a/xmake/core/base/cpu.lua b/xmake/core/base/cpu.lua new file mode 100644 index 000000000..a09aea4c9 --- /dev/null +++ b/xmake/core/base/cpu.lua @@ -0,0 +1,336 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file cpu.lua +-- + +-- define module +local cpu = cpu or {} + +-- load modules +local os = require("base/os") +local winos = require("base/winos") +local io = require("base/io") +local hashset = require("base/hashset") + +-- get cpu micro architecture for Intel +-- +-- @see https://en.wikichip.org/wiki/intel/cpuid +-- https://github.com/xmake-io/xmake/issues/1120 +-- +function cpu._march_intel() + local cpu_family = cpu.family() + local cpu_model = cpu.model() + if cpu_family == 3 then + return "80386" + elseif cpu_family == 4 then + if cpu_model >= 1 and cpu_model <= 9 then + return "80486" + end + elseif cpu_family == 5 then + if cpu_model == 9 or cpu_model == 10 then + return "Lakemont" + elseif cpu_model == 1 or cpu_model == 2 or + cpu_model == 4 or cpu_model == 7 or cpu_model == 8 then + return "P5" + end + elseif cpu_family == 6 then + -- mic architecture + if cpu_model == 133 then + return "Knights Mill" + elseif cpu_model == 87 then + return "Knights Landing" + end + + -- small cores + if cpu_model == 134 then + return "Tremont" + elseif cpu_model == 122 then + return "Goldmont Plus" + elseif cpu_model == 95 or cpu_model == 92 then + return "Goldmont" + elseif cpu_model == 76 then + return "Airmont" + elseif cpu_model == 93 or cpu_model == 90 or + cpu_model == 77 or cpu_model == 74 or cpu_model == 55 then + return "Silvermont" + elseif cpu_model == 54 or cpu_model == 53 or cpu_model == 39 then + return "Saltwell" + elseif cpu_model == 38 or cpu_model == 28 then + return "Bonnell" + end + + -- big cores + if cpu_model == 140 then + return "Tiger Lake" + elseif cpu_model == 126 or cpu_model == 125 then + return "Ice Lake" + elseif cpu_model == 165 then + return "Comet Lake" + elseif cpu_model == 102 then + return "Cannon Lake" + elseif cpu_model == 142 or cpu_model == 158 then + return "Kaby Lake" + elseif cpu_model == 94 or cpu_model == 78 or cpu_model == 85 then + return "Skylake" + elseif cpu_model == 71 or cpu_model == 61 or cpu_model == 79 or cpu_model == 86 then + return "Broadwell" + elseif cpu_model == 70 or cpu_model == 69 or cpu_model == 60 or cpu_model == 63 then + return "Haswell" + elseif cpu_model == 58 or cpu_model == 62 then + return "Ivy Bridge" + elseif cpu_model == 42 or cpu_model == 45 then + return "Sandy Bridge" + elseif cpu_model == 37 or cpu_model == 44 or cpu_model == 47 then + return "Westmere" + elseif cpu_model == 31 or cpu_model == 30 or cpu_model == 46 or cpu_model == 26 then + return "Nehalem" + elseif cpu_model == 23 or cpu_model == 29 then + return "Penryn" + elseif cpu_model == 22 or cpu_model == 15 then + return "Core" + elseif cpu_model == 14 then + return "Modified Pentium M" + elseif cpu_model == 21 or cpu_model == 13 or cpu_model == 9 then + return "Pentium M" + elseif cpu_model == 11 or cpu_model == 10 or cpu_model == 8 or cpu_model == 7 or + cpu_model == 6 or cpu_model == 5 or cpu_model == 1 then + return "P6" + end + elseif cpu_family == 7 then + -- TODO Itanium + elseif cpu_family == 11 then + if cpu_model == 0 then + return "knights-ferry" + elseif cpu_model == 1 then + return "knights-corner" + end + elseif cpu_family == 15 then + if cpu_model <= 6 then + return "netburst" + end + end +end + +-- get cpu micro architecture for AMD +-- +-- @see https://en.wikichip.org/wiki/amd/cpuid +-- +function cpu._march_amd() + local cpu_family = cpu.family() + local cpu_model = cpu.model() + if cpu_family == 25 then + return "Zen 3" + elseif cpu_family == 24 then + return "Zen" + elseif cpu_family == 23 then + if cpu_model == 144 or cpu_model == 113 or cpu_model == 96 or cpu_model == 49 then + return "Zen 2" + elseif cpu_model == 24 or cpu_model == 8 then + return "Zen+" + else + return "Zen" + end + elseif cpu_family == 22 then + return "AMD 16h" + elseif cpu_family == 21 then + if cpu_model < 2 then + return "Bulldozer" + else + -- TODO and Steamroller, Excavator .. + return "Piledriver" + end + elseif cpu_family == 20 then + return "Bobcat" + elseif cpu_family == 16 then + return "K10" + elseif cpu_family == 15 then + if cpu_model > 64 then + return "K8-sse3" + else + return "K8" + end + end +end + +-- get cpu info +function cpu._info() + local cpuinfo = cpu._CPUINFO + if cpuinfo == nil then + cpuinfo = {} + if os.host() == "macosx" then + local ok, sysctl_result = os.iorun("/usr/sbin/sysctl -n machdep.cpu.vendor machdep.cpu.model machdep.cpu.family machdep.cpu.features machdep.cpu.brand_string") + if ok and sysctl_result then + sysctl_result = sysctl_result:trim():split('\n', {plain = true}) + cpuinfo.vendor_id = sysctl_result[1] + cpuinfo.cpu_model = sysctl_result[2] + cpuinfo.cpu_family = sysctl_result[3] + cpuinfo.cpu_features = sysctl_result[4] + if cpuinfo.cpu_features then + cpuinfo.cpu_features = cpuinfo.cpu_features:lower():gsub("%.", "_") + end + cpuinfo.cpu_model_name = sysctl_result[5] + end + elseif os.host() == "linux" then + -- FIXME + -- local proc_cpuinfo = io.readfile("/proc/cpuinfo") + local ok, proc_cpuinfo = os.iorun("cat /proc/cpuinfo") + if ok and proc_cpuinfo then + for _, line in ipairs(proc_cpuinfo:split('\n', {plain = true})) do + if not cpuinfo.vendor_id and line:startswith("vendor_id") then + cpuinfo.vendor_id = line:match("vendor_id%s+:%s+(.*)") + end + if not cpuinfo.cpu_model and line:startswith("model") then + cpuinfo.cpu_model = line:match("model%s+:%s+(.*)") + end + if not cpuinfo.cpu_model_name and line:startswith("model name") then + cpuinfo.cpu_model_name = line:match("model name%s+:%s+(.*)") + end + if not cpuinfo.cpu_family and line:startswith("cpu family") then + cpuinfo.cpu_family = line:match("cpu family%s+:%s+(.*)") + end + if not cpuinfo.cpu_features and line:startswith("flags") then + cpuinfo.cpu_features = line:match("flags%s+:%s+(.*)") + end + -- termux on android + if not cpuinfo.cpu_features and line:startswith("Features") then + cpuinfo.cpu_features = line:match("Features%s+:%s+(.*)") + end + end + end + elseif os.host() == "windows" then + cpuinfo.vendor_id = winos.registry_query("HKEY_LOCAL_MACHINE\\Hardware\\Description\\System\\CentralProcessor\\0;VendorIdentifier") + cpuinfo.cpu_model_name = winos.registry_query("HKEY_LOCAL_MACHINE\\Hardware\\Description\\System\\CentralProcessor\\0;ProcessorNameString") + local cpu_id = winos.registry_query("HKEY_LOCAL_MACHINE\\Hardware\\Description\\System\\CentralProcessor\\0;Identifier") + if cpu_id then + local cpu_family, cpu_model = cpu_id:match("Family (%d+) Model (%d+)") + cpuinfo.cpu_family = cpu_family + cpuinfo.cpu_model = cpu_model + end + elseif os.host() == "bsd" then + local ok, dmesginfo = os.iorun("dmesg") + if ok and dmesginfo then + for _, line in ipairs(dmesginfo:split('\n', {plain = true})) do + if not cpuinfo.vendor_id and line:find("Origin=", 1, true) then + cpuinfo.vendor_id = line:match("Origin=\"(.-)\"") + end + if not cpuinfo.cpu_model and line:find("Model=", 1, true) then + cpuinfo.cpu_model = line:match("Model=([%d%w]+)") + end + if not cpuinfo.cpu_family and line:find("Family=", 1, true) then + cpuinfo.cpu_family = line:match("Family=([%d%w]+)") + end + if line:find("Features=", 1, true) then + local cpu_features = line:match("Features=.*<(.-)>") + if cpu_features then + if cpuinfo.cpu_features then + cpuinfo.cpu_features = cpuinfo.cpu_features .. "," .. cpu_features + else + cpuinfo.cpu_features = cpu_features + end + end + end + end + if cpuinfo.cpu_features then + cpuinfo.cpu_features = cpuinfo.cpu_features:lower():gsub(",", " ") + end + local ok, cpu_model_name = os.iorun("sysctl -n hw.model") + if ok and cpu_model_name then + cpuinfo.cpu_model_name = cpu_model_name:trim() + end + end + end + cpu._CPUINFO = cpuinfo + end + return cpuinfo +end + +-- get vendor id +function cpu.vendor() + return cpu._info().vendor_id +end + +-- get cpu model +function cpu.model() + local cpu_model = cpu._info().cpu_model + return cpu_model and tonumber(cpu_model) +end + +-- get cpu model name +function cpu.model_name() + return cpu._info().cpu_model_name +end + +-- get cpu family +function cpu.family() + local cpu_family = cpu._info().cpu_family + return cpu_family and tonumber(cpu_family) +end + +-- get cpu features +function cpu.features() + return cpu._info().cpu_features +end + +-- has the given feature? +function cpu.has_feature(name) + local features = cpu._FEATURES + if not features then + features = cpu.features() + if features then + features = hashset.from(features:split('%s')) + end + cpu._FEATURES = features + end + return features:has(name) +end + +-- get cpu micro architecture +function cpu.march() + local march = cpu._MARCH + if march == nil then + local cpu_vendor = cpu.vendor() + if cpu_vendor == "GenuineIntel" then + march = cpu._march_intel() + elseif cpu_vendor == "AuthenticAMD" then + march = cpu._march_amd() + end + cpu._MARCH = march + end + return march +end + +-- get cpu number +function cpu.number() + return os._cpuinfo().ncpu +end + +-- get cpu info +function cpu.info(name) + local cpuinfo = {} + cpuinfo.vendor = cpu.vendor() + cpuinfo.model = cpu.model() + cpuinfo.family = cpu.family() + cpuinfo.march = cpu.march() + cpuinfo.ncpu = cpu.number() + cpuinfo.features = cpu.features() + cpuinfo.model_name = cpu.model_name() + return name and cpuinfo[name] or cpuinfo +end + +-- return module +return cpu diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index e60a630a1..2f26e20ce 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -983,7 +983,7 @@ function interpreter:api_register_scope(...) for name, values in pairs(scope_info) do local apifunc = self:api_func("set_" .. name) or self:api_func("add_" .. name) or self:api_func("on_" .. name) or self:api_func(name) if apifunc then - apifunc(values) + apifunc(table.unpack(table.wrap(values))) else os.raise("unknown %s for %s(\"%s\")", name, scope_kind, scope_name) end @@ -1286,6 +1286,7 @@ function interpreter:api_register_set_paths(scope_kind, ...) end -- translate paths + values = table.join(unpack(values)) local paths = self:_api_translate_paths(values, "set_" .. name) -- save values @@ -1318,7 +1319,7 @@ function interpreter:api_register_del_paths(scope_kind, ...) local implementation = function (self, scope, name, ...) -- translate paths - local values = {...} + local values = table.join(...) local paths = self:_api_translate_paths(values, "del_" .. name) -- mark these paths as deleted @@ -1357,6 +1358,7 @@ function interpreter:api_register_add_paths(scope_kind, ...) end -- translate paths + values = table.join(unpack(values)) local paths = self:_api_translate_paths(values, "add_" .. name) -- save values diff --git a/xmake/core/base/json.lua b/xmake/core/base/json.lua index 1807ad2ea..e43ae7d52 100644 --- a/xmake/core/base/json.lua +++ b/xmake/core/base/json.lua @@ -33,28 +33,11 @@ json.null = cjson.null -- -- @param jsonstr the json string -- @param opt the options --- - max_depth --- - invalid_numbers -- -- @return the lua table -- function json.decode(jsonstr, opt) - local cjsonobj = cjson - if opt then - if opt.max_depth then - if cjsonobj == cjson then - cjsonobj = cjson.new() - end - cjsonobj.decode_max_depth(opt.max_depth) - end - if opt.invalid_numbers then - if cjsonobj == cjson then - cjsonobj = cjson.new() - end - cjsonobj.decode_invalid_numbers(opt.invalid_numbers) - end - end - local ok, luatable_or_errors = utils.trycall(cjsonobj.decode, nil, jsonstr) + local ok, luatable_or_errors = utils.trycall(cjson.decode, nil, jsonstr) if not ok then return nil, string.format("decode json failed, %s", luatable_or_errors) end @@ -65,42 +48,11 @@ end -- -- @param luatable the lua table -- @param opt the options --- - max_depth --- - invalid_numbers --- - keep_buffer --- - number_precision -- -- @return the json string -- function json.encode(luatable, opt) - local cjsonobj = cjson - if opt then - if opt.max_depth then - if cjsonobj == cjson then - cjsonobj = cjson.new() - end - cjsonobj.encode_max_depth(opt.max_depth) - end - if opt.invalid_numbers then - if cjsonobj == cjson then - cjsonobj = cjson.new() - end - cjsonobj.encode_invalid_numbers(opt.invalid_numbers) - end - if opt.keep_buffer then - if cjsonobj == cjson then - cjsonobj = cjson.new() - end - cjsonobj.encode_keep_buffer(opt.keep_buffer) - end - if opt.number_precision then - if cjsonobj == cjson then - cjsonobj = cjson.new() - end - cjsonobj.encode_number_precision(opt.number_precision) - end - end - local ok, jsonstr_or_errors = utils.trycall(cjsonobj.encode, nil, luatable) + local ok, jsonstr_or_errors = utils.trycall(cjson.encode, nil, luatable) if not ok then return nil, string.format("encode json failed, %s", jsonstr_or_errors) end @@ -113,8 +65,6 @@ end -- @param opt the options -- - encoding for io/file, e.g. utf8, utf16, utf16le, utf16be .. -- - continuation for io/read (concat string with the given continuation characters) --- - max_depth --- - invalid_numbers -- -- @return the lua table -- @@ -132,10 +82,6 @@ end -- @param luatable the lua table -- @param opt the options -- - encoding for io/file, e.g. utf8, utf16, utf16le, utf16be .. --- - max_depth --- - invalid_numbers --- - keep_buffer --- - number_precision -- -- @return the json string -- diff --git a/xmake/core/base/linuxos.lua b/xmake/core/base/linuxos.lua new file mode 100644 index 000000000..b622479bc --- /dev/null +++ b/xmake/core/base/linuxos.lua @@ -0,0 +1,195 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file linuxos.lua +-- + +-- define module: linuxos +local linuxos = linuxos or {} + +-- load modules +local os = require("base/os") +local path = require("base/path") +local semver = require("base/semver") + +-- get lsb_release information +-- +-- e.g. +-- +-- Distributor ID: Ubuntu +-- Description: Ubuntu 16.04.7 LTS +-- Release: 16.04 +-- Codename: xenial +-- +function linuxos._lsb_release() + local lsb_release = linuxos._LSB_RELEASE + if lsb_release == nil then + local ok, result = os.iorun("lsb_release -a") + if ok then + lsb_release = result + end + if lsb_release then + lsb_release = lsb_release:trim():lower() + end + linuxos._LSB_RELEASE = lsb_release or false + end + return lsb_release or nil +end + +-- get uname information +function linuxos._uname_r() + local uname_r = linuxos._UNAME_R + if uname_r == nil then + local ok, result = os.iorun("uname -r") + if ok then + uname_r = result + end + if uname_r then + uname_r = uname_r:trim():lower() + end + linuxos._UNAME_R = uname_r or false + end + return uname_r or nil +end + +-- get system name +-- +-- e.g. +-- - ubuntu +-- - debian +-- - archlinux +-- - rhel +-- - centos +-- - fedora +-- - opensuse +-- - ... +function linuxos.name() + local name = linuxos._NAME + if name == nil then + -- get it from /etc/os-release first + if name == nil and os.isfile("/etc/os-release") then + local os_release = io.readfile("/etc/os-release") + if os_release then + os_release = os_release:trim():lower() + if os_release:find("arch linux", 1, true) or os_release:find("archlinux", 1, true) then + name = "archlinux" + elseif os_release:find("centos linux", 1, true) or os_release:find("centos", 1, true) then + name = "centos" + elseif os_release:find("fedora", 1, true) then + name = "fedora" + elseif os_release:find("linux mint", 1, true) or os_release:find("linuxmint", 1, true) then + name = "linuxmint" + elseif os_release:find("ubuntu", 1, true) then + name = "ubuntu" + elseif os_release:find("debian", 1, true) then + name = "debian" + elseif os_release:find("opensuse", 1, true) then + name = "opensuse" + elseif os_release:find("manjaro", 1, true) then + name = "manjaro" + end + end + end + + -- get it from lsb release + if name == nil then + local lsb_release = linuxos._lsb_release() + if lsb_release and lsb_release:find("ubuntu", 1, true) then + name = "ubuntu" + end + end + + -- is archlinux? + if name == nil and os.isfile("/etc/arch-release") then + name = "archlinux" + end + + -- unknown + name = name or "unknown" + linuxos._NAME = name + end + return name +end + +-- get system version +function linuxos.version() + local version = linuxos._VERSION + if version == nil then + + -- get it from /etc/os-release first + if version == nil and os.isfile("/etc/os-release") then + local os_release = io.readfile("/etc/os-release") + if os_release then + os_release = os_release:trim():lower():split("\n") + for _, line in ipairs(os_release) do + -- ubuntu: VERSION="16.04.7 LTS (Xenial Xerus)" + -- fedora: VERSION="32 (Container Image)" + -- debian: VERSION="9 (stretch)" + if line:find("version=") then + line = line:sub(9) + version = semver.match(line) + if not version then + version = line:match("\"(%d+)%s+.*\"") + if version then + version = semver.new(version .. ".0") + end + end + if version then + break + end + end + end + end + end + + -- get it from lsb release + if version == nil then + local lsb_release = linuxos._lsb_release() + if lsb_release and lsb_release:find("ubuntu", 1, true) then + for _, line in ipairs(lsb_release:split("\n")) do + -- release: 16.04 + if line:find("release:") then + version = semver.match(line, 9) + if version then + break + end + end + end + end + end + linuxos._VERSION = version + end + return version +end + +-- get linux kernel version +function linuxos.kernelver() + local version = linuxos._KERNELVER + if version == nil then + if version == nil then + local uname_r = linuxos._uname_r() + if uname_r then + version = semver.match(uname_r) + end + end + linuxos._KERNELVER = version + end + return version +end + +-- return module: linuxos +return linuxos diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua index 126ebfb0a..539f3f637 100644 --- a/xmake/core/base/option.lua +++ b/xmake/core/base/option.lua @@ -19,11 +19,12 @@ -- -- define module: option -local option = option or {} +local option = {} -- load modules local cli = require("base/cli") local table = require("base/table") +local tty = require("base/tty") local colors = require("base/colors") local text = require("base/text") @@ -499,14 +500,14 @@ function option.show_logo(logo, opt) -- make rainbow for logo opt = opt or {} - if colors.truecolor() or colors.color256() then + if tty.has_color24() or tty.has_color256() then local lines = {} local seed = opt.seed or 236 for _, line in ipairs(logo:split("\n")) do local i = 0 local line2 = "" line:gsub(".", function (c) - local code = colors.truecolor() and colors.rainbow24(i, seed) or colors.rainbow256(i, seed) + local code = tty.has_color24() and colors.rainbow24(i, seed) or colors.rainbow256(i, seed) line2 = string.format("%s${bright %s}%s", line2, code, c) i = i + 1 end) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 099ceb799..e9f403d92 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -39,6 +39,7 @@ os._rmdir = os._rmdir or os.rmdir os._tmpdir = os._tmpdir or os.tmpdir os._setenv = os._setenv or os.setenv os._getenvs = os._getenvs or os.getenvs +os._cpuinfo = os._cpuinfo or os.cpuinfo os._readlink = os._readlink or os.readlink -- syserror code @@ -180,11 +181,23 @@ function os._ramdir() return ramdir_root or nil end +-- set on change environments callback for scheduler +function os._sched_chenvs_set(envs) + os._SCHED_CHENVS = envs +end + -- set on change directory callback for scheduler function os._sched_chdir_set(chdir) os._SCHED_CHDIR = chdir end +-- notify envs have been changed +function os._notify_envs_changed(envs) + if os._SCHED_CHENVS then + os._SCHED_CHENVS(envs) + end +end + -- the current host is belong to the given hosts? function os._is_host(host, ...) @@ -225,6 +238,28 @@ function os._match_wildcard_pathes(v) return v end +-- split too long path environment variable for windows +-- +-- @see https://github.com/xmake-io/xmake-repo/pull/489 +-- https://stackoverflow.com/questions/34491244/environment-variable-is-too-large-on-windows-10 +-- +function os._remove_repeat_pathenv(value) + if value and #value > 4096 then + local itemset = {} + local results = {} + for _, item in ipairs(path.splitenv(value)) do + if not itemset[item] then + table.insert(results, item) + itemset[item] = true + end + end + if #results > 0 then + value = path.joinenv(results) + end + end + return value +end + -- match files or directories -- -- @param pattern the search pattern @@ -257,11 +292,7 @@ function os.match(pattern, mode, callback) local _excludes = {} for _, exclude in ipairs(excludes) do exclude = path.translate(exclude) - exclude = exclude:gsub("([%+%.%-%^%$%(%)%%])", "%%%1") - exclude = exclude:gsub("%*%*", "\001") - exclude = exclude:gsub("%*", "\002") - exclude = exclude:gsub("\001", ".*") - exclude = exclude:gsub("\002", "[^/]*") + exclude = path.pattern(exclude) table.insert(_excludes, exclude) end excludes = _excludes @@ -479,7 +510,7 @@ function os.cd(dir) -- do chdir callback for scheduler if os._SCHED_CHDIR then - os._SCHED_CHDIR(oldir, os.curdir()) + os._SCHED_CHDIR(os.curdir()) end -- ok @@ -687,10 +718,13 @@ function os.execv(program, argv, opt) if opt.envs then local envars = os.getenvs() for k, v in pairs(opt.envs) do - -- TODO if type(v) == "table" then v = path.joinenv(v) end + -- we try to fix too long value before running process + if type(v) == "string" and #v > 4096 and os.host() == "windows" then + v = os._remove_repeat_pathenv(v) + end envars[k] = v end envs = {} @@ -817,15 +851,17 @@ function os.isexec(filepath) -- TODO -- check permission - -- is *.exe for windows? + -- check executable program exist + if os.isfile(filepath) then + return true + end if os.host() == "windows" then - if not filepath:endswith(".exe") and not filepath:endswith(".cmd") and not filepath:endswith(".bat") then - filepath = filepath .. ".exe" + for _, suffix in ipairs({".exe", ".cmd", ".bat"}) do + if os.isfile(filepath .. suffix) then + return true + end end end - - -- file exists? - return os.isfile(filepath) end -- get system host @@ -971,7 +1007,18 @@ function os.fscase() return os._FSCASE end +-- get shell +function os.shell() + return require("base/tty").shell() +end + +-- get term +function os.term() + return require("base/tty").term() +end + -- get all current environment variables +-- e.g. envs["PATH"] = "/xxx:/yyy/foo" function os.getenvs() local envs = {} for _, line in ipairs(os._getenvs()) do @@ -990,28 +1037,119 @@ function os.getenvs() return envs end +-- set all current environment variables +-- e.g. envs["PATH"] = "/xxx:/yyy/foo" +function os.setenvs(envs) + local oldenvs = os.getenvs() + if envs then + local changed = false + -- remove new added values + for name, _ in pairs(oldenvs) do + if not envs[name] then + if os._setenv(name, "") then + changed = true + end + end + end + -- change values + for name, values in pairs(envs) do + if oldenvs[name] ~= values then + if os._setenv(name, values) then + changed = true + end + end + end + if changed then + os._notify_envs_changed(envs) + end + end + return oldenvs +end + +-- add environment variables +-- e.g. envs["PATH"] = "/xxx:/yyy/foo" +function os.addenvs(envs) + local oldenvs = os.getenvs() + if envs then + local changed = false + for name, values in pairs(envs) do + local ok + local oldenv = oldenvs[name] + if oldenv == "" or oldenv == nil then + ok = os._setenv(name, values) + elseif not oldenv:startswith(values) then + ok = os._setenv(name, values .. path.envsep() .. oldenv) + end + if ok then + changed = true + end + end + if changed then + os._notify_envs_changed() + end + end + return oldenvs +end + +-- join environment variables +function os.joinenvs(envs, oldenvs) + oldenvs = oldenvs or os.getenvs() + local newenvs = oldenvs + if envs then + newenvs = table.copy(oldenvs) + for name, values in pairs(envs) do + local oldenv = oldenvs[name] + if oldenv == "" or oldenv == nil then + newenvs[name] = values + elseif not oldenv:startswith(values) then + newenvs[name] = values .. path.envsep() .. oldenv + end + end + end + return newenvs +end + -- set values to environment variable function os.setenv(name, ...) + local ok local values = {...} if #values <= 1 then -- keep compatible with original implementation - return os._setenv(name, values[1] or "") + ok = os._setenv(name, values[1] or "") else - return os._setenv(name, path.joinenv(values)) + ok = os._setenv(name, path.joinenv(values)) + end + if ok then + os._notify_envs_changed() end + return ok end -- add values to environment variable function os.addenv(name, ...) local values = {...} if #values > 0 then + local ok + local changed = false local oldenv = os.getenv(name) local appendenv = path.joinenv(values) if oldenv == "" or oldenv == nil then - return os._setenv(name, appendenv) + ok = os._setenv(name, appendenv) + if ok then + changed = true + end + elseif not oldenv:startswith(appendenv) then + ok = os._setenv(name, appendenv .. path.envsep() .. oldenv) + if ok then + changed = true + end else - return os._setenv(name, appendenv .. path.envsep() .. oldenv) + ok = true + end + if changed then + os._notify_envs_changed() end + return ok else return true end @@ -1020,7 +1158,11 @@ end -- set values to environment variable with the given seperator function os.setenvp(name, values, sep) sep = sep or path.envsep() - return os._setenv(name, table.concat(table.wrap(values), sep)) + local ok = os._setenv(name, table.concat(table.wrap(values), sep)) + if ok then + os._notify_envs_changed() + end + return ok end -- add values to environment variable with the given seperator @@ -1028,13 +1170,27 @@ function os.addenvp(name, values, sep) sep = sep or path.envsep() values = table.wrap(values) if #values > 0 then + local ok + local changed = false local oldenv = os.getenv(name) local appendenv = table.concat(values, sep) if oldenv == "" or oldenv == nil then - return os._setenv(name, appendenv) + ok = os._setenv(name, appendenv) + if ok then + changed = true + end + elseif not oldenv:startswith(appendenv) then + ok = os._setenv(name, appendenv .. sep .. oldenv) + if ok then + changed = true + end else - return os._setenv(name, appendenv .. sep .. oldenv) + ok = true end + if changed then + os._notify_envs_changed() + end + return ok else return true end @@ -1068,6 +1224,11 @@ function os.pbcopy(data) end end +-- get cpu info +function os.cpuinfo(name) + return require("base/cpu").info(name) +end + -- read the content of symlink function os.readlink(symlink) return os._readlink(path.absolute(symlink)) diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua index 494961c09..18dbc6b01 100644 --- a/xmake/core/base/path.lua +++ b/xmake/core/base/path.lua @@ -69,9 +69,12 @@ function path.basename(p) end -- get the file extension of the path: .xxx -function path.extension(p) +function path.extension(p, level) local i = p:lastof(".", true) if i then + if level and level > 1 then + return path.extension(p:sub(1, i - 1), level - 1) .. p:sub(i) + end return p:sub(i) else return "" @@ -188,7 +191,11 @@ function path.pattern(pattern) pattern = pattern:gsub("%*%*", "\001") pattern = pattern:gsub("%*", "\002") pattern = pattern:gsub("\001", ".*") - pattern = pattern:gsub("\002", "[^/]*") + if path.sep() == '\\' then + pattern = pattern:gsub("\002", "[^/\\]*") + else + pattern = pattern:gsub("\002", "[^/]*") + end -- case-insensitive filesystem? if not os.fscase() then @@ -197,5 +204,15 @@ function path.pattern(pattern) return pattern end +-- get cygwin-style path on msys2/cygwin, e.g. "c:\xxx" -> "/c/xxx" +function path.cygwin_path(p) + p = p:gsub("\\", "/") + local pos = p:find(":/") + if pos == 2 then + return "/" .. p:sub(1, 1) .. p:sub(3) + end + return p +end + -- return module: path return path diff --git a/xmake/core/base/profiler.lua b/xmake/core/base/profiler.lua index 9929e75e6..41911c5db 100644 --- a/xmake/core/base/profiler.lua +++ b/xmake/core/base/profiler.lua @@ -30,79 +30,43 @@ local string = require("base/string") -- get the function title function profiler:_func_title(funcinfo) - - -- check - assert(funcinfo) - - -- the function name local name = funcinfo.name or 'anonymous' - - -- the function line local line = string.format("%d", funcinfo.linedefined or 0) - - -- the function source local source = funcinfo.short_src or 'C_FUNC' if os.isfile(source) then source = path.relative(source, xmake._PROGRAM_DIR) end - - -- make title return string.format("%-30s: %s: %s", name, source, line) end -- get the function report function profiler:_func_report(funcinfo) - - -- get the function title local title = self:_func_title(funcinfo) - - -- get the function report local report = self._REPORTS_BY_TITLE[title] if not report then - - -- init report report = { title = self:_func_title(funcinfo) , callcount = 0 , totaltime = 0 } - - -- save it self._REPORTS_BY_TITLE[title] = report table.insert(self._REPORTS, report) end - - -- ok? return report end -- profiling call function profiler:_profiling_call(funcinfo) - - -- get the function report local report = self:_func_report(funcinfo) - assert(report) - - -- save the call time report.calltime = os.clock() - - -- update the call count report.callcount = report.callcount + 1 - end -- profiling return function profiler:_profiling_return(funcinfo) - - -- get the stoptime local stoptime = os.clock() - - -- get the function report local report = self:_func_report(funcinfo) - assert(report) - - -- update the total time if report.calltime and report.calltime > 0 then report.totaltime = report.totaltime + (stoptime - report.calltime) report.calltime = 0 @@ -111,11 +75,7 @@ end -- the profiling handler function profiler._profiling_handler(hooktype) - - -- the function info local funcinfo = debug.getinfo(2, 'nS') - - -- dispatch it if hooktype == "call" then profiler:_profiling_call(funcinfo) elseif hooktype == "return" then @@ -125,58 +85,38 @@ end -- the tracing handler function profiler._tracing_handler(hooktype) - - -- the function info local funcinfo = debug.getinfo(2, 'nS') - - -- is call? if hooktype == "call" then - - -- is xmake function? local name = funcinfo.name - local source = funcinfo.short_src or 'C_FUNC' - if name and os.isfile(source) then - - -- the function line + local source = funcinfo.short_src + if name and source and source:endswith(".lua") then local line = string.format("%d", funcinfo.linedefined or 0) - - -- get the relative source - source = path.relative(source, xmake._PROGRAM_DIR) - - -- trace it utils.print("%-30s: %s: %s", name, source, line) end end end -- start profiling -function profiler:start(mode) - - -- trace? +function profiler:start() + local mode = self:mode() if mode and mode == "trace" then debug.sethook(profiler._tracing_handler, 'cr', 0) else - -- init reports self._REPORTS = {} self._REPORTS_BY_TITLE = {} - - -- save the start time self._STARTIME = os.clock() - - -- start to hook debug.sethook(profiler._profiling_handler, 'cr', 0) end end -- stop profiling -function profiler:stop(mode) +function profiler:stop() -- trace? + local mode = self:mode() if mode and mode == "trace" then - -- stop to hook debug.sethook() - else -- save the stop time @@ -208,5 +148,20 @@ function profiler:stop(mode) end end +-- get profiler mode +function profiler:mode() + local mode = self._MODE + if not mode then + mode = os.getenv("XMAKE_PROFILE") + self._MODE = mode + end + return mode +end + +-- profiler is enabled? +function profiler:enabled() + return self:mode() ~= nil +end + -- return module return profiler diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua index 20f19adf9..70ba07414 100644 --- a/xmake/core/base/scheduler.lua +++ b/xmake/core/base/scheduler.lua @@ -87,6 +87,16 @@ function _coroutine:is_suspended() return self:status() == "suspended" end +-- is isolated? +function _coroutine:is_isolated() + return self._ISOLATED +end + +-- isolate coroutine environments +function _coroutine:isolate(isolate) + self._ISOLATED = isolate +end + -- get the current timer task function _coroutine:_timer_task() return self._TIMER_TASK @@ -238,21 +248,51 @@ end -- update the current directory hash of current coroutine function scheduler:_co_curdir_update(curdir) + -- get running coroutine + local running = self:co_running() + if not running then + return + end + -- save the current directory hash curdir = curdir or os.curdir() local curdir_hash = hash.uuid4(path.absolute(curdir)):sub(1, 8) - self._CO_CURDIR = curdir_hash + self._CO_CURDIR_HASH = curdir_hash -- save the current directory for each coroutine + local co_curdirs = self._CO_CURDIRS + if not co_curdirs then + co_curdirs = {} + self._CO_CURDIRS = co_curdirs + end + co_curdirs[running] = {curdir_hash, curdir} +end + +-- update the current environments hash of current coroutine +function scheduler:_co_curenvs_update(envs) + + -- get running coroutine local running = self:co_running() - if running then - local co_curdirs = self._CO_CURDIRS - if not co_curdirs then - co_curdirs = {} - self._CO_CURDIRS = co_curdirs - end - co_curdirs[running] = {curdir_hash, curdir} + if not running then + return end + + -- save the current directory hash + local envs_hash = "" + envs = envs or os.getenvs() + for _, key in ipairs(table.orderkeys(envs)) do + envs_hash = envs_hash .. key:upper() .. envs[key] + end + envs_hash = hash.uuid4(envs_hash):sub(1, 8) + self._CO_CURENVS_HASH = envs_hash + + -- save the current directory for each coroutine + local co_curenvs = self._CO_CURENVS + if not co_curenvs then + co_curenvs = {} + self._CO_CURENVS = co_curenvs + end + co_curenvs[running] = {envs_hash, envs} end -- resume it's waiting coroutine if all coroutines are dead in group @@ -304,8 +344,15 @@ end -- start a new named coroutine task function scheduler:co_start_named(coname, cotask, ...) + return self:co_start_withopt({name = coname}, cotask, ...) +end + +-- start a new coroutine task with options +function scheduler:co_start_withopt(opt, cotask, ...) -- check coroutine task + opt = opt or {} + local coname = opt.name if not cotask then return nil, string.format("cannot start coroutine, invalid cotask(%s/%s)", coname and coname or "anonymous", cotask) end @@ -314,12 +361,16 @@ function scheduler:co_start_named(coname, cotask, ...) local co co = _coroutine.new(coname, coroutine.create(function(...) self:_co_curdir_update() + self:_co_curenvs_update() cotask(...) self:co_tasks()[co:thread()] = nil if self:co_count() > 0 then self._CO_COUNT = self:co_count() - 1 end end)) + if opt.isolate then + co:isolate(true) + end self:co_tasks()[co:thread()] = co self._CO_COUNT = self:co_count() + 1 if self._STARTED then @@ -355,12 +406,19 @@ function scheduler:co_suspend(...) -- if the current directory has been changed? restore it local running = assert(self:co_running()) - local curdir = self._CO_CURDIR + local curdir = self._CO_CURDIR_HASH local olddir = self._CO_CURDIRS and self._CO_CURDIRS[running] or nil if olddir and curdir ~= olddir[1] then -- hash changed? os.cd(olddir[2]) end + -- if the current environments has been changed? restore it + local curenvs = self._CO_CURENVS_HASH + local oldenvs = self._CO_CURENVS and self._CO_CURENVS[running] or nil + if oldenvs and curenvs ~= oldenvs[1] and running:is_isolated() then -- hash changed? + os.setenvs(oldenvs[2]) + end + -- return results return table.unpack(results) end @@ -493,7 +551,7 @@ end -- get waiting objects for the given group name function scheduler:co_group_waitobjs(name) local objs = hashset.new() - for _, co in ipairs(self:co_group(name)) do + for _, co in ipairs(table.wrap(self:co_group(name))) do if not co:is_dead() then local obj = co:waitobj() if obj then @@ -750,10 +808,15 @@ function scheduler:runloop() end -- set on change directory callback for scheduler - os._sched_chdir_set(function (oldir, curdir) + os._sched_chdir_set(function (curdir) self:_co_curdir_update(curdir) end) + -- set on change environments callback for scheduler + os._sched_chenvs_set(function (envs) + self:_co_curenvs_update(envs) + end) + -- start all ready coroutine tasks local co_ready_tasks = self._CO_READY_TASKS if co_ready_tasks then diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua index 45a7761f2..70755e14a 100644 --- a/xmake/core/base/scopeinfo.lua +++ b/xmake/core/base/scopeinfo.lua @@ -519,7 +519,7 @@ end -- function (target) -- _instance:extraconf("includedirs", "inc", "public") -> true -- _instance:extraconf("includedirs", "inc") -> {public = true} --- _instance:extraconf("includedirs") -> {["inc"] = {public = true}} +-- _instance:extraconf("includedirs") -> {inc = {public = true}} -- end -- function _instance:extraconf(name, item, key) @@ -549,6 +549,33 @@ function _instance:extraconf(name, item, key) return value end +-- set the extra configuration +-- +-- e.g. +-- +-- add_includedirs("inc", {public = true}) +-- +-- function (target) +-- _instance:extraconf_set("includedirs", "inc", "public", true) +-- _instance:extraconf_set("includedirs", "inc", {public = true}) +-- _instance:extraconf_set("includedirs", {inc = {public = true}}) +-- end +-- +function _instance:extraconf_set(name, item, key, value) + if key ~= nil then + local extraconf = self:get("__extra_" .. name) or {} + if value ~= nil then + extraconf[item] = extraconf[item] or {} + extraconf[item][key] = value + else + extraconf[item] = key + end + self:set("__extra_" .. name, extraconf) + else + self:set("__extra_" .. name, item) + end +end + -- clone a new instance from the current function _instance:clone() return _instance.new(self:kind(), self:info(), {interpreter = self:interpreter(), remove_repeat = self._REMOVE_REPEAT, enable_filter = self._ENABLE_FILTER}) diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua index 180232f50..0417f9b8f 100644 --- a/xmake/core/base/tty.lua +++ b/xmake/core/base/tty.lua @@ -38,6 +38,19 @@ function tty._iowrite(...) end end +-- get colorterm setting +-- +-- COLORTERM: 8color/color8, 256color/color256, truecolor, nocolor +-- +function tty._colorterm() + local colorterm = tty._COLORTERM + if colorterm == nil then + colorterm = os.getenv("XMAKE_COLORTERM") or os.getenv("COLORTERM") or "" + tty._COLORTERM = colorterm + end + return colorterm +end + -- erases from the current cursor position to the end of the current line. function tty.erase_line_to_end() tty._iowrite("\x1b[K") @@ -112,5 +125,272 @@ function tty.flush() return tty end +-- get shell name +function tty.shell() + local shell = tty._SHELL + if shell == nil then + local subhost = xmake._SUBHOST + if subhost == "windows" then + if os.getenv("PROMPT") then + shell = "cmd" + else + local ok, result = os.iorun("pwsh -v") + if ok then + shell = "pwsh" + else + shell = "powershell" + end + end + else + shell = os.getenv("SHELL") + if shell then + for _, shellname in ipairs({"zsh", "bash", "sh"}) do + if shell:find(shellname) then + shell = shellname + break + end + end + end + end + tty._SHELL = shell or "sh" + end + return tty._SHELL +end + +-- get terminal name +-- - xterm +-- - cmd +-- - vstudio (in visual studio) +-- - vscode (in vscode) +-- - msys2 +-- - cygwin +-- - pwsh +-- - powershell +-- - mintty +-- - windows-terminal +-- - gnome-terminal +-- - xfce4-terminal +-- - konsole +-- - terminator +-- - rxvt +-- - lxterminal +-- - unknown +-- +function tty.term() + local term = tty._TERM + if term == nil then + + -- get term from $TERM_PROGRAM + if term == nil then + local TERM_PROGRAM = os.getenv("TERM_PROGRAM") + if TERM_PROGRAM ~= nil then + if TERM_PROGRAM:find("vscode", 1, true) then + term = "vscode" + elseif TERM_PROGRAM == "mintty" then + term = "mintty" -- git bash + end + end + end + + -- get term from $TERM + if term == nil then + local TERM = os.getenv("TERM") + if TERM ~= nil then + if TERM:find("xterm", 1, true) then + term = "xterm" + elseif TERM == "cygwin" then + term = "cygwin" + end + end + end + + -- get term from system + if term == nil then + local subhost = xmake._SUBHOST + if subhost == "windows" then + if os.getenv("XMAKE_IN_VSTUDIO") then + term = "vstudio" + elseif os.getenv("WT_SESSION") then + term = "windows-terminal" + else + term = tty.shell() + end + elseif subhost == "msys" then + term = "msys2" + elseif subhost == "cygwin" then + term = "cygwin" + elseif subhost == "macosx" then + term = "xterm" + end + end + tty._TERM = term or "unknown" + end + return tty._TERM +end + +-- has emoji? +function tty.has_emoji() + local has_emoji = tty._HAS_EMOJI + if has_emoji == nil then + local term = tty.term() + local winos = require("base/winos") + + -- before win8? disable it + if has_emoji == nil and (os.host() == "windows" and winos.version():le("win8")) then + has_emoji = false + end + + -- on msys2/cygwin/powershell? disable it + if has_emoji == nil and (term == "msys2" or term == "cygwin" or term == "powershell") then + has_emoji = false + end + + -- enable it by default + if has_emoji == nil then + has_emoji = true + end + tty._HAS_EMOJI = has_emoji or false + end + return has_emoji +end + +-- has 8 colors? +function tty.has_color8() + local has_color8 = tty._HAS_COLOR8 + if has_color8 == nil then + + -- detect it from $COLORTERM + if has_color8 == nil then + local colorterm = tty._colorterm() + if colorterm == "nocolor" then + has_color8 = false + elseif colorterm and colorterm:find("8color", 1, true) then + has_color8 = true + elseif tty.has_color256() or tty.has_color24() then + has_color8 = true + end + end + + -- detect it from $TERM + local term = tty.term() + if has_color8 == nil then + if term == "vstudio" then + has_color8 = false + elseif term == "xterm" or term == "mintty" then + has_color8 = true + end + end + + -- detect it from system + if has_color8 == nil then + if os.host() == "windows" then + local winos = require("base/winos") + if os.getenv("ANSICON") then + has_color8 = true + elseif winos.version():le("win8") then + has_color8 = false + else + has_color8 = true + end + else + -- alway enabled for unix-like system + has_color8 = true + end + end + tty._HAS_COLOR8 = has_color8 or false + end + return has_color8 +end + +-- has 256 colors? +function tty.has_color256() + + local has_color256 = tty._HAS_COLOR256 + if has_color256 == nil then + + -- detect it from $COLORTERM + if has_color256 == nil then + local colorterm = tty._colorterm() + if colorterm == "nocolor" then + has_color256 = false + elseif colorterm and (colorterm:find("256color", 1, true) or colorterm:find("color256", 1, true)) then + has_color256 = true + elseif tty.has_color24() then + has_color256 = true + end + end + + -- detect it from $TERM + local term = tty.term() + local term_env = os.getenv("TERM") + if has_color256 == nil then + if term == "vstudio" then + has_color256 = false + elseif term_env and (term_env:find("256color", 1, true) or term_env:find("color256", 1, true)) then + has_color256 = true + end + end + + -- detect it from system + if has_color256 == nil then + if os.host() == "windows" then + has_color256 = false + elseif os.host() == "linux" or os.host("macosx") then + -- alway enabled for linux/macOS, $TERM maybe xterm, not xterm-256color, but it is supported + has_color256 = true + else + has_color256 = false + end + end + tty._HAS_COLOR256 = has_color256 or false + end + return has_color256 +end + +-- has 24bits true color? +-- +-- There's no reliable way, and ncurses/terminfo's maintainer expressed he has no intent on introducing support. +-- S-Lang author added a check for $COLORTERM containing either "truecolor" or "24bit" (case sensitive). +-- In turn, VTE, Konsole and iTerm2 set this variable to "truecolor" (it's been there in VTE for a while, +-- it's relatively new and maybe still git-only in Konsole and iTerm2). +-- +-- This is obviously not a reliable method, and is not forwarded via sudo, ssh etc. However, whenever it errs, +-- it errs on the safe side: does not advertise support whereas it's actually supported. +-- App developers can freely choose to check for this same variable, or introduce their own method +-- (e.g. an option in their config file), whichever matches better the overall design of the given app. +-- Checking $COLORTERM is recommended though, since that would lead to a more unique desktop experience +-- where the user has to set one variable only and it takes effect across all the apps, rather than something +-- separately for each app. +-- +function tty.has_color24() + + local has_color24 = tty._HAS_COLOR24 + if has_color24 == nil then + + -- detect it from $COLORTERM + if has_color24 == nil then + local colorterm = tty._colorterm() + if colorterm == "nocolor" then + has_color24 = false + elseif colorterm and (colorterm:find("truecolor", 1, true) or colorterm:find("24bit", 1, true)) then + has_color24 = true + end + end + + -- detect it from $TERM + local term = tty.term() + local term_env = os.getenv("TERM") + if has_color256 == nil then + if term == "vstudio" then + has_color256 = false + elseif term_env and (term_env:find("truecolor", 1, true) or term_env:find("24bit", 1, true)) then + has_color256 = true + end + end + tty._HAS_COLOR24 = has_color24 or false + end + return has_color24 +end + -- return module return tty diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua index 4071490f5..c1b78af4d 100644 --- a/xmake/core/base/utils.lua +++ b/xmake/core/base/utils.lua @@ -314,18 +314,18 @@ function utils.confirm(opt) local description = opt.description or "" -- get confirm result - local confirm = option.get("yes") or option.get("confirm") - if type(confirm) == "string" then - confirm = confirm:lower() - if confirm == "d" or confirm == "def" then - confirm = default + local result = option.get("yes") or option.get("confirm") + if type(result) == "string" then + result = result:lower() + if result == "d" or result == "def" then + result = default else - confirm = nil + result = nil end end -- get user confirm - if confirm == nil then + if result == nil then -- show tips if type(description) == "function" then @@ -333,16 +333,20 @@ function utils.confirm(opt) else utils.cprint("${bright color.warning}note: ${clear}%s (pass -y or --confirm=y/n/d to skip confirm)?", description) end - utils.cprint("please input: ${bright}%s${clear} (y/n)", default and "y" or "n") -- get answer - io.flush() - confirm = option.boolean((io.read() or "false"):trim()) - if type(confirm) ~= "boolean" then - confirm = default + if opt.answer then + result = opt.answer() + else + utils.cprint("please input: ${bright}%s${clear} (y/n)", default and "y" or "n") + io.flush() + result = option.boolean((io.read() or "false"):trim()) + if type(result) ~= "boolean" then + result = default + end end end - return confirm + return result end function utils.table(data, opt) diff --git a/xmake/core/base/winos.lua b/xmake/core/base/winos.lua index 59c705708..d19faf0cb 100644 --- a/xmake/core/base/winos.lua +++ b/xmake/core/base/winos.lua @@ -155,7 +155,7 @@ function winos.version() end -- get command arguments on windows to solve 8192 character command line length limit -function winos.cmdargv(argv, key) +function winos.cmdargv(argv, opt) -- too long arguments? local limit = 4096 @@ -167,13 +167,32 @@ function winos.cmdargv(argv, key) end end if argn > limit then - local argsfile = os.tmpfile(key or table.concat(argv, '')) .. ".args.txt" - local f = io.open(argsfile, 'w') + opt = opt or {} + local argsfile = os.tmpfile(opt.tmpkey or table.concat(argv, '')) .. ".args.txt" + local f = io.open(argsfile, 'w', {encoding = "ansi"}) if f then -- we need split args file to solve `fatal error LNK1170: line in command file contains 131071 or more characters` -- @see https://github.com/xmake-io/xmake/issues/812 - for _, arg in ipairs(argv) do - f:write(os.args(arg, {escape = true}) .. "\n") + local idx = 1 + while idx <= #argv do + arg = argv[idx] + -- we need ensure `/name value` in same line, + -- otherwise cl.exe will prompt that the corresponding parameter value cannot be found + -- + -- e.g. + -- + -- /sourceDependencies xxxx.json + -- -Dxxx + -- foo.obj + -- + if idx + 1 <= #argv and arg:find("^[-/]") and not argv[idx + 1]:find("^[-/]") then + f:write(os.args(arg, {escape = opt.escape}) .. " ") + f:write(os.args(argv[idx + 1], {escape = opt.escape}) .. "\n") + idx = idx + 2 + else + f:write(os.args(arg, {escape = opt.escape}) .. "\n") + idx = idx + 1 + end end f:close() end @@ -196,7 +215,7 @@ function winos.registry_query(keypath) -- get value name local splitinfo = keypath:split(';', {plain = true}) - local valuename = splitinfo[2] or "(Default)" + local valuename = splitinfo[2] or "" keypath = splitinfo[1] -- get rootkey, e.g. HKEY_LOCAL_MACHINE diff --git a/xmake/core/cache/localcache.lua b/xmake/core/cache/localcache.lua index 3fd5d040f..fc68533f5 100644 --- a/xmake/core/cache/localcache.lua +++ b/xmake/core/cache/localcache.lua @@ -50,17 +50,22 @@ end -- load cache function _instance:load() - local result = io.load(path.join(config.cachedir(), self:name())) - if result ~= nil then - self._DATA = result + if os.isfile(os.projectfile()) or os.isdir(config.directory()) then + local result = io.load(path.join(config.cachedir(), self:name())) + if result ~= nil then + self._DATA = result + end end end -- save cache function _instance:save() - local ok, errors = io.save(path.join(config.cachedir(), self:name()), self._DATA) - if not ok then - os.raise(errors) + -- for xmake project or trybuild mode + if os.isfile(os.projectfile()) or os.isdir(config.directory()) then + local ok, errors = io.save(path.join(config.cachedir(), self:name()), self._DATA) + if not ok then + os.raise(errors) + end end end @@ -79,7 +84,7 @@ end -- get cache value in level/3 function _instance:get3(key1, key2, key3) - local value2 = self:get2(key1) + local value2 = self:get2(key1, key2) if value2 ~= nil then return value2[key3] end diff --git a/xmake/core/cache/memcache.lua b/xmake/core/cache/memcache.lua index 2a3b9802e..ffdcd25f3 100644 --- a/xmake/core/cache/memcache.lua +++ b/xmake/core/cache/memcache.lua @@ -58,7 +58,7 @@ end -- get cache value in level/3 function _instance:get3(key1, key2, key3) - local value2 = self:get2(key1) + local value2 = self:get2(key1, key2) if value2 ~= nil then return value2[key3] end diff --git a/xmake/core/language/language.lua b/xmake/core/language/language.lua index 0626e18e0..4815d47db 100644 --- a/xmake/core/language/language.lua +++ b/xmake/core/language/language.lua @@ -123,7 +123,7 @@ end -- e.g. -- {binary = "ld", static = "ar", shared = "sh"} -- -function _instance:targetkinds() +function _instance:kinds() return self._INFO:get("targetkinds") end @@ -260,10 +260,12 @@ function language.load(name) -- load all languages if not name then - for _, name in ipairs(table.wrap(os.match(path.join(language._directory(), "*"), true))) do - local instance, errors = language.load(path.basename(name)) - if not instance then - return nil, errors + if not language._LANGUAGES then + for _, name in ipairs(table.wrap(os.match(path.join(language._directory(), "*"), true))) do + local instance, errors = language.load(path.basename(name)) + if not instance then + return nil, errors + end end end return language._LANGUAGES @@ -594,7 +596,7 @@ function language.linkerinfos_of(targetkind, sourcekinds) for name, instance in pairs(languages) do for _, mixingkind in ipairs(table.wrap(instance:mixingkinds())) do local targetflags = instance:targetflags() - for _targetkind, linkerkind in pairs(table.wrap(instance:targetkinds())) do + for _targetkind, linkerkind in pairs(table.wrap(instance:kinds())) do -- init linker info linkerinfos[_targetkind] = linkerinfos[_targetkind] or {} @@ -667,7 +669,7 @@ function language.targetkinds() -- merge all for each language local targetkinds = {} for name, instance in pairs(languages) do - for targetkind, linkerkind in pairs(table.wrap(instance:targetkinds())) do + for targetkind, linkerkind in pairs(table.wrap(instance:kinds())) do targetkinds[targetkind] = targetkinds[targetkind] or {} table.insert(targetkinds[targetkind], linkerkind) end diff --git a/xmake/core/main.lua b/xmake/core/main.lua index 8eb3e065b..4664a1c40 100644 --- a/xmake/core/main.lua +++ b/xmake/core/main.lua @@ -38,15 +38,12 @@ local theme = require("theme/theme") local config = require("project/config") local project = require("project/project") local localcache = require("cache/localcache") ---local profiler = require("base/profiler") +local profiler = require("base/profiler") -- init the option menu local menu = { - -- title title = "${bright}xmake v" .. _VERSION .. ", A cross-platform build utility based on Lua${clear}" - - -- copyright , copyright = "Copyright (C) 2015-present Ruki Wang, ${underline}tboox.org${clear}, ${underline}xmake.io${clear}" -- the tasks: xmake [task] @@ -63,33 +60,17 @@ local menu = -- show help and version info function main._show_help() - - -- show help if option.get("help") then - - -- print menu option.show_menu(option.taskname()) - - -- ok return true - - -- show version elseif option.get("version") then - - -- show title if menu.title then utils.cprint(menu.title) end - - -- show copyright if menu.copyright then utils.cprint(menu.copyright) end - - -- show logo option.show_logo() - - -- ok return true end end @@ -138,6 +119,9 @@ end -- the init function for main function main._init() + -- disable scheduler first + scheduler:enable(false) + -- get project directory and project file from the argument option local options, err = main._basicparse() if not options then @@ -196,13 +180,15 @@ function main._init() end -- exit main program -function main._exit(errors) +function main._exit(ok, errors) -- show errors local retval = 0 - if errors then + if not ok then retval = -1 - utils.error(errors) + if errors then + utils.error(errors) + end end -- show warnings @@ -221,13 +207,13 @@ function main.entry() -- init local ok, errors = main._init() if not ok then - return main._exit(errors) + return main._exit(ok, errors) end -- load global configuration ok, errors = global.load() if not ok then - return main._exit(errors) + return main._exit(ok, errors) end -- load theme @@ -239,7 +225,7 @@ function main.entry() -- init option ok, errors = option.init(menu) if not ok then - return main._exit(errors) + return main._exit(ok, errors) end -- check run command as root @@ -251,17 +237,19 @@ As xmake does not drop privileges on installation you would be giving all build scripts full access to your system. Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily. ]] - return main._exit(errors) + return main._exit(false, errors) end end end -- start profiling - -- profiler:start() + if profiler:enabled() then + profiler:start() + end -- show help? if main._show_help() then - return main._exit() + return main._exit(true) end -- save command lines to history and we need to make sure that the .xmake directory is not generated everywhere @@ -278,12 +266,13 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily. -- get task instance local taskname = option.taskname() or "build" - local taskinst = project.task(taskname) or task.task(taskname) + local taskinst = task.task(taskname) or project.task(taskname) if not taskinst then - return main._exit(string.format("do unknown task(%s)!", taskname)) + return main._exit(false, string.format("do unknown task(%s)!", taskname)) end -- run task + scheduler:enable(true) scheduler:co_start_named("xmake " .. taskname, function () local ok, errors = taskinst:run() if not ok then @@ -292,14 +281,16 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily. end) ok, errors = scheduler:runloop() if not ok then - return main._exit(errors) + return main._exit(ok, errors) end -- stop profiling - -- profiler:stop() + if profiler:enabled() then + profiler:stop() + end -- exit normally - return main._exit() + return main._exit(true) end -- return module: main diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 52c9a0c7c..1e3d2172b 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -19,8 +19,8 @@ -- -- define module -local package = package or {} -local _instance = _instance or {} +local package = {} +local _instance = {} -- load modules local os = require("base/os") @@ -31,11 +31,14 @@ local table = require("base/table") local global = require("base/global") local semver = require("base/semver") local option = require("base/option") +local hashset = require("base/hashset") local scopeinfo = require("base/scopeinfo") local interpreter = require("base/interpreter") local memcache = require("cache/memcache") +local toolchain = require("tool/toolchain") local sandbox = require("sandbox/sandbox") local config = require("project/config") +local policy = require("project/policy") local platform = require("platform/platform") local platform_menu = require("platform/menu") local language = require("language/language") @@ -45,11 +48,13 @@ local sandbox_os = require("sandbox/modules/os") local sandbox_module = require("sandbox/modules/import/core/sandbox/module") -- new an instance -function _instance.new(name, info, scriptdir) +function _instance.new(name, info, opt) + opt = opt or {} local instance = table.inherit(_instance) - instance._NAME = name - instance._INFO = info - instance._SCRIPTDIR = scriptdir and path.absolute(scriptdir) + instance._NAME = name + instance._INFO = info + instance._REPO = opt.repo + instance._SCRIPTDIR = opt.scriptdir and path.absolute(opt.scriptdir) return instance end @@ -58,6 +63,11 @@ function _instance:name() return self._NAME end +-- get the type: package +function _instance:type() + return "package" +end + -- get the package configure function _instance:get(name) @@ -83,6 +93,11 @@ function _instance:extraconf(name, item, key) return self._INFO:extraconf(name, item, key) end +-- set the extra configuration +function _instance:extraconf_set(name, item, key, value) + return self._INFO:extraconf_set(name, item, key, value) +end + -- get the package license function _instance:license() return self:get("license") @@ -96,41 +111,46 @@ end -- get the platform of package function _instance:plat() -- @note we uses os.host() instead of them for the binary package - if self:kind() == "binary" then - return os.host() + if self:is_binary() then + return os.subhost() end local requireinfo = self:requireinfo() - if requireinfo and requireinfo.plat then + if not plat and requireinfo and requireinfo.plat then return requireinfo.plat end - return self:get("plat") or config.get("plat") or os.host() + return self:get("plat") or package._target_plat() end -- get the architecture of package function _instance:arch() -- @note we uses os.arch() instead of them for the binary package - if self:kind() == "binary" then - return os.arch() + if self:is_binary() then + return os.subarch() end + return self:targetarch() +end + +-- get the target os +function _instance:targetos() local requireinfo = self:requireinfo() - if requireinfo and requireinfo.arch then - return requireinfo.arch + if requireinfo and requireinfo.targetos then + return requireinfo.targetos end - return self:get("arch") or config.get("arch") or os.arch() + return config.get("target_os") or platform.os() end --- get the target os -function _instance:os() +-- get the target architecture +function _instance:targetarch() local requireinfo = self:requireinfo() - if requireinfo and requireinfo.os then - return requireinfo.os + if requireinfo and requireinfo.arch then + return requireinfo.arch end - return platform.os() + return self:get("arch") or package._target_arch() end -- get the build mode function _instance:mode() - return self:debug() and "debug" or "release" + return self:is_debug() and "debug" or "release" end -- get the repository of this package @@ -159,10 +179,20 @@ function _instance:is_arch(...) end -- the current platform is belong to the given target os? -function _instance:is_os(...) - local os = self:os() +function _instance:is_targetos(...) + local targetos = self:targetos() + for _, v in ipairs(table.join(...)) do + if v and targetos == v then + return true + end + end +end + +-- the current architecture is belong to the given target architectures? +function _instance:is_targetarch(...) + local targetarch = self:targetarch() for _, v in ipairs(table.join(...)) do - if v and os == v then + if v and targetarch:find("^" .. v:gsub("%-", "%%-") .. "$") then return true end end @@ -176,6 +206,12 @@ function _instance:alias() end end +-- get external package sources, e.g. pkgconfig::xxx, system::xxx, conan::xxx +-- we can use it to improve self:fetch() for find_package +function _instance:extsources() + return self:get("extsources") +end + -- get urls function _instance:urls() return self._URLS or table.wrap(self:get("urls")) @@ -201,6 +237,40 @@ function _instance:url_excludes(url) return self:extraconf("urls", url, "excludes") end +-- set artifacts info +function _instance:artifacts_set(artifacts_info) + local versions = self:get("versions") + if versions then + -- we switch to urls of the precompiled artifacts + self:urls_set(table.wrap(artifacts_info.urls)) + versions[self:version_str()] = artifacts_info.sha256 + self:set("install", function (package) + sandbox_module.import("lib.detect.find_path") + local rootdir = find_path("manifest.txt", path.join(os.curdir(), "*", "*", "*")) + if not rootdir then + os.raise("package(%s): manifest.txt not found when installing artifacts!", package:displayname()) + end + os.cp(path.join(rootdir, "*"), package:installdir()) + local manifest = package:manifest_load() + if not manifest then + os.raise("package(%s): load manifest.txt failed when installing artifacts!", package:displayname()) + end + local vars = manifest.vars + if vars then + for k, v in pairs(vars) do + package:set(k, v) + end + end + end) + self._IS_PRECOMPILED = true + end +end + +-- is this package built? +function _instance:is_built() + return not self._IS_PRECOMPILED +end + -- get the given dependent package function _instance:dep(name) local deps = self:deps() @@ -219,15 +289,14 @@ function _instance:orderdeps() return self._ORDERDEPS end --- add deps -function _instance:deps_add(...) - for _, dep in ipairs({...}) do - self:add("deps", dep:name()) - self._DEPS = self._DEPS or {} - self._DEPS[dep:name()] = dep - self._ORDERDEPS = self._ORDERDEPS or {} - table.insert(self._ORDERDEPS, dep) - end +-- get plain deps +function _instance:plaindeps() + return self._PLAINDEPS +end + +-- get link deps +function _instance:linkdeps() + return self._LINKDEPS end -- get parents @@ -245,12 +314,9 @@ end -- get hash of the source package for the url_alias@version_str function _instance:sourcehash(url_alias) - - -- get sourcehash local versions = self:get("versions") local version_str = self:version_str() if versions and version_str then - local sourcehash = nil if url_alias then sourcehash = versions[url_alias .. ":" ..version_str] @@ -258,8 +324,9 @@ function _instance:sourcehash(url_alias) if not sourcehash then sourcehash = versions[version_str] end - - -- ok? + if sourcehash then + sourcehash = sourcehash:lower() + end return sourcehash end end @@ -273,7 +340,30 @@ function _instance:revision(url_alias) end end --- get the package kind, binary or nil(library) +-- get the package policy +function _instance:policy(name) + local policies = self._POLICIES + if not policies then + policies = self:get("policy") + self._POLICIES = policies + if policies then + local defined_policies = policy.policies() + for name, _ in pairs(policies) do + if not defined_policies[name] then + utils.warning("unknown policy(%s), please run `xmake l core.project.policy.policies` if you want to all policies", name) + end + end + end + end + return policy.check(name, policies and policies[name]) +end + +-- get the package kind +-- +-- - binary +-- - toolchain (is also binary) +-- - library(default) +-- function _instance:kind() local kind = self:get("kind") if not kind then @@ -285,13 +375,109 @@ function _instance:kind() return kind end +-- is binary package? +function _instance:is_binary() + return self:kind() == "binary" or self:kind() == "toolchain" +end + +-- is toolchain package? +function _instance:is_toolchain() + return self:kind() == "toolchain" +end + +-- is library package? +function _instance:is_library() + return self:kind() == nil or self:kind() == "library" +end + +-- is header only? +function _instance:is_headeronly() + return self:is_library() and self:extraconf("kind", "library", "headeronly") +end + +-- is top level? user top requires in xmake.lua +function _instance:is_toplevel() + local requireinfo = self:requireinfo() + return requireinfo and requireinfo.is_toplevel +end + +-- is the system package? +function _instance:is_system() + return self._is_system +end + +-- is the third-party package? e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable +-- we need install and find package by third-party package manager directly +-- +function _instance:is_thirdparty() + return self._is_thirdparty +end + +-- is fetch only? +function _instance:is_fetchonly() + return self:get("fetch") and not self:get("install") +end + +-- is optional package? +function _instance:is_optional() + local requireinfo = self:requireinfo() + return requireinfo and requireinfo.optional or false +end + +-- is private package? +function _instance:is_private() + local requireinfo = self:requireinfo() + return requireinfo and requireinfo.private or false +end + +-- verify sha256sum and versions? +function _instance:is_verify() + local requireinfo = self:requireinfo() + local verify = requireinfo and requireinfo.verify + if verify == nil then + verify = true + end + return verify +end + +-- is debug package? +function _instance:is_debug() + return self:config("debug") +end + +-- is the supported package? +function _instance:is_supported() + -- attempt to get the install script with the current plat/arch + return self:script("install") ~= nil +end + +-- support parallelize for installation? +function _instance:is_parallelize() + return self:get("parallelize") ~= false +end + +-- is debug package? (deprecated) +function _instance:debug() + return self:is_debug() +end + +-- is cross-compilation? +function _instance:is_cross() + if not self:is_plat(os.host()) and not self:is_plat(os.subhost()) then + return true + end + if not self:is_arch(os.arch()) and not self:is_arch(os.subarch()) then + return true + end +end + -- get the filelock of the whole package directory function _instance:filelock() local filelock = self._FILELOCK if filelock == nil then filelock = io.openlock(path.join(self:cachedir(), "package.lock")) if not filelock then - os.raise("cannot create filelock for package(%s)!", package:name()) + os.raise("cannot create filelock for package(%s)!", self:name()) end self._FILELOCK = filelock end @@ -302,8 +488,8 @@ end function _instance:lock(opt) if self:filelock():trylock(opt) then return true - elseif option.get("diagnosis") then - utils.warning("the current package is being accessed by other processes, please waiting!") + else + utils.cprint("${color.warning}package(%s) is being accessed by other processes, please waiting!", self:name()) end local ok, errors = self:filelock():lock(opt) if not ok then @@ -327,12 +513,20 @@ end -- get the installed directory of this package function _instance:installdir(...) - local name = self:name():lower():gsub("::", "_") - local dir = path.join(package.installdir(), name:sub(1, 1):lower(), name) - if self:version_str() then - dir = path.join(dir, self:version_str()) + local installdir = self._INSTALLDIR + if not installdir then + installdir = self:get("installdir") + if not installdir then + local name = self:name():lower():gsub("::", "_") + installdir = path.join(package.installdir(), name:sub(1, 1):lower(), name) + if self:version_str() then + installdir = path.join(installdir, self:version_str()) + end + installdir = path.join(installdir, self:buildhash()) + end + self._INSTALLDIR = installdir end - dir = path.join(dir, self:buildhash(), ...) + local dir = path.join(installdir, ...) if not os.isdir(dir) then os.mkdir(dir) end @@ -394,6 +588,16 @@ function _instance:manifest_save() manifest.configs = self:configs() manifest.envs = self:envs() + -- save enabled link deps + if self:linkdeps() then + manifest.linkdeps = {} + for _, dep in ipairs(self:linkdeps()) do + if dep:exists() then + table.insert(manifest.linkdeps, dep:name()) + end + end + end + -- save variables local vars = {} local apis = language.apis() @@ -429,7 +633,7 @@ function _instance:envs() local envs = self._ENVS if not envs then envs = {} - if self:kind() == "binary" or self:is_plat("windows", "mingw") then -- bin/*.dll for windows + if self:is_binary() or self:is_plat("windows", "mingw") then -- bin/*.dll for windows envs.PATH = {"bin"} end -- add LD_LIBRARY_PATH to load *.so directory @@ -457,18 +661,8 @@ end -- enter the package environments function _instance:envs_enter() - - -- save the old environments - local oldenvs = self._OLDENVS - if not oldenvs then - oldenvs = {} - self._OLDENVS = oldenvs - end - - -- add the new environments local installdir = self:installdir() for name, values in pairs(self:envs()) do - oldenvs[name] = oldenvs[name] or os.getenv(name) if name == "PATH" or name == "LD_LIBRARY_PATH" or name == "DYLD_LIBRARY_PATH" then for _, value in ipairs(values) do if path.is_absolute(value) then @@ -483,24 +677,6 @@ function _instance:envs_enter() end end --- leave the package environments -function _instance:envs_leave() - local oldenvs = self._OLDENVS - if oldenvs then - -- remove new added values - for name, _ in pairs(self:envs()) do - if not oldenvs[name] then - os.setenv(name, nil) - end - end - -- restore old values - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end - self._OLDENVS = nil - end -end - -- get the given environment variable function _instance:getenv(name) return self:envs()[name] @@ -540,12 +716,9 @@ function _instance:build_envs(lazy_loading) setmetatable(build_envs, { __index = function (tbl, key) local value = config.get(key) if value == nil then - value = platform.toolconfig(key, self:plat()) - end - if value == nil then - value = platform.tool(key, self:plat()) + value = self:tool(key) end - value = table.unique(table.join(table.wrap(value), self:config(key))) + value = table.unique(table.join(table.wrap(value), table.wrap(self:config(key)), self:toolconfig(key))) if #value > 0 then value = table.unwrap(value) rawset(tbl, key, value) @@ -571,6 +744,48 @@ function _instance:build_envs(lazy_loading) return build_envs end +-- get toolchains +function _instance:toolchains() + local toolchains = self._TOOLCHAINS + if toolchains == nil then + local project = package._project() + for _, name in ipairs(table.wrap(self:config("toolchains"))) do + local toolchain_opt = project and project.extraconf("target.toolchains", name) or {} + toolchain_opt.plat = self:plat() + toolchain_opt.arch = self:arch() + local toolchain_inst, errors = toolchain.load(name, toolchain_opt) + if not toolchain_inst and project then + toolchain_inst = project.toolchain(name, toolchain_opt) + end + if not toolchain_inst then + os.raise(errors) + end + toolchains = toolchains or {} + table.insert(toolchains, toolchain_inst) + end + self._TOOLCHAINS = toolchains or false + end + return toolchains or nil +end + +-- get the program and name of the given tool kind +function _instance:tool(toolkind) + if self:toolchains() then + return toolchain.tool(self:toolchains(), toolkind, {cachekey = "package", plat = self:plat(), arch = self:arch()}) + else + return platform.tool(toolkind, self:plat(), self:arch()) + end +end + +-- get tool configuration from the toolchains +function _instance:toolconfig(name) + if self:toolchains() then + return toolchain.toolconfig(self:toolchains(), name, {cachekey = "package", plat = self:plat(), arch = self:arch()}) + else + return platform.toolconfig(name, self:plat(), self:arch()) + end +end + -- get the user private data function _instance:data(name) return self._DATA and self._DATA[name] or nil @@ -622,7 +837,7 @@ end -- get the version string function _instance:version_str() - if self:is3rd() then + if self:is_thirdparty() then local requireinfo = self:requireinfo() if requireinfo then return requireinfo.version @@ -677,6 +892,22 @@ function _instance:requireinfo_set(requireinfo) self._REQUIREINFO = requireinfo end +-- get label +function _instance:label() + local requireinfo = self:requireinfo() + return requireinfo and requireinfo.label +end + +-- get the display name +function _instance:displayname() + return self._DISPLAYNAME +end + +-- set the display name +function _instance:displayname_set(displayname) + self._DISPLAYNAME = displayname +end + -- get the given configuration value of package function _instance:config(name) local configs = self:configs() @@ -685,6 +916,14 @@ function _instance:config(name) end end +-- set configuration value +function _instance:config_set(name, value) + local configs = self:configs() + if configs then + configs[name] = value + end +end + -- get the configurations of package function _instance:configs() local configs = self._CONFIGS @@ -713,23 +952,77 @@ end function _instance:buildhash() local buildhash = self._BUILDHASH if buildhash == nil then - local str = self:plat() .. self:arch() - local configs = self:configs() - if configs then - -- since luajit v2.1, the key order of the table is random and undefined. - -- We cannot directly deserialize the table, so the result may be different each time - local configs_order = {} - for k, v in pairs(table.wrap(configs)) do - table.insert(configs_order, k .. "=" .. tostring(v)) + local function _get_buildhash(configs, opt) + opt = opt or {} + local str = self:plat() .. self:arch() + local label = self:label() + if label then + str = str .. label + end + if configs then + -- since luajit v2.1, the key order of the table is random and undefined. + -- We cannot directly deserialize the table, so the result may be different each time + local configs_order = {} + for k, v in pairs(table.wrap(configs)) do + table.insert(configs_order, k .. "=" .. tostring(v)) + end + table.sort(configs_order) + + -- we need to be compatible with the hash value string for the previous luajit version + local configs_str = string.serialize(configs_order, true) + configs_str = configs_str:gsub("\"", "") + str = str .. configs_str + end + if opt.sourcehash ~= false then + local sourcehashs = hashset.new() + for _, url in ipairs(self:urls()) do + local url_alias = self:url_alias(url) + local sourcehash = self:sourcehash(url_alias) + if sourcehash then + sourcehashs:insert(sourcehash) + end + end + if not sourcehashs:empty() then + local hashs = sourcehashs:to_array() + table.sort(hashs) + str = str .. "_" .. table.concat(hashs, "_") + end + end + return hash.uuid4(str):gsub('-', ''):lower() + end + local function _get_installdir(...) + local name = self:name():lower():gsub("::", "_") + local dir = path.join(package.installdir(), name:sub(1, 1):lower(), name) + if self:version_str() then + dir = path.join(dir, self:version_str()) + end + return path.join(dir, ...) + end + + -- we need to be compatible with the hash value string for the previous xmake version + -- without builtin pic configuration (< 2.5.1). + if self:config("pic") then + local configs = table.copy(self:configs()) + configs.pic = nil + buildhash = _get_buildhash(configs, {sourcehash = false}) + if not os.isdir(_get_installdir(buildhash)) then + buildhash = nil end - table.sort(configs_order) + end + + -- we need to be compatible with the hash value string for the previous xmake version + -- without sourcehash (< 2.5.2) + if not buildhash then + buildhash = _get_buildhash(self:configs(), {sourcehash = false}) + if not os.isdir(_get_installdir(buildhash)) then + buildhash = nil + end + end - -- We need to be compatible with the hash value string for the previous luajit version - local configs_str = string.serialize(configs_order, true) - configs_str = configs_str:gsub("\"", "") - str = str .. configs_str + -- get build hash for current version + if not buildhash then + buildhash = _get_buildhash(self:configs()) end - buildhash = hash.uuid4(str):gsub('-', ''):lower() self._BUILDHASH = buildhash end return buildhash @@ -743,50 +1036,6 @@ function _instance:group() end end --- is optional package? -function _instance:optional() - local requireinfo = self:requireinfo() - return requireinfo and requireinfo.optional or false -end - --- verify sha256sum and versions? -function _instance:verify() - local requireinfo = self:requireinfo() - local verify = requireinfo and requireinfo.verify - if verify == nil then - verify = true - end - return verify -end - --- is debug package? -function _instance:debug() - return self:config("debug") -end - --- is the supported package? -function _instance:supported() - -- attempt to get the install script with the current plat/arch - return self:script("install") ~= nil -end - --- support parallelize for installation? -function _instance:parallelize() - return self:get("parallelize") ~= false -end - --- is the third-party package? e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable --- we need install and find package by third-party package manager directly --- -function _instance:is3rd() - return self._is3rd -end - --- is the system package? -function _instance:isSys() - return self._isSys -end - -- get xxx_script function _instance:script(name, generic) @@ -844,11 +1093,136 @@ function _instance:script(name, generic) end end end - - -- ok return result end +-- do fetch tool +function _instance:_fetch_tool(opt) + opt = opt or {} + local fetchinfo + local on_fetch = self:script("fetch") + if on_fetch then + fetchinfo = on_fetch(self, {force = opt.force, + system = opt.system, + require_version = opt.require_version}) + if opt.require_version and opt.require_version:find(".", 1, true) then + local version = type(fetchinfo) == "table" and fetchinfo.version + if not (version and (version == opt.require_version or semver.satisfies(version, opt.require_version))) then + fetchinfo = nil + end + end + end + if fetchinfo == nil then + self._find_tool = self._find_tool or sandbox_module.import("lib.detect.find_tool", {anonymous = true}) + if opt.system then + local fetchnames = {self:name()} + if not self:is_thirdparty() then + table.join2(fetchnames, self:extsources()) + end + for _, fetchname in ipairs(fetchnames) do + fetchinfo = self:find_tool(fetchname, opt) + if fetchinfo then + break + end + end + else + fetchinfo = self:find_tool(self:name(), {require_version = opt.require_version, + cachekey = "fetch_package_xmake", + norun = true, -- we need not run it to check for xmake/packages, @see https://github.com/xmake-io/xmake-repo/issues/66 + force = opt.force}) + + -- may be toolset, not single tool + if not fetchinfo then + fetchinfo = self:manifest_load() + end + end + end + return fetchinfo or nil +end + +-- do fetch library +-- +-- @param opt the options, e.g. {force, system, external, require_version} +-- +function _instance:_fetch_library(opt) + opt = opt or {} + local fetchinfo + local on_fetch = self:script("fetch") + if on_fetch then + fetchinfo = on_fetch(self, {force = opt.force, + system = opt.system, + external = opt.external, + require_version = opt.require_version}) + if opt.require_version and opt.require_version:find(".", 1, true) then + local version = fetchinfo and fetchinfo.version + if not (version and (version == opt.require_version or semver.satisfies(version, opt.require_version))) then + fetchinfo = nil + end + end + if fetchinfo then + if opt.external then + fetchinfo.sysincludedirs = fetchinfo.sysincludedirs or fetchinfo.includedirs + fetchinfo.includedirs = nil + else + fetchinfo.includedirs = fetchinfo.includedirs or fetchinfo.sysincludedirs + fetchinfo.sysincludedirs = nil + end + end + end + if fetchinfo == nil then + if opt.system then + local fetchnames = {self:name()} + if not self:is_thirdparty() then + table.join2(fetchnames, self:extsources()) + end + for _, fetchname in ipairs(fetchnames) do + fetchinfo = self:find_package(fetchname, opt) + if fetchinfo then + break + end + end + else + fetchinfo = self:find_package("xmake::" .. self:name(), { + require_version = opt.require_version, + cachekey = "fetch_package_xmake", + external = opt.external, + force = opt.force}) + end + end + return fetchinfo or nil +end + +-- find tool +function _instance:find_tool(name, opt) + opt = opt or {} + self._find_tool = self._find_tool or sandbox_module.import("lib.detect.find_tool", {anonymous = true}) + return self._find_tool(name, {cachekey = opt.cachekey or "fetch_package_system", + require_version = opt.require_version, + norun = opt.norun, + force = opt.force}) +end + +-- find package +function _instance:find_package(name, opt) + opt = opt or {} + self._find_package = self._find_package or sandbox_module.import("lib.detect.find_package", {anonymous = true}) + local system = opt.system + if system == nil and not name:startswith("xmake::") then + system = true -- find system package by default + end + return self._find_package(name, { + force = opt.force, + require_version = opt.require_version, + mode = self:mode(), + plat = self:plat(), + arch = self:arch(), + pkgconfigs = self:configs(), + buildhash = self:buildhash(), -- for xmake package or 3rd package manager, e.g. go:: .. + cachekey = opt.cachekey or "fetch_package_system", + external = opt.external, + system = system}) +end + -- fetch the local package info -- -- @param opt the fetch option, e.g. {force = true, external = false} @@ -868,7 +1242,7 @@ function _instance:fetch(opt) -- fetch the require version local require_ver = opt.version or self:requireinfo().version - if not self:is3rd() and not require_ver:find('.', 1, true) then + if not self:is_thirdparty() and not require_ver:find('.', 1, true) then -- strip branch version only system package require_ver = nil end @@ -876,11 +1250,17 @@ function _instance:fetch(opt) -- nil: find xmake or system packages -- true: only find system package -- false: only find xmake packages - local system = opt.system or self:requireinfo().system - if self:is3rd() then + local system = opt.system + if system == nil then + system = self:requireinfo().system + end + if self:is_thirdparty() then -- we need ignore `{system = true/false}` argument if be 3rd package -- @see https://github.com/xmake-io/xmake/issues/726 system = nil + elseif self:is_cross() then + -- we need disable system package for cross-compilation + system = false end -- use sysincludedirs/-isystem instead of -I? @@ -896,67 +1276,39 @@ function _instance:fetch(opt) -- fetch binary tool? fetchinfo = nil - local isSys = nil - if self:kind() == "binary" then - - -- import find_tool - self._find_tool = self._find_tool or sandbox_module.import("lib.detect.find_tool", {anonymous = true}) + local is_system = nil + if self:is_binary() then -- only fetch it from the xmake repository first - if not fetchinfo and system ~= true and not self:is3rd() then - fetchinfo = self._find_tool(self:name(), {require_version = self:version_str(), - cachekey = "fetch_package_xmake", - buildhash = self:buildhash(), - norun = true, -- we need not run it to check for xmake/packages, @see https://github.com/xmake-io/xmake-repo/issues/66 - force = opt.force}) - - -- may be toolset, not single tool - if not fetchinfo then - fetchinfo = self:manifest_load() - end + if not fetchinfo and system ~= true and not self:is_thirdparty() then + fetchinfo = self:_fetch_tool({require_version = self:version_str(), force = opt.force}) if fetchinfo then - isSys = self._isSys + is_system = self._is_system end end -- fetch it from the system directories if not fetchinfo and system ~= false then - fetchinfo = self._find_tool(self:name(), {cachekey = "fetch_package_system", - force = opt.force}) + fetchinfo = self:_fetch_tool({system = true, require_version = require_ver, force = opt.force}) if fetchinfo then - isSys = true + is_system = true end end else - -- import find_package - self._find_package = self._find_package or sandbox_module.import("lib.detect.find_package", {anonymous = true}) - -- only fetch it from the xmake repository first - if not fetchinfo and system ~= true and not self:is3rd() then - fetchinfo = self._find_package("xmake::" .. self:name(), {require_version = self:version_str(), - cachekey = "fetch_package_xmake", - buildhash = self:buildhash(), - pkgconfigs = self:configs(), - external = external, - force = opt.force}) + if not fetchinfo and system ~= true and not self:is_thirdparty() then + fetchinfo = self:_fetch_library({require_version = self:version_str(), external = external, force = opt.force}) if fetchinfo then - isSys = self._isSys + is_system = self._is_system end end - -- fetch it from the system directories + -- fetch it from the system and external package sources if not fetchinfo and system ~= false then - fetchinfo = self._find_package(self:name(), {force = opt.force, - require_version = require_ver, - mode = self:mode(), - pkgconfigs = self:configs(), - buildhash = self:is3rd() and self:buildhash(), -- only for 3rd package manager, e.g. go:: .. - cachekey = "fetch_package_system", - external = external, - system = true}) + fetchinfo = self:_fetch_library({system = true, require_version = require_ver, external = external, force = opt.force}) if fetchinfo then - isSys = true + is_system = true end end end @@ -965,8 +1317,8 @@ function _instance:fetch(opt) self._FETCHINFO = fetchinfo -- mark as system package? - if isSys ~= nil then - self._isSys = isSys + if is_system ~= nil then + self._is_system = is_system end return fetchinfo end @@ -976,22 +1328,25 @@ function _instance:exists() return self._FETCHINFO ~= nil end --- fetch all local info with dependencies -function _instance:fetchdeps() +-- fetch link info of dependencies +function _instance:fetch_linkdeps() local fetchinfo = self:fetch() if not fetchinfo then return end - local orderdeps = self:orderdeps() - if orderdeps then - local total = #orderdeps - for idx, _ in ipairs(orderdeps) do - local dep = orderdeps[total + 1 - idx] + fetchinfo = table.copy(fetchinfo) -- avoid the cached fetchinfo be modified + local linkdeps = self:linkdeps() + if linkdeps then + local total = #linkdeps + for idx, _ in ipairs(linkdeps) do + local dep = linkdeps[total + 1 - idx] local depinfo = dep:fetch() if depinfo then for name, values in pairs(depinfo) do - fetchinfo[name] = table.wrap(fetchinfo[name]) - table.join2(fetchinfo[name], values) + if name ~= "license" and name ~= "version" then + fetchinfo[name] = table.wrap(fetchinfo[name]) + table.join2(fetchinfo[name], values) + end end end end @@ -1094,7 +1449,7 @@ end -- generate building configs for has_xxx/check_xxx function _instance:_generate_build_configs(configs) - configs = table.join(self:fetchdeps(), configs) + configs = table.join(self:fetch_linkdeps(), configs) if self:is_plat("windows") then local ld = self:build_getenv("ld") local vs_runtime = self:config("vs_runtime") @@ -1118,11 +1473,8 @@ end -- @return true or false -- function _instance:has_cfuncs(funcs, opt) - if self:plat() ~= config.get("plat") then - -- TODO - return true - end opt = opt or {} + opt.target = self opt.configs = self:_generate_build_configs(opt.configs) return sandbox_module.import("lib.detect.has_cfuncs", {anonymous = true})(funcs, opt) end @@ -1130,16 +1482,13 @@ end -- has the given c++ funcs? -- -- @param funcs the funcs --- @param opt the argument options, e.g. { includes = ""} +-- @param opt the argument options, e.g. {includes = ""} -- -- @return true or false -- function _instance:has_cxxfuncs(funcs, opt) - if self:plat() ~= config.get("plat") then - -- TODO - return true - end opt = opt or {} + opt.target = self opt.configs = self:_generate_build_configs(opt.configs) return sandbox_module.import("lib.detect.has_cxxfuncs", {anonymous = true})(funcs, opt) end @@ -1152,11 +1501,8 @@ end -- @return true or false -- function _instance:has_ctypes(types, opt) - if self:plat() ~= config.get("plat") then - -- TODO - return true - end opt = opt or {} + opt.target = self opt.configs = self:_generate_build_configs(opt.configs) return sandbox_module.import("lib.detect.has_ctypes", {anonymous = true})(types, opt) end @@ -1169,11 +1515,8 @@ end -- @return true or false -- function _instance:has_cxxtypes(types, opt) - if self:plat() ~= config.get("plat") then - -- TODO - return true - end opt = opt or {} + opt.target = self opt.configs = self:_generate_build_configs(opt.configs) return sandbox_module.import("lib.detect.has_cxxtypes", {anonymous = true})(types, opt) end @@ -1186,11 +1529,8 @@ end -- @return true or false -- function _instance:has_cincludes(includes, opt) - if self:plat() ~= config.get("plat") then - -- TODO - return true - end opt = opt or {} + opt.target = self opt.configs = self:_generate_build_configs(opt.configs) return sandbox_module.import("lib.detect.has_cincludes", {anonymous = true})(includes, opt) end @@ -1203,11 +1543,8 @@ end -- @return true or false -- function _instance:has_cxxincludes(includes, opt) - if self:plat() ~= config.get("plat") then - -- TODO - return true - end opt = opt or {} + opt.target = self opt.configs = self:_generate_build_configs(opt.configs) return sandbox_module.import("lib.detect.has_cxxincludes", {anonymous = true})(includes, opt) end @@ -1220,11 +1557,8 @@ end -- @return true or false -- function _instance:check_csnippets(snippets, opt) - if self:plat() ~= config.get("plat") then - -- TODO - return true - end opt = opt or {} + opt.target = self opt.configs = self:_generate_build_configs(opt.configs) return sandbox_module.import("lib.detect.check_csnippets", {anonymous = true})(snippets, opt) end @@ -1237,11 +1571,8 @@ end -- @return true or false -- function _instance:check_cxxsnippets(snippets, opt) - if self:plat() ~= config.get("plat") then - -- TODO - return true - end opt = opt or {} + opt.target = self opt.configs = self:_generate_build_configs(opt.configs) return sandbox_module.import("lib.detect.check_cxxsnippets", {anonymous = true})(snippets, opt) end @@ -1253,12 +1584,22 @@ end -- the current platform is belong to the given platforms? function package._api_is_plat(interp, ...) - return config.is_plat(...) + local plat = package._target_plat() + for _, v in ipairs(table.join(...)) do + if v and plat == v then + return true + end + end end -- the current platform is belong to the given architectures? function package._api_is_arch(interp, ...) - return config.is_arch(...) + local arch = package._target_arch() + for _, v in ipairs(table.join(...)) do + if v and arch:find("^" .. v:gsub("%-", "%%-") .. "$") then + return true + end + end end -- the current host is belong to the given hosts? @@ -1296,6 +1637,53 @@ function package._memcache() return memcache.cache("core.base.package") end +-- get project +function package._project() + local project = package._PROJECT + if not project then + if os.isfile(os.projectfile()) then + project = require("project/project") + end + end + return project +end + +-- get global target platform of package +function package._target_plat() + local plat = package._memcache():get("target_plat") + if plat == nil then + if not plat and package._project() then + local targetplat_root = package._project().get("target.plat") + if targetplat_root then + plat = targetplat_root + end + end + if not plat then + plat = config.get("plat") or os.subhost() + end + package._memcache():set("target_plat", plat) + end + return plat +end + +-- get global target architecture of pacakge +function package._target_arch() + local arch = package._memcache():get("target_arch") + if arch == nil then + if not arch and package._project() then + local targetarch_root = package._project().get("target.arch") + if targetarch_root then + arch = targetarch_root + end + end + if not arch then + arch = config.get("arch") or os.subarch() + end + package._memcache():set("target_arch", arch) + end + return arch +end + -- get package apis function package.apis() @@ -1312,31 +1700,28 @@ function package.apis() , "package.set_homepage" , "package.set_description" , "package.set_parallelize" + , "package.set_installdir" -- package.add_xxx , "package.add_deps" , "package.add_urls" , "package.add_imports" , "package.add_configs" + , "package.add_extsources" } , script = { -- package.on_xxx "package.on_load" + , "package.on_fetch" , "package.on_install" , "package.on_test" - - -- package.before_xxx - , "package.before_install" - , "package.before_test" - - -- package.before_xxx - , "package.after_install" - , "package.after_test" } , keyvalues = { + -- package.set_xxx + "package.set_policy" -- package.add_xxx - "package.add_patches" + , "package.add_patches" , "package.add_resources" } , dictionary = @@ -1356,13 +1741,27 @@ function package.apis() end -- the cache directory -function package.cachedir() - return path.join(global.cachedir(), "packages", os.date("%y%m")) +function package.cachedir(opt) + opt = opt or {} + local cachedir = package._CACHEDIR + if not cachedir then + cachedir = os.getenv("XMAKE_PKG_CACHEDIR") or path.join(global.cachedir(), "packages") + package._CACHEDIR = cachedir + end + if opt.rootonly then + return cachedir + end + return path.join(cachedir, os.date("%y%m")) end -- the install directory function package.installdir() - return global.get("pkg_installdir") or path.join(global.directory(), "packages") + local installdir = package._INSTALLDIR + if not installdir then + installdir = os.getenv("XMAKE_PKG_INSTALLDIR") or global.get("pkg_installdir") or path.join(global.directory(), "packages") + package._INSTALLDIR = installdir + end + return installdir end -- the search directories @@ -1384,7 +1783,7 @@ function package.load_from_system(packagename) -- get package info local packageinfo = {} - local is3rd = false + local is_thirdparty = false if packagename:find("::", 1, true) then -- get interpreter @@ -1393,7 +1792,7 @@ function package.load_from_system(packagename) -- on install script local on_install = function (pkg) local opt = table.copy(pkg:configs()) - opt.mode = pkg:debug() and "debug" or "release" + opt.mode = pkg:is_debug() and "debug" or "release" opt.plat = pkg:plat() opt.arch = pkg:arch() opt.require_version = pkg:version_str() @@ -1412,7 +1811,7 @@ function package.load_from_system(packagename) -- is third-party package? if not packagename:startswith("xmake::") then - is3rd = true + is_thirdparty = true end end @@ -1420,10 +1819,10 @@ function package.load_from_system(packagename) instance = _instance.new(packagename, scopeinfo.new("package", packageinfo)) -- mark as system or 3rd package - instance._isSys = true - instance._is3rd = is3rd + instance._is_system = true + instance._is_thirdparty = is_thirdparty - if is3rd then + if is_thirdparty then -- add configurations for the 3rd package local install_package = sandbox_module.import("package.manager." .. packagename:split("::")[1]:lower() .. ".install_package", {try = true, anonymous = true}) if install_package and install_package.configurations then @@ -1456,14 +1855,8 @@ function package.load_from_project(packagename, project) return nil, errors end - -- strip trailng ~tag, e.g. zlib~debug - local realname = packagename - if realname:find('~', 1, true) then - realname = realname:gsub("~.+$", "") - end - - -- not found? - local packageinfo = packages[realname] + -- get package info + local packageinfo = packages[packagename] if not packageinfo then return end @@ -1494,7 +1887,7 @@ function package.load_from_repository(packagename, repo, packagedir, packagefile scriptpath = path.join(packagedir, "xmake.lua") end if not scriptpath or not os.isfile(scriptpath) then - return nil, string.format("the package %s not found!", packagename) + return nil, string.format("package %s not found!", packagename) end -- get interpreter @@ -1512,25 +1905,14 @@ function package.load_from_repository(packagename, repo, packagedir, packagefile return nil, errors end - -- get the package info - local packageinfo = nil - for _, info in pairs(results) do - -- @note we cannot use the name of package(), because we need support `xxx~tag` for add_requires("zlib~xxx") - -- so we use `xxx~tag` as the real package - packageinfo = info - break - end - - -- check this package + -- get package info + local packageinfo = results[packagename] if not packageinfo then - return nil, string.format("%s: the package %s not found!", scriptpath, packagename) + return nil, string.format("%s: package(%s) not found!", scriptpath, packagename) end -- new an instance - instance = _instance.new(packagename, packageinfo, path.directory(scriptpath)) - - -- save repository - instance._REPO = repo + instance = _instance.new(packagename, packageinfo, {scriptdir = path.directory(scriptpath), repo = repo}) -- save instance to the cache package._memcache():set2("packages", instance) diff --git a/xmake/core/package/repository.lua b/xmake/core/package/repository.lua index 736517d00..6485b426f 100644 --- a/xmake/core/package/repository.lua +++ b/xmake/core/package/repository.lua @@ -184,7 +184,7 @@ function repository.load(name, url, branch, is_global) end -- the repository directory - local repodir = os.isdir(url) and url or path.join(repository.directory(is_global), name) + local repodir = os.isdir(url) and path.absolute(url) or path.join(repository.directory(is_global), name) -- new an instance local instance, errors = _instance.new(name, url, branch, repodir, is_global) diff --git a/xmake/core/platform/environment.lua b/xmake/core/platform/environment.lua index cec1cf980..721507c6e 100644 --- a/xmake/core/platform/environment.lua +++ b/xmake/core/platform/environment.lua @@ -25,57 +25,17 @@ local environment = environment or {} local os = require("base/os") local table = require("base/table") local global = require("base/global") -local platform_core = require("platform/platform") local sandbox = require("sandbox/sandbox") local package = require("package/package") local import = require("sandbox/modules/import") -- enter the toolchains environment function environment._enter_toolchains() - - -- get the current platform - local platform, errors = platform_core.load() - if not platform then - return false, errors - end - - -- add $programdir/winenv/bin to $path - local oldenvs = {} - oldenvs.PATH = os.getenv("PATH") - if os.host() == "windows" then - os.addenv("PATH", path.join(os.programdir(), "winenv", "bin")) - end - environment._OLDENVS_TOOLCHAINS = oldenvs return true end -- leave the toolchains environment function environment._leave_toolchains() - local oldenvs = environment._OLDENVS_TOOLCHAINS - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end - return true -end - --- enter the running environment -function environment._enter_run() - local oldenvs = {} - oldenvs.PATH = os.getenv("PATH") - oldenvs.LD_LIBRARY_PATH = os.getenv("LD_LIBRARY_PATH") - if os.host() == "macosx" then - oldenvs.DYLD_LIBRARY_PATH = os.getenv("DYLD_LIBRARY_PATH") - end - environment._OLDENVS_RUN = oldenvs - return true -end - --- leave the running environment -function environment._leave_run() - local oldenvs = environment._OLDENVS_RUN - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end return true end @@ -93,7 +53,7 @@ function environment.enter(name) end -- do enter - local maps = {toolchains = environment._enter_toolchains, run = environment._enter_run} + local maps = {toolchains = environment._enter_toolchains} local func = maps[name] if func then local ok, errors = func() @@ -119,7 +79,7 @@ function environment.leave(name) end -- do leave - local maps = {toolchains = environment._leave_toolchains, run = environment._leave_run} + local maps = {toolchains = environment._leave_toolchains} local func = maps[name] if func then local ok, errors = func() diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index 281b716f5..ea41777c6 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -29,6 +29,7 @@ local utils = require("base/utils") local table = require("base/table") local interpreter = require("base/interpreter") local toolchain = require("tool/toolchain") +local memcache = require("cache/memcache") local sandbox = require("sandbox/sandbox") local config = require("project/config") local global = require("base/global") @@ -42,6 +43,16 @@ function _instance.new(name, arch, info) return instance end +-- get memcache +function _instance:_memcache() + local cache = self._MEMCACHE + if not cache then + cache = memcache.cache("core.platform.platform." .. tostring(self)) + self._MEMCACHE = cache + end + return cache +end + -- get platform name function _instance:name() return self._NAME @@ -99,7 +110,7 @@ end -- get the platform os function _instance:os() - return self._INFO:get("os") or config.get("target_os") + return self._INFO:get("os") end -- get the platform menu @@ -138,7 +149,7 @@ end -- get the toolchains function _instance:toolchains(opt) - local toolchains = self._TOOLCHAINS + local toolchains = self:_memcache():get("toolchains") if not toolchains then -- get current valid toolchains from configuration cache @@ -164,7 +175,7 @@ function _instance:toolchains(opt) end -- get the platform toolchains - if (not toolchain_given or not toolchain_given:standalone()) and self._INFO:get("toolchains") then + if (not toolchain_given or not toolchain_given:is_standalone()) and self._INFO:get("toolchains") then names = self._INFO:get("toolchains") end end @@ -181,77 +192,22 @@ function _instance:toolchains(opt) table.insert(toolchains, toolchain_inst) end end - self._TOOLCHAINS = toolchains + self:_memcache():set("toolchains", toolchains) end return toolchains end -- get the program and name of the given tool kind function _instance:tool(toolkind) - - -- init tools - local tools = self._TOOLS - if not tools then - tools = {} - self._TOOLS = tools - end - - -- get tool program - local program, toolname, toolchain_info - local toolinfo = tools[toolkind] - if toolinfo == nil then - toolinfo = {} - local toolchains = self:toolchains() - for idx, toolchain_inst in ipairs(toolchains) do - program, toolname = toolchain_inst:tool(toolkind) - if program then - toolchain_info = {name = toolchain_inst:name(), - plat = toolchain_inst:plat(), - arch = toolchain_inst:arch(), - cachekey = toolchain_inst:cachekey()} - toolinfo[1] = program - toolinfo[2] = toolname - toolinfo[3] = toolchain_info - break - end - end - tools[toolkind] = toolinfo - else - program = toolinfo[1] - toolname = toolinfo[2] - toolchain_info = toolinfo[3] - end - return program, toolname, toolchain_info + return toolchain.tool(self:toolchains(), toolkind, {cachekey = "platform", plat = self:name(), arch = self:arch(), + before_get = function () + return config.get(toolkind) + end}) end -- get tool configuration from the toolchains function _instance:toolconfig(name) - - -- init tool configs - local toolconfigs = self._TOOLCONFIGS - if not toolconfigs then - toolconfigs = {} - self._TOOLCONFIGS = toolconfigs - end - - -- get configuration - local toolconfig = toolconfigs[name] - if toolconfig == nil then - - -- get them from all toolchains - for _, toolchain_inst in ipairs(self:toolchains()) do - local values = toolchain_inst:get(name) - if values then - toolconfig = toolconfig or {} - table.join2(toolconfig, values) - end - end - - -- cache it - toolconfig = toolconfig or false - toolconfigs[name] = toolconfig - end - return toolconfig or nil + return toolchain.toolconfig(self:toolchains(), name, {cachekey = "platform", plat = self:name(), arch = self:arch()}) end -- get the platform script @@ -288,11 +244,11 @@ function _instance:check() while idx <= num do local toolchain = toolchains[idx] -- we need remove other standalone toolchains if standalone toolchain found - if (standalone and toolchain:standalone()) or not toolchain:check() then + if (standalone and toolchain:is_standalone()) or not toolchain:check() then table.remove(toolchains, idx) num = num - 1 else - if toolchain:standalone() then + if toolchain:is_standalone() then standalone = true end idx = idx + 1 @@ -400,6 +356,11 @@ function platform._apis() } end +-- get memcache +function platform._memcache() + return memcache.cache("core.platform.platform") +end + -- get platform directories function platform.directories() @@ -509,41 +470,12 @@ end -- e.g. cc, cxx, mm, mxx, as, ar, ld, sh, .. -- function platform.tool(toolkind, plat, arch) - - -- attempt to get program from config first - plat = plat or config.get("plat") or os.host() - arch = arch or config.get("arch") or os.arch() - local key = toolkind .. "_" .. plat .. "_" .. arch - local program = config.get(toolkind) or config.get("__tool_" .. key) - local toolname = config.get("__toolname_" .. key) - local toolchain_info = config.get("__toolchain_info_" .. key) - if program == nil then - - -- get the current platform - local instance, errors = platform.load(plat, arch) - if not instance then - os.raise(errors) - end - - -- get it from the platform toolchains - program, toolname, toolchain_info = instance:tool(toolkind) - if program then - config.set("__tool_" .. key, program, {force = true, readonly = true}) - config.set("__toolname_" .. key, toolname) - config.set("__toolchain_info_" .. key, toolchain_info) - config.save() - end - end - - -- contain toolname? parse it, e.g. '[email protected]' - if program and type(program) == "string" then - local pos = program:find('@', 1, true) - if pos then - toolname = program:sub(1, pos - 1) - program = program:sub(pos + 1) - end + local instance, errors = platform.load(plat, arch) + if instance then + return instance:tool(toolkind) + else + os.raise(errors) end - return program, toolname, toolchain_info end -- get the given tool configuration @@ -583,26 +515,22 @@ end -- get the all toolchains function platform.toolchains() - - -- return it directly if exists - if platform._TOOLCHAINS then - return platform._TOOLCHAINS - end - - -- get all toolchains - local toolchains = {} - local dirs = toolchain.directories() - for _, dir in ipairs(dirs) do - local dirs = os.dirs(path.join(dir, "*")) - if dirs then - for _, dir in ipairs(dirs) do - if os.isfile(path.join(dir, "xmake.lua")) then - table.insert(toolchains, path.basename(dir)) + local toolchains = platform._memcache():get("toolchains") + if not toolchains then + toolchains = {} + local dirs = toolchain.directories() + for _, dir in ipairs(dirs) do + local dirs = os.dirs(path.join(dir, "*")) + if dirs then + for _, dir in ipairs(dirs) do + if os.isfile(path.join(dir, "xmake.lua")) then + table.insert(toolchains, path.basename(dir)) + end end end end + platform._memcache():set("toolchains", toolchains) end - platform._TOOLCHAINS = toolchains return toolchains end diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index f27fc2857..31e7d0cb5 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -29,36 +29,8 @@ local table = require("base/table") local utils = require("base/utils") local option = require("base/option") --- load the project configure -function config._load(targetname) - - -- check - targetname = targetname or "all" - - -- load configure from the file first - local filepath = config.filepath() - if os.isfile(filepath) then - - -- load it - local results, errors = io.load(filepath) - if not results then - return nil, errors - end - - -- load the target configure - if results._TARGETS then - return table.wrap(results._TARGETS[targetname]) - end - end - - -- empty - return {} -end - --- get the current given configure +-- get the current given configuration function config.get(name) - - -- get it local value = nil if config._CONFIGS then value = config._CONFIGS[name] @@ -66,8 +38,6 @@ function config.get(name) value = nil end end - - -- get it return value end @@ -107,18 +77,15 @@ end -- get all options function config.options() - -- check - assert(config._CONFIGS) - -- remove values with "auto" and private item local configs = {} - for name, value in pairs(config._CONFIGS) do - if not name:find("^_%u+") and (type(value) ~= "string" or value ~= "auto") then - configs[name] = value + if config._CONFIGS then + for name, value in pairs(config._CONFIGS) do + if not name:find("^_%u+") and (type(value) ~= "string" or value ~= "auto") then + configs[name] = value + end end end - - -- get it return configs end @@ -169,69 +136,53 @@ function config.directory() return config._DIRECTORY end --- load the project configure -function config.load(targetname) - - -- load configure - local results, errors = config._load(targetname) - if not results then - utils.error(errors) - return false +-- load the project configuration +function config.load(filepath) + local configs, errors + filepath = filepath or config.filepath() + if os.isfile(filepath) then + configs, errors = io.load(filepath) + if not configs then + utils.error(errors) + return false + end end - - -- merge the target configure first + -- merge into the current configuration local ok = false - for name, value in pairs(results) do - if config.get(name) == nil then - config.set(name, value) - ok = true + if configs then + for name, value in pairs(configs) do + if config.get(name) == nil then + config.set(name, value) + ok = true + end end end - - -- ok? return ok end --- save the project configure -function config.save(targetname) - - -- check - targetname = targetname or "all" - - -- load the previous results from configure - local results = {} - local filepath = config.filepath() - if os.isfile(filepath) then - results = io.load(filepath) or {} - end - - -- the targets - local targets = results._TARGETS or {} - results._TARGETS = targets - - -- clear target first - targets[targetname] = {} - - -- update target - local target = targets[targetname] - for name, value in pairs(config.options()) do - target[name] = value +-- save the project configuration +function config.save(filepath, opt) + opt = opt or {} + filepath = filepath or config.filepath() + if opt.public then + local configs = {} + for name, value in pairs(config.options()) do + if not name:startswith("__") then + configs[name] = value + end + end + return io.save(filepath, configs) + else + return io.save(filepath, config.options()) end - - -- add version - results.__version = xmake._VERSION_SHORT - - -- save it - return io.save(config.filepath(), results) end --- read value from the configure file directly -function config.read(name, targetname) - - -- load configs - local configs = config._load(targetname) - - -- get it +-- read value from the configuration file directly +function config.read(name) + local configs + if os.isfile(config.filepath()) then + configs = io.load(config.filepath()) + end local value = nil if configs then value = configs[name] @@ -239,8 +190,6 @@ function config.read(name, targetname) value = nil end end - - -- ok? return value end diff --git a/xmake/core/project/deprecated/project.lua b/xmake/core/project/deprecated/project.lua index e90f5ad26..91a38106a 100644 --- a/xmake/core/project/deprecated/project.lua +++ b/xmake/core/project/deprecated/project.lua @@ -33,71 +33,6 @@ local platform = require("platform/platform") local deprecated = require("base/deprecated") local deprecated_interpreter = require("base/deprecated/interpreter") --- load all packages from the given directories -function deprecated_project._api_add_pkgdirs(interp, ...) - - -- get all directories - local pkgdirs = {} - local dirs = table.join(...) - for _, dir in ipairs(dirs) do - table.insert(pkgdirs, dir .. "/*.pkg") - end - - -- add all packages - interp:api_builtin_includes(pkgdirs) -end - --- load the given packages -function deprecated_project._api_add_pkgs(interp, ...) - - -- add all packages - interp:api_builtin_includes(...) -end - --- load all packages from the given directories -function deprecated_project._api_add_packagedirs(interp, ...) - - -- make values - local values = "" - for _, v in ipairs(table.join(...)) do - if v and type(v) == "string" then - if #values == 0 then - values = v - else - values = values .. ", " .. v - end - end - end - - -- deprecated - deprecated.add("add_packagedirs(\"%s\")", "add_pkgdirs(\"%s\")", values) - - -- done - return deprecated_project._api_add_pkgdirs(interp, ...) -end - --- load the given packages -function deprecated_project._api_add_packages(interp, ...) - - -- make values - local values = "" - for _, v in ipairs(table.join(...)) do - if v and type(v) == "string" then - if #values == 0 then - values = v - else - values = values .. ", " .. v - end - end - end - - -- deprecated - deprecated.add("add_packages(\"%s\")", "add_pkgs(\"%s\")", values) - - -- done - return deprecated_project._api_add_pkgs(interp, ...) -end - -- set modes function deprecated_project._api_set_modes(interp, ...) @@ -116,24 +51,6 @@ function deprecated_project._api_set_modes(interp, ...) end) end --- add_csnippet/add_cxxsnippet for option -function deprecated_project._api_option_add_cxsnippet(interp, apiname) - - -- get api function - local apifunc = interp:_api_within_scope("option", apiname) - assert(apifunc) - - -- register api - interp:_api_within_scope_set("option", apiname, function (...) - - -- deprecated - deprecated.add(apiname .. "s(...)", apiname .. "(...)") - - -- dispatch it - apifunc(...) - end) -end - -- add_headers for target function deprecated_project._api_target_add_headers(interp) @@ -152,60 +69,6 @@ function deprecated_project._api_target_add_headers(interp) end) end --- add_headerdirs for target -function deprecated_project._api_target_add_headerdirs(interp) - - -- get api function - local apifunc = interp:_api_within_scope("target", "add_headerdirs") - assert(apifunc) - - -- register api - interp:_api_within_scope_set("target", "add_headerdirs", function (value, ...) - - -- deprecated - deprecated.add("add_includedirs(%s, {public|interface = true})", "add_headerdirs(%s)", tostring(value)) - - -- dispatch it - apifunc(value, ...) - end) -end - --- add_defines_h for target -function deprecated_project._api_target_add_defines_h(interp) - - -- get api function - local apifunc = interp:_api_within_scope("target", "add_defines_h") - assert(apifunc) - - -- register api - interp:_api_within_scope_set("target", "add_defines_h", function (value, ...) - - -- deprecated - deprecated.add("add_configfiles() and set_configvar(%s)", "add_defines_h(%s)", tostring(value)) - - -- dispatch it - apifunc(value, ...) - end) -end - --- add_defines_h for option -function deprecated_project._api_option_add_defines_h(interp) - - -- get api function - local apifunc = interp:_api_within_scope("option", "add_defines_h") - assert(apifunc) - - -- register api - interp:_api_within_scope_set("option", "add_defines_h", function (value, ...) - - -- deprecated - deprecated.add("add_configfiles() and set_configvar(%s)", "add_defines_h(%s)", tostring(value)) - - -- dispatch it - apifunc(value, ...) - end) -end - -- set_config_header for target function deprecated_project._api_target_set_config_header(interp) @@ -321,29 +184,16 @@ end -- register api function deprecated_project.api_register(interp) - -- register api: add_pkgdirs() to root - interp:api_register(nil, "add_pkgdirs", deprecated_project._api_add_packagedirs) - - -- register api: add_pkgs() to root - interp:api_register(nil, "add_pkgs", deprecated_project._api_add_packages) - -- register api: is_option() to root interp:api_register(nil, "is_option", deprecated_project._api_is_option) -- register api: set_modes() to root deprecated_project._api_set_modes(interp) - -- register api: add_csnippet/add_cxxsnippet() to option - deprecated_project._api_option_add_cxsnippet(interp, "add_csnippet") - deprecated_project._api_option_add_cxsnippet(interp, "add_cxxsnippet") - -- register api: add_headers() to target deprecated_project._api_target_add_headers(interp) - deprecated_project._api_target_add_headerdirs(interp) - -- register api: add_defines_h()/set_config_header() to option/target - deprecated_project._api_option_add_defines_h(interp) - deprecated_project._api_target_add_defines_h(interp) + -- register api: set_config_header() to option/target deprecated_project._api_target_set_config_header(interp) -- register api: set_headerdir() to target diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua index e7d1c159c..a92f8922f 100644 --- a/xmake/core/project/option.lua +++ b/xmake/core/project/option.lua @@ -19,8 +19,8 @@ -- -- define module -local option = option or {} -local _instance = _instance or {} +local option = {} +local _instance = {} -- load modules local io = require("base/io") @@ -39,6 +39,7 @@ local compiler = require("tool/compiler") local sandbox = require("sandbox/sandbox") local language = require("language/language") local sandbox = require("sandbox/sandbox") +local sandbox_os = require("sandbox/modules/os") local sandbox_module = require("sandbox/modules/import/core/sandbox/module") -- new an instance @@ -435,7 +436,7 @@ function option.interpreter() , mode = function() return config.get("mode") or "release" end , host = os.host() , subhost = os.subhost() - , prefix = "$(prefix)" + , scriptdir = function () return interp:pending() and interp:scriptdir() or sandbox_os.scriptdir() end , globaldir = global.directory() , configdir = config.directory() , projectdir = os.projectdir() diff --git a/xmake/core/project/requireinfo.lua b/xmake/core/project/package.lua index 205b7f6e9..9918bcbc1 100644 --- a/xmake/core/project/requireinfo.lua +++ b/xmake/core/project/package.lua @@ -15,11 +15,11 @@ -- Copyright (C) 2015-present, TBOOX Open Source Group. -- -- @author ruki --- @file requireinfo.lua +-- @file package.lua -- -- define module -local requireinfo = requireinfo or {} +local package = {} -- load modules local io = require("base/io") @@ -33,32 +33,18 @@ local sandbox = require("sandbox/sandbox") local localcache = require("cache/localcache") -- get cache -function requireinfo._cache() +function package._cache() return localcache.cache("package") end -- save the requires info to the cache -function requireinfo:save() - - -- To ensure that the full information (version, ..) is obtained, delay loading it - if not self._LOADED then - local on_load = self:script("on_load") - if on_load then - local ok, errors = sandbox.load(on_load, self) - if not ok then - os.raise(errors) - end - end - self._LOADED = true - end - - -- save it - requireinfo._cache():set(self:name(), self._INFO) - requireinfo._cache():save() +function package:save() + package._cache():set(self:name(), self._INFO) + package._cache():save() end --- clear the requireinfo -function requireinfo:clear() +-- clear the package +function package:clear() local info = self._INFO if info then for k, v in pairs(info) do @@ -69,28 +55,23 @@ function requireinfo:clear() end end --- dump this requireinfo -function requireinfo:dump() +-- dump this package +function package:dump() utils.dump(self._INFO) end -- get the require info -function requireinfo:get(infoname) +function package:get(infoname) return self._INFO[infoname] end -- get the require name -function requireinfo:name() +function package:name() return self._NAME end --- get the given script -function requireinfo:script(name) - return self._SCRIPTS and self._SCRIPTS[name] or nil -end - -- get the package version -function requireinfo:version() +function package:version() -- get it from cache first if self._VERSION ~= nil then @@ -108,27 +89,37 @@ function requireinfo:version() end -- get the package license -function requireinfo:license() +function package:license() return self:get("license") end -- has static libraries? -function requireinfo:has_static() +function package:has_static() return self:get("static") end -- has shared libraries? -function requireinfo:has_shared() +function package:has_shared() return self:get("shared") end -- get the require string -function requireinfo:requirestr() +function package:requirestr() return self:get("__requirestr") end +-- get the install directory +function package:installdir() + return self:get("__installdir") +end + +-- get library files +function package:libraryfiles() + return self:get("libfiles") +end + -- get the extra info from the given name -function requireinfo:extra(name) +function package:extra(name) local extrainfo = self:extrainfo() if extrainfo then return extrainfo[name] @@ -136,12 +127,12 @@ function requireinfo:extra(name) end -- get the extra info -function requireinfo:extrainfo() +function package:extrainfo() return self:get("__extrainfo") end -- set the value to the requires info -function requireinfo:set(name_or_info, ...) +function package:set(name_or_info, ...) if type(name_or_info) == "string" then local args = ... if args ~= nil then @@ -157,7 +148,7 @@ function requireinfo:set(name_or_info, ...) end -- add the value to the requires info -function requireinfo:add(name_or_info, ...) +function package:add(name_or_info, ...) if type(name_or_info) == "string" then local info = table.wrap(self._INFO[name_or_info]) self._INFO[name_or_info] = table.unwrap(table.unique(table.join(info, ...))) @@ -169,7 +160,7 @@ function requireinfo:add(name_or_info, ...) end -- this require info is enabled? -function requireinfo:enabled() +function package:enabled() return self:get("__enabled") end @@ -177,28 +168,28 @@ end -- -- @param enabled enable it? -- -function requireinfo:enable(enabled) +function package:enable(enabled) self:set("__enabled", enabled) end -- load the requires info from the cache -function requireinfo.load(name) +function package.load(name) -- check assert(name) -- get info - local info = requireinfo._cache():get(name) + local info = package._cache():get(name) if info == nil then return end - -- init requireinfo instance - local instance = table.inherit(requireinfo) + -- init package instance + local instance = table.inherit(package) instance._INFO = info instance._NAME = name return instance end -- return module -return requireinfo +return package diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 7a9d3a03d..7040182a2 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -42,7 +42,9 @@ function policy.policies() -- we will check the compatibility of target and package licenses ["check.target_package_licenses"] = {description = "Enable check the compatibility of target and package licenses.", default = true, type = "boolean"}, -- we can compile the source files for each target in parallel - ["build.across_targets_in_parallel"] = {description = "Enable compile the source files for each target in parallel.", default = true, type = "boolean"} + ["build.across_targets_in_parallel"] = {description = "Enable compile the source files for each target in parallel.", default = true, type = "boolean"}, + -- we need enable longpaths when building target or installing package + ["platform.longpaths"] = {description = "Enable long paths when building target or installing package on windows.", default = false, type = "boolean"} } policy._POLICIES = policies end diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index db00493ea..9bdb4ca4d 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -38,7 +38,7 @@ local target = require("project/target") local config = require("project/config") local option = require("project/option") local policy = require("project/policy") -local requireinfo = require("project/requireinfo") +local project_package = require("project/package") local deprecated_project = require("project/deprecated/project") local package = require("package/package") local platform = require("platform/platform") @@ -167,11 +167,12 @@ function project._load(force, disable_filter) -- load script local ok, errors = interp:load(project.rootfile(), {on_load_data = function (data) - local xmakerc_file = project.rcfile() - if xmakerc_file and os.isfile(xmakerc_file) then - local rcdata = io.readfile(xmakerc_file) - if rcdata then - data = rcdata .. "\n" .. data + for _, xmakerc_file in ipairs(project.rcfiles()) do + if xmakerc_file and os.isfile(xmakerc_file) then + local rcdata = io.readfile(xmakerc_file) + if rcdata then + data = rcdata .. "\n" .. data + end end end return data @@ -193,10 +194,8 @@ function project._load(force, disable_filter) end -- save the root info - for name, value in pairs(rootinfo_target:info()) do - rootinfo:set("target." .. name, value) - end project._memcache():set("rootinfo", rootinfo) + project._memcache():set("rootinfo_target", rootinfo_target) -- leave the project directory oldir, errors = os.cd(oldir) @@ -359,35 +358,6 @@ function project._load_target(t, requires) return false, errors end - -- load packages - t._PACKAGES = t._PACKAGES or {} - for _, packagename in ipairs(table.wrap(t:get("packages"))) do - local p = requires[packagename] - if p then - table.insert(t._PACKAGES, p) - end - end - - -- load toolchains - local toolchains = t:get("toolchains") - if toolchains then - t._TOOLCHAINS = {} - for _, name in ipairs(table.wrap(toolchains)) do - local toolchain_opt = table.copy(t:extraconf("toolchains", name)) - toolchain_opt.arch = t:arch() - toolchain_opt.plat = t:plat() - local toolchain_inst, errors = toolchain.load(name, toolchain_opt) - -- attempt to load toolchain from project - if not toolchain_inst then - toolchain_inst = project.toolchain(name, toolchain_opt) - end - if not toolchain_inst then - return false, errors - end - table.insert(t._TOOLCHAINS, toolchain_inst) - end - end - -- do after_load() for target and all rules ok, errors = t:_load_after() if not ok then @@ -405,7 +375,7 @@ function project._load_targets() project._memcache():set("targets_loaded", true) -- load all requires first and reload the project file to ensure has_package() works for targets - local requires = project.requires() + local requires = project.required_packages() local ok, errors = project._load(true) if not ok then return nil, errors @@ -462,15 +432,18 @@ function project._load_targets() for _, rulename in ipairs(rulenames) do local r = project.rule(rulename) or rule.rule(rulename) if r then - t._RULES[rulename] = r - for _, deprule in ipairs(r:orderdeps()) do - local name = deprule:name() - if not t._RULES[name] then - t._RULES[name] = deprule - table.insert(t._ORDERULES, deprule) + -- only add target rules + if r:kind() == "target" then + t._RULES[rulename] = r + for _, deprule in ipairs(r:orderdeps()) do + local name = deprule:name() + if not t._RULES[name] then + t._RULES[name] = deprule + table.insert(t._ORDERULES, deprule) + end end + table.insert(t._ORDERULES, r) end - table.insert(t._ORDERULES, r) else return nil, string.format("unknown rule(%s) in target(%s)!", rulename, t:name()) end @@ -565,20 +538,8 @@ function project._load_options(disable_filter) -- check options local options = {} for optionname, optioninfo in pairs(results) do - - -- init an option instance local instance = option.new(optionname, optioninfo) - - -- save it options[optionname] = instance - - -- mark add_defines_h_if_ok and add_undefines_h_if_ok as deprecated - if instance:get("defines_h_if_ok") then - deprecated.add("add_defines_h(\"%s\")", "add_defines_h_if_ok(\"%s\")", table.concat(table.wrap(instance:get("defines_h_if_ok")), "\", \"")) - end - if instance:get("undefines_h_if_ok") then - deprecated.add("add_undefines_h(\"%s\")", "add_undefines_h_if_ok(\"%s\")", table.concat(table.wrap(instance:get("undefines_h_if_ok")), "\", \"")) - end end -- load and attach options deps @@ -612,31 +573,20 @@ function project._load_requires() end -- load it from cache first (@note will discard scripts in extrainfo) - local instance = requireinfo.load(alias or packagename) + local instance = project_package.load(alias or packagename) if not instance then - - -- init a require info instance - instance = table.inherit(requireinfo) - - -- save name and info + instance = table.inherit(project_package) instance._NAME = alias or packagename instance._INFO = { __requirestr = requirestr, __extrainfo = extrainfo } end - -- move scripts of extrainfo (e.g. on_load ..) + -- @deprecated discard scripts in extrainfo, we need not it now (e.g. on_load ..) if extrainfo then for k, v in pairs(extrainfo) do if type(v) == "function" then - instance._SCRIPTS = instance._SCRIPTS or {} - instance._SCRIPTS[k] = v extrainfo[k] = nil end end - - -- TODO exists deprecated option? show tips - if extrainfo.option then - os.raise("`option = {}` is no longger supported in add_requires(), please update xmake.lua") - end end -- add require info @@ -704,6 +654,7 @@ function project.apis() , "set_description" -- add_xxx , "add_requires" + , "add_requireconfs" , "add_repositories" } , paths = @@ -844,28 +795,35 @@ end -- get all loaded project files with subfiles (xmake.lua) function project.allfiles() - local rcfile = project.rcfile() - if rcfile and os.isfile(rcfile) then - return table.join(project.interpreter():scriptfiles(), rcfile) - else - return project.interpreter():scriptfiles() + local files = {} + table.join2(files, project.interpreter():scriptfiles()) + for _, rcfile in ipairs(project.rcfiles()) do + if rcfile and os.isfile(rcfile) then + table.insert(files, rcfile) + end end + return files end --- get the global rcfile: ~/.xmakerc.lua -function project.rcfile() - local xmakerc = project._XMAKE_RCFILE - if xmakerc == nil then - xmakerc = "/etc/xmakerc.lua" - if not os.isfile(xmakerc) then - xmakerc = "~/.xmakerc.lua" - if not os.isfile(xmakerc) then - xmakerc = path.join(global.directory(), "xmakerc.lua") +-- get the global rcfiles: ~/.xmakerc.lua +function project.rcfiles() + local rcfiles = project._XMAKE_RCFILES + if rcfiles == nil then + rcfiles = {} + local rcpaths = {} + local rcpaths_env = os.getenv("XMAKE_RCFILES") + if rcpaths_env then + table.join2(rcpaths, path.splitenv(rcpaths_env)) + end + table.join2(rcpaths, {"/etc/xmakerc.lua", "~/.xmakerc.lua", path.join(global.directory(), "xmakerc.lua")}) + for _, rcfile in ipairs(rcpaths) do + if os.isfile(rcfile) then + table.insert(rcfiles, rcfile) end end - project._XMAKE_RCFILE = xmakerc + project._XMAKE_RCFILES = rcfiles end - return xmakerc + return rcfiles end -- get the project directory @@ -884,12 +842,30 @@ function project.filelock() return filelock, errors end --- get the project info from the given name +-- get the root configuration function project.get(name) - local rootinfo = project._memcache():get("rootinfo") + local rootinfo + if name and name:startswith("target.") then + name = name:sub(8) + rootinfo = project._memcache():get("rootinfo_target") + else + rootinfo = project._memcache():get("rootinfo") + end return rootinfo and rootinfo:get(name) or nil end +-- get the root extra configuration +function project.extraconf(name, item, key) + local rootinfo + if name and name:startswith("target.") then + name = name:sub(8) + rootinfo = project._memcache():get("rootinfo_target") + else + rootinfo = project._memcache():get("rootinfo") + end + return rootinfo and rootinfo:extraconf(name, item, key) or nil +end + -- get the project name function project.name() local name = project.get("project") @@ -931,7 +907,8 @@ end -- get the given target function project.target(name) - return project.targets()[name] + local targets = project.targets() + return targets and targets[name] end -- get targets @@ -940,7 +917,7 @@ function project.targets() if not targets then local ordertargets, errors targets, ordertargets, errors = project._load_targets() - if not targets or not ordertargets then + if errors then os.raise(errors) end project._memcache():set("targets", targets) @@ -955,6 +932,7 @@ function project.ordertargets() if not ordertargets then -- ensure ordertargets to be cached project.targets() + ordertargets = project._memcache():get("ordertargets") end return ordertargets end @@ -978,13 +956,13 @@ function project.options() return options end --- get the given require info -function project.require(name) - return project.requires()[name] +-- get the given required package +function project.required_package(name) + return project.required_packages()[name] end --- get requires info -function project.requires() +-- get required packages +function project.required_packages() local requires = project._memcache():get("requires") if not requires then local errors @@ -1013,10 +991,23 @@ function project.requires_str() requires_str, requires_extra = project.get("requires"), project.get("__extra_requires") project._memcache():set("requires_str", requires_str or false) project._memcache():set("requires_extra", requires_extra) + + -- get raw requireconfs + local requireconfs_str, requireconfs_extra = project.get("requireconfs"), project.get("__extra_requireconfs") + project._memcache():set("requireconfs_str", requireconfs_str or false) + project._memcache():set("requireconfs_extra", requireconfs_extra) end return requires_str or nil, requires_extra end +-- get string requireconfs +function project.requireconfs_str() + project.requires_str() + local requireconfs_str = project._memcache():get("requireconfs_str") + local requireconfs_extra = project._memcache():get("requireconfs_extra") + return requireconfs_str, requireconfs_extra +end + -- get the given rule function project.rule(name) return project.rules()[name] @@ -1038,7 +1029,8 @@ end -- get the given toolchain function project.toolchain(name, opt) - local info = project._toolchains()[name] + local toolchain_name = toolchain.parsename(name) -- we need ignore `@packagename` + local info = project._toolchains()[toolchain_name] if info then return toolchain.load_withinfo(name, info, opt) end diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua index 7b984a3f4..87a082888 100644 --- a/xmake/core/project/rule.lua +++ b/xmake/core/project/rule.lua @@ -155,6 +155,7 @@ function rule.apis() -- rule.set_xxx "rule.set_extensions" , "rule.set_sourcekinds" + , "rule.set_kind" -- rule.add_xxx , "rule.add_deps" , "rule.add_imports" @@ -164,6 +165,7 @@ function rule.apis() -- rule.on_xxx "rule.on_run" , "rule.on_load" + , "rule.on_config" , "rule.on_link" , "rule.on_build" , "rule.on_build_file" @@ -172,6 +174,9 @@ function rule.apis() , "rule.on_package" , "rule.on_install" , "rule.on_uninstall" + , "rule.on_buildcmd" + , "rule.on_buildcmd_file" + , "rule.on_buildcmd_files" -- rule.before_xxx , "rule.before_run" , "rule.before_load" @@ -183,6 +188,9 @@ function rule.apis() , "rule.before_package" , "rule.before_install" , "rule.before_uninstall" + , "rule.before_buildcmd" + , "rule.before_buildcmd_file" + , "rule.before_buildcmd_files" -- rule.after_xxx , "rule.after_run" , "rule.after_load" @@ -194,6 +202,9 @@ function rule.apis() , "rule.after_package" , "rule.after_install" , "rule.after_uninstall" + , "rule.after_buildcmd" + , "rule.after_buildcmd_file" + , "rule.after_buildcmd_files" } } end @@ -221,6 +232,16 @@ function rule:name() return self._NAME end +-- get the rule kind +-- +-- current supported kind: +-- - target: default, only for each target +-- - project: global rule, for whole project +-- +function rule:kind() + return self:get("kind") or "target" +end + -- get the given dependent rule function rule:dep(name) local deps = self:deps() diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index cd94045db..38d207656 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -23,37 +23,49 @@ local target = target or {} local _instance = _instance or {} -- load modules -local bit = require("bit") -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local table = require("base/table") -local baseoption = require("base/option") -local deprecated = require("base/deprecated") -local rule = require("project/rule") -local option = require("project/option") -local config = require("project/config") -local policy = require("project/policy") -local requireinfo = require("project/requireinfo") -local tool = require("tool/tool") -local linker = require("tool/linker") -local compiler = require("tool/compiler") -local platform = require("platform/platform") -local environment = require("platform/environment") -local language = require("language/language") -local sandbox = require("sandbox/sandbox") -local sandbox_module = require("sandbox/modules/import/core/sandbox/module") +local bit = require("bit") +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") +local table = require("base/table") +local baseoption = require("base/option") +local deprecated = require("base/deprecated") +local memcache = require("cache/memcache") +local rule = require("project/rule") +local option = require("project/option") +local config = require("project/config") +local policy = require("project/policy") +local project_package = require("project/package") +local tool = require("tool/tool") +local linker = require("tool/linker") +local compiler = require("tool/compiler") +local toolchain = require("tool/toolchain") +local platform = require("platform/platform") +local environment = require("platform/environment") +local language = require("language/language") +local sandbox = require("sandbox/sandbox") +local sandbox_module = require("sandbox/modules/import/core/sandbox/module") -- new a target instance function _instance.new(name, info, project) - local instance = table.inherit(_instance) - instance._NAME = name - instance._INFO = info - instance._PROJECT = project - instance._CACHEID = 1 + local instance = table.inherit(_instance) + instance._NAME = name + instance._INFO = info + instance._PROJECT = project + instance._CACHEID = 1 return instance end +-- get memcache +function _instance:_memcache() + local cache = self._MEMCACHE + if not cache then + cache = memcache.cache("core.project.target." .. tostring(self)) + self._MEMCACHE = cache + end + return cache +end + -- load rule, move cache to target function _instance:_load_rule(ruleinst, suffix) @@ -128,11 +140,7 @@ end function _instance:_load_after() -- enter the environments of the target packages - local oldenvs = {} - for name, values in pairs(self:pkgenvs()) do - oldenvs[name] = os.getenv(name) - os.addenv(name, unpack(values)) - end + local oldenvs = os.addenvs(self:pkgenvs()) -- do after_load with target rules local ok, errors = self:_load_rules("after") @@ -141,9 +149,7 @@ function _instance:_load_after() end -- leave the environments of the target packages - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end + os.setenvs(oldenvs) return true end @@ -320,24 +326,26 @@ function _instance:get_from_deps(name, opt) local depinherit = self:extraconf("deps", dep:name(), "inherit") if depinherit == nil or depinherit then table.join2(values, dep:get(name, opt)) + table.join2(values, dep:get_from_opts(name, opt)) + table.join2(values, dep:get_from_pkgs(name, opt)) end end return values end --- get values from target options -function _instance:get_from_opts(name) +-- get values from target options with {interface|public = ...} +function _instance:get_from_opts(name, opt) local values = {} - for _, opt in ipairs(self:orderopts()) do - table.join2(values, table.wrap(opt:get(name))) + for _, opt_ in ipairs(self:orderopts(opt)) do + table.join2(values, table.wrap(opt_:get(name))) end return values end --- get values from target packages -function _instance:get_from_pkgs(name) +-- get values from target packages with {interface|public = ...} +function _instance:get_from_pkgs(name, opt) local values = {} - for _, pkg in ipairs(self:orderpkgs()) do + for _, pkg in ipairs(self:orderpkgs(opt)) do -- uses them instead of the builtin configs if exists extra package config -- e.g. `add_packages("xxx", {links = "xxx"})` local configinfo = self:pkgconfig(pkg:name()) @@ -436,7 +444,7 @@ function _instance:info() return self._INFO:info() end --- get the type: option +-- get the type: target function _instance:type() return "target" end @@ -446,6 +454,16 @@ function _instance:name() return self._NAME end +-- get the target kind +function _instance:kind() + return self:get("kind") or "binary" +end + +-- get the target kind (deprecated) +function _instance:targetkind() + return self:kind() +end + -- get the platform of this target function _instance:plat() return self:get("plat") or config.get("plat") or os.host() @@ -557,7 +575,7 @@ function _instance:linker() end -- get the linker instance - local instance, errors = linker.load(self:targetkind(), self:sourcekinds(), self) + local instance, errors = linker.load(self:kind(), self:sourcekinds(), self) if not instance then os.raise(errors) end @@ -616,13 +634,40 @@ function _instance:rule(name) end -- is phony target? -function _instance:isphony() +function _instance:is_phony() + local targetkind = self:kind() + return not targetkind or targetkind == "phony" +end - -- get target kind - local targetkind = self:targetkind() +-- is binary target? +function _instance:is_binary() + return self:kind() == "binary" +end - -- is phony? - return not targetkind or targetkind == "phony" +-- is shared library target? +function _instance:is_shared() + return self:kind() == "shared" +end + +-- is static library target? +function _instance:is_static() + return self:kind() == "static" +end + +-- is library target? +function _instance:is_library() + return self:is_static() or self:is_shared() +end + +-- is default target? +function _instance:is_default() + local default = self:get("default") + return default == nil or default == true +end + +-- is enabled? +function _instance:is_enabled() + return self:get("enabled") ~= false end -- get the enabled option @@ -648,37 +693,41 @@ function _instance:opts() return self._OPTS_ENABLED end --- get the enabled ordered options -function _instance:orderopts() - - -- attempt to get it from cache first - if self._ORDEROPTS_ENABLED then - return self._ORDEROPTS_ENABLED +-- get the enabled ordered options with {public|interface = ...} +function _instance:orderopts(opt) + opt = opt or {} + local cachekey = "orderopts" + if opt.public then + cachekey = cachekey .. "_public" + elseif opt.interface then + cachekey = cachekey .. "_interface" end + local orderopts = self:_memcache():get(cachekey) + if not orderopts then - -- load options if be enabled - self._ORDEROPTS_ENABLED = {} - for _, name in ipairs(table.wrap(self:get("options"))) do - local opt = nil - if config.get(name) then opt = option.load(name) end - if opt then - table.insert(self._ORDEROPTS_ENABLED, opt) + -- load options if be enabled + orderopts = {} + for _, name in ipairs(table.wrap(self:get("options"))) do + local opt_ = nil + if config.get(name) then opt_ = option.load(name) end + if opt_ then + table.insert(orderopts, opt_) + end end - end - -- load options from packages if no require info, be compatible with the option package in (*.pkg) - for _, name in ipairs(table.wrap(self:get("packages"))) do - if not requireinfo.load(name) then - local opt = nil - if config.get(name) then opt = option.load(name) end - if opt then - table.insert(self._ORDEROPTS_ENABLED, opt) + -- load options from packages if no require info, be compatible with the option package in (*.pkg) + for _, name in ipairs(table.wrap(self:get("packages"))) do + if not project_package.load(name) then + local opt_ = nil + if config.get(name) then opt_ = option.load(name) end + if opt_ then + table.insert(orderopts, opt_) + end end end + self:_memcache():set(cachekey, orderopts) end - - -- get it - return self._ORDEROPTS_ENABLED + return orderopts end -- get the enabled package @@ -699,45 +748,61 @@ function _instance:pkgs() for _, pkg in ipairs(self:orderpkgs()) do self._PKGS_ENABLED[pkg:name()] = pkg end - - -- get it return self._PKGS_ENABLED end --- get the required packages -function _instance:orderpkgs() - if not self._ORDERPKGS_ENABLED then - local packages = {} - for _, pkg in ipairs(self._PACKAGES) do - if pkg:enabled() then - table.insert(packages, pkg) +-- get the required packages with {interface|public = ..} +function _instance:orderpkgs(opt) + opt = opt or {} + local cachekey = "orderpkgs" + if opt.public then + cachekey = cachekey .. "_public" + elseif opt.interface then + cachekey = cachekey .. "_interface" + end + local packages = self:_memcache():get(cachekey) + if not packages then + packages = {} + local requires = self._PROJECT.required_packages() + if requires then + for _, packagename in ipairs(table.wrap(self:get("packages", opt))) do + local pkg = requires[packagename] + if pkg and pkg:enabled() then + table.insert(packages, pkg) + end end end - self._ORDERPKGS_ENABLED = packages + self:_memcache():set(cachekey, packages) end - return self._ORDERPKGS_ENABLED + return packages end -- get the environments of packages function _instance:pkgenvs() local pkgenvs = self._PKGENVS - if not pkgenvs then - pkgenvs = {} - self._PKGENVS = pkgenvs + if pkgenvs == nil then for _, pkgname in ipairs(table.wrap(self:get("packages"))) do local pkg = self:pkg(pkgname) if pkg then local envs = pkg:get("envs") if envs then for name, values in pairs(envs) do - pkgenvs[name] = pkgenvs[name] or {} - table.join2(pkgenvs[name], values) + if type(values) == "table" then + values = path.joinenv(values) + end + pkgenvs = pkgenvs or {} + if pkgenvs[name] then + pkgenvs[name] = pkgenvs[name] .. path.envsep() .. values + else + pkgenvs[name] = values + end end end end end + self._PKGENVS = pkgenvs or false end - return pkgenvs + return pkgenvs or nil end -- get the config info of the given package @@ -890,11 +955,6 @@ function _instance:autogenfile(sourcefile, opt) return path.join(rootdir, (opt and opt.filename) and opt.filename or path.filename(sourcefile)) end --- get the target kind -function _instance:targetkind() - return self:get("kind") or "phony" -end - -- get the target directory function _instance:targetdir() @@ -926,26 +986,54 @@ function _instance:targetdir() return targetdir end --- get the target file -function _instance:targetfile() - - -- the target directory - local targetdir = self:targetdir() - - -- get target kind - local targetkind = self:targetkind() +-- get the target file name +function _instance:filename() -- only compile objects? no target file + local targetkind = self:kind() if targetkind == "object" then return end -- make the target file name and attempt to use the format of linker first - local filename = self:get("filename") or target.filename(self:basename(), targetkind, {plat = self:plat(), arch = self:arch(), format = self:linker():format(targetkind)}) - assert(filename) + local filename = self:get("filename") + if not filename then + local prefixname = self:get("prefixname") + local suffixname = self:get("suffixname") + local extension = self:get("extension") + filename = target.filename(self:basename(), targetkind, { + plat = self:plat(), arch = self:arch(), + prefixname = prefixname, + suffixname = suffixname, + extension = extension, + format = self:linker():format(targetkind)}) + end + return filename +end - -- make the target file path - return path.join(targetdir, filename) +-- get the link name only for static/shared library +function _instance:linkname() + if self:is_static() or self:is_shared() then + local filename = self:get("filename") + if filename then + return target.linkname(filename) + else + local linkname = self:basename() + local suffixname = self:get("suffixname") + if suffixname then + linkname = linkname .. suffixname + end + return linkname + end + end +end + +-- get the target file +function _instance:targetfile() + local filename = self:filename() + if filename then + return path.join(self:targetdir(), filename) + end end -- get the symbol file @@ -987,24 +1075,16 @@ end function _instance:installdir() -- get it from the cache - local installdir = self._INSTALLDIR + local installdir = baseoption.get("installdir") if not installdir then - -- get it from target - installdir = baseoption.get("installdir") - if not installdir then - - -- DESTDIR: be compatible with https://www.gnu.org/prep/standards/html_node/DESTDIR.html - installdir = self:get("installdir") or os.getenv("INSTALLDIR") or os.getenv("PREFIX") or os.getenv("DESTDIR") or platform.get("installdir") - if installdir then - installdir = installdir:trim() - end + -- DESTDIR: be compatible with https://www.gnu.org/prep/standards/html_node/DESTDIR.html + installdir = self:get("installdir") or os.getenv("INSTALLDIR") or os.getenv("PREFIX") or os.getenv("DESTDIR") or platform.get("installdir") + if installdir then + installdir = installdir:trim() end - self._INSTALLDIR = installdir or false end - - -- ok - return installdir or nil + return installdir end -- get rules of the source file @@ -1050,7 +1130,10 @@ function _instance:filerules(sourcefile) end -- get target rules from the given sourcekind or extension - for _, r in ipairs(table.wrap(key2rules[self:sourcekind_of(sourcefile)] or key2rules[path.extension(sourcefile):lower()])) do + local filename = path.filename(sourcefile):lower() + for _, r in ipairs(table.wrap(key2rules[path.extension(filename, 2)] or + key2rules[path.extension(filename)] or + key2rules[self:sourcekind_of(filename)])) do table.insert(rules, r) end return rules @@ -1125,6 +1208,7 @@ function _instance:sourcefiles() local sourcefiles_deleted = {} local sourcefiles_inserted = {} local deleted_count = 0 + local targetcache = memcache.cache("core.project.target") for _, file in ipairs(table.wrap(files)) do -- mark as deleted files? @@ -1134,13 +1218,22 @@ function _instance:sourcefiles() deleted = true end - -- find source files - local results = os.files(file) - if #results == 0 then - -- attempt to find source directories if maybe compile it as directory with the custom rules - if #self:filerules(file) > 0 then - results = os.dirs(file) + -- find source files and try to cache the matching results of os.match across targets + -- @see https://github.com/xmake-io/xmake/issues/1353 + local results = targetcache:get2("sourcefiles", file) + if not results then + if deleted then + results = {file} + else + results = os.files(file) + if #results == 0 then + -- attempt to find source directories if maybe compile it as directory with the custom rules + if #self:filerules(file) > 0 then + results = os.dirs(file) + end + end end + targetcache:set2("sourcefiles", file, results) end if #results == 0 then local sourceinfo = (self:get("__sourceinfo_files") or {})[file] or {} @@ -1158,7 +1251,7 @@ function _instance:sourcefiles() -- add or delete it if deleted then deleted_count = deleted_count + 1 - sourcefiles_deleted[sourcefile] = true + table.insert(sourcefiles_deleted, sourcefile) elseif not sourcefiles_inserted[sourcefile] then table.insert(sourcefiles, sourcefile) sourcefiles_inserted[sourcefile] = true @@ -1170,8 +1263,15 @@ function _instance:sourcefiles() if deleted_count > 0 then for i = #sourcefiles, 1, -1 do local sourcefile = sourcefiles[i] - if sourcefiles_deleted[sourcefile] then - table.remove(sourcefiles, i) + for _, deletefile in ipairs(sourcefiles_deleted) do + local pattern = path.translate(deletefile:gsub("|.*$", "")) + if pattern:sub(1, 2):find('%.[/\\]') then + pattern = pattern:sub(3) + end + pattern = path.pattern(pattern) + if sourcefile:match(pattern) then + table.remove(sourcefiles, i) + end end end end @@ -1216,7 +1316,7 @@ function _instance:objectfiles() -- get object files from all dependent targets (object kind) if self:orderdeps() then for _, dep in ipairs(self:orderdeps()) do - if dep:targetkind() == "object" then + if dep:kind() == "object" then table.join2(objectfiles, dep:objectfiles()) remove_repeat = true end @@ -1516,7 +1616,7 @@ function _instance:sourcebatches() -- attempt to get source kind from the builtin languages local sourcekind = self:sourcekind_of(sourcefile) - if sourcekind and not override then + if sourcekind and filerule:get("sourcekinds") and not override then -- save source kind sourcebatch.sourcekind = sourcekind @@ -1632,11 +1732,6 @@ function _instance:configprefix() if type(configheader_extra) == "table" then configprefix = table.wrap(configheader_extra[configheader]).prefix end - if not configprefix then - configprefix = self:get("config_h_prefix") or (self:name():upper() .. "_CONFIG") - end - - -- ok? return configprefix end @@ -1644,16 +1739,11 @@ end function _instance:configheader(outputdir) -- get config header - local configheader = self:get("config_header") or self:get("config_h") + local configheader = self:get("config_header") if not configheader then return end - -- mark as deprecated - if self:get("config_h") then - deprecated.add("set_config_header(\"%s\", {prefix = \"...\"})", "set_config_h(\"%s\")", path.relative(self:get("config_h"), os.projectdir())) - end - -- get the root directory local rootdir, count = configheader:gsub("|.*$", ""):gsub("%(.*%)$", "") if count == 0 then @@ -1726,134 +1816,71 @@ end -- get the toolchains function _instance:toolchains() - local toolchains = self._TOOLCHAINS + local toolchains = self:_memcache():get("toolchains") if toolchains == nil then - toolchains = self:platform():toolchains() - self._TOOLCHAINS = toolchains + + -- load target toolchains + local target_toolchains = self:get("toolchains") + if target_toolchains then + toolchains = {} + for _, name in ipairs(table.wrap(target_toolchains)) do + local toolchain_opt = table.copy(self:extraconf("toolchains", name)) + toolchain_opt.arch = self:arch() + toolchain_opt.plat = self:plat() + local toolchain_inst, errors = toolchain.load(name, toolchain_opt) + -- attempt to load toolchain from project + if not toolchain_inst and self._PROJECT then + toolchain_inst = self._PROJECT.toolchain(name, toolchain_opt) + end + if not toolchain_inst then + os.raise(errors) + end + table.insert(toolchains, toolchain_inst) + end + else + -- load platform toolchains + toolchains = self:platform():toolchains() + end + self:_memcache():set("toolchains", toolchains) end return toolchains end -- get the program and name of the given tool kind function _instance:tool(toolkind) - - -- init tools - local tools = self._TOOLS - if not tools then - tools = {} - self._TOOLS = tools - end - - -- get tool program - local key = self:name() .. "_" .. toolkind .. "_" .. self:plat() .. "_" .. self:arch() - local program, toolname, toolchain_info - local toolinfo = tools[key] - if toolinfo == nil then - toolinfo = {} - + return toolchain.tool(self:toolchains(), toolkind, {cachekey = "target_" .. self:name(), plat = self:plat(), arch = self:arch(), + before_get = function() -- get program from set_toolchain/set_tools (deprecated) - program = self:get("toolset." .. toolkind) or self:get("toolchain." .. toolkind) + local program = self:get("toolset." .. toolkind) or self:get("toolchain." .. toolkind) if not program then local tools = self:get("tools") -- TODO: deprecated if tools then program = tools[toolkind] end end - - -- attempt to get program from config first if no the given toolchains in target + -- get program from `xmake f --cc` if not program and not self:get("toolchains") then - program = config.get(toolkind) or config.get("__tool_" .. key) - toolname = config.get("__toolname_" .. key) - toolchain_info = config.get("__toolchain_info_" .. key) - end - - -- get program from target/toolchains - if not program then - local toolchains = self:toolchains() - for idx, toolchain_inst in ipairs(toolchains) do - program, toolname = toolchain_inst:tool(toolkind) - if program then - toolchain_info = {name = toolchain_inst:name(), - plat = toolchain_inst:plat(), - arch = toolchain_inst:arch(), - cachekey = toolchain_inst:cachekey()} - break - end - end - end - - -- contain toolname? parse it, e.g. '[email protected]' - if program and type(program) == "string" then - local pos = program:find('@', 1, true) - if pos then - toolname = program:sub(1, pos - 1) - program = program:sub(pos + 1) - end - end - - if program then - toolinfo[1] = program - toolinfo[2] = toolname - toolinfo[3] = toolchain_info - config.set("__tool_" .. key, program, {force = true, readonly = true}) - config.set("__toolname_" .. key, toolname) - config.set("__toolchain_info_" .. key, toolchain_info) - config.save() + program = config.get(toolkind) end - tools[key] = toolinfo - else - program = toolinfo[1] - toolname = toolinfo[2] - toolchain_info = toolinfo[3] - end - return program, toolname, toolchain_info + return program + end}) end -- get tool configuration from the toolchains function _instance:toolconfig(name) - - -- init tool configs - local toolconfigs = self._TOOLCONFIGS - if not toolconfigs then - toolconfigs = {} - self._TOOLCONFIGS = toolconfigs - end - - -- get configuration - local toolconfig = toolconfigs[name] - if toolconfig == nil then - - -- get them from all toolchains - for _, toolchain_inst in ipairs(self:toolchains()) do - - -- get xxflags - local values = toolchain_inst:get(name) - if values then - toolconfig = toolconfig or {} - table.join2(toolconfig, values) - end - - -- get flags from target.on_xxflags() - local script = toolchain_inst:get("target.on_" .. name) - if type(script) == "function" then - local ok, result_or_errors = utils.trycall(script, nil, self) - if ok then - values = result_or_errors - if values then - toolconfig = toolconfig or {} - table.join2(toolconfig, values) - end - else - os.raise(result_or_errors) - end + return toolchain.toolconfig(self:toolchains(), name, {cachekey = "target_" .. self:name(), plat = self:plat(), arch = self:arch(), + after_get = function(toolchain_inst) + -- get flags from target.on_xxflags() + local script = toolchain_inst:get("target.on_" .. name) + if type(script) == "function" then + local ok, result_or_errors = utils.trycall(script, nil, self) + if ok then + return result_or_errors + else + os.raise(result_or_errors) end end - - -- cache it - toolconfig = toolconfig or false - toolconfigs[name] = toolconfig - end - return toolconfig or nil + end}) end -- get target apis @@ -1878,6 +1905,9 @@ function target.apis() , "target.set_symbols" , "target.set_filename" , "target.set_basename" + , "target.set_extension" + , "target.set_prefixname" + , "target.set_suffixname" , "target.set_warnings" , "target.set_fpmodels" , "target.set_optimize" @@ -1892,6 +1922,7 @@ function target.apis() , "target.add_imports" , "target.add_languages" , "target.add_vectorexts" + , "target.add_toolchains" } , keyvalues = { @@ -1934,6 +1965,7 @@ function target.apis() -- target.on_xxx "target.on_run" , "target.on_load" + , "target.on_config" , "target.on_link" , "target.on_build" , "target.on_build_file" @@ -1974,8 +2006,30 @@ function target.filename(targetname, targetkind, opt) assert(targetname and targetkind) -- make filename by format + local filename = targetname local format = opt.format or platform.format(targetkind, opt.plat, opt.arch) - return format and (format:gsub("%$%(name%)", targetname)) or targetname + if format then + local splitinfo = format:split("$(name)", {plain = true, strict = true}) + local prefixname = splitinfo[1] or "" + local suffixname = "" + local extension = splitinfo[2] or "" + splitinfo = extension:split('.', {plain = true, limit = 2, strict = true}) + if #splitinfo == 2 and splitinfo[1] ~= "" then + suffixname = splitinfo[1] + extension = "." .. splitinfo[2] + end + if opt.prefixname then + prefixname = opt.prefixname + end + if opt.suffixname then + suffixname = opt.suffixname + end + if opt.extension then + extension = opt.extension + end + filename = prefixname .. targetname .. suffixname .. extension + end + return filename end -- get the link name of the target file @@ -1984,8 +2038,8 @@ function target.linkname(filename) if count == 0 then linkname, count = filename:gsub(target.filename("__pattern__", "shared"):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") end - if count == 0 and config.is_plat("mingw") then - -- for the mingw platform, it is compatible with the libxxx.a and xxx.lib + if count == 0 then + -- for the mingw/cross platform, it is compatible with the libxxx.a and xxx.lib local formats = {static = "lib$(name).a", shared = "lib$(name).so"} linkname, count = filename:gsub(target.filename("__pattern__", "static", {format = formats["static"]}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") if count == 0 then @@ -2002,3 +2056,4 @@ end -- return module return target + diff --git a/xmake/core/sandbox/modules/has_package.lua b/xmake/core/sandbox/modules/has_package.lua index de9359b6f..8d6c8ec3f 100644 --- a/xmake/core/sandbox/modules/has_package.lua +++ b/xmake/core/sandbox/modules/has_package.lua @@ -21,7 +21,7 @@ -- return module return function (...) require("sandbox/modules/import/core/sandbox/module").import("core.project.project") - local requires = project.requires() + local requires = project.required_packages() if requires then for _, name in ipairs(table.join(...)) do local pkg = requires[name] diff --git a/xmake/core/sandbox/modules/import/core/base/cpu.lua b/xmake/core/sandbox/modules/import/core/base/cpu.lua new file mode 100644 index 000000000..22940c97e --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/base/cpu.lua @@ -0,0 +1,24 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file cpu.lua +-- + +-- load modules +return require("base/cpu") + + diff --git a/xmake/core/sandbox/modules/import/core/base/scheduler.lua b/xmake/core/sandbox/modules/import/core/base/scheduler.lua index d0fff1504..50832d88c 100644 --- a/xmake/core/sandbox/modules/import/core/base/scheduler.lua +++ b/xmake/core/sandbox/modules/import/core/base/scheduler.lua @@ -49,6 +49,15 @@ function sandbox_core_base_scheduler.co_start_named(coname, cotask, ...) return co end +-- start a new coroutine task with options +function sandbox_core_base_scheduler.co_start_withopt(opt, cotask, ...) + local co, errors = scheduler:co_start_withopt(opt, cotask, ...) + if not co then + raise(errors) + end + return co +end + -- resume the given coroutine function sandbox_core_base_scheduler.co_resume(co, ...) return scheduler:resume(co:thread(), ...) diff --git a/xmake/core/sandbox/modules/import/core/base/task.lua b/xmake/core/sandbox/modules/import/core/base/task.lua index 711ee09fd..8b055aac5 100644 --- a/xmake/core/sandbox/modules/import/core/base/task.lua +++ b/xmake/core/sandbox/modules/import/core/base/task.lua @@ -54,7 +54,7 @@ function sandbox_core_base_task.run(taskname, options, ...) -- get task instance local taskname = option.taskname() or "build" - local taskinst = project.task(taskname) or task.task(taskname) + local taskinst = task.task(taskname) or project.task(taskname) if not taskinst then raise("do unknown task(%s)!", taskname) end diff --git a/xmake/core/sandbox/modules/import/core/package/package.lua b/xmake/core/sandbox/modules/import/core/package/package.lua index c08462c10..4ba67d246 100644 --- a/xmake/core/sandbox/modules/import/core/package/package.lua +++ b/xmake/core/sandbox/modules/import/core/package/package.lua @@ -27,8 +27,8 @@ local package = require("package/package") local raise = require("sandbox/modules/raise") -- get cache directory -function sandbox_core_package_package.cachedir() - return package.cachedir() +function sandbox_core_package_package.cachedir(opt) + return package.cachedir(opt) end -- the install directory @@ -43,40 +43,28 @@ end -- load the package from the project file function sandbox_core_package_package.load_from_project(packagename) - - -- load package instance local instance, errors = package.load_from_project(packagename, project) if errors then raise(errors) end - - -- ok return instance end -- load the package from the system function sandbox_core_package_package.load_from_system(packagename) - - -- load package instance local instance, errors = package.load_from_system(packagename) if errors then raise(errors) end - - -- ok return instance end -- load the package from repositories function sandbox_core_package_package.load_from_repository(packagename, repo, packagedir, packagefile) - - -- load package instance local instance, errors = package.load_from_repository(packagename, repo, packagedir, packagefile) if not instance then raise(errors) end - - -- ok return instance end diff --git a/xmake/core/sandbox/modules/import/core/package/repository.lua b/xmake/core/sandbox/modules/import/core/package/repository.lua index 56e45f0c1..86f27b497 100644 --- a/xmake/core/sandbox/modules/import/core/package/repository.lua +++ b/xmake/core/sandbox/modules/import/core/package/repository.lua @@ -24,6 +24,7 @@ local sandbox_core_package_repository = sandbox_core_package_repository or {} -- load modules local global = require("base/global") local project = require("project/project") +local localcache = require("cache/localcache") local repository = require("package/repository") local raise = require("sandbox/modules/raise") local import = require("sandbox/modules/import") @@ -106,18 +107,44 @@ function sandbox_core_package_repository.repositories(is_global) end end - -- add main global xmake repository - if is_global and global.get("network") ~= "private" then - - -- import fasturl - import("net.fasturl") + -- add global xmake repositories + if is_global then - -- sort main urls - local mainurls = {"https://github.com/xmake-io/xmake-repo.git", "https://gitlab.com/tboox/xmake-repo.git", "https://gitee.com/tboox/xmake-repo.git"} - fasturl.add(mainurls) - mainurls = fasturl.sort(mainurls) + -- add artifacts urls + local artifacts_urls = localcache.cache("repository"):get("artifacts_urls") + if not artifacts_urls then + artifacts_urls = {"https://github.com/xmake-mirror/build-artifacts.git", + "https://gitlab.com/xmake-mirror/build-artifacts.git", + "https://gitee.com/xmake-mirror/build-artifacts.git"} + if global.get("network") ~= "private" then + import("net.fasturl") + fasturl.add(artifacts_urls) + artifacts_urls = fasturl.sort(artifacts_urls) + localcache.cache("repository"):set("artifacts_urls", artifacts_urls) + localcache.cache("repository"):save() + end + end + if #artifacts_urls > 0 then + local repo = repository.load("build-artifacts", artifacts_urls[1], "main", true) + if repo then + table.insert(repositories, repo) + end + end - -- add main url + -- add main urls + local mainurls = localcache.cache("repository"):get("mainurls") + if not mainurls then + mainurls = {"https://github.com/xmake-io/xmake-repo.git", + "https://gitlab.com/tboox/xmake-repo.git", + "https://gitee.com/tboox/xmake-repo.git"} + if global.get("network") ~= "private" then + import("net.fasturl") + fasturl.add(mainurls) + mainurls = fasturl.sort(mainurls) + localcache.cache("repository"):set("mainurls", mainurls) + localcache.cache("repository"):save() + end + end if #mainurls > 0 then local repo = repository.load("xmake-repo", mainurls[1], "master", true) if repo then diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua index 9b122c2e6..f8177871a 100644 --- a/xmake/core/sandbox/modules/import/core/project/config.lua +++ b/xmake/core/sandbox/modules/import/core/project/config.lua @@ -87,23 +87,21 @@ function sandbox_core_project_config.readonly(name) end -- load the configuration -function sandbox_core_project_config.load(targetname) - return config.load(targetname) +function sandbox_core_project_config.load(filepath) + return config.load(filepath) end -- save the configuration -function sandbox_core_project_config.save(targetname) - - -- save it - local ok, errors = config.save(targetname) +function sandbox_core_project_config.save(filepath, opt) + local ok, errors = config.save(filepath, opt) if not ok then raise(errors) end end -- read the value from the configuration file directly -function sandbox_core_project_config.read(name, targetname) - return config.read(name, targetname) +function sandbox_core_project_config.read(name) + return config.read(name) end -- clear the configuration diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index 1e5faa2a9..dcd78b205 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -36,31 +36,33 @@ local package = require("package/package") local import = require("sandbox/modules/import") -- export some readonly interfaces -sandbox_core_project.get = project.get -sandbox_core_project.rule = project.rule -sandbox_core_project.rules = project.rules -sandbox_core_project.toolchain = project.toolchain -sandbox_core_project.toolchains = project.toolchains -sandbox_core_project.target = project.target -sandbox_core_project.targets = project.targets -sandbox_core_project.ordertargets = project.ordertargets -sandbox_core_project.option = project.option -sandbox_core_project.options = project.options -sandbox_core_project.rootfile = project.rootfile -sandbox_core_project.allfiles = project.allfiles -sandbox_core_project.rcfile = project.rcfile -sandbox_core_project.directory = project.directory -sandbox_core_project.name = project.name -sandbox_core_project.modes = project.modes -sandbox_core_project.mtimes = project.mtimes -sandbox_core_project.version = project.version -sandbox_core_project.require = project.require -sandbox_core_project.requires = project.requires -sandbox_core_project.requires_str = project.requires_str -sandbox_core_project.policy = project.policy -sandbox_core_project.tmpdir = project.tmpdir -sandbox_core_project.tmpfile = project.tmpfile -sandbox_core_project.is_loaded = project.is_loaded +sandbox_core_project.get = project.get +sandbox_core_project.extraconf = project.extraconf +sandbox_core_project.rule = project.rule +sandbox_core_project.rules = project.rules +sandbox_core_project.toolchain = project.toolchain +sandbox_core_project.toolchains = project.toolchains +sandbox_core_project.target = project.target +sandbox_core_project.targets = project.targets +sandbox_core_project.ordertargets = project.ordertargets +sandbox_core_project.option = project.option +sandbox_core_project.options = project.options +sandbox_core_project.rootfile = project.rootfile +sandbox_core_project.allfiles = project.allfiles +sandbox_core_project.rcfiles = project.rcfiles +sandbox_core_project.directory = project.directory +sandbox_core_project.name = project.name +sandbox_core_project.modes = project.modes +sandbox_core_project.mtimes = project.mtimes +sandbox_core_project.version = project.version +sandbox_core_project.required_package = project.required_package +sandbox_core_project.required_packages = project.required_packages +sandbox_core_project.requires_str = project.requires_str +sandbox_core_project.requireconfs_str = project.requireconfs_str +sandbox_core_project.policy = project.policy +sandbox_core_project.tmpdir = project.tmpdir +sandbox_core_project.tmpfile = project.tmpfile +sandbox_core_project.is_loaded = project.is_loaded -- check project options function sandbox_core_project.check() @@ -133,7 +135,8 @@ function sandbox_core_project.lock(opt) if sandbox_core_project.trylock(opt) then return true elseif baseoption.get("diagnosis") then - utils.warning("the current project is being accessed by other processes, please waiting!") + utils.cprint("${color.warning}the current project is being accessed by other processes, please waiting!") + io.flush() end local ok, errors = sandbox_core_project.filelock():lock(opt) if not ok then diff --git a/xmake/core/sandbox/modules/import/core/tool/linker.lua b/xmake/core/sandbox/modules/import/core/tool/linker.lua index 2511d309b..015e4ab73 100644 --- a/xmake/core/sandbox/modules/import/core/tool/linker.lua +++ b/xmake/core/sandbox/modules/import/core/tool/linker.lua @@ -28,14 +28,10 @@ local raise = require("sandbox/modules/raise") -- load the linker from the given target kind function sandbox_core_tool_linker.load(targetkind, sourcekinds, opt) - - -- get the linker instance local instance, errors = linker.load(targetkind, sourcekinds, opt and opt.target or nil) if not instance then raise(errors) end - - -- ok return instance end @@ -46,14 +42,8 @@ end -- make arguments list for linking target file function sandbox_core_tool_linker.linkargv(targetkind, sourcekinds, objectfiles, targetfile, opt) - - -- init options opt = opt or {} - - -- get the linker instance local instance = sandbox_core_tool_linker.load(targetkind, sourcekinds, opt) - - -- make arguments list return instance:linkargv(objectfiles, targetfile, opt) end @@ -78,14 +68,8 @@ end -- link target file function sandbox_core_tool_linker.link(targetkind, sourcekinds, objectfiles, targetfile, opt) - - -- init options opt = opt or {} - - -- get the linker instance local instance = sandbox_core_tool_linker.load(targetkind, sourcekinds, opt) - - -- link it local ok, errors = instance:link(objectfiles, targetfile, opt) if not ok then raise(errors) @@ -102,14 +86,8 @@ end -- @return the supported flags or nil -- function sandbox_core_tool_linker.has_flags(targetkind, sourcekinds, flags, opt) - - -- init options opt = opt or {} - - -- get the linker instance local instance = sandbox_core_tool_linker.load(targetkind, sourcekinds, opt) - - -- has flags? return instance:has_flags(flags) end @@ -123,14 +101,8 @@ end -- @return flags or nil -- function sandbox_core_tool_linker.map_flags(targetkind, sourcekinds, name, values, opt) - - -- init options opt = opt or {} - - -- get the linker instance local instance = sandbox_core_tool_linker.load(targetkind, sourcekinds, opt) - - -- map flags return instance:map_flags(name, values, opt) end diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_library.lua b/xmake/core/sandbox/modules/import/lib/detect/find_library.lua index bad638548..bfb2315a5 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_library.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_library.lua @@ -58,14 +58,14 @@ function sandbox_lib_detect_find_library.main(names, paths, opt) opt = opt or {} -- init kinds - kinds = opt.kind or {"static", "shared"} + local kinds = opt.kind or {"static", "shared"} -- find library file from the given paths for _, name in ipairs(table.wrap(names)) do for _, kind in ipairs(table.wrap(kinds)) do local filepath = find_file(target.filename(name, kind), paths, opt) - if not filepath and config.is_plat("mingw") then - -- for the mingw platform, it is compatible with the libxxx.a and xxx.lib + if not filepath then + -- for the mingw/cross platform, it is compatible with the libxxx.a and xxx.lib local formats = {static = "lib$(name).a", shared = "lib$(name).so"} filepath = find_file(target.filename(name, kind, {format = formats[kind]}), paths, opt) end diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 8e466bbd2..4e5eadc14 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -31,6 +31,7 @@ local option = require("base/option") local project = require("project/project") local detectcache = require("cache/detectcache") local sandbox = require("sandbox/sandbox") +local package = require("package/package") local raise = require("sandbox/modules/raise") local vformat = require("sandbox/modules/vformat") local scheduler = require("sandbox/modules/import/core/base/scheduler") @@ -38,15 +39,8 @@ local scheduler = require("sandbox/modules/import/core/base/scheduler") -- globals local checking = nil --- check program -function sandbox_lib_detect_find_program._check(program, opt) - - -- is *.exe for windows? - if os.host() == "windows" then - if not program:endswith(".exe") and not program:endswith(".cmd") and not program:endswith(".bat") then - program = program .. ".exe" - end - end +-- do check +function sandbox_lib_detect_find_program._do_check(program, opt) -- do not attempt to run program? check it fastly if opt.norun then @@ -78,6 +72,24 @@ function sandbox_lib_detect_find_program._check(program, opt) return ok end +-- check program +function sandbox_lib_detect_find_program._check(program, opt) + local findname = program + if os.subhost() == "windows" then + if not program:endswith(".exe") and not program:endswith(".cmd") and not program:endswith(".bat") then + findname = program .. ".exe" + end + elseif os.subhost() == "msys" and os.isfile(program) and os.filesize(program) < 256 then + -- only a sh script on msys2? e.g. c:/msys64/usr/bin/7z + -- we need use sh to wrap it, otherwise os.exec cannot run it + program = "sh " .. program + findname = program + end + if sandbox_lib_detect_find_program._do_check(findname, opt) then + return program + end +end + -- find program from the given paths function sandbox_lib_detect_find_program._find_from_paths(name, paths, opt) @@ -113,9 +125,9 @@ function sandbox_lib_detect_find_program._find_from_paths(name, paths, opt) -- the program path if program_path and (os.isexec(program_path) or os.isexec(program_path:split("%s")[1])) then - -- check it - if sandbox_lib_detect_find_program._check(program_path, opt) then - return program_path + local program_path_real = sandbox_lib_detect_find_program._check(program_path, opt) + if program_path_real then + return program_path_real end end end @@ -173,11 +185,11 @@ function sandbox_lib_detect_find_program._find(name, paths, opt) end program_path = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" .. program_name) if program_path then - -- check it program_path = program_path:trim() if os.isexec(program_path) then - if sandbox_lib_detect_find_program._check(program_path, opt) then - return program_path + local program_path_real = sandbox_lib_detect_find_program._check(program_path, opt) + if program_path_real then + return program_path_real end end end @@ -185,18 +197,21 @@ function sandbox_lib_detect_find_program._find(name, paths, opt) -- attempt to find it use `which program` command local ok, program_path = os.iorunv("which", {name}) if ok and program_path then - -- check it program_path = program_path:trim() - if os.isexec(program_path) then - if sandbox_lib_detect_find_program._check(program_path, opt) then - return program_path - end + local program_path_real = sandbox_lib_detect_find_program._check(program_path, opt) + if program_path_real then + return program_path_real end end end - -- attempt to find it from the some default system directories + -- attempt to find it from the some default $PATH and system directories local syspaths = {} + --[[ + local envpaths = os.getenv("PATH") + if envpaths then + table.join2(syspaths, path.splitenv(envpaths)) + end]] if os.host() ~= "windows" then table.insert(syspaths, "/usr/local/bin") table.insert(syspaths, "/usr/bin") @@ -212,8 +227,9 @@ function sandbox_lib_detect_find_program._find(name, paths, opt) -- -- @note must be detected at the end, because full path is more accurate -- - if sandbox_lib_detect_find_program._check(name, opt) then - return name + local program_path_real = sandbox_lib_detect_find_program._check(name, opt) + if program_path_real then + return program_path_real end end diff --git a/xmake/core/sandbox/modules/import/core/platform/environment.lua b/xmake/core/sandbox/modules/interpreter/linuxos.lua index 362952950..a94ff888f 100644 --- a/xmake/core/sandbox/modules/import/core/platform/environment.lua +++ b/xmake/core/sandbox/modules/interpreter/linuxos.lua @@ -15,36 +15,20 @@ -- Copyright (C) 2015-present, TBOOX Open Source Group. -- -- @author ruki --- @file environment.lua +-- @file linuxos.lua -- --- define module -local sandbox_core_platform_environment = sandbox_core_platform_environment or {} - -- load modules -local platform = require("platform/platform") -local environment = require("platform/environment") -local raise = require("sandbox/modules/raise") - --- enter the given environment -function sandbox_core_platform_environment.enter(name) +local linuxos = require("base/linuxos") - -- enter it - local ok, errors = environment.enter(name) - if not ok then - raise(errors) - end -end - --- leave the given environment -function sandbox_core_platform_environment.leave(name) +-- define module +local sandbox_linuxos = sandbox_linuxos or {} - -- enter it - local ok, errors = environment.leave(name) - if not ok then - raise(errors) - end -end +-- export some readonly interfaces +sandbox_linuxos.name = linuxos.name +sandbox_linuxos.version = linuxos.version +sandbox_linuxos.kernelver = linuxos.kernelver -- return module -return sandbox_core_platform_environment +return sandbox_linuxos + diff --git a/xmake/core/sandbox/modules/interpreter/os.lua b/xmake/core/sandbox/modules/interpreter/os.lua index bc3675633..10c4b710c 100644 --- a/xmake/core/sandbox/modules/interpreter/os.lua +++ b/xmake/core/sandbox/modules/interpreter/os.lua @@ -27,6 +27,7 @@ local interpreter = require("base/interpreter") local sandbox_os = sandbox_os or {} -- export some readonly interfaces +sandbox_os.term = os.term sandbox_os.host = os.host sandbox_os.arch = os.arch sandbox_os.subhost = os.subhost @@ -65,12 +66,8 @@ end -- get the script directory function sandbox_os.scriptdir() - - -- get the current interpreter instance local instance = interpreter.instance() assert(instance) - - -- get the script directory return instance:scriptdir() end diff --git a/xmake/core/sandbox/modules/linuxos.lua b/xmake/core/sandbox/modules/linuxos.lua new file mode 100644 index 000000000..7b4dabeaf --- /dev/null +++ b/xmake/core/sandbox/modules/linuxos.lua @@ -0,0 +1,57 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file linuxos.lua +-- + +-- load modules +local linuxos = require("base/linuxos") +local raise = require("sandbox/modules/raise") + +-- define module +local sandbox_linuxos = sandbox_linuxos or {} + +-- get linux system name +function sandbox_linuxos.name() + local name = linuxos.name() + if not name then + raise("cannot get the system name of the current linux!") + end + return name +end + +-- get linux system version +function sandbox_linuxos.version() + local linuxver = linuxos.version() + if not linuxver then + raise("cannot get the system version of the current linux!") + end + return linuxver +end + +-- get linux kernel version +function sandbox_linuxos.kernelver() + local kernelver = linuxos.kernelver() + if not kernelver then + raise("cannot get the kernel version of the current linux!") + end + return kernelver +end + +-- return module +return sandbox_linuxos + diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 7633801d3..beb60ddab 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -33,6 +33,8 @@ local vformat = require("sandbox/modules/vformat") local sandbox_os = sandbox_os or {} -- inherit some builtin interfaces +sandbox_os.shell = os.shell +sandbox_os.term = os.term sandbox_os.host = os.host sandbox_os.arch = os.arch sandbox_os.subhost = os.subhost @@ -57,6 +59,9 @@ sandbox_os.addenv = os.addenv sandbox_os.setenvp = os.setenvp sandbox_os.addenvp = os.addenvp sandbox_os.getenvs = os.getenvs +sandbox_os.setenvs = os.setenvs +sandbox_os.addenvs = os.addenvs +sandbox_os.joinenvs = os.joinenvs sandbox_os.pbpaste = os.pbpaste sandbox_os.pbcopy = os.pbcopy sandbox_os.cpuinfo = os.cpuinfo @@ -426,17 +431,17 @@ end -- match directories function sandbox_os.dirs(pattern, callback) - return sandbox_os.match(pattern, 'd', callback) + return (sandbox_os.match(pattern, 'd', callback)) end -- match files function sandbox_os.files(pattern, callback) - return sandbox_os.match(pattern, 'f', callback) + return (sandbox_os.match(pattern, 'f', callback)) end -- match files and directories function sandbox_os.filedirs(pattern, callback) - return sandbox_os.match(pattern, 'a', callback) + return (sandbox_os.match(pattern, 'a', callback)) end -- is directory? diff --git a/xmake/core/sandbox/sandbox.lua b/xmake/core/sandbox/sandbox.lua index f7196a242..766e6061c 100644 --- a/xmake/core/sandbox/sandbox.lua +++ b/xmake/core/sandbox/sandbox.lua @@ -323,7 +323,10 @@ function sandbox.instance(script) while level < 32 do -- get scope - local scope = getfenv(level) + local ok, scope = pcall(getfenv, level) + if not ok then + break; + end if scope then -- enable to read _SANDBOX @@ -344,8 +347,6 @@ function sandbox.instance(script) -- next level = level + 1 end - - -- ok? return instance end diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index 984b23992..33733eaab 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -155,17 +155,21 @@ function builder:_add_flags_from_config(flags) end end --- add flags from the option -function builder:_add_flags_from_option(flags, opt) - for _, flagkind in ipairs(self:_flagkinds()) do - self:_add_flags_from_flagkind(flags, opt, flagkind) +-- add flags from the target options +function builder:_add_flags_from_targetopts(flags, target) + for _, opt in ipairs(target:orderopts()) do + for _, flagkind in ipairs(self:_flagkinds()) do + self:_add_flags_from_flagkind(flags, opt, flagkind) + end end end --- add flags from the package -function builder:_add_flags_from_package(flags, pkg, target) - for _, flagkind in ipairs(self:_flagkinds()) do - table.join2(flags, self:_mapflags(pkg:get(flagkind), flagkind, target)) +-- add flags from the target packages +function builder:_add_flags_from_targetpkgs(flags, target) + for _, pkg in ipairs(target:orderpkgs()) do + for _, flagkind in ipairs(self:_flagkinds()) do + table.join2(flags, self:_mapflags(pkg:get(flagkind), flagkind, target)) + end end end @@ -177,6 +181,12 @@ function builder:_add_flags_from_target(flags, target) return end + -- only for target and option + local target_type = target:type() + if target_type ~= "target" and target_type ~= "option" then + return + end + -- init cache self._TARGETFLAGS = self._TARGETFLAGS or {} local cache = self._TARGETFLAGS @@ -191,17 +201,13 @@ function builder:_add_flags_from_target(flags, target) self:_add_flags_from_language(targetflags, target) -- add flags for the target - if target:type() == "target" then + if target_type == "target" then -- add flags from options - for _, opt in ipairs(target:orderopts()) do - self:_add_flags_from_option(targetflags, opt) - end + self:_add_flags_from_targetopts(targetflags, target) -- add flags from packages - for _, pkg in ipairs(target:orderpkgs()) do - self:_add_flags_from_package(targetflags, pkg, target) - end + self:_add_flags_from_targetpkgs(targetflags, target) -- inherit flags (public/interface) from all dependent targets self:_inherit_flags_from_targetdeps(targetflags, target) @@ -211,12 +217,8 @@ function builder:_add_flags_from_target(flags, target) for _, flagkind in ipairs(self:_flagkinds()) do self:_add_flags_from_flagkind(targetflags, target, flagkind) end - - -- cache it cache[key] = targetflags end - - -- add flags table.join2(flags, targetflags) end @@ -225,11 +227,7 @@ function builder:_add_flags_from_argument(flags, target, args) -- add flags from the flag kinds (cxflags, ..) for _, flagkind in ipairs(self:_flagkinds()) do - - -- add auto mapping flags table.join2(flags, self:_mapflags(args[flagkind], flagkind, target)) - - -- add original flags local original_flags = (args.force or {})[flagkind] if original_flags then table.join2(flags, original_flags) @@ -237,16 +235,18 @@ function builder:_add_flags_from_argument(flags, target, args) end -- add flags (named) from the language - if target then - local key = target:type() - self:_add_flags_from_language(flags, target, { - [key] = function (name) return args[name] end, - toolchain = function (name) return platform.toolconfig(name) end}) - else - self:_add_flags_from_language(flags, nil, { - target = function (name) return args[name] end, - toolchain = function (name) return platform.toolconfig(name) end}) - end + self:_add_flags_from_language(flags, nil, { + target = function (name) return args[name] end, + toolchain = function (name) + local plat, arch + if target and target.plat then + plat = target:plat() + end + if target and target.arch then + arch = target:arch() + end + return platform.toolconfig(name, plat, arch) + end}) end -- add flags from the language @@ -275,28 +275,19 @@ function builder:_add_flags_from_language(flags, target, getters) end end , target = function (name) - - -- only for target local results = {} if target:type() == "target" then - -- get flagvalues (public or interface) of all dependent targets - table.join2(results, target:get_from_deps(name, {interface = true})) - -- get flagvalues of target with given flagname table.join2(results, target:get(name)) - end - return results - end - , option = function (name) - -- is target? get flagvalues of the attached options and packages - local results = {} - if target:type() == "target" then + -- get flagvalues of the attached options and packages table.join2(results, target:get_from_opts(name)) table.join2(results, target:get_from_pkgs(name)) - -- is option? get flagvalues of option with given flagname + -- get flagvalues (public or interface) of all dependent targets (contain packages/options) + table.join2(results, target:get_from_deps(name, {interface = true})) + elseif target:type() == "option" then table.join2(results, target:get(name)) end @@ -317,16 +308,7 @@ function builder:_add_flags_from_language(flags, target, getters) if getter then -- get api name of tool - -- - -- ignore "nf_" and "_if_ok" (deprecated) - -- - -- e.g. - -- - -- defines => define - -- defines_if_ok => define - -- ... - -- - local apiname = flagname:gsub("^nf_", ""):gsub("_if_ok$", "") + local apiname = flagname:gsub("^nf_", "") -- use multiple values mapper if be defined in tool module local multival = false @@ -345,14 +327,14 @@ function builder:_add_flags_from_language(flags, target, getters) local results = mapper(self:_tool(), table.wrap(getter(flagname)), target, self:_targetkind()) for _, flag in ipairs(table.wrap(results)) do if flag and flag ~= "" and (not checkstate or self:has_flags(flag)) then - table.join2(flags, flag) + table.insert(flags, flag) end end else for _, flagvalue in ipairs(table.wrap(getter(flagname))) do local flag = mapper(self:_tool(), flagvalue, target, self:_targetkind()) if flag and flag ~= "" and (not checkstate or self:has_flags(flag)) then - table.join2(flags, flag) + table.insert(flags, flag) end end end @@ -364,23 +346,46 @@ end -- preprocess flags function builder:_preprocess_flags(flags) - -- remove repeat - flags = table.unique(flags) + -- remove repeat by right direction, because we need consider links/deps order + -- @note https://github.com/xmake-io/xmake/issues/1240 + local unique = {} + local count = #flags + if count > 1 then + local flags_new = {} + for idx = count, 1, -1 do + local flag = flags[idx] + local flagkey = type(flag) == "table" and table.concat(flag, "") or flag + if flag and not unique[flagkey] then + table.insert(flags_new, flag) + unique[flagkey] = true + end + end + flags = flags_new + count = #flags_new + end - -- split flag group, e.g. "-I /xxx" => {"-I", "/xxx"} + -- remove repeat first and split flags group, e.g. "-I /xxx" => {"-I", "/xxx"} local results = {} - for _, flag in ipairs(flags) do - flag = flag:trim() - if #flag > 0 then - if flag:find(" ", 1, true) then - table.join2(results, os.argv(flag)) + if count > 0 then + for idx = count, 1, -1 do + local flag = flags[idx] + if type(flag) == "string" then + flag = flag:trim() + if #flag > 0 then + if flag:find(" ", 1, true) then + table.join2(results, os.argv(flag, {splitonly = true})) + else + table.insert(results, flag) + end + end else - table.insert(results, flag) + -- may be a table group? e.g. {"-I", "/xxx"} + if #flag > 0 then + table.join2(results, flag) + end end end end - - -- get it return results end diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index 22a4233df..0e64de8c3 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -46,7 +46,7 @@ function compiler:_add_flags_from_toolchains(flags, targetkind, target) -- add flags for platform with the given target kind, e.g. binary.gcc.cxflags or binary.cxflags if targetkind then local toolname = self:name() - if target and target:type() == "target" then + if target and target.toolconfig then for _, flagkind in ipairs(self:_flagkinds()) do local toolflags = target:toolconfig(targetkind .. '.' .. toolname .. '.' .. flagkind) table.join2(flags, toolflags or target:toolconfig(targetkind .. '.' .. flagkind)) @@ -79,7 +79,7 @@ function compiler._load_tool(sourcekind, target) -- get program from target local program, toolname, toolchain_info - if target and target:type() == "target" then + if target and target.tool then program, toolname, toolchain_info = target:tool(sourcekind) end @@ -138,7 +138,7 @@ function compiler.load(sourcekind, target) -- add toolchains flags to the compiler tool, e.g. gcc.cxflags or cxflags local toolname = compiler_tool:name() - if target and target:type() == "target" then + if target and target.toolconfig then for _, flagkind in ipairs(instance:_flagkinds()) do compiler_tool:add(flagkind, target:toolconfig(toolname .. '.' .. flagkind) or target:toolconfig(flagkind)) end @@ -175,7 +175,7 @@ function compiler:build(sourcefiles, targetfile, opt) -- get target kind local targetkind = opt.targetkind if not targetkind and opt.target and opt.target.targetkind then - targetkind = opt.target:targetkind() + targetkind = opt.target:kind() end -- get it @@ -207,7 +207,7 @@ function compiler:buildargv(sourcefiles, targetfile, opt) -- get target kind local targetkind = opt.targetkind if not targetkind and opt.target and opt.target.targetkind then - targetkind = opt.target:targetkind() + targetkind = opt.target:kind() end -- get it @@ -296,8 +296,8 @@ function compiler:compflags(opt) -- get target kind local targetkind = opt.targetkind - if not targetkind and target and target.targetkind then - targetkind = target:targetkind() + if not targetkind and target and target:type() == "target" then + targetkind = target:kind() end -- add flags from compiler/toolchains diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index 17eafe7dc..25276bdce 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -43,7 +43,7 @@ function linker:_add_flags_from_toolchains(flags, targetkind, target) if targetkind then local toolkind = self:kind() local toolname = self:name() - if target and target:type() == "target" then + if target and target.toolconfig then for _, flagkind in ipairs(self:_flagkinds()) do local toolflags = target:toolconfig(targetkind .. '.' .. toolname .. '.' .. toolkind .. 'flags') or target:toolconfig(targetkind .. '.' .. toolname .. '.' .. flagkind) table.join2(flags, toolflags or target:toolconfig(targetkind .. '.' .. toolkind .. 'flags') or target:toolconfig(targetkind .. '.' .. flagkind)) @@ -86,7 +86,7 @@ function linker._load_tool(targetkind, sourcekinds, target) -- get program from target local program, toolname, toolchain_info - if target and target:type() == "target" then + if target and target.tool then program, toolname, toolchain_info = target:tool(_linkerinfo.linkerkind) end @@ -185,7 +185,7 @@ function linker.load(targetkind, sourcekinds, target) -- add special lanugage flags first, e.g. go.gcldflags or gcc.ldflags or gcldflags or ldflags local toolkind = linkertool:kind() local toolname = linkertool:name() - if target and target:type() == "target" then + if target and target.toolconfig then for _, flagkind in ipairs(instance:_flagkinds()) do linkertool:add(toolkind .. 'flags', target:toolconfig(toolname .. '.' .. toolkind .. 'flags') or target:toolconfig(toolkind .. 'flags')) linkertool:add(flagkind, target:toolconfig(toolname .. '.' .. flagkind) or target:toolconfig(flagkind)) @@ -230,8 +230,8 @@ function linker:linkflags(opt) -- get target kind local targetkind = opt.targetkind - if not targetkind and target and target.targetkind then - targetkind = target:targetkind() + if not targetkind and target and target:type() == "target" then + targetkind = target:kind() end -- add flags from linker/toolchains diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index 78caadc12..868d05746 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -31,6 +31,7 @@ local global = require("base/global") local option = require("base/option") local interpreter = require("base/interpreter") local config = require("project/config") +local memcache = require("cache/memcache") local localcache = require("cache/localcache") local language = require("language/language") local sandbox = require("sandbox/sandbox") @@ -41,7 +42,7 @@ function _instance.new(name, info, cachekey, configs) local instance = table.inherit(_instance) instance._NAME = name instance._INFO = info - instance._CACHE = localcache.cache("toolchain") + instance._CACHE = toolchain._localcache() instance._CACHEKEY = cachekey instance._CONFIGS = instance._CACHE:get(cachekey) or {} for k, v in pairs(configs) do @@ -142,13 +143,22 @@ function _instance:kind() return self:info():get("kind") end +-- is cross-compilation toolchain? +function _instance:is_cross() + if self:kind() == "cross" then + return true + elseif self:kind() == "standalone" and (self:cross() or self:sdkdir()) then + return true + end +end + -- is standalone toolchain? -function _instance:standalone() - return self:kind() == "standalone" +function _instance:is_standalone() + return self:kind() == "standalone" or self:kind() == "cross" end --- global toolchain for whole platform -function _instance:global() +-- is global toolchain for whole platform +function _instance:is_global() return self:config("__global") end @@ -194,12 +204,12 @@ end -- get the cross function _instance:cross() - return config.get("cross") or self:info():get("cross") + return self:config("cross") or config.get("cross") or self:info():get("cross") end -- get the bin directory function _instance:bindir() - local bindir = config.get("bin") or self:info():get("bindir") + local bindir = self:config("bindir") or config.get("bin") or self:info():get("bindir") if not bindir and self:cross() and self:sdkdir() and os.isdir(path.join(self:sdkdir(), "bin")) then bindir = path.join(self:sdkdir(), "bin") end @@ -208,7 +218,7 @@ end -- get the sdk directory function _instance:sdkdir() - return config.get("sdk") or self:info():get("sdkdir") + return self:config("sdkdir") or config.get("sdk") or self:info():get("sdkdir") end -- get cachekey @@ -260,10 +270,31 @@ function _instance:load_cross_toolchain() return sandbox_module.import("toolchains.cross.load", {rootdir = os.programdir(), anonymous = true})(self) end +-- get packages +function _instance:packages() + local packages = self._PACKAGES + if packages == nil then + local project = require("project/project") + -- we will get packages from `set_toolchains("foo", {packages})` or `set_toolchains("foo@packages")` + for _, pkgname in ipairs(table.wrap(self:config("packages"))) do + local requires = project.required_packages() + if requires then + local pkginfo = requires[pkgname] + if pkginfo then + packages = packages or {} + table.insert(packages, pkginfo) + end + end + end + self._PACKAGES = packages or false + end + return packages or nil +end + -- on check (builtin) function _instance:_on_check() local on_check = self:info():get("check") - if not on_check and self:standalone() and (self:cross() or self:sdkdir()) then + if not on_check and self:is_cross() then on_check = self.check_cross_toolchain end return on_check @@ -272,7 +303,7 @@ end -- on load (builtin) function _instance:_on_load() local on_load = self:info():get("load") - if not on_load and self:standalone() and (self:cross() or self:sdkdir()) then + if not on_load and self:is_cross() then on_load = self.load_cross_toolchain end return on_load @@ -347,6 +378,13 @@ end -- check the given tool path function _instance:_checktool(toolkind, toolpath) + -- get result from cache first + local cachekey = self:cachekey() .. "_checktool" .. toolkind + local result = toolchain._memcache():get3(cachekey, toolkind, toolpath) + if result then + return result[1], result[2] + end + -- get find_tool local find_tool = self._find_tool if not find_tool then @@ -368,12 +406,22 @@ function _instance:_checktool(toolkind, toolpath) end end - -- find tool program + -- contain toolname? parse it, e.g. '[email protected]' + -- https://github.com/xmake-io/xmake/issues/1361 local program, toolname - local tool = find_tool(toolpath, {cachekey = self:cachekey(), program = toolpath, paths = self:bindir(), envs = self:get("runenvs")}) + if toolpath then + local pos = toolpath:find('@', 1, true) + if pos then + toolname = toolpath:sub(1, pos - 1) + program = toolpath:sub(pos + 1) + end + end + + -- find tool program + local tool = find_tool(toolpath, {cachekey = cachekey, program = program or toolpath, paths = self:bindir(), envs = self:get("runenvs")}) if tool then program = tool.program - toolname = tool.name + toolname = toolname or tool.name end -- get tool description from the tool kind @@ -387,9 +435,20 @@ function _instance:_checktool(toolkind, toolpath) utils.cprint("${dim}checking for %s (%s: ${bright}%s${clear}) ... ${color.nothing}${text.nothing}", description, toolkind, toolpath) end end + toolchain._memcache():set3(cachekey, toolkind, toolpath, {program, toolname}) return program, toolname end +-- get memcache +function toolchain._memcache() + return memcache.cache("core.tool.toolchain") +end + +-- get local cache +function toolchain._localcache() + return localcache.cache("toolchain") +end + -- the interpreter function toolchain._interpreter() @@ -426,6 +485,24 @@ function toolchain._cachekey(name, opt) return cachekey end +-- parse toolchain and package name +-- +-- format: toolchain@package +-- e.g. "clang@llvm-10", "@muslcc", zig +-- +function toolchain.parsename(name) + local splitinfo = name:split('@', {plain = true, strict = true}) + local toolchain_name = splitinfo[1] + if toolchain_name == "" then + toolchain_name = nil + end + local packages = splitinfo[2] + if packages == "" then + packages = nil + end + return toolchain_name or packages, packages +end + -- get toolchain apis function toolchain.apis() return @@ -470,16 +547,22 @@ end -- load toolchain function toolchain.load(name, opt) - -- init cache key + -- get toolchain name and packages opt = opt or {} + local packages + name, packages = toolchain.parsename(name) + opt.packages = opt.packages or packages + + -- get cache opt.plat = opt.plat or config.get("plat") or os.host() opt.arch = opt.arch or config.get("arch") or os.arch() + local cache = toolchain._memcache() local cachekey = toolchain._cachekey(name, opt) -- get it directly from cache dirst - toolchain._TOOLCHAINS = toolchain._TOOLCHAINS or {} - if toolchain._TOOLCHAINS[cachekey] then - return toolchain._TOOLCHAINS[cachekey] + local instance = cache:get(cachekey) + if instance then + return instance end -- find the toolchain script path @@ -516,31 +599,137 @@ function toolchain.load(name, opt) end -- save instance to the cache - local instance = _instance.new(name, result, cachekey, opt) - toolchain._TOOLCHAINS[cachekey] = instance + instance = _instance.new(name, result, cachekey, opt) + cache:set(cachekey, instance) return instance end -- load toolchain from the give toolchain info function toolchain.load_withinfo(name, info, opt) - -- init cache key + -- get toolchain name and packages opt = opt or {} + local packages + name, packages = toolchain.parsename(name) + opt.packages = opt.packages or packages + + -- get cache key opt.plat = opt.plat or config.get("plat") or os.host() opt.arch = opt.arch or config.get("arch") or os.arch() + local cache = toolchain._memcache() local cachekey = toolchain._cachekey(name, opt) -- get it directly from cache dirst - toolchain._TOOLCHAINS = toolchain._TOOLCHAINS or {} - if toolchain._TOOLCHAINS[cachekey] then - return toolchain._TOOLCHAINS[cachekey] + local instance = cache:get(cachekey) + if instance then + return instance end -- save instance to the cache - local instance = _instance.new(name, info, cachekey, opt) - toolchain._TOOLCHAINS[cachekey] = instance + instance = _instance.new(name, info, cachekey, opt) + cache:set(cachekey, instance) return instance end +-- get the program and name of the given tool kind +function toolchain.tool(toolchains, toolkind, opt) + + -- get plat and arch + opt = opt or {} + local plat = opt.plat or config.get("plat") or os.host() + local arch = opt.arch or config.get("arch") or os.arch() + + -- get cache and cachekey + local cache = toolchain._localcache() + local cachekey = "tool_" .. (opt.cachekey or "") .. "_" .. plat .. "_" .. arch .. "_" .. toolkind + local updatecache = false + + -- get program from before_script + local program, toolname, toolchain_info + local before_get = opt.before_get + if before_get then + program, toolname, toolchain_info = before_get(toolkind) + if program then + updatecache = true + end + end + + -- get program from local cache + if not program then + program = cache:get2(cachekey, "program") + toolname = cache:get2(cachekey, "toolname") + toolchain_info = cache:get2(cachekey, "toolchain_info") + end + + -- get program from toolchains + if not program then + for idx, toolchain_inst in ipairs(toolchains) do + program, toolname = toolchain_inst:tool(toolkind) + if program then + toolchain_info = {name = toolchain_inst:name(), + plat = toolchain_inst:plat(), + arch = toolchain_inst:arch(), + cachekey = toolchain_inst:cachekey()} + updatecache = true + break + end + end + end + + -- contain toolname? parse it, e.g. '[email protected]' + if program and type(program) == "string" then + local pos = program:find('@', 1, true) + if pos then + toolname = program:sub(1, pos - 1) + program = program:sub(pos + 1) + updatecache = true + end + end + + -- update cache + if program and updatecache then + cache:set2(cachekey, "program", program) + cache:set2(cachekey, "toolname", toolname) + cache:set2(cachekey, "toolchain_info", toolchain_info) + cache:save() + end + return program, toolname, toolchain_info +end + +-- get tool configuration from the toolchains +function toolchain.toolconfig(toolchains, name, opt) + + -- get plat and arch + opt = opt or {} + local plat = opt.plat or config.get("plat") or os.host() + local arch = opt.arch or config.get("arch") or os.arch() + + -- get cache and cachekey + local cache = toolchain._memcache() + local cachekey = "toolconfig_" .. (opt.cachekey or "") .. "_" .. plat .. "_" .. arch + + -- get configuration + local toolconfig = cache:get2(cachekey, name) + if toolconfig == nil then + for _, toolchain_inst in ipairs(toolchains) do + local values = toolchain_inst:get(name) + if values then + toolconfig = toolconfig or {} + table.join2(toolconfig, values) + end + local after_get = opt.after_get + if after_get then + values = after_get(toolchain_inst, name) + if values then + toolconfig = toolconfig or {} + table.join2(toolconfig, values) + end + end + end + cache:set2(cachekey, name, toolconfig or false) + end + return toolconfig or nil +end + -- return module return toolchain diff --git a/xmake/languages/asm/api.lua b/xmake/languages/asm/api.lua index af0ccf8b3..49bda6a36 100644 --- a/xmake/languages/asm/api.lua +++ b/xmake/languages/asm/api.lua @@ -75,7 +75,6 @@ function apis() { -- target.add_xxx "target.add_headers" -- TODO deprecated - , "target.add_headerdirs" , "target.add_headerfiles" , "target.add_linkdirs" , "target.add_includedirs" diff --git a/xmake/languages/asm/xmake.lua b/xmake/languages/asm/xmake.lua index d184ac4d7..a57790027 100644 --- a/xmake/languages/asm/xmake.lua +++ b/xmake/languages/asm/xmake.lua @@ -59,21 +59,10 @@ language("asm") , "target.includedirs" , "target.defines" , "target.undefines" - , "option.symbols" - , "option.warnings" - , "option.optimize:check" - , "option.vectorexts:check" - , "option.languages" - , "option.includedirs" - , "option.defines" - , "option.undefines" - , "option.defines_if_ok" - , "option.undefines_if_ok" , "toolchain.includedirs" , "toolchain.defines" , "toolchain.undefines" , "target.sysincludedirs" - , "option.sysincludedirs" , "toolchain.sysincludedirs" } , binary = @@ -83,15 +72,10 @@ language("asm") , "target.rpathdirs" , "target.strip" , "target.symbols" - , "option.strip" - , "option.symbols" - , "option.linkdirs" - , "option.rpathdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" } , shared = @@ -100,17 +84,12 @@ language("asm") , "target.linkdirs" , "target.strip" , "target.symbols" - , "option.strip" - , "option.symbols" - , "option.linkdirs" , "toolchain.linkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , static = diff --git a/xmake/languages/c++/api.lua b/xmake/languages/c++/api.lua index 29e59ef60..e3e8e7041 100644 --- a/xmake/languages/c++/api.lua +++ b/xmake/languages/c++/api.lua @@ -80,7 +80,6 @@ function _api_add_cfunc(interp, module, alias, links, includes, func) interp:api_call("add_cfuncs", func) if links then interp:api_call("add_links", links) end if includes then interp:api_call("add_cincludes", includes) end - interp:api_call("add_defines_h", define) -- restore the current scope interp:scope_restore(scope) @@ -134,7 +133,6 @@ function _api_add_cxxfunc(interp, module, alias, links, includes, func) interp:api_call("add_cxxfuncs", func) if links then interp:api_call("add_links", links) end if includes then interp:api_call("add_cxxincludes", includes) end - interp:api_call("add_defines_h", define) -- restore the current scope interp:scope_restore(scope) @@ -159,10 +157,8 @@ function apis() -- init apis _g.values = { - -- target.set_xxx - "target.set_config_h_prefix" -- deprecated -- target.add_xxx - , "target.add_links" + "target.add_links" , "target.add_syslinks" , "target.add_cflags" , "target.add_cxflags" @@ -172,8 +168,6 @@ function apis() , "target.add_shflags" , "target.add_defines" , "target.add_undefines" - , "target.add_defines_h" - , "target.add_undefines_h" , "target.add_frameworks" , "target.add_rpathdirs" -- @note do not translate path, it's usually an absolute path or contains $ORIGIN/@loader_path -- option.add_xxx @@ -192,13 +186,7 @@ function apis() , "option.add_arflags" , "option.add_shflags" , "option.add_defines" - , "option.add_defines_h" -- TODO deprecated - , "option.add_defines_if_ok" -- TODO deprecated - , "option.add_defines_h_if_ok" -- TODO deprecated , "option.add_undefines" - , "option.add_undefines_h" -- TODO deprecated - , "option.add_undefines_if_ok" -- TODO deprecated - , "option.add_undefines_h_if_ok"-- TODO deprecated , "option.add_frameworks" , "option.add_rpathdirs" -- package.add_xxx @@ -240,13 +228,11 @@ function apis() { -- target.set_xxx "target.set_headerdir" -- TODO deprecated - , "target.set_config_h" -- TODO deprecated , "target.set_config_header" -- TODO deprecated , "target.set_pcheader" , "target.set_pcxxheader" -- target.add_xxx , "target.add_headers" -- TODO deprecated - , "target.add_headerdirs" -- TODO deprecated , "target.add_headerfiles" , "target.add_linkdirs" , "target.add_includedirs" @@ -261,9 +247,7 @@ function apis() _g.dictionary = { -- option.add_xxx - "option.add_csnippet" -- TODO deprecated - , "option.add_csnippets" - , "option.add_cxxsnippet" -- TODO deprecated + "option.add_csnippets" , "option.add_cxxsnippets" } _g.custom = diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua index f21db9e5b..4a18dc5df 100644 --- a/xmake/languages/c++/xmake.lua +++ b/xmake/languages/c++/xmake.lua @@ -70,26 +70,12 @@ language("c++") , "target.frameworks" , "target.pcheader" , "target.pcxxheader" - , "option.symbols" - , "option.warnings" - , "option.fpmodels" - , "option.optimize:check" - , "option.vectorexts:check" - , "option.languages" - , "option.includedirs" - , "option.defines" - , "option.undefines" - , "option.defines_if_ok" - , "option.undefines_if_ok" - , "option.frameworkdirs" - , "option.frameworks" , "toolchain.includedirs" , "toolchain.defines" , "toolchain.undefines" , "toolchain.frameworkdirs" , "toolchain.frameworks" , "target.sysincludedirs" - , "option.sysincludedirs" , "toolchain.sysincludedirs" } , binary = @@ -102,25 +88,17 @@ language("c++") , "target.strip" , "target.symbols" , "target.runtimes" - , "option.strip" - , "option.symbols" - , "option.linkdirs" - , "option.rpathdirs" - , "option.frameworkdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "toolchain.frameworkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.frameworks" , "target.frameworks" - , "option.frameworks" , "toolchain.frameworks" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , shared = @@ -133,25 +111,17 @@ language("c++") , "target.strip" , "target.symbols" , "target.runtimes" - , "option.strip" - , "option.symbols" - , "option.linkdirs" - , "option.rpathdirs" - , "option.frameworkdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "toolchain.frameworkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.frameworks" , "target.frameworks" - , "option.frameworks" , "toolchain.frameworks" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , static = diff --git a/xmake/languages/cuda/xmake.lua b/xmake/languages/cuda/xmake.lua index d58f44a96..1915730d0 100644 --- a/xmake/languages/cuda/xmake.lua +++ b/xmake/languages/cuda/xmake.lua @@ -62,19 +62,10 @@ language("cuda") , "target.languages" , "target.defines" , "target.undefines" - , "option.symbols" - , "option.warnings" - , "option.optimize:check" - , "option.vectorexts:check" - , "option.includedirs" - , "option.languages" - , "option.defines" - , "option.undefines" , "toolchain.includedirs" , "toolchain.defines" , "toolchain.undefines" , "target.sysincludedirs" - , "option.sysincludedirs" , "toolchain.sysincludedirs" } , binary = @@ -84,17 +75,13 @@ language("cuda") , "target.rpathdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" - , "option.rpathdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , shared = @@ -103,15 +90,12 @@ language("cuda") , "target.linkdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" , "toolchain.linkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , static = @@ -123,15 +107,12 @@ language("cuda") { "config.linkdirs" , "target.linkdirs" - , "option.linkdirs" , "toolchain.linkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } } diff --git a/xmake/languages/dlang/load.lua b/xmake/languages/dlang/load.lua index fd547b488..97ef5346a 100644 --- a/xmake/languages/dlang/load.lua +++ b/xmake/languages/dlang/load.lua @@ -23,11 +23,7 @@ import("api") -- load it function main() - - -- init apis _g.apis = api.apis() - - -- ok return _g end diff --git a/xmake/languages/dlang/xmake.lua b/xmake/languages/dlang/xmake.lua index 4dbbcc494..c9df5657b 100644 --- a/xmake/languages/dlang/xmake.lua +++ b/xmake/languages/dlang/xmake.lua @@ -59,10 +59,8 @@ language("dlang") , "target.optimize:check" , "target.vectorexts:check" , "target.includedirs" - , "option.includedirs" , "toolchain.includedirs" , "target.sysincludedirs" - , "option.sysincludedirs" , "toolchain.sysincludedirs" } , binary = @@ -72,17 +70,13 @@ language("dlang") , "target.rpathdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" - , "option.rpathdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , shared = @@ -91,15 +85,12 @@ language("dlang") , "target.linkdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" , "toolchain.linkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , static = diff --git a/xmake/languages/fortran/xmake.lua b/xmake/languages/fortran/xmake.lua index 3307b9cc6..435b55ca2 100644 --- a/xmake/languages/fortran/xmake.lua +++ b/xmake/languages/fortran/xmake.lua @@ -70,17 +70,13 @@ language("fortran") , "target.rpathdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" - , "option.rpathdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , shared = @@ -89,15 +85,12 @@ language("fortran") , "target.linkdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" , "toolchain.linkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , static = diff --git a/xmake/languages/golang/xmake.lua b/xmake/languages/golang/xmake.lua index e6e9007c8..cae73ca26 100644 --- a/xmake/languages/golang/xmake.lua +++ b/xmake/languages/golang/xmake.lua @@ -61,12 +61,10 @@ language("golang") , "target.defines" , "target.undefines" , "target.includedirs" - , "option.includedirs" , "toolchain.includedirs" , "toolchain.defines" , "toolchain.undefines" , "target.sysincludedirs" - , "option.sysincludedirs" , "toolchain.sysincludedirs" } , binary = @@ -75,15 +73,12 @@ language("golang") , "target.linkdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" , "toolchain.linkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , shared = @@ -92,15 +87,12 @@ language("golang") , "target.linkdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" , "toolchain.linkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } } diff --git a/xmake/languages/msrc/xmake.lua b/xmake/languages/msrc/xmake.lua index e890b8879..e5becdba7 100644 --- a/xmake/languages/msrc/xmake.lua +++ b/xmake/languages/msrc/xmake.lua @@ -48,10 +48,6 @@ language("msrc") , "target.defines" , "target.undefines" , "target.includedirs" - , "option.defines" - , "option.undefines" - , "option.defines_if_ok" - , "option.undefines_if_ok" , "toolchain.includedirs" , "toolchain.defines" , "toolchain.undefines" diff --git a/xmake/languages/objc++/api.lua b/xmake/languages/objc++/api.lua index 0816e3d15..8df275896 100644 --- a/xmake/languages/objc++/api.lua +++ b/xmake/languages/objc++/api.lua @@ -24,10 +24,8 @@ function apis() -- init apis _g.values = { - -- target.set_xxx - "target.set_config_h_prefix" -- deprecated -- target.add_xxx - , "target.add_links" + "target.add_links" , "target.add_syslinks" , "target.add_mflags" , "target.add_mxflags" @@ -37,8 +35,6 @@ function apis() , "target.add_shflags" , "target.add_defines" , "target.add_undefines" - , "target.add_defines_h" - , "target.add_undefines_h" , "target.add_frameworks" , "target.add_rpathdirs" -- @note do not translate path, it's usually an absolute path or contains $ORIGIN/@loader_path -- option.add_xxx @@ -57,11 +53,7 @@ function apis() , "option.add_arflags" , "option.add_shflags" , "option.add_defines" - , "option.add_defines_if_ok" - , "option.add_defines_h_if_ok" , "option.add_undefines" - , "option.add_undefines_if_ok" - , "option.add_undefines_h_if_ok" , "option.add_frameworks" , "option.add_rpathdirs" -- toolchain.add_xxx @@ -86,13 +78,11 @@ function apis() { -- target.set_xxx "target.set_headerdir" -- TODO deprecated - , "target.set_config_h" -- TODO deprecated , "target.set_config_header" , "target.set_pcheader" , "target.set_pcxxheader" -- target.add_xxx , "target.add_headers" -- TODO deprecated - , "target.add_headerdirs" , "target.add_headerfiles" , "target.add_linkdirs" , "target.add_includedirs" diff --git a/xmake/languages/objc++/xmake.lua b/xmake/languages/objc++/xmake.lua index aafece100..e503ba264 100644 --- a/xmake/languages/objc++/xmake.lua +++ b/xmake/languages/objc++/xmake.lua @@ -68,25 +68,12 @@ language("objc++") , "target.frameworks" , "target.pcheader" , "target.pcxxheader" - , "option.symbols" - , "option.warnings" - , "option.optimize:check" - , "option.vectorexts:check" - , "option.languages" - , "option.includedirs" - , "option.defines" - , "option.undefines" - , "option.defines_if_ok" - , "option.undefines_if_ok" - , "option.frameworkdirs" - , "option.frameworks" , "toolchain.includedirs" , "toolchain.defines" , "toolchain.undefines" , "toolchain.frameworkdirs" , "toolchain.frameworks" , "target.sysincludedirs" - , "option.sysincludedirs" , "toolchain.sysincludedirs" } , binary = @@ -98,25 +85,17 @@ language("objc++") , "target.frameworkdirs" , "target.strip" , "target.symbols" - , "option.strip" - , "option.symbols" - , "option.linkdirs" - , "option.rpathdirs" - , "option.frameworkdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "toolchain.frameworkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.frameworks" , "target.frameworks" - , "option.frameworks" , "toolchain.frameworks" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , shared = @@ -127,23 +106,16 @@ language("objc++") , "target.frameworkdirs" , "target.strip" , "target.symbols" - , "option.strip" - , "option.symbols" - , "option.linkdirs" - , "option.frameworkdirs" , "toolchain.linkdirs" , "toolchain.frameworkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.frameworks" , "target.frameworks" - , "option.frameworks" , "toolchain.frameworks" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , static = diff --git a/xmake/languages/rust/xmake.lua b/xmake/languages/rust/xmake.lua index 7802b8e7f..9c7e94edc 100644 --- a/xmake/languages/rust/xmake.lua +++ b/xmake/languages/rust/xmake.lua @@ -65,8 +65,6 @@ language("rust") , "target.rpathdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" - , "option.rpathdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" } @@ -76,7 +74,6 @@ language("rust") , "target.linkdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" , "toolchain.linkdirs" } , static = diff --git a/xmake/languages/swift/xmake.lua b/xmake/languages/swift/xmake.lua index bae455844..b0de2d067 100644 --- a/xmake/languages/swift/xmake.lua +++ b/xmake/languages/swift/xmake.lua @@ -63,18 +63,6 @@ language("swift") , "target.undefines" , "target.frameworkdirs" , "target.frameworks" - , "option.symbols" - , "option.warnings" - , "option.optimize:check" - , "option.vectorexts:check" - , "option.languages" - , "option.includedirs" - , "option.defines" - , "option.undefines" - , "option.defines_if_ok" - , "option.undefines_if_ok" - , "option.frameworkdirs" - , "option.frameworks" , "toolchain.includedirs" , "toolchain.defines" , "toolchain.undefines" @@ -90,25 +78,17 @@ language("swift") , "target.frameworkdirs" , "target.strip" , "target.symbols" - , "option.strip" - , "option.symbols" - , "option.linkdirs" - , "option.rpathdirs" - , "option.frameworkdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "toolchain.frameworkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.frameworks" , "target.frameworks" - , "option.frameworks" , "toolchain.frameworks" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , shared = @@ -119,23 +99,16 @@ language("swift") , "target.frameworkdirs" , "target.strip" , "target.symbols" - , "option.strip" - , "option.symbols" - , "option.linkdirs" - , "option.frameworkdirs" , "toolchain.linkdirs" , "toolchain.frameworkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.frameworks" , "target.frameworks" - , "option.frameworks" , "toolchain.frameworks" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , static = diff --git a/xmake/languages/zig/xmake.lua b/xmake/languages/zig/xmake.lua index 3aeba0524..117890613 100644 --- a/xmake/languages/zig/xmake.lua +++ b/xmake/languages/zig/xmake.lua @@ -65,17 +65,13 @@ language("zig") , "target.rpathdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" - , "option.rpathdirs" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , shared = @@ -84,15 +80,12 @@ language("zig") , "target.linkdirs" , "target.strip" , "target.symbols" - , "option.linkdirs" , "toolchain.linkdirs" , "config.links" , "target.links" - , "option.links" , "toolchain.links" , "config.syslinks" , "target.syslinks" - , "option.syslinks" , "toolchain.syslinks" } , static = diff --git a/xmake/modules/core/tools/ar.lua b/xmake/modules/core/tools/ar.lua index 868b4eae1..dc858a19e 100644 --- a/xmake/modules/core/tools/ar.lua +++ b/xmake/modules/core/tools/ar.lua @@ -52,7 +52,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) opt = opt or {} local argv = table.join(flags, targetfile, objectfiles) if is_host("windows") and not opt.rawargs then - argv = winos.cmdargv(argv) + argv = winos.cmdargv(argv, {escape = true}) end -- make it diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 64d4d2773..d95d58e5d 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -85,7 +85,6 @@ function init(self) -- others , ["-ftrapv"] = "" - , ["-fsanitize=address"] = "" }) end @@ -260,9 +259,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - -- @note we use os.args() to escape and wrap it, - -- because all flags will be preprocessed in `builder:_preprocess_flags`/`os.argv()` - return "-I" .. os.args(path.translate(dir)) + return {"-I" .. path.translate(dir)} end -- make the sysincludedir flag @@ -276,7 +273,7 @@ function nf_sysincludedir(self, dir) _g._HAS_EXTERNAL_INCLUDEDIR = has_external_includedir end if has_external_includedir then - return {"-experimental:external", "-external:W0", "-external:I" .. os.args(path.translate(dir))} + return {"-experimental:external", "-external:W0", "-external:I" .. path.translate(dir)} else return nf_includedir(self, dir) end @@ -293,9 +290,7 @@ function nf_pcheader(self, pcheaderfile, target) if objectfiles then table.insert(objectfiles, target:pcoutputfile("c") .. ".obj") end - - -- make flag - return "-Yu" .. path.filename(pcheaderfile) .. " -FI" .. path.filename(pcheaderfile) .. " -Fp" .. os.args(target:pcoutputfile("c")) + return {"-Yu" .. path.filename(pcheaderfile), "-FI" .. path.filename(pcheaderfile), "-Fp" .. target:pcoutputfile("c")} end end @@ -310,9 +305,7 @@ function nf_pcxxheader(self, pcheaderfile, target) if objectfiles then table.insert(objectfiles, target:pcoutputfile("cxx") .. ".obj") end - - -- make flag - return "-Yu" .. path.filename(pcheaderfile) .. " -FI" .. path.filename(pcheaderfile) .. " -Fp" .. os.args(target:pcoutputfile("cxx")) + return {"-Yu" .. path.filename(pcheaderfile), "-FI" .. path.filename(pcheaderfile), "-Fp" .. target:pcoutputfile("cxx")} end end @@ -388,7 +381,6 @@ function compargv(self, sourcefile, objectfile, flags, opt) end -- make the compile arguments list - -- @note only flags in nf_xxx() need be wrapped via os.args, @see nf_includedir local argv = table.join("-c", flags, "-Fo" .. objectfile, sourcefile) return self:program(), (opt and opt.rawargs) and argv or winos.cmdargv(argv) end @@ -474,7 +466,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt) end end if #lines > 0 then - local warnings = table.concat(table.slice(lines, 1, ifelse(#lines > 8, 8, #lines)), "\r\n") + local warnings = table.concat(table.slice(lines, 1, (#lines > 8 and 8 or #lines)), "\r\n") if progress.showing_without_scroll() then print("") end diff --git a/xmake/modules/core/tools/clang_cl.lua b/xmake/modules/core/tools/clang_cl.lua index 26ad13184..4e0046fe8 100644 --- a/xmake/modules/core/tools/clang_cl.lua +++ b/xmake/modules/core/tools/clang_cl.lua @@ -21,6 +21,7 @@ -- inherit cl inherit("cl") import("core.base.option") +import("core.base.tty") import("core.base.colors") -- init it @@ -65,7 +66,7 @@ end function _has_color_diagnostics(self) local colors_diagnostics = _g._HAS_COLOR_DIAGNOSTICS if colors_diagnostics == nil then - if io.isatty() and (colors.color8() or colors.color256()) then + if io.isatty() and (tty.has_color8() or tty.has_color256()) then local theme = colors.theme() if theme and theme:name() ~= "plain" then -- for clang @@ -204,7 +205,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) -- get 16 lines of errors if start > 0 then - lines = table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start)) + lines = table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))) end end @@ -219,7 +220,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) if ok and errdata and #errdata > 0 and (option.get("diagnosis") or option.get("warning")) then local lines = errdata:split('\n', {plain = true}) if #lines > 0 then - local warnings = table.concat(table.slice(lines, 1, ifelse(#lines > 8, 8, #lines)), "\n") + local warnings = table.concat(table.slice(lines, 1, (#lines > 8 and 8 or #lines)), "\n") cprint("${color.warning}%s", warnings) end end diff --git a/xmake/modules/core/tools/cparser.lua b/xmake/modules/core/tools/cparser.lua index e24ca87fc..a155b7fa2 100644 --- a/xmake/modules/core/tools/cparser.lua +++ b/xmake/modules/core/tools/cparser.lua @@ -115,7 +115,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I" .. dir} end -- make the sysincludedir flag @@ -135,7 +135,7 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L" .. os.args(dir) + return {"-L" .. dir} end -- make the link arguments list @@ -191,7 +191,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) -- get 16 lines of errors if start > 0 or not option.get("verbose") then if start == 0 then start = 1 end - errors = table.concat(table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start)), "\n") + errors = table.concat(table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))), "\n") end -- raise compiling errors diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua index c172641ac..2a9d860e1 100644 --- a/xmake/modules/core/tools/dmd.lua +++ b/xmake/modules/core/tools/dmd.lua @@ -94,7 +94,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I" .. dir} end -- make the sysincludedir flag @@ -114,20 +114,19 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L-L" .. os.args(dir) + return {"-L-L" .. dir} end -- make the rpathdir flag function nf_rpathdir(self, dir) dir = path.translate(dir) if self:has_flags("-L-rpath=" .. dir, "ldflags") then - return "-L-rpath=" .. os.args(dir:gsub("@[%w_]+", function (name) + return {"-L-rpath=" .. (dir:gsub("@[%w_]+", function (name) local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"} return maps[name] - end)) - + end))} elseif self:has_flags("-L-rpath -L" .. dir, "ldflags") then - return "-L-rpath -L" .. os.args(dir:gsub("%$ORIGIN", "@loader_path")) + return {"-L-rpath", "-L" .. (dir:gsub("%$ORIGIN", "@loader_path"))} end end diff --git a/xmake/modules/core/tools/emcc.lua b/xmake/modules/core/tools/emcc.lua index 39f4ddfbf..a443f43f6 100644 --- a/xmake/modules/core/tools/emcc.lua +++ b/xmake/modules/core/tools/emcc.lua @@ -36,7 +36,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) opt = opt or {} local argv = table.join("-o", targetfile, objectfiles, flags) if is_host("windows") and not opt.rawargs then - argv = winos.cmdargv(argv) + argv = winos.cmdargv(argv, {escape = true}) end return self:program(), argv end diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index ef3fb4ce9..89b732ec9 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.base.tty") import("core.base.colors") import("core.base.global") import("core.project.config") @@ -232,12 +233,12 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(path.translate(dir)) + return {"-I" .. path.translate(dir)} end -- make the sysincludedir flag function nf_sysincludedir(self, dir) - return "-isystem " .. os.args(path.translate(dir)) + return {"-isystem", path.translate(dir)} end -- make the link flag @@ -252,30 +253,30 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L" .. os.args(path.translate(dir)) + return {"-L" .. path.translate(dir)} end -- make the rpathdir flag function nf_rpathdir(self, dir) dir = path.translate(dir) if self:has_flags("-Wl,-rpath=" .. dir, "ldflags") then - return "-Wl,-rpath=" .. os.args(dir:gsub("@[%w_]+", function (name) + return {"-Wl,-rpath=" .. (dir:gsub("@[%w_]+", function (name) local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"} return maps[name] - end)) + end))} elseif self:has_flags("-Xlinker -rpath -Xlinker " .. dir, "ldflags") then - return "-Xlinker -rpath -Xlinker " .. os.args(dir:gsub("%$ORIGIN", "@loader_path")) + return {"-Xlinker", "-rpath", "-Xlinker", (dir:gsub("%$ORIGIN", "@loader_path"))} end end -- make the framework flag function nf_framework(self, framework) - return "-framework " .. framework + return {"-framework", framework} end -- make the frameworkdir flag function nf_frameworkdir(self, frameworkdir) - return "-F " .. os.args(path.translate(frameworkdir)) + return {"-F", path.translate(frameworkdir)} end -- make the c precompiled header flag @@ -283,9 +284,9 @@ function nf_pcheader(self, pcheaderfile, target) if self:kind() == "cc" then local pcoutputfile = target:pcoutputfile("c") if self:name() == "clang" then - return "-include " .. os.args(pcheaderfile) .. " -include-pch " .. os.args(pcoutputfile) + return {"-include", pcheaderfile, "-include-pch", pcoutputfile} else - return "-include " .. path.filename(pcheaderfile) .. " -I" .. os.args(path.directory(pcoutputfile)) + return {"-include", path.filename(pcheaderfile), "-I", path.directory(pcoutputfile)} end end end @@ -295,9 +296,9 @@ function nf_pcxxheader(self, pcheaderfile, target) if self:kind() == "cxx" then local pcoutputfile = target:pcoutputfile("cxx") if self:name() == "clang" then - return "-include " .. os.args(pcheaderfile) .. " -include-pch " .. os.args(pcoutputfile) + return {"-include", pcheaderfile, "-include-pch", pcoutputfile} else - return "-include " .. path.filename(pcheaderfile) .. " -I" .. os.args(path.directory(pcoutputfile)) + return {"-include", path.filename(pcheaderfile), "-I", path.directory(pcoutputfile)} end end end @@ -340,7 +341,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) opt = opt or {} local argv = table.join("-o", targetfile, objectfiles, flags, flags_extra) if is_host("windows") and not opt.rawargs then - argv = winos.cmdargv(argv) + argv = winos.cmdargv(argv, {escape = true}) end return self:program(), argv end @@ -360,15 +361,15 @@ end function _has_color_diagnostics(self) local colors_diagnostics = _g._HAS_COLOR_DIAGNOSTICS if colors_diagnostics == nil then - if io.isatty() and (colors.color8() or colors.color256()) then + if io.isatty() and (tty.has_color8() or tty.has_color256()) then local theme = colors.theme() if theme and theme:name() ~= "plain" then - -- for clang - if self:has_flags("-fcolor-diagnostics", "cxflags") then - colors_diagnostics = "-fcolor-diagnostics" -- for gcc - elseif self:has_flags("-fdiagnostics-color=always", "cxflags") then + if self:has_flags("-fdiagnostics-color=always", "cxflags") then colors_diagnostics = "-fdiagnostics-color=always" + -- for clang + elseif self:has_flags("-fcolor-diagnostics", "cxflags") then + colors_diagnostics = "-fcolor-diagnostics" end end end @@ -472,7 +473,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) -- get 16 lines of errors if start > 0 then - lines = table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start)) + lines = table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))) end end @@ -487,7 +488,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) if ok and errdata and #errdata > 0 and (option.get("diagnosis") or option.get("warning") or global.get("build_warning")) then local lines = errdata:split('\n', {plain = true}) if #lines > 0 then - local warnings = table.concat(table.slice(lines, 1, ifelse(#lines > 8, 8, #lines)), "\n") + local warnings = table.concat(table.slice(lines, 1, (#lines > 8 and 8 or #lines)), "\n") if progress.showing_without_scroll() then print("") end diff --git a/xmake/modules/core/tools/go.lua b/xmake/modules/core/tools/go.lua index 17e15bf8c..fbd046cf0 100644 --- a/xmake/modules/core/tools/go.lua +++ b/xmake/modules/core/tools/go.lua @@ -80,7 +80,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I " .. os.args(dir) + return {"-I", dir} end -- make the sysincludedir flag @@ -90,7 +90,7 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L " .. os.args(dir) + return {"-L", dir} end -- make the link arguments list diff --git a/xmake/modules/core/tools/ifort.lua b/xmake/modules/core/tools/ifort.lua index cca51c683..2d48f34c7 100644 --- a/xmake/modules/core/tools/ifort.lua +++ b/xmake/modules/core/tools/ifort.lua @@ -47,7 +47,7 @@ if is_host("windows") then opt = opt or {} local argv = table.join("-o", targetfile, objectfiles, "/link", flags) if not opt.rawargs then - argv = winos.cmdargv(argv) + argv = winos.cmdargv(argv, {escape = true}) end -- @note we cannot put -dll to @args.txt if targetkind == "shared" then diff --git a/xmake/modules/core/tools/ld.lua b/xmake/modules/core/tools/ld.lua index 2e337a572..0eaa8fc91 100644 --- a/xmake/modules/core/tools/ld.lua +++ b/xmake/modules/core/tools/ld.lua @@ -65,17 +65,15 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L" .. os.args(path.translate(dir)) + return {"-L", path.translate(dir)} end -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) - - -- init arguments opt = opt or {} local argv = table.join("-o", targetfile, objectfiles, flags) if is_host("windows") and not opt.rawargs then - argv = winos.cmdargv(argv) + argv = winos.cmdargv(argv, {escape = true}) end return self:program(), argv end diff --git a/xmake/modules/core/tools/ldc2.lua b/xmake/modules/core/tools/ldc2.lua index 02d067b19..d62c45a53 100644 --- a/xmake/modules/core/tools/ldc2.lua +++ b/xmake/modules/core/tools/ldc2.lua @@ -47,4 +47,12 @@ function nf_optimize(self, level) return maps[level] end +-- make the symbol flag +function nf_symbol(self, level) + local maps = + { + debug = "-g --d-debug" + } + return maps[level] +end diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua index 26abc8983..b5ee775af 100644 --- a/xmake/modules/core/tools/link.lua +++ b/xmake/modules/core/tools/link.lua @@ -58,16 +58,19 @@ function get(self, name) end -- make the strip flag -function nf_strip(self, level) +function nf_strip(self, level, target) -- @note we explicitly strip some useless code, because `/debug` may keep them -- @see https://github.com/xmake-io/xmake/issues/907 - -- - local maps = - { - debug = "/opt:ref /opt:icf" - , all = "/opt:ref /opt:icf /ltcg" -- we enable /ltcg for optimize/smallest:/Gl - } - return maps[level] + if level == "all" then + -- we enable /ltcg for optimize/smallest:/Gl + local flags = {"/opt:ref", "/opt:icf"} + if target and target:get("optimize") == "smallest" then + table.insert(flags, "/ltcg") + end + return flags + elseif level == "debug" then + return {"/opt:ref", "/opt:icf"} + end end -- make the symbol flag @@ -75,12 +78,15 @@ function nf_symbol(self, level, target) -- debug? generate *.pdb file local flags = nil - local targetkind = target:get("kind") - if level == "debug" and (targetkind == "binary" or targetkind == "shared") then - if target and target.symbolfile then - flags = "-debug -pdb:" .. target:symbolfile() - else - flags = "-debug" + if target then + if target:type() == "target" then + if level == "debug" and (target:is_binary() or target:is_shared()) then + flags = {"-debug", "-pdb:" .. target:symbolfile()} + end + else -- for option + if level == "debug" then + flags = "-debug" + end end end return flags @@ -105,7 +111,7 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-libpath:" .. os.args(path.translate(dir)) + return {"-libpath:" .. path.translate(dir)} end -- make the link arguments list diff --git a/xmake/modules/core/tools/llvm_ar.lua b/xmake/modules/core/tools/llvm_ar.lua index fb20c2320..b00c4435e 100644 --- a/xmake/modules/core/tools/llvm_ar.lua +++ b/xmake/modules/core/tools/llvm_ar.lua @@ -50,7 +50,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) opt = opt or {} local argv = table.join(flags, targetfile, objectfiles) if is_host("windows") and not opt.rawargs then - argv = winos.cmdargv(argv) + argv = winos.cmdargv(argv, {escape = true}) end -- make it diff --git a/xmake/modules/core/tools/llvm_rc.lua b/xmake/modules/core/tools/llvm_rc.lua index 342670d5e..7feb8a621 100644 --- a/xmake/modules/core/tools/llvm_rc.lua +++ b/xmake/modules/core/tools/llvm_rc.lua @@ -29,17 +29,17 @@ end -- make the define flag function nf_define(self, macro) - return "/D " .. macro + return {"/D", macro} end -- make the undefine flag function nf_undefine(self, macro) - return "/U " .. macro + return {"/U", macro} end -- make the includedir flag function nf_includedir(self, dir) - return "/I " .. os.args(dir) + return {"/I", dir} end -- make the sysincludedir flag diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index e3893d05e..83da11fb6 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -87,7 +87,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I" .. dir} end -- make the sysincludedir flag @@ -97,7 +97,7 @@ end -- make the compile arguments list function compargv(self, sourcefile, objectfile, flags) - return self:program(), table.join("-c", flags, "-Fo" .. os.args(objectfile), sourcefile) + return self:program(), table.join("-c", flags, "-Fo" .. objectfile, sourcefile) end -- compile the source file diff --git a/xmake/modules/core/tools/nasm.lua b/xmake/modules/core/tools/nasm.lua index 9f2a51882..8297e21bc 100644 --- a/xmake/modules/core/tools/nasm.lua +++ b/xmake/modules/core/tools/nasm.lua @@ -70,7 +70,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I", dir} end -- make the sysincludedir flag diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index c0e844356..784b606c5 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -200,7 +200,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I", dir} end -- make the sysincludedir flag @@ -220,29 +220,29 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L" .. os.args(dir) + return {"-L", dir} end -- make the rpathdir flag function nf_rpathdir(self, dir) if self:has_flags("-Wl,-rpath=" .. dir, "ldflags") then - return "-Wl,-rpath=" .. os.args(dir:gsub("@[%w_]+", function (name) + return {"-Wl,-rpath=" .. (dir:gsub("@[%w_]+", function (name) local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"} return maps[name] - end)) + end))} elseif self:has_flags("-Xlinker -rpath -Xlinker " .. dir, "ldflags") then - return "-Xlinker -rpath -Xlinker " .. os.args(dir:gsub("%$ORIGIN", "@loader_path")) + return {"-Xlinker", "-rpath", "-Xlinker", (dir:gsub("%$ORIGIN", "@loader_path"))} end end -- make the c precompiled header flag function nf_pcheader(self, pcheaderfile, target) - return "-include " .. os.args(pcheaderfile) + return {"-include", pcheaderfile} end -- make the c++ precompiled header flag function nf_pcxxheader(self, pcheaderfile, target) - return "-include " .. os.args(pcheaderfile) + return {"-include", pcheaderfile} end -- make the link arguments list @@ -260,7 +260,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags) -- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc if targetkind == "shared" and config.plat() == "mingw" then table.insert(flags_extra, "-Xlinker") - table.insert(flags_extra, "-Wl,--out-implib," .. os.args(path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib"))) + table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib")) end -- make link args @@ -269,18 +269,15 @@ end -- link the target file function link(self, objectfiles, targetkind, targetfile, flags) - - -- ensure the target directory os.mkdir(path.directory(targetfile)) - - -- link it - os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) + local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags) + os.runv(program, argv, {envs = self:runenvs()}) end -- support `-MMD -MF depfile.d`? some old gcc does not support it at same time function _has_flags_mmd_mf(self) local has_mmd_mf = _g._HAS_MMD_MF - if has_mmd_mf == nil then + if has_mmd_mf == nil and not is_host("windows") then has_mmd_mf = self:has_flags({"-MMD", "-MF", os.nuldev()}, "cuflags", { flagskey = "-MMD -MF" }) or false _g._HAS_MMD_MF = has_mmd_mf end @@ -290,7 +287,7 @@ end -- support `-MM -o depfile.d`? function _has_flags_mm(self) local has_mm = _g._HAS_MM - if not has_mmd_mf and has_mm == nil then + if not has_mmd_mf and has_mm == nil and not is_host("windows") then has_mm = self:has_flags("-MM", "cuflags", { flagskey = "-MM" }) or false _g._HAS_MM = has_mm end @@ -321,12 +318,14 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) compflags = table.join(compflags, "-MMD", "-MF", depfile) elseif _has_flags_mm(self) then -- since -MD is not supported, run nvcc twice - os.runv(compargv(self, sourcefile, depfile, table.join(flags, "-MM"))) + local program, argv = compargv(self, sourcefile, depfile, table.join(flags, "-MM")) + os.runv(program, argv, {envs = self:runenvs()}) end end -- do compile - local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, compflags)) + local program, argv = compargv(self, sourcefile, objectfile, compflags) + local outdata, errdata = os.iorunv(program, argv, {envs = self:runenvs()}) return (outdata or "") .. (errdata or "") end, catch @@ -350,7 +349,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) -- get 16 lines of errors if start > 0 or not option.get("verbose") then if start == 0 then start = 1 end - errors = table.concat(table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start)), "\n") + errors = table.concat(table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))), "\n") end -- raise compiling errors diff --git a/xmake/modules/core/tools/rc.lua b/xmake/modules/core/tools/rc.lua index a9db3903c..208161b67 100644 --- a/xmake/modules/core/tools/rc.lua +++ b/xmake/modules/core/tools/rc.lua @@ -43,7 +43,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I" .. dir} end -- make the sysincludedir flag diff --git a/xmake/modules/core/tools/rustc.lua b/xmake/modules/core/tools/rustc.lua index 0af2acdd9..ade2daea4 100644 --- a/xmake/modules/core/tools/rustc.lua +++ b/xmake/modules/core/tools/rustc.lua @@ -72,7 +72,7 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L" .. os.args(dir) + return {"-L" .. dir} end -- make the build arguments list diff --git a/xmake/modules/core/tools/sdar.lua b/xmake/modules/core/tools/sdar.lua index 056ca32d3..41b961444 100644 --- a/xmake/modules/core/tools/sdar.lua +++ b/xmake/modules/core/tools/sdar.lua @@ -52,7 +52,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) opt = opt or {} local argv = table.join(flags, targetfile, objectfiles) if is_host("windows") and not opt.rawargs then - argv = winos.cmdargv(argv) + argv = winos.cmdargv(argv, {escape = true}) end -- make it diff --git a/xmake/modules/core/tools/sdcc.lua b/xmake/modules/core/tools/sdcc.lua index 0f307d6ff..00e081384 100644 --- a/xmake/modules/core/tools/sdcc.lua +++ b/xmake/modules/core/tools/sdcc.lua @@ -133,7 +133,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I" .. dir} end -- make the sysincludedir flag @@ -153,7 +153,7 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L" .. os.args(dir) + return {"-L" .. dir} end -- make the link arguments list @@ -209,7 +209,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) -- get 16 lines of errors if start > 0 or not option.get("verbose") then if start == 0 then start = 1 end - errors = table.concat(table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start)), "\n") + errors = table.concat(table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))), "\n") end -- raise compiling errors diff --git a/xmake/modules/core/tools/swiftc.lua b/xmake/modules/core/tools/swiftc.lua index f56e9b392..f67a809bf 100644 --- a/xmake/modules/core/tools/swiftc.lua +++ b/xmake/modules/core/tools/swiftc.lua @@ -142,22 +142,22 @@ end -- make the define flag function nf_define(self, macro) - return "-Xcc -D" .. macro + return {"-Xcc", "-D" .. macro} end -- make the undefine flag function nf_undefine(self, macro) - return "-Xcc -U" .. macro + return {"-Xcc", "-U" .. macro} end -- make the framework flag function nf_framework(self, framework) - return "-framework " .. framework + return {"-framework", framework} end -- make the frameworkdir flag function nf_frameworkdir(self, frameworkdir) - return "-F " .. os.args(frameworkdir) + return {"-F", frameworkdir} end -- make the link flag @@ -172,7 +172,7 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L" .. os.args(dir) + return {"-L", dir} end -- make the link arguments list @@ -182,11 +182,7 @@ end -- link the target file function link(self, objectfiles, targetkind, targetfile, flags) - - -- ensure the target directory os.mkdir(path.directory(targetfile)) - - -- link it os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) end diff --git a/xmake/modules/core/tools/tcc.lua b/xmake/modules/core/tools/tcc.lua index 39d78b598..7d306997f 100644 --- a/xmake/modules/core/tools/tcc.lua +++ b/xmake/modules/core/tools/tcc.lua @@ -97,7 +97,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I" .. dir} end -- make the sysincludedir flag @@ -117,7 +117,7 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L" .. os.args(dir) + return {"-L" .. dir} end -- make the link arguments list @@ -179,7 +179,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) -- get 16 lines of errors if start > 0 or not option.get("verbose") then if start == 0 then start = 1 end - errors = table.concat(table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start)), "\n") + errors = table.concat(table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))), "\n") end -- raise compiling errors diff --git a/xmake/modules/core/tools/windres.lua b/xmake/modules/core/tools/windres.lua index 67a108cf7..9acb34515 100644 --- a/xmake/modules/core/tools/windres.lua +++ b/xmake/modules/core/tools/windres.lua @@ -39,7 +39,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I", dir} end -- make the sysincludedir flag diff --git a/xmake/modules/core/tools/yasm.lua b/xmake/modules/core/tools/yasm.lua index 4a2ab476d..75b835762 100644 --- a/xmake/modules/core/tools/yasm.lua +++ b/xmake/modules/core/tools/yasm.lua @@ -70,7 +70,7 @@ end -- make the includedir flag function nf_includedir(self, dir) - return "-I" .. os.args(dir) + return {"-I", dir} end -- make the sysincludedir flag @@ -79,12 +79,12 @@ function nf_sysincludedir(self, dir) end -- make the compile arguments list -function _compargv1(self, sourcefile, objectfile, flags) +function compargv(self, sourcefile, objectfile, flags) return self:program(), table.join(flags, "-o", objectfile, sourcefile) end -- compile the source file -function _compile1(self, sourcefile, objectfile, dependinfo, flags) +function compile(self, sourcefile, objectfile, dependinfo, flags) -- ensure the object directory os.mkdir(path.directory(objectfile)) @@ -93,7 +93,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) local outdata, errdata = try { function () - return os.iorunv(_compargv1(self, sourcefile, objectfile, flags)) + return os.iorunv(compargv(self, sourcefile, objectfile, flags)) end, catch { @@ -122,23 +122,3 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) } end --- make the compile arguments list -function compargv(self, sourcefiles, objectfile, flags) - - -- only support single source file now - assert(type(sourcefiles) ~= "table", "'object:sources' not support!") - - -- for only single source file - return _compargv1(self, sourcefiles, objectfile, flags) -end - --- compile the source file -function compile(self, sourcefiles, objectfile, dependinfo, flags) - - -- only support single source file now - assert(type(sourcefiles) ~= "table", "'object:sources' not support!") - - -- for only single source file - _compile1(self, sourcefiles, objectfile, dependinfo, flags) -end - diff --git a/xmake/modules/core/tools/zig.lua b/xmake/modules/core/tools/zig.lua index ce03bc3cd..2270e2a3e 100644 --- a/xmake/modules/core/tools/zig.lua +++ b/xmake/modules/core/tools/zig.lua @@ -75,29 +75,29 @@ end -- make the linkdir flag function nf_linkdir(self, dir) - return "-L" .. os.args(dir) + return {"-L", dir} end -- make the framework flag function nf_framework(self, framework) - return "-framework " .. framework + return {"-framework", framework} end -- make the frameworkdir flag function nf_frameworkdir(self, frameworkdir) - return "-F " .. os.args(path.translate(frameworkdir)) + return {"-F", path.translate(frameworkdir)} end -- make the rpathdir flag function nf_rpathdir(self, dir) dir = path.translate(dir) if is_plat("macosx") then - return "-rpath " .. os.args(dir:gsub("%$ORIGIN", "@loader_path")) + return {"-rpath", (dir:gsub("%$ORIGIN", "@loader_path"))} else - return "-rpath " .. os.args(dir:gsub("@[%w_]+", function (name) + return {"-rpath", (dir:gsub("@[%w_]+", function (name) local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"} return maps[name] - end)) + end))} end end diff --git a/xmake/modules/core/tools/zig_cc.lua b/xmake/modules/core/tools/zig_cc.lua new file mode 100644 index 000000000..1e263a4f6 --- /dev/null +++ b/xmake/modules/core/tools/zig_cc.lua @@ -0,0 +1,23 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file zig_cc.lua +-- + +-- inherit gcc +inherit("gcc") + diff --git a/xmake/modules/core/tools/zig_cxx.lua b/xmake/modules/core/tools/zig_cxx.lua new file mode 100644 index 000000000..f9d7f9c72 --- /dev/null +++ b/xmake/modules/core/tools/zig_cxx.lua @@ -0,0 +1,23 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file zig_cxx.lua +-- + +inherit("zig_cc") + + diff --git a/xmake/modules/detect/packages/find_mkl.lua b/xmake/modules/detect/packages/find_mkl.lua new file mode 100644 index 000000000..a34d2bf3a --- /dev/null +++ b/xmake/modules/detect/packages/find_mkl.lua @@ -0,0 +1,73 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author xq114 +-- @file find_mkl.lua +-- + +-- imports +import("lib.detect.find_path") +import("lib.detect.find_library") +import("lib.detect.find_package") + +-- find mkl +-- +-- @param opt the package options. e.g. see the options of find_package() +-- +-- @return see the return value of find_package() +-- +function main(opt) + + -- for windows platform + if opt.plat == "windows" then + + -- init bits + local rdir = (opt.arch == "x64" and "intel64" or "ia32") + + -- init search paths + local paths = { + "$(env ONEAPI_ROOT)\\mkl\\latest" + } + + -- find library + local result = {links = {}, linkdirs = {}, includedirs = {}, threading = ""} + local linkinfo = find_library("mkl_core", paths, {suffixes = path.join("lib", rdir)}) + if not linkinfo then + return + end + table.insert(result.linkdirs, linkinfo.linkdir) + if rdir == "intel64" then + table.insert(result.links, "mkl_intel_ilp64") + else + table.insert(result.links, "mkl_intel_c") + end + + -- use tbb if available + local tbb_res = find_package("tbb") + if tbb_res then + table.join2(result.linkdirs, tbb_res.linkdirs) + table.join2(result.links, {"mkl_tbb_thread", "mkl_core", "tbb"}) + result.threading = "tbb" + else + table.join2(result.links, {"mkl_sequential", "mkl_core"}) + result.threading = "seq" + end + + -- find include + table.insert(result.includedirs, find_path("mkl.h", paths, {suffixes = "include"})) + return result + end +end diff --git a/xmake/modules/detect/packages/find_nvtx.lua b/xmake/modules/detect/packages/find_nvtx.lua new file mode 100644 index 000000000..5fce673c3 --- /dev/null +++ b/xmake/modules/detect/packages/find_nvtx.lua @@ -0,0 +1,80 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author xq114 +-- @file find_nvtx.lua +-- + +-- imports +import("lib.detect.find_path") +import("lib.detect.find_library") +import("detect.sdks.find_cuda") + +-- find nvtx +-- +-- @param opt the package options. e.g. see the options of find_package() +-- +-- @return see the return value of find_package() +-- +function main(opt) + if opt.plat == "windows" then + + -- init bits + local rdir = (opt.arch == "x64" and "x64" or "Win32") + local libname = (opt.arch == "x64" and "nvToolsExt64_1" or "nvToolsExt32_1") + + -- init search paths + local paths = + { + "$(env NVTOOLSEXT_PATH)", + "$(env PROGRAMFILES)/NVIDIA Corporation/NvToolsExt" + } + + -- find library + local result = {links = {}, linkdirs = {}, includedirs = {}, libfiles = {}} + local linkinfo = find_library(libname, paths, {suffixes = path.join("lib", rdir)}) + if linkinfo then + local nvtx_dir = path.directory(path.directory(linkinfo.linkdir)) + table.insert(result.linkdirs, linkinfo.linkdir) + table.insert(result.links, libname) + table.insert(result.libfiles, path.join(nvtx_dir, "bin", rdir, libname .. ".dll")) + table.insert(result.libfiles, path.join(nvtx_dir, "lib", rdir, libname .. ".lib")) + else + -- not found? + return + end + + -- find include + table.insert(result.includedirs, find_path("nvToolsExt.h", paths, {suffixes = "include"})) + return result + else + local cuda = find_cuda() + if cuda then + local result = {links = {}, linkdirs = {}, includedirs = {}} + + -- find library + local linkinfo = find_library("nvToolsExt", cuda.linkdirs) + if linkinfo then + table.insert(result.links, "nvToolsExt") + table.insert(result.linkdirs, linkinfo.linkdir) + else + return + end + table.join2(result.includedirs, cuda.includedirs) + return result + end + end +end diff --git a/xmake/modules/detect/packages/find_tbb.lua b/xmake/modules/detect/packages/find_tbb.lua new file mode 100644 index 000000000..e06bcfeb1 --- /dev/null +++ b/xmake/modules/detect/packages/find_tbb.lua @@ -0,0 +1,61 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author xq114 +-- @file find_tbb.lua +-- + +-- imports +import("lib.detect.find_path") +import("lib.detect.find_library") + +-- find tbb +-- +-- @param opt the package options. e.g. see the options of find_package() +-- +-- @return see the return value of find_package() +-- +function main(opt) + + -- for windows platform + if opt.plat == "windows" then + + -- init bits + local rdir = (opt.arch == "x64" and "intel64" or "ia32") + + -- init search paths + local paths = { + "$(env ONEAPI_ROOT)\\tbb\\latest" + } + + -- find library + local result = {links = {}, linkdirs = {}, includedirs = {}} + local linkinfo = find_library("tbb", paths, {suffixes = path.join("lib", rdir, "vc14")}) + if linkinfo then + table.insert(result.linkdirs, linkinfo.linkdir) + table.join2(result.links, {"tbb", "tbb_malloc"}) + else + -- not found? + return + end + + -- find include + table.insert(result.includedirs, find_path(path.join("tbb", "tbb.h"), paths, {suffixes = "include"})) + + -- ok + return result + end +end diff --git a/xmake/modules/detect/packages/find_vulkansdk.lua b/xmake/modules/detect/packages/find_vulkansdk.lua new file mode 100644 index 000000000..902fdd498 --- /dev/null +++ b/xmake/modules/detect/packages/find_vulkansdk.lua @@ -0,0 +1,59 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author xq114 +-- @file find_vulkansdk.lua +-- + +-- imports +import("lib.detect.find_path") +import("lib.detect.find_library") + +-- find vulkansdk +-- +-- @param opt the package options. e.g. see the options of find_package() +-- +-- @return see the return value of find_package() +-- +function main(opt) + + -- init search paths + local paths = + { + "$(env VK_SDK_PATH)", + "$(env VULKAN_SDK)" + } + + -- find library + local result = {links = {}, linkdirs = {}, includedirs = {}} + local libname = (opt.plat == "windows" and "vulkan-1" or "vulkan") + local libsuffix = ((opt.plat == "windows" and opt.arch == "x86") and "lib32" or "lib") + local binsuffix = ((opt.plat == "windows" and opt.arch == "x86") and "bin32" or "bin") + local linkinfo = find_library(libname, paths, {suffixes = libsuffix}) + if linkinfo then + result.sdkdir = path.directory(linkinfo.linkdir) + result.bindir = path.join(result.sdkdir, binsuffix) + table.insert(result.linkdirs, linkinfo.linkdir) + table.insert(result.links, libname) + else + -- not found? + return + end + + -- find include + table.insert(result.includedirs, find_path(path.join("vulkan", "vulkan.h"), paths, {suffixes = "include"})) + return result +end diff --git a/xmake/modules/detect/sdks/find_cross_toolchain.lua b/xmake/modules/detect/sdks/find_cross_toolchain.lua index f2df87e2f..04c66e626 100644 --- a/xmake/modules/detect/sdks/find_cross_toolchain.lua +++ b/xmake/modules/detect/sdks/find_cross_toolchain.lua @@ -31,7 +31,6 @@ function _find_bindir(sdkdir, opt) table.insert(bindirs, opt.bindir) end table.insert(bindirs, path.join(sdkdir, "bin")) - table.insert(bindirs, path.join(sdkdir, "**", "bin")) -- attempt to find *-[gcc|clang|ld] for _, toolname in ipairs({"gcc", "clang", "ld"}) do @@ -44,15 +43,17 @@ function _find_bindir(sdkdir, opt) end -- find tool path - toolpath = find_file(toolname, bindirs) - if toolpath then - return path.directory(toolpath), "" + if not opt.cross then + toolpath = find_file(toolname, bindirs) + if toolpath then + return path.directory(toolpath), "" + end end end -- attempt to use the bin directory local bindir = opt.bindir or path.join(sdkdir, "bin") - if os.isdir(bindir) then + if os.isdir(bindir) and not opt.cross then return bindir end end diff --git a/xmake/modules/detect/sdks/find_ndk.lua b/xmake/modules/detect/sdks/find_ndk.lua index 996b63e8c..bc07f6081 100644 --- a/xmake/modules/detect/sdks/find_ndk.lua +++ b/xmake/modules/detect/sdks/find_ndk.lua @@ -25,6 +25,24 @@ import("core.project.config") import("core.cache.detectcache") import("lib.detect.find_directory") +-- get triple +function _get_triple(arch) + local triples = + { + ["armv5te"] = "arm-linux-androideabi" -- deprecated + , ["armv7-a"] = "arm-linux-androideabi" -- deprecated + , ["armeabi"] = "arm-linux-androideabi" -- removed in ndk r17 + , ["armeabi-v7a"] = "arm-linux-androideabi" + , ["arm64-v8a"] = "aarch64-linux-android" + , i386 = "i686-linux-android" -- deprecated + , x86 = "i686-linux-android" + , x86_64 = "x86_64-linux-android" + , mips = "mips-linux-android" -- removed in ndk r17 + , mips64 = "mips64-linux-android" -- removed in ndk r17 + } + return triples[arch] +end + -- find ndk directory function _find_ndkdir(sdkdir) @@ -46,7 +64,7 @@ function _find_ndkdir(sdkdir) end -- find the sdk version of ndk -function _find_ndk_sdkver(sdkdir, bindir, arch) +function _find_ndk_sdkver(sdkdir, bindir, sysroot, arch) -- uses llvm stl? local use_llvm = false @@ -60,18 +78,32 @@ function _find_ndk_sdkver(sdkdir, bindir, arch) use_llvm = true end + -- get triple + local triple = _get_triple(arch) + -- try to select the best compatible version local sdkver = "16" if use_llvm or arch == "arm64-v8a" then sdkver = "21" end + if sysroot then + if os.isdir(path.join(sysroot, "usr", "lib", triple, sdkver)) then + return sdkver + end + end if os.isdir(path.join(sdkdir, "platforms", "android-" .. sdkver)) then return sdkver end -- find the max version local sdkver_max = 0 - for _, sdkdir in ipairs(os.dirs(path.join(sdkdir, "platforms", "android-*"))) do + local sdkver_dir_pattern + if sysroot and os.isdir(path.join(sysroot, "usr", "lib")) then + sdkver_dir_pattern = path.join(sysroot, "usr", "lib", triple, "*") + else + sdkver_dir_pattern = path.join(sdkdir, "platforms", "android-*") + end + for _, sdkdir in ipairs(os.dirs(sdkver_dir_pattern)) do -- get version local filename = path.filename(sdkdir) @@ -95,6 +127,25 @@ function _find_ndk_toolchains_ver(bindir) return bindir:match("%-(%d*%.%d*)[/\\]") end +-- find sysroot directory +function _find_ndk_sysroot(sdkdir) + + -- get sysroot above ndk r22 + -- @see https://github.com/android/ndk/wiki/Changelog-r22 + local prebuilt = (is_host("macosx") and "darwin" or os.host()) .. "-x86_64" + local sysroot_r22 = path.join(sdkdir, "toolchains", "llvm", "prebuilt", prebuilt, "sysroot") + if os.isdir(sysroot_r22) then + return sysroot_r22 + end + + -- get sysroot above ndk r14 + -- @see https://android.googlesource.com/platform/ndk/+/master/docs/UnifiedHeaders.md + local sysroot_r14 = path.join(sdkdir, "sysroot") + if os.isdir(sysroot_r14) then + return sysroot_r14 + end +end + -- find the ndk toolchain function _find_ndk(sdkdir, arch, ndk_sdkver, ndk_toolchains_ver) @@ -145,9 +196,6 @@ function _find_ndk(sdkdir, arch, ndk_sdkver, ndk_toolchains_ver) return end - -- find the sdk version - local sdkver = ndk_sdkver or _find_ndk_sdkver(sdkdir, bindir, arch) - -- find the gcc toolchain local gcc_toolchain = find_directory("bin", path.join(sdkdir, "toolchains", gcc_toolchain_subdir, "prebuilt", "*")) if gcc_toolchain then @@ -157,21 +205,35 @@ function _find_ndk(sdkdir, arch, ndk_sdkver, ndk_toolchains_ver) -- find the toolchains version local toolchains_ver = ndk_toolchains_ver or _find_ndk_toolchains_ver(gcc_toolchain or bindir) + -- find sysroot directory + local sysroot = _find_ndk_sysroot(sdkdir) + + -- find the sdk version + local sdkver = ndk_sdkver or _find_ndk_sdkver(sdkdir, bindir, sysroot, arch) + -- get ndk version, e.g. r16b, .. local ndkver = nil - local ndk_version_header = path.join(sdkdir, "sysroot/usr/include/android/ndk-version.h") - if os.isfile(ndk_version_header) then - local ndk_version_info = io.readfile(ndk_version_header) - if ndk_version_info then - ndk_version_info = ndk_version_info:match("#define __NDK_MAJOR__ (%d+)") + if sysroot then + local ndk_version_header = path.join(sysroot, "usr/include/android/ndk-version.h") + if os.isfile(ndk_version_header) then + local ndk_version_info = io.readfile(ndk_version_header) if ndk_version_info then - ndkver = tonumber(ndk_version_info) + ndk_version_info = ndk_version_info:match("#define __NDK_MAJOR__ (%d+)") + if ndk_version_info then + ndkver = tonumber(ndk_version_info) + end end end end - -- ok? - return {ndkver = ndkver, sdkdir = sdkdir, bindir = bindir, cross = cross, sdkver = sdkver, gcc_toolchain = gcc_toolchain, toolchains_ver = toolchains_ver} + return {ndkver = ndkver, + sdkdir = sdkdir, + bindir = bindir, + cross = cross, + sdkver = sdkver, + gcc_toolchain = gcc_toolchain, + toolchains_ver = toolchains_ver, + sysroot = sysroot} end -- find ndk toolchains diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua index 1996ac2f9..3b71a5640 100644 --- a/xmake/modules/detect/sdks/find_qt.lua +++ b/xmake/modules/detect/sdks/find_qt.lua @@ -81,8 +81,10 @@ function _find_sdkdir(sdkdir, sdkver) { "HKEY_CLASSES_ROOT\\Applications\\QtProject.QtCreator.c\\shell\\Open\\Command", "HKEY_CLASSES_ROOT\\Applications\\QtProject.QtCreator.cpp\\shell\\Open\\Command", + "HKEY_CLASSES_ROOT\\Applications\\QtProject.QtCreator.pro\\shell\\Open\\Command", "HKEY_CURRENT_USER\\SOFTWARE\\Classes\\Applications\\QtProject.QtCreator.c\\shell\\Open\\Command", - "HKEY_CURRENT_USER\\SOFTWARE\\Classes\\Applications\\QtProject.QtCreator.cpp\\shell\\Open\\Command" + "HKEY_CURRENT_USER\\SOFTWARE\\Classes\\Applications\\QtProject.QtCreator.cpp\\shell\\Open\\Command", + "HKEY_CURRENT_USER\\SOFTWARE\\Classes\\Applications\\QtProject.QtCreator.pro\\shell\\Open\\Command" } for _, reg in ipairs(regs) do table.insert(paths, function () diff --git a/xmake/modules/detect/sdks/find_vcpkgdir.lua b/xmake/modules/detect/sdks/find_vcpkgdir.lua new file mode 100644 index 000000000..d2f6bd3fd --- /dev/null +++ b/xmake/modules/detect/sdks/find_vcpkgdir.lua @@ -0,0 +1,64 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_vcpkgdir.lua +-- + +-- imports +import("core.base.option") +import("core.base.global") +import("core.project.config") +import("core.cache.detectcache") +import("lib.detect.find_tool") + +-- find vcpkgdir +function main() + local vcpkgdir = detectcache:get("detect.sdks.find_vcpkgdir") + if vcpkgdir == nil then + if not vcpkgdir then + vcpkgdir = config.get("vcpkg") or global.get("vcpkg") + if vcpkgdir then + if os.isfile(vcpkgdir) then + vcpkgdir = path.directory(vcpkgdir) + end + end + end + if not vcpkgdir then + vcpkgdir = os.getenv("VCPKG_ROOT") or os.getenv("VCPKG_INSTALLATION_ROOT") + end + if not vcpkgdir and is_host("macosx", "linux") then + local brew = find_tool("brew") + if brew then + dir = try + { + function () + return os.iorunv(brew.program, {"--prefix", "vcpkg"}) + end + } + end + if dir then + dir = path.join(dir:trim(), "libexec") + if os.isdir(path.join(dir, "installed")) then + vcpkgdir = dir + end + end + end + detectcache:set("detect.sdks.find_vcpkgdir", vcpkgdir or false) + detectcache:save() + end + return vcpkgdir or nil +end diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index 309b3dd64..362a2a705 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -43,9 +43,11 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt) -- make the genvcvars.bat opt = opt or {} local genvcvars_bat = os.tmpfile() .. "_genvcvars.bat" - local genvcvars_dat = os.tmpfile() .. "_genvcvars.txt" local file = io.open(genvcvars_bat, "w") file:print("@echo off") + -- @note we need get utf8 output from cmd.exe + -- because some %PATH% and other envs maybe contains unicode characters + file:print("chcp 65001") -- fix error caused by the new vsDevCmd.bat of vs2019 -- @see https://github.com/xmake-io/xmake/issues/549 if vsver and tonumber(vsver) >= 16 then @@ -57,16 +59,19 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt) file:print("call \"%s\" %s %s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "") end for idx, var in ipairs(vcvars) do - file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", genvcvars_dat) + file:print("echo " .. var .. " = %%" .. var .. "%%") end file:close() -- run genvcvars.bat - os.run(genvcvars_bat) + local outdata = try {function () return os.iorun(genvcvars_bat) end} + if not outdata then + return + end -- load all envirnoment variables local variables = {} - for _, line in ipairs((io.readfile(genvcvars_dat) or ""):split("\n")) do + for _, line in ipairs(outdata:split("\n")) do local p = line:find('=', 1, true) if p then local name = line:sub(1, p - 1):trim() @@ -145,7 +150,8 @@ function main(opt) -- init vsvers local vsvers = { - ["16.0"] = "2019" + ["17.0"] = "2022" + , ["16.0"] = "2019" , ["15.0"] = "2017" , ["14.0"] = "2015" , ["12.0"] = "2013" @@ -218,7 +224,7 @@ function main(opt) VCInstallDir } local vcvarsall = find_file("vcvarsall.bat", paths) or find_file("vcvars32.bat", paths) - if vcvarsall and os.isfile(vcvarsall) then + if vcvarsall and os.isfile(vcvarsall) and vsvers[VisualStudioVersion] then -- load vcvarsall local vcvarsall_x86 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "x86", opt) @@ -248,7 +254,7 @@ function main(opt) local vswhere_VCAuxiliaryBuildDir = nil if (tonumber(version) >= 15) and vswhere then local vswhere_vrange = format("%s,%s)", version, (version + 1)) - local result = os.iorunv(vswhere.program, {"-property", "installationpath", "-version", vswhere_vrange}) + local result = os.iorunv(vswhere.program, {"-prerelease", "-property", "installationpath", "-version", vswhere_vrange}) if result then vswhere_VCAuxiliaryBuildDir = path.join(result:trim(), "VC", "Auxiliary", "Build") end diff --git a/xmake/modules/detect/sdks/find_xcode.lua b/xmake/modules/detect/sdks/find_xcode.lua index 02ea606bf..e3c927979 100644 --- a/xmake/modules/detect/sdks/find_xcode.lua +++ b/xmake/modules/detect/sdks/find_xcode.lua @@ -53,6 +53,12 @@ function _find_xcode_sdkver(sdkdir, opt) else platsdkdir = "Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS*.*.sdk" end + elseif plat == "appletvos" then + if arch == "i386" or arch == "x86_64" then + platsdkdir = "Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator*.*.sdk" + else + platsdkdir = "Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS*.*.sdk" + end else platsdkdir = "Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.*.sdk" end @@ -82,10 +88,11 @@ function _find_xcode(sdkdir, opt) end -- find codesign + local codesign_identity, mobile_provision if opt.find_codesign then -- find codesign identity - local codesign_identity = config.get("xcode_codesign_identity") + codesign_identity = config.get("xcode_codesign_identity") if codesign_identity == nil then -- we will disable codesign_identity if be false codesign_identity = global.get("xcode_codesign_identity") end @@ -100,7 +107,6 @@ function _find_xcode(sdkdir, opt) end -- find mobile provision only for iphoneos - local mobile_provision if opt.plat == "iphoneos" then local mobile_provisions = codesign.mobile_provisions() if mobile_provisions then diff --git a/xmake/modules/detect/tools/cl/has_flags.lua b/xmake/modules/detect/tools/cl/has_flags.lua index 2a398041d..a1cb9ace7 100644 --- a/xmake/modules/detect/tools/cl/has_flags.lua +++ b/xmake/modules/detect/tools/cl/has_flags.lua @@ -59,7 +59,8 @@ end function _check_try_running(flags, opt) -- make an stub source file - local sourcefile = path.join(os.tmpdir(), "detect", "cl_has_flags.c") + local tmpdir = path.join(os.tmpdir(), "detect") + local sourcefile = path.join(tmpdir, "cl_has_flags.c") if not os.isfile(sourcefile) then io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") end @@ -67,7 +68,8 @@ function _check_try_running(flags, opt) -- check it local errors = nil return try { function () - local _, errs = os.iorunv(opt.program, table.join("-c", "-nologo", flags, "-Fo" .. os.nuldev(), sourcefile), {envs = opt.envs}) + local _, errs = os.iorunv(opt.program, table.join("-c", "-nologo", flags, "-Fo" .. os.nuldev(), sourcefile), + {envs = opt.envs, curdir = tmpdir}) -- we need switch to tmpdir to avoid generating some tmp files, e.g. /Zi -> vc140.pdb if errs and #errs:trim() > 0 then return false, errs end diff --git a/xmake/modules/detect/tools/find_7z.lua b/xmake/modules/detect/tools/find_7z.lua index 08c0d172b..b441c2200 100644 --- a/xmake/modules/detect/tools/find_7z.lua +++ b/xmake/modules/detect/tools/find_7z.lua @@ -43,6 +43,12 @@ function main(opt) opt.command = opt.command or "--help" opt.parse = "(%d+%.?%d*)%s" + -- find 7z from builtin xmake/winenv + if is_host("windows") then + opt.paths = opt.paths or {} + table.insert(opt.paths, path.join(os.programdir(), "winenv", "bin")) + end + -- find program local program = find_program(opt.program or "7z", opt) if not program and not opt.program then @@ -54,7 +60,5 @@ function main(opt) if program and opt and opt.version then version = find_programver(program, opt) end - - -- ok? return program, version end diff --git a/xmake/modules/detect/tools/find_bash.lua b/xmake/modules/detect/tools/find_bash.lua new file mode 100644 index 000000000..0c1322ad2 --- /dev/null +++ b/xmake/modules/detect/tools/find_bash.lua @@ -0,0 +1,61 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author xq114 +-- @file find_bash.lua +-- + +-- imports +import("lib.detect.find_tool") +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find bash +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local bash = find_bash() +-- local bash, version = find_bash({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find bash from git for windows + if is_host("windows") then + opt.paths = opt.paths or {} + table.insert(opt.paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\GitForWindows;InstallPath)\\bin") + end + + -- find program + local program = find_program(opt.program or "bash", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tools/find_bzip2.lua b/xmake/modules/detect/tools/find_bzip2.lua new file mode 100644 index 000000000..a1544dd4a --- /dev/null +++ b/xmake/modules/detect/tools/find_bzip2.lua @@ -0,0 +1,55 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_bzip2.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find bzip2 +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local bzip2 = find_bzip2() +-- local bzip2, version = find_bzip2({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + opt.check = opt.check or "--help" + opt.command = opt.command or "--help" + opt.parse = "(%d+%.?%d*)%s" + + -- find program + local program = find_program(opt.program or "bzip2", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/find_cmake.lua b/xmake/modules/detect/tools/find_cmake.lua index e227c22a6..7c967f600 100644 --- a/xmake/modules/detect/tools/find_cmake.lua +++ b/xmake/modules/detect/tools/find_cmake.lua @@ -49,7 +49,7 @@ function main(opt) if not program and is_host("windows") then local msvc = toolchain.load("msvc") if msvc:check() then - opt.envs = toolchain.load("msvc"):runenvs() -- we attempt to find it from vstudio environments + opt.envs = msvc:runenvs() -- we attempt to find it from vstudio environments opt.force = true program = find_program(opt.program or "cmake", opt) end diff --git a/xmake/modules/detect/tools/find_conda.lua b/xmake/modules/detect/tools/find_conda.lua new file mode 100644 index 000000000..1e50c196e --- /dev/null +++ b/xmake/modules/detect/tools/find_conda.lua @@ -0,0 +1,58 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_conda.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find conda +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local conda = find_conda() +-- local conda, version = find_conda({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + if is_host("windows") then + opt.paths = {"$(env CONDA_BAT)", + "$(env USERPROFILE)/miniconda3/condabin"} + end + local program = find_program(opt.program or (is_host("windows") and "conda.bat" or "conda"), opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tools/find_curl.lua b/xmake/modules/detect/tools/find_curl.lua index 7807a65a3..493264684 100644 --- a/xmake/modules/detect/tools/find_curl.lua +++ b/xmake/modules/detect/tools/find_curl.lua @@ -40,6 +40,12 @@ function main(opt) -- init options opt = opt or {} + -- find curl from builtin xmake/winenv + if is_host("windows") then + opt.paths = opt.paths or {} + table.insert(opt.paths, path.join(os.programdir(), "winenv", "bin")) + end + -- find program local program = find_program(opt.program or "curl", opt) diff --git a/xmake/modules/detect/tools/find_dumpbin.lua b/xmake/modules/detect/tools/find_dumpbin.lua new file mode 100644 index 000000000..de56d66de --- /dev/null +++ b/xmake/modules/detect/tools/find_dumpbin.lua @@ -0,0 +1,55 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_dumpbin.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find dumpbin +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local dumpbin = find_dumpbin() +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + opt.check = opt.check or function (program) os.runv(program, {"/symbols"}, {envs = opt.envs}) end + + -- find program + local program = find_program(opt.program or "dumpbin.exe", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + opt.command = opt.command or function () local info = os.iorunv(program, {"/symbols"}, {envs = opt.envs}); return info end + opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end + version = find_programver(program, opt) + end + return program, version +end + diff --git a/xmake/modules/detect/tools/find_ninja.lua b/xmake/modules/detect/tools/find_ninja.lua index f9f8a08be..36b8b0db8 100644 --- a/xmake/modules/detect/tools/find_ninja.lua +++ b/xmake/modules/detect/tools/find_ninja.lua @@ -44,7 +44,7 @@ function main(opt) if not program and is_host("windows") then local msvc = toolchain.load("msvc") if msvc:check() then - opt.envs = toolchain.load("msvc"):runenvs() -- we attempt to find it from vstudio environments + opt.envs = msvc:runenvs() -- we attempt to find it from vstudio environments opt.force = true program = find_program(opt.program or "ninja", opt) end diff --git a/xmake/modules/detect/tools/find_perl.lua b/xmake/modules/detect/tools/find_perl.lua new file mode 100644 index 000000000..a930d5891 --- /dev/null +++ b/xmake/modules/detect/tools/find_perl.lua @@ -0,0 +1,61 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author xq114 +-- @file find_perl.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find perl +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local perl = find_perl() +-- local perl, version = find_perl({program = "perl", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- init the search directories + local paths = {} + if is_host("windows") then + table.insert(paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\GitForWindows;InstallPath)\\usr\\bin") + end + opt.paths = paths + + -- find program + local program = find_program(opt.program or "perl", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tools/find_python2.lua b/xmake/modules/detect/tools/find_python2.lua index eea226f06..1e9c7b228 100644 --- a/xmake/modules/detect/tools/find_python2.lua +++ b/xmake/modules/detect/tools/find_python2.lua @@ -43,6 +43,7 @@ function main(opt) -- find program local program = find_program(opt.program or "python2", opt) if not program then + opt.force = true program = find_program("python", opt) opt.version = true end diff --git a/xmake/modules/detect/tools/find_python3.lua b/xmake/modules/detect/tools/find_python3.lua index 2bc659ff5..3b606f279 100644 --- a/xmake/modules/detect/tools/find_python3.lua +++ b/xmake/modules/detect/tools/find_python3.lua @@ -41,15 +41,19 @@ function main(opt) opt = opt or {} if is_host("windows") then opt.paths = opt.paths or {} - table.insert(opt.paths, "$(reg HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.7\\InstallPath;ExecutablePath)") - table.insert(opt.paths, "$(reg HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.7-32\\InstallPath;ExecutablePath)") - table.insert(opt.paths, "$(reg HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.6\\InstallPath;ExecutablePath)") - table.insert(opt.paths, "$(reg HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.6-32\\InstallPath;ExecutablePath)") + local keys = winos.registry_keys("HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\3.*\\InstallPath") + for _, key in ipairs(keys) do + local value = try {function () return winos.registry_query(key .. ";ExecutablePath") end} + if value and os.isfile(value) then + table.insert(opt.paths, value) + end + end end -- find program local program = find_program(opt.program or "python3", opt) if not program then + opt.force = true program = find_program("python", opt) opt.version = true end @@ -68,8 +72,5 @@ function main(opt) if version and not version:startswith("3.") then return end - - -- ok? return program, version - end diff --git a/xmake/modules/detect/tools/find_vcpkg.lua b/xmake/modules/detect/tools/find_vcpkg.lua index 13eb032dd..46ae1ea36 100644 --- a/xmake/modules/detect/tools/find_vcpkg.lua +++ b/xmake/modules/detect/tools/find_vcpkg.lua @@ -21,8 +21,8 @@ -- imports import("lib.detect.find_file") import("lib.detect.find_program") -import("core.base.global") import("core.project.config") +import("detect.sdks.find_vcpkgdir") -- find vcpkg -- @@ -46,12 +46,9 @@ function main(opt) -- init the search directories local paths = {} - local vcpkg = config.get("vcpkg") or global.get("vcpkg") - if vcpkg then - if os.isfile(vcpkg) then - vcpkg = path.directory(vcpkg) - end - table.insert(paths, vcpkg) + local vcpkgdir = find_vcpkgdir() + if vcpkgdir then + table.insert(paths, vcpkgdir) end if is_host("windows") then -- attempt to read path info after running `vcpkg integrate install` diff --git a/xmake/modules/detect/tools/find_zig_cc.lua b/xmake/modules/detect/tools/find_zig_cc.lua new file mode 100644 index 000000000..3ef1511bb --- /dev/null +++ b/xmake/modules/detect/tools/find_zig_cc.lua @@ -0,0 +1,52 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_zig_cc.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find zig_cc +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local zig_cc = find_zig_cc() +-- local zig_cc, version, hintname = find_zig_cc({program = "zig cc", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "zig cc", opt) + + -- find program version + local version = nil + if program and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/find_zig_cxx.lua b/xmake/modules/detect/tools/find_zig_cxx.lua new file mode 100644 index 000000000..d9e63e7de --- /dev/null +++ b/xmake/modules/detect/tools/find_zig_cxx.lua @@ -0,0 +1,52 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_zig_cxx.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find zig_cxx +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local zig_cxx = find_zig_cxx() +-- local zig_cxx, version, hintname = find_zig_cxx({program = "zig c++", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "zig c++", opt) + + -- find program version + local version = nil + if program and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/link/has_flags.lua b/xmake/modules/detect/tools/link/has_flags.lua index 819a84279..e0e2d8292 100644 --- a/xmake/modules/detect/tools/link/has_flags.lua +++ b/xmake/modules/detect/tools/link/has_flags.lua @@ -76,7 +76,7 @@ function _check_try_running(flags, opt) -- make an stub source file local flags_str = table.concat(flags, " "):lower() local winmain = flags_str:find("subsystem:windows") - local sourcefile = path.join(os.tmpdir(), "detect", ifelse(winmain, "winmain_", "") .. "link_has_flags.c") + local sourcefile = path.join(os.tmpdir(), "detect", (winmain and "winmain_" or "") .. "link_has_flags.c") if not os.isfile(sourcefile) then if winmain then io.writefile(sourcefile, "int WinMain(void* instance, void* previnst, char** argv, int argc)\n{return 0;}") diff --git a/xmake/modules/detect/tools/nvcc/has_flags.lua b/xmake/modules/detect/tools/nvcc/has_flags.lua index 9a66c5f42..c30c87363 100644 --- a/xmake/modules/detect/tools/nvcc/has_flags.lua +++ b/xmake/modules/detect/tools/nvcc/has_flags.lua @@ -37,10 +37,9 @@ function _islinker(flags, opt) end -- try running -function _try_running(...) - local argv = {...} +function _try_running(program, argv, opt) local errors = nil - return try { function () os.runv(unpack(argv)); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors + return try { function () os.runv(program, argv, opt); return true end, catch { function (errs) errors = (errs or ""):trim() end }}, errors end -- attempt to check it from the argument list @@ -124,7 +123,7 @@ function _check_try_running(flags, opt, islinker) end -- check flags - return _try_running(opt.program, table.join(flags, args)) + return _try_running(opt.program, table.join(flags, args), opt) end -- has_flags(flags)? diff --git a/xmake/modules/detect/tools/zig_cc/features.lua b/xmake/modules/detect/tools/zig_cc/features.lua new file mode 100644 index 000000000..b887b9efc --- /dev/null +++ b/xmake/modules/detect/tools/zig_cc/features.lua @@ -0,0 +1,23 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file features.lua +-- + +-- imports +inherit("detect.tools.gcc.features") + diff --git a/xmake/modules/detect/tools/zig_cc/has_flags.lua b/xmake/modules/detect/tools/zig_cc/has_flags.lua new file mode 100644 index 000000000..6464e10b6 --- /dev/null +++ b/xmake/modules/detect/tools/zig_cc/has_flags.lua @@ -0,0 +1,23 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file has_flags.lua +-- + +-- imports +inherit("detect.tools.gcc.has_flags") + diff --git a/xmake/modules/detect/tools/zig_cxx/features.lua b/xmake/modules/detect/tools/zig_cxx/features.lua new file mode 100644 index 000000000..b887b9efc --- /dev/null +++ b/xmake/modules/detect/tools/zig_cxx/features.lua @@ -0,0 +1,23 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file features.lua +-- + +-- imports +inherit("detect.tools.gcc.features") + diff --git a/xmake/modules/detect/tools/zig_cxx/has_flags.lua b/xmake/modules/detect/tools/zig_cxx/has_flags.lua new file mode 100644 index 000000000..6464e10b6 --- /dev/null +++ b/xmake/modules/detect/tools/zig_cxx/has_flags.lua @@ -0,0 +1,23 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file has_flags.lua +-- + +-- imports +inherit("detect.tools.gcc.has_flags") + diff --git a/xmake/modules/devel/git/clean.lua b/xmake/modules/devel/git/clean.lua index 0f6c57e3f..ae21c3d88 100644 --- a/xmake/modules/devel/git/clean.lua +++ b/xmake/modules/devel/git/clean.lua @@ -56,6 +56,11 @@ function main(opt) table.insert(argv, "-f") end + -- remove all files and does not use the standard ignore rules + if opt.all then + table.insert(argv, "-x") + end + -- enter repository directory local oldir = nil if opt.repodir then diff --git a/xmake/modules/devel/git/clone.lua b/xmake/modules/devel/git/clone.lua index 876a2f867..534ae8ac3 100644 --- a/xmake/modules/devel/git/clone.lua +++ b/xmake/modules/devel/git/clone.lua @@ -33,7 +33,7 @@ import("net.proxy") -- import("devel.git") -- -- git.clone("[email protected]:xmake-io/xmake.git") --- git.clone("[email protected]:xmake-io/xmake.git", {depth = 1, branch = "master", outputdir = "/tmp/xmake"}) +-- git.clone("[email protected]:xmake-io/xmake.git", {depth = 1, branch = "master", outputdir = "/tmp/xmake", longpaths = true}) -- -- @endcode -- @@ -71,6 +71,12 @@ function main(url, opt) table.insert(argv, "--shallow-submodules") end + -- use longpaths, we need it on windows + if opt.longpaths then + table.insert(argv, "-c") + table.insert(argv, "core.longpaths=true") + end + -- set outputdir if opt.outputdir then table.insert(argv, path.translate(opt.outputdir)) @@ -78,7 +84,7 @@ function main(url, opt) -- use proxy? local envs - local proxy_conf = proxy.get(url) + local proxy_conf = proxy.config(url) if proxy_conf then envs = {ALL_PROXY = proxy_conf} end diff --git a/xmake/modules/devel/git/ls_remote.lua b/xmake/modules/devel/git/ls_remote.lua index c736c85d9..78ee36197 100644 --- a/xmake/modules/devel/git/ls_remote.lua +++ b/xmake/modules/devel/git/ls_remote.lua @@ -58,7 +58,7 @@ function main(reftype, url) -- use proxy? local envs - local proxy_conf = proxy.get(url) + local proxy_conf = proxy.config(url) if proxy_conf then envs = {ALL_PROXY = proxy_conf} end diff --git a/xmake/modules/devel/git/pull.lua b/xmake/modules/devel/git/pull.lua index e40707e4e..9970f8dbc 100644 --- a/xmake/modules/devel/git/pull.lua +++ b/xmake/modules/devel/git/pull.lua @@ -66,7 +66,7 @@ function main(opt) -- use proxy? local envs - local proxy_conf = proxy.get() + local proxy_conf = proxy.config() if proxy_conf then -- get proxy configuration from the current remote url local remoteinfo = try { function() return os.iorunv(git.program, {"remote", "-v"}) end } @@ -76,7 +76,7 @@ function main(opt) if #splitinfo > 1 and splitinfo[1] == (opt.remote or "origin") then local url = splitinfo[2] if url then - proxy_conf = proxy.get(url) + proxy_conf = proxy.config(url) end break end diff --git a/xmake/modules/devel/git/submodule/update.lua b/xmake/modules/devel/git/submodule/update.lua index 6256c673f..5d9323a02 100644 --- a/xmake/modules/devel/git/submodule/update.lua +++ b/xmake/modules/devel/git/submodule/update.lua @@ -30,8 +30,8 @@ import("lib.detect.find_tool") -- -- import("devel.git.submodule") -- --- submodule.update("master", {repodir = "/tmp/xmake", init = true, remote = true}) --- submodule.update("v1.0.1", {repodir = "/tmp/xmake", recursive = true, reference = "xxx", paths = "xxx"}) +-- submodule.update({repodir = "/tmp/xmake", init = true, remote = true}) +-- submodule.update({repodir = "/tmp/xmake", recursive = true, longpaths = true, reference = "xxx", paths = "xxx"}) -- -- @endcode -- @@ -64,9 +64,29 @@ function main(opt) oldir = os.cd(opt.repodir) end + -- enable long paths + local longpaths_old + local longpaths_changed = false + if opt.longpaths then + local longpaths_old = try {function () return os.iorunv(git.program, {"config", "--get", "--global", "core.longpaths"}) end} + if not longpaths_old or not longpaths_old:find("true") then + os.vrunv(git.program, {"config", "--global", "core.longpaths", "true"}) + longpaths_changed = true + end + end + -- submodule it os.vrunv(git.program, argv) + -- restore old long paths configuration + if longpaths_changed then + if longpaths_old and longpaths_old:find("false") then + os.vrunv(git.program, {"config", "--global", "core.longpaths", "false"}) + else + os.vrunv(git.program, {"config", "--global", "--unset", "core.longpaths"}) + end + end + -- leave repository directory if oldir then os.cd(oldir) diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua index ecf33aefc..aa728e27b 100644 --- a/xmake/modules/lib/detect/check_cxsnippets.lua +++ b/xmake/modules/lib/detect/check_cxsnippets.lua @@ -145,16 +145,17 @@ function main(snippets, opt) -- get links local links = {} + local target = opt.target if configs and configs.links then table.join2(links, configs.links) end - if opt.target then - table.join2(links, opt.target:get("links")) + if target and target:type() ~= "package" then + table.join2(links, target:get("links")) end if configs and configs.syslinks then table.join2(links, configs.syslinks) end - if opt.target then + if target and target:type() ~= "package" then table.join2(links, opt.target:get("syslinks")) end @@ -237,8 +238,6 @@ function main(snippets, opt) if errors and option.get("diagnosis") and #tostring(errors) > 0 then cprint("${color.warning}checkinfo:${clear dim} %s", errors) end - - -- ok? return ok end diff --git a/xmake/modules/lib/detect/features.lua b/xmake/modules/lib/detect/features.lua index 19b6067cc..614d8c592 100644 --- a/xmake/modules/lib/detect/features.lua +++ b/xmake/modules/lib/detect/features.lua @@ -72,7 +72,7 @@ function main(name, opt) end -- detect.tools.xxx.features(opt)? - _g._checking = ifelse(coroutine_running, key, nil) + _g._checking = coroutine_running and key or nil local features = import("detect.tools." .. tool.name .. ".features", {try = true}) if features then result = features(opt) diff --git a/xmake/modules/lib/detect/find_package.lua b/xmake/modules/lib/detect/find_package.lua index 5e50c2345..7b7ba7032 100644 --- a/xmake/modules/lib/detect/find_package.lua +++ b/xmake/modules/lib/detect/find_package.lua @@ -56,23 +56,28 @@ function main(name, opt) opt.mode = opt.mode or config.mode() or "release" -- init cache key - local key = "find_package_" .. opt.plat .. "_" .. opt.arch - if opt.require_version then - key = key .. "_" .. opt.require_version - end + local cachekey = "find_package_" .. opt.plat .. "_" .. opt.arch if opt.cachekey then - key = key .. "_" .. opt.cachekey + cachekey = cachekey .. "_" .. opt.cachekey + end + + -- init package key + local packagekey = name + if opt.buildhash then + packagekey = packagekey .. "_" .. opt.buildhash end if opt.mode then - key = key .. "_" .. opt.mode + packagekey = packagekey .. "_" .. opt.mode + end + if opt.require_version then + packagekey = packagekey .. "_" .. opt.require_version end if opt.external then - key = key .. "_external" + packagekey = packagekey .. "_external" end -- attempt to get result from cache first - local cacheinfo = detectcache:get(key) or {} - local result = cacheinfo[name] + local result = detectcache:get2(cachekey, packagekey) if result == nil or opt.force then -- find package @@ -86,8 +91,7 @@ function main(name, opt) end -- cache result - cacheinfo[name] = result and result or false - detectcache:set(key, cacheinfo) + detectcache:set2(cachekey, packagekey, result and result or false) detectcache:save() -- trace diff --git a/xmake/modules/lib/detect/find_tool.lua b/xmake/modules/lib/detect/find_tool.lua index 9d494d68f..02c9c03d1 100644 --- a/xmake/modules/lib/detect/find_tool.lua +++ b/xmake/modules/lib/detect/find_tool.lua @@ -22,6 +22,7 @@ import("lib.detect.find_program") import("lib.detect.find_programver") import("lib.detect.find_toolname") +import("core.base.semver") -- find tool from modules function _find_from_modules(name, opt) @@ -37,31 +38,7 @@ function _find_from_modules(name, opt) end -- find tool --- --- @param name the tool name --- @param opt the options, e.g. {program = "xcrun -sdk macosx clang", paths = {"/usr/bin"}, --- check = function (tool) os.run("%s -h", tool) end, version = true --- force = true, cachekey = "xxx", envs = {PATH = "xxx"}} --- --- @return {name = "", program = "", version = ""} or nil --- --- @code --- --- local tool = find_tool("clang") --- local tool = find_tool("clang", {program = "xcrun -sdk macosx clang"}) --- local tool = find_tool("clang", {paths = {"/usr/bin", "/usr/local/bin"}}) --- local tool = find_tool("clang", {check = "--help"}) -- simple check command: ccache --help --- local tool = find_tool("clang", {check = function (tool) os.run("%s -h", tool) end}) --- local tool = find_tool("clang", {paths = {"$(env PATH)", "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger)"}}) --- local tool = find_tool("clang", {paths = {"$(env PATH)", function () return "/usr/bin"end}}) --- local tool = find_tool("ccache", {version = true}) --- --- @endcode --- -function main(name, opt) - - -- init options - opt = opt or {} +function _find_tool(name, opt) -- find tool name local toolname = find_toolname(name or opt.program) @@ -90,3 +67,43 @@ function main(name, opt) end return {name = toolname, program = program, version = version} end + +-- find tool +-- +-- @param name the tool name +-- @param opt the options, e.g. {program = "xcrun -sdk macosx clang", paths = {"/usr/bin"}, +-- check = function (tool) os.run("%s -h", tool) end, version = true +-- force = true, cachekey = "xxx", envs = {PATH = "xxx"}} +-- +-- @return {name = "", program = "", version = ""} or nil +-- +-- @code +-- +-- local tool = find_tool("clang") +-- local tool = find_tool("clang", {program = "xcrun -sdk macosx clang"}) +-- local tool = find_tool("clang", {paths = {"/usr/bin", "/usr/local/bin"}}) +-- local tool = find_tool("clang", {check = "--help"}) -- simple check command: ccache --help +-- local tool = find_tool("clang", {check = function (tool) os.run("%s -h", tool) end}) +-- local tool = find_tool("clang", {paths = {"$(env PATH)", "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger)"}}) +-- local tool = find_tool("clang", {paths = {"$(env PATH)", function () return "/usr/bin"end}}) +-- local tool = find_tool("ccache", {version = true}) +-- +-- @endcode +-- +function main(name, opt) + + -- do find + opt = opt or {} + if opt.require_version then + opt.version = true + end + local result = _find_tool(name, opt) + + -- match version? + if opt.require_version and opt.require_version:find('.', 1, true) and result then + if not (result.version and (result.version == opt.require_version or semver.satisfies(result.version, opt.require_version))) then + result = nil + end + end + return result +end diff --git a/xmake/modules/lib/detect/find_toolname.lua b/xmake/modules/lib/detect/find_toolname.lua index 21b424fb7..b7201ead8 100644 --- a/xmake/modules/lib/detect/find_toolname.lua +++ b/xmake/modules/lib/detect/find_toolname.lua @@ -35,7 +35,7 @@ function _find(program) -- remove arguments: " -xxx" or " --xxx" name = name:gsub("%s%-+%w+", " ") - -- get the last name by ' ': xxx xxx toolname + -- try the last name by ' ': xxx xxx toolname local names = name:split("%s") if #names > 0 then name = names[#names] @@ -43,14 +43,12 @@ function _find(program) -- remove suffix: ".xxx" name = name:gsub("%.%w+", "") - - -- find_toolname.lua exists? found - local toolname = name:gsub("[%+%-]", function (ch) return ifelse(ch == "+", "x", "_") end) + local toolname = name:gsub("[%+%-]", function (ch) return (ch == "+" and "x" or "_") end) if module.find("detect.tools.find_" .. toolname) then return toolname end - -- get the last valid name: xxx-xxx-toolname-5 + -- try last valid name: xxx-xxx-toolname-5 local partnames = {} for partname in name:gmatch("([%a%+]+)") do table.insert(partnames, partname) @@ -58,18 +56,36 @@ function _find(program) if #partnames > 0 then name = partnames[#partnames] end - - -- find_toolname.lua exists? found toolname = name:gsub("%+", "x") if module.find("detect.tools.find_" .. toolname) then return toolname end + + -- try the the whole name with spaces, e.g. "zig cc" -> zig_cc + partnames = {} + names = path.filename(program):lower():split("%s") + for _, name in ipairs(names) do + -- remove suffix: ".exe", e.g. "zig.exe cc" + name = name:gsub("%.%w+", "") + -- "zig c++" -> zig_cxx + name = name:gsub("%+", "x") + -- skip -arguments + if not name:startswith("-") then + table.insert(partnames, name) + end + end + toolname = table.concat(partnames, "_") + if module.find("detect.tools.find_" .. toolname) then + return toolname + end end -- find tool name -- -- e.g. -- "xcrun -sdk macosx clang": clang +-- "zig cc": zig_cc +-- "zig.exe c++": zig_c++ -- "/usr/bin/arm-linux-gcc": gcc -- "link.exe -lib": link -- "gcc-5": gcc @@ -88,16 +104,14 @@ function main(program) -- get it from the cache first local toolname = toolnames[program] if toolname ~= nil then - return ifelse(toolname, toolname, nil) + return toolname and toolname or nil end -- find the tool name toolname = _find(program) -- save result to cache - toolnames[program] = ifelse(toolname, toolname, false) + toolnames[program] = toolname and toolname or false _g._TOOLNAMES = toolnames - - -- found? return toolname end diff --git a/xmake/modules/lib/detect/pkg_config.lua b/xmake/modules/lib/detect/pkgconfig.lua index f9e1e9aeb..9cd07a1e7 100644 --- a/xmake/modules/lib/detect/pkg_config.lua +++ b/xmake/modules/lib/detect/pkgconfig.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-present, TBOOX Open Source Group. -- -- @author ruki --- @file pkg_config.lua +-- @file pkgconfig.lua -- -- imports @@ -34,8 +34,8 @@ import("detect.tools.find_pkg_config") function version(name, opt) -- attempt to add search paths from pkg-config - local pkg_config = find_pkg_config() - if not pkg_config then + local pkgconfig = find_pkg_config() + if not pkgconfig then return end @@ -50,7 +50,7 @@ function version(name, opt) end -- get version - local version = try { function() return os.iorunv(pkg_config, {"--modversion", name}) end } + local version = try { function() return os.iorunv(pkgconfig, {"--modversion", name}) end } if version then version = version:trim() end @@ -73,8 +73,8 @@ end function variables(name, variables, opt) -- attempt to add search paths from pkg-config - local pkg_config = find_pkg_config() - if not pkg_config then + local pkgconfig = find_pkg_config() + if not pkgconfig then return end @@ -92,7 +92,7 @@ function variables(name, variables, opt) local result = nil if variables then for _, variable in ipairs(table.wrap(variables)) do - local value = try { function () return os.iorunv(pkg_config, {"--variable=" .. variable, name}) end } + local value = try { function () return os.iorunv(pkgconfig, {"--variable=" .. variable, name}) end } if value ~= nil then result = result or {} result[variable] = value:trim() @@ -118,15 +118,15 @@ end -- -- @code -- --- local libinfo = pkg_config.libinfo("openssl") +-- local libinfo = pkgconfig.libinfo("openssl") -- -- @endcode -- function libinfo(name, opt) -- attempt to add search paths from pkg-config - local pkg_config = find_pkg_config() - if not pkg_config then + local pkgconfig = find_pkg_config() + if not pkgconfig then return end @@ -134,15 +134,15 @@ function libinfo(name, opt) opt = opt or {} -- init PKG_CONFIG_PATH - local configdirs_old = os.getenv("PKG_CONFIG_PATH") + local envs = {} local configdirs = table.wrap(opt.configdirs) if #configdirs > 0 then - os.setenv("PKG_CONFIG_PATH", unpack(configdirs)) + envs.PKG_CONFIG_PATH = path.joinenv(configdirs) end -- get libs and cflags local result = nil - local flags = try { function () return os.iorunv(pkg_config, {"--libs", "--cflags", name}) end } + local flags = try { function () return os.iorunv(pkgconfig, {"--libs", "--cflags", name}, {envs = envs}) end } if flags then -- init result @@ -172,16 +172,11 @@ function libinfo(name, opt) end -- get version - local version = try { function() return os.iorunv(pkg_config, {"--modversion", name}) end } + local version = try { function() return os.iorunv(pkgconfig, {"--modversion", name}, {envs = envs}) end } if version then result = result or {} result.version = version:trim() end - - -- restore PKG_CONFIG_PATH - if configdirs_old then - os.setenv("PKG_CONFIG_PATH", configdirs_old) - end return result end diff --git a/xmake/modules/net/http/download.lua b/xmake/modules/net/http/download.lua index 00cdf58a5..7a90ac8bc 100644 --- a/xmake/modules/net/http/download.lua +++ b/xmake/modules/net/http/download.lua @@ -53,7 +53,7 @@ function _get_user_agent() end -- download url using curl -function _curl_download(tool, url, outputfile) +function _curl_download(tool, url, outputfile, opt) -- set basic arguments local argv = {} @@ -64,7 +64,7 @@ function _curl_download(tool, url, outputfile) end -- use proxy? - local proxy_conf = proxy.get(url) + local proxy_conf = proxy.config(url) if proxy_conf then table.insert(argv, "-x") table.insert(argv, proxy_conf) @@ -80,6 +80,12 @@ function _curl_download(tool, url, outputfile) table.insert(argv, user_agent) end + -- continue to download? + if opt.continue then + table.insert(argv, "-C") + table.insert(argv, "-") + end + -- set url table.insert(argv, url) @@ -98,7 +104,7 @@ function _curl_download(tool, url, outputfile) end -- download url using wget -function _wget_download(tool, url, outputfile) +function _wget_download(tool, url, outputfile, opt) -- ensure output directory local argv = {url} @@ -108,7 +114,7 @@ function _wget_download(tool, url, outputfile) end -- use proxy? - local proxy_conf = proxy.get(url) + local proxy_conf = proxy.config(url) if proxy_conf then table.insert(argv, "-e") table.insert(argv, "use_proxy=yes") @@ -134,6 +140,11 @@ function _wget_download(tool, url, outputfile) table.insert(argv, user_agent) end + -- continue to download? + if opt.continue then + table.insert(argv, "-c") + end + -- set outputfile table.insert(argv, "-O") table.insert(argv, outputfile) @@ -146,22 +157,24 @@ end -- -- @param url the input url -- @param outputfile the output file +-- @param opt the option, {continue = true} -- -- -function main(url, outputfile) +function main(url, outputfile, opt) -- init output file + opt = opt or {} outputfile = outputfile or path.filename(url):gsub("%?.+$", "") -- attempt to download url using curl first local tool = find_tool("curl", {version = true}) if tool then - return _curl_download(tool, url, outputfile) + return _curl_download(tool, url, outputfile, opt) end -- download url using wget tool = find_tool("wget", {version = true}) if tool then - return _wget_download(tool, url, outputfile) + return _wget_download(tool, url, outputfile, opt) end end diff --git a/xmake/modules/net/ping.lua b/xmake/modules/net/ping.lua index 1f361a5d6..5f555cccd 100644 --- a/xmake/modules/net/ping.lua +++ b/xmake/modules/net/ping.lua @@ -21,7 +21,6 @@ -- imports import("core.cache.detectcache") import("detect.tools.find_ping") -import("detect.tools.find_nmap") import("private.async.runjobs") -- send ping to hosts @@ -78,21 +77,6 @@ function main(hosts, opt) if data then timeval = data:match("time=([%d%s%.]-)ms", 1, true) or data:match("=([%d%s%.]-)ms TTL", 1, true) or "65535" end - if timeval == "65535" then - local nmap = find_nmap() - if nmap then - data = try { function() return os.iorun("%s -T5 --max-retries 1 -p 80 --max-rtt-timeout 1 %s", nmap, host) end } - if data then - local timeval_s = data:match("in ([%d%.]-) seconds") - if timeval_s then - timeval_s = tonumber(timeval_s:trim()) * 1000 - if timeval_s > 0 then - timeval = tostring(timeval_s) - end - end - end - end - end -- save results if timeval then @@ -114,8 +98,6 @@ function main(hosts, opt) detectcache:set("net.ping", cacheinfo) detectcache:save() end - - -- ok? return results end diff --git a/xmake/modules/net/proxy.lua b/xmake/modules/net/proxy.lua index 0f358172c..6aac4af4c 100644 --- a/xmake/modules/net/proxy.lua +++ b/xmake/modules/net/proxy.lua @@ -35,6 +35,20 @@ function _proxy_hosts() end -- get proxy pac file +-- +-- pac.lua +-- +-- @code +-- function mirror(url) +-- return url:gsub("github.com", "hub.fastgit.org") +-- end +-- function main(url, host) +-- if host:find("bintray.com") then +-- return true +-- end +-- end +-- @endcode +-- function _proxy_pac() local proxy_pac = _g._PROXY_PAC if proxy_pac == nil then @@ -64,13 +78,37 @@ function _host_pattern(pattern) return pattern end +-- has main entry? it will be callable directly +function _is_callable(func) + if type(func) == "function" then + return true + elseif type(func) == "table" then + local meta = debug.getmetatable(func) + if meta and meta.__call then + return true + end + end +end + +-- get proxy mirror url +function mirror(url) + local proxy_pac = _proxy_pac() + if proxy_pac and proxy_pac.mirror then + return proxy_pac.mirror(url) + end + return url +end + -- get proxy configuration from the given url, [protocol://]host[:port] -function get(url) +-- +-- @see https://github.com/xmake-io/xmake/issues/854 +-- +function config(url) -- enable proxy for the given url and configuration pattern if url then - -- get proxy from the given hosts pattern + -- filter proxy host from the given hosts pattern local host = url:match("://(.-)/") or url:match("@(.-):") local proxy_hosts = _proxy_hosts() if host and proxy_hosts then @@ -83,9 +121,14 @@ function get(url) end end - -- get proxy from the pac file + -- filter proxy host from the pac file local proxy_pac = _proxy_pac() - if proxy_pac and proxy_pac(url, host) then + if proxy_pac and host and _is_callable(proxy_pac) and proxy_pac(url, host) then + return global.get("proxy") + end + + -- use global proxy + if not proxy_pac and not proxy_hosts then return global.get("proxy") end return diff --git a/xmake/modules/package/manager/apt/find_package.lua b/xmake/modules/package/manager/apt/find_package.lua new file mode 100644 index 000000000..f27968c0e --- /dev/null +++ b/xmake/modules/package/manager/apt/find_package.lua @@ -0,0 +1,89 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_package.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("core.project.target") +import("lib.detect.find_tool") + +-- find package using the dpkg package manager +-- +-- @param name the package name +-- @param opt the options, e.g. {verbose = true, version = "1.12.0") +-- +function main(name, opt) + + -- check + opt = opt or {} + if not is_host(opt.plat) or os.arch() ~= opt.arch then + return + end + + -- find dpkg + local dpkg = find_tool("dpkg") + if not dpkg then + return + end + + -- find package + local result = nil + local listinfo = try {function () return os.iorunv(dpkg.program, {"--listfiles", name}) end} + if listinfo then + for _, line in ipairs(listinfo:split('\n', {plain = true})) do + line = line:trim() + + -- get includedirs + -- we need not add it, gcc/clang will use /usr/ as default sysroot + --[[ + local pos = line:find("include/", 1, true) + if pos then + result = result or {} + result.includedirs = result.includedirs or {} + table.insert(result.includedirs, line:sub(1, pos + 7)) + end]] + + -- get linkdirs and links + if line:endswith(".a") or line:endswith(".so") then + result = result or {} + result.links = result.links or {} + result.linkdirs = result.linkdirs or {} + result.libfiles = result.libfiles or {} + table.insert(result.linkdirs, path.directory(line)) + table.insert(result.links, target.linkname(path.filename(line))) + table.insert(result.libfiles, path.join(path.directory(line), path.filename(line))) + end + end + end + + -- remove repeat + if result then + if result.links then + result.links = table.unique(result.links) + end + if result.linkdirs then + result.linkdirs = table.unique(result.linkdirs) + end + if result.includedirs then + result.includedirs = table.unique(result.includedirs) + end + end + return result +end diff --git a/xmake/modules/package/manager/apt/search_package.lua b/xmake/modules/package/manager/apt/search_package.lua new file mode 100644 index 000000000..0e3abbdae --- /dev/null +++ b/xmake/modules/package/manager/apt/search_package.lua @@ -0,0 +1,64 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file search_package.lua +-- + +-- imports +import("core.base.option") +import("lib.detect.find_tool") + +-- search package using the apt package manager +-- +-- @param name the package name with pattern +-- +function main(name) + + -- find apt + local apt = find_tool("apt") + if not apt then + raise("apt not found!") + end + + -- search packages + -- + -- libzopfli1/groovy 1.0.3-1build1 amd64 + -- zlib (gzip, deflate) compatible compressor - shared library + -- + -- lua-zlib/groovy 1.2-2 amd64 + -- zlib library for the Lua language + -- + local results = {} + local searchdata = os.iorunv(apt.program, {"search", name}) + local packagename + for _, line in ipairs(searchdata:split("\n", {plain = true})) do + if line:find("/", 1, true) then + local splitinfo = line:split("%s+", {limit = 3}) + packagename = splitinfo[1] + if packagename then + packagename = packagename:split('/')[1] + end + elseif line:trim() ~= "" and packagename then + local description = line:trim() + if packagename:find(name, 1, true) then + table.insert(results, {name = "apt::" .. packagename, version = version, description = description}) + end + packagename = nil + end + end + return results +end diff --git a/xmake/modules/package/manager/brew/find_package.lua b/xmake/modules/package/manager/brew/find_package.lua index 1fa9d6978..49db5a464 100644 --- a/xmake/modules/package/manager/brew/find_package.lua +++ b/xmake/modules/package/manager/brew/find_package.lua @@ -22,7 +22,7 @@ import("lib.detect.find_tool") import("lib.detect.find_file") import("lib.detect.find_path") -import("lib.detect.pkg_config") +import("lib.detect.pkgconfig") import("core.project.target") import("package.manager.find_package") @@ -65,18 +65,27 @@ function main(name, opt) local nameinfo = name:split('/') local pcname = nameinfo[2] or nameinfo[1] - -- find package from pkg-config/*.pc + -- find package from pkg-config/*.pc, attempt to find it from `brew --prefix`/package first local result = nil local pcfile = find_file(pcname .. ".pc", path.join(brew_pkg_rootdir, nameinfo[1], "*/lib/pkgconfig")) + if not pcfile then + -- attempt to find it from `brew --prefix package` + local brew = find_tool("brew") + local brew_pkgdir = brew and try {function () return os.iorunv(brew.program, {"--prefix", nameinfo[1]}) end} + if brew_pkgdir then + brew_pkgdir = brew_pkgdir:trim() + pcfile = find_file(pcname .. ".pc", path.join(brew_pkgdir, "lib/pkgconfig")) + end + end if pcfile then opt.configdirs = path.directory(pcfile) - result = find_package("pkg_config::" .. pcname, opt) - if not result then + result = find_package("pkgconfig::" .. pcname, opt) + if not result or not result.includedirs then -- attempt to get includedir variable from pkg-config/xx.pc - local varinfo = pkg_config.variables(pcname, "includedir", opt) + local varinfo = pkgconfig.variables(pcname, "includedir", opt) if varinfo and varinfo.includedir then result = result or {} - result.version = pkg_config.version(pcname, opt) + result.version = pkgconfig.version(pcname, opt) result.includedirs = varinfo.includedir end end diff --git a/xmake/modules/package/manager/conan/install_package.lua b/xmake/modules/package/manager/conan/install_package.lua index 0b27fdb24..97af3b4b8 100644 --- a/xmake/modules/package/manager/conan/install_package.lua +++ b/xmake/modules/package/manager/conan/install_package.lua @@ -271,10 +271,11 @@ function main(name, opt) envs.ARFLAGS = table.concat(table.wrap(_conan_get_build_env("arflags", opt.plat)), ' ') envs.LDFLAGS = table.concat(table.wrap(_conan_get_build_env("ldflags", opt.plat)), ' ') envs.SHFLAGS = table.concat(table.wrap(_conan_get_build_env("shflags", opt.plat)), ' ') - local ndk = config.get("ndk") - if ndk then + local toolchain_ndk = toolchain.load("ndk", {plat = opt.plat, arch = opt.arch}) + local ndk_sysroot = toolchain_ndk:config("ndk_sysroot") + if ndk_sysroot then table.insert(argv, "-e") - table.insert(argv, "CONAN_CMAKE_FIND_ROOT_PATH=" .. path.join(ndk, "sysroot")) + table.insert(argv, "CONAN_CMAKE_FIND_ROOT_PATH=" .. ndk_sysroot) end for k, v in pairs(envs) do table.insert(argv, "-e") diff --git a/xmake/modules/package/manager/conan/search_package.lua b/xmake/modules/package/manager/conan/search_package.lua new file mode 100644 index 000000000..a783a0463 --- /dev/null +++ b/xmake/modules/package/manager/conan/search_package.lua @@ -0,0 +1,47 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file search_package.lua +-- + +-- imports +import("core.base.option") +import("lib.detect.find_tool") + +-- search package using the conan package manager +-- +-- @param name the package name with pattern +-- +function main(name) + + -- find conan + local conan = find_tool("conan") + if not conan then + raise("conan not found!") + end + + -- search packages + local results = {} + local searchdata = os.iorunv(conan.program, {"search", name}) + for _, line in ipairs(searchdata:split("\n", {plain = true})) do + local packagename = line:trim() + if packagename:find(name, 1, true) then + table.insert(results, {name = "conan::" .. packagename}) + end + end + return results +end diff --git a/xmake/modules/package/manager/conda/find_package.lua b/xmake/modules/package/manager/conda/find_package.lua new file mode 100644 index 000000000..5d2634d63 --- /dev/null +++ b/xmake/modules/package/manager/conda/find_package.lua @@ -0,0 +1,159 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_package.lua +-- + +-- imports +import("core.base.json") +import("core.base.option") +import("core.project.config") +import("core.project.target") +import("lib.detect.find_tool") + +-- get conda prefix directory +function _conda_prefixdir(conda) + local prefixdir = _g.prefixdir + if prefixdir == nil then + prefixdir = os.getenv("CONDA_PREFIX") + if not prefixdir then + local info = try {function () return os.iorunv(conda.program, {"info"}) end} + if info then + for _, line in ipairs(info:split('\n', {plain = true})) do + if line:find("base environment") then + prefixdir = line:match("ase environment : (.-) %(writable%)") + if prefixdir then + prefixdir = prefixdir:trim() + end + break + end + end + end + end + _g.prefixdir = prefixdir + end + return prefixdir +end + +-- find package using the conda package manager +-- +-- @param name the package name +-- @param opt the options, e.g. {verbose = true, version = "1.12.0") +-- +function main(name, opt) + + -- check + opt = opt or {} + if not is_host(opt.plat) or os.arch() ~= opt.arch then + return + end + + -- find conda + local conda = find_tool("conda") + if not conda then + return + end + + -- find package + local version, build + local listinfo = try {function () return os.iorunv(conda.program, {"list", name}) end} + if listinfo then + for _, line in ipairs(listinfo:split('\n', {plain = true})) do + if line:startswith(name) then + version, build = listinfo:match(name .. "%s-([%w%.%d%-%+]+)%s-([%w%d_]+)") + if version and build then + break + end + end + end + end + if not version or not build then + return + end + if opt.require_version and opt.require_version:find('.', 1, true) and opt.require_version ~= version then + return + end + + -- get meta info of package + -- e.g. ~/miniconda2/conda-meta/libpng-1.6.37-ha441bb4_0.json + local prefixdir = _conda_prefixdir(conda) + if not prefixdir then + return + end + local metafile = path.join(prefixdir, "conda-meta", name .. "-" .. version .. "-" .. build .. ".json") + if not os.isfile(metafile) then + return + end + local metainfo = json.loadfile(metafile) + if not metainfo or not metainfo.extracted_package_dir then + return + end + + -- save includedirs, linkdirs and links + local result = nil + local packagedir = metainfo.extracted_package_dir + for _, line in ipairs(metainfo.files) do + line = line:trim() + + -- get includedirs + local pos = line:find("include/", 1, true) + if pos then + result = result or {} + result.includedirs = result.includedirs or {} + table.insert(result.includedirs, path.join(packagedir, line:sub(1, pos + 7))) + end + + -- get linkdirs and links + if line:endswith(".lib") or line:endswith(".a") or line:endswith(".so") or line:endswith(".dylib") then + result = result or {} + result.links = result.links or {} + result.linkdirs = result.linkdirs or {} + result.libfiles = result.libfiles or {} + table.insert(result.linkdirs, path.join(packagedir, path.directory(line))) + table.insert(result.links, target.linkname(path.filename(line))) + table.insert(result.libfiles, path.join(packagedir, path.directory(line), path.filename(line))) + end + + -- add shared library directory (/bin/) to linkdirs for running with PATH on windows + if opt.plat == "windows" and line:endswith(".dll") then + result = result or {} + result.linkdirs = result.linkdirs or {} + result.libfiles = result.libfiles or {} + table.insert(result.linkdirs, path.join(packagedir, path.directory(line))) + table.insert(result.libfiles, path.join(packagedir, path.directory(line), path.filename(line))) + end + end + + -- save version + if result then + result.version = metainfo.version or version + end + + -- remove repeat + if result then + if result.links then + result.links = table.unique(result.links) + end + if result.linkdirs then + result.linkdirs = table.unique(result.linkdirs) + end + if result.includedirs then + result.includedirs = table.unique(result.includedirs) + end + end + return result +end diff --git a/xmake/modules/package/manager/conda/install_package.lua b/xmake/modules/package/manager/conda/install_package.lua new file mode 100644 index 000000000..fd37a4768 --- /dev/null +++ b/xmake/modules/package/manager/conda/install_package.lua @@ -0,0 +1,55 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file install_package.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("lib.detect.find_tool") + +-- install package +-- +-- @param name the package name, e.g. conda::libpng 1.6.37 +-- @param opt the options, e.g. { verbose = true } +-- +-- @return true or false +-- +function main(name, opt) + + -- check + opt = opt or {} + assert(is_host(opt.plat) and os.arch() == opt.arch, "conda cannot install %s for %s/%s", name, opt.plat, opt.arch) + + -- find conda + local conda = find_tool("conda") + if not conda then + raise("conda not found!") + end + + -- install package + local argv = {"install", "-y"} + if option.get("verbose") then + table.insert(argv, "-v") + end + if opt.require_version and opt.require_version:find('.', 1, true) then + name = name .. "=" .. opt.require_version + end + table.insert(argv, name) + os.vrunv(conda.program, argv) +end diff --git a/xmake/modules/package/manager/conda/search_package.lua b/xmake/modules/package/manager/conda/search_package.lua new file mode 100644 index 000000000..c1e3742c7 --- /dev/null +++ b/xmake/modules/package/manager/conda/search_package.lua @@ -0,0 +1,50 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file search_package.lua +-- + +-- imports +import("core.base.option") +import("lib.detect.find_tool") + +-- search package using the conda package manager +-- +-- @param name the package name with pattern +-- +function main(name) + + -- find conda + local conda = find_tool("conda") + if not conda then + raise("conda not found!") + end + + -- search packages + local results = {} + local searchdata = os.iorunv(conda.program, {"search", "-q", name}) + for _, line in ipairs(searchdata:split("\n", {plain = true})) do + local splitinfo = line:split("%s+", {limit = 3}) + local packagename = splitinfo[1] + local version = splitinfo[2] + local description = splitinfo[3] + if packagename:find(name, 1, true) then + table.insert(results, {name = "conda::" .. packagename, version = version, description = description}) + end + end + return results +end diff --git a/xmake/modules/package/manager/find_package.lua b/xmake/modules/package/manager/find_package.lua index 0f98106aa..41c110796 100644 --- a/xmake/modules/package/manager/find_package.lua +++ b/xmake/modules/package/manager/find_package.lua @@ -56,13 +56,18 @@ function _find_package_with_builtin_rule(package_name, opt) -- only support the current sub-host platform and sub-architecture, e.g. linux, macosx, or msys (subsystem) if opt.plat == os.subhost() and opt.arch == os.subarch() then + -- find it from pkg-config + table.insert(managers, "pkgconfig") + -- find it from pacman if is_subhost("linux", "msys") and not is_plat("windows") and find_tool("pacman") then table.insert(managers, "pacman") end - -- find it from pkg-config - table.insert(managers, "pkg_config") + -- find it from portage + if is_subhost("linux", "msys") and not is_plat("windows") and find_tool("emerge") then + table.insert(managers, "portage") + end -- find it from system table.insert(managers, "system") @@ -93,6 +98,12 @@ function _find_package(manager_name, package_name, opt) -- trace dprint("finding %s from %s ..", package_name, manager_name) + -- TODO compatible with the previous version: pkg_config (deprecated) + if manager_name == "pkg_config" then + manager_name = "pkgconfig" + wprint("please use find_package(\"pkgconfig::%s\") instead of `pkg_config::%s`", package_name, package_name) + end + -- find it result = import("package.manager." .. manager_name .. ".find_package", {anonymous = true})(package_name, opt) else diff --git a/xmake/modules/package/manager/install_package.lua b/xmake/modules/package/manager/install_package.lua index 735c4651f..1c5d5ab07 100644 --- a/xmake/modules/package/manager/install_package.lua +++ b/xmake/modules/package/manager/install_package.lua @@ -38,6 +38,7 @@ function _install_package(manager_name, package_name, opt) table.insert(managers, "apt") table.insert(managers, "yum") table.insert(managers, "pacman") + table.insert(managers, "portage") table.insert(managers, "brew") elseif is_host("macosx") then table.insert(managers, "vcpkg") diff --git a/xmake/modules/package/manager/pacman/find_package.lua b/xmake/modules/package/manager/pacman/find_package.lua index b34f8eff0..4b2be0403 100644 --- a/xmake/modules/package/manager/pacman/find_package.lua +++ b/xmake/modules/package/manager/pacman/find_package.lua @@ -21,7 +21,7 @@ -- imports import("core.base.option") import("lib.detect.find_tool") -import("package.manager.pkg_config.find_package", {alias = "find_package_from_pkgconfig"}) +import("package.manager.pkgconfig.find_package", {alias = "find_package_from_pkgconfig"}) -- find package from the system directories -- @@ -51,15 +51,13 @@ function main(name, opt) end -- parse package files list - local pkgconfig_dir = nil - local pkgconfig_name = nil local linkdirs = {} local has_includes = false + local pkgconfig_files = {} for _, line in ipairs(list:split('\n', {plain = true})) do line = line:trim():split('%s+')[2] - if not pkgconfig_dir and line:find("/pkgconfig/", 1, true) and line:endswith(".pc") then - pkgconfig_dir = path.directory(line) - pkgconfig_name = path.basename(line) + if line:find("/pkgconfig/", 1, true) and line:endswith(".pc") then + pkgconfig_files[path.basename(line)] = line end if line:endswith(".so") or line:endswith(".a") or line:endswith(".lib") then table.insert(linkdirs, path.directory(line)) @@ -68,12 +66,23 @@ function main(name, opt) end end + -- get pkgconfig file + local pkgconfig_file = pkgconfig_files[name] + if not pkgconfig_file then + for _, file in pairs(pkgconfig_files) do + pkgconfig_file = file + break + end + end + -- find package local result = nil - if pkgconfig_dir then + if pkgconfig_file then + local pkgconfig_dir = path.directory(pkgconfig_file) + local pkgconfig_name = path.basename(pkgconfig_file) linkdirs = table.unique(linkdirs) includedirs = table.unique(includedirs) - result = find_package_from_pkgconfig(pkgconfig_name or name, {configdirs = pkgconfig_dir, linkdirs = linkdirs}) + result = find_package_from_pkgconfig(pkgconfig_name, {configdirs = pkgconfig_dir, linkdirs = linkdirs}) if not result and has_includes then -- header only and hidden /usr/include? we need only return empty {} result = {} diff --git a/xmake/modules/package/manager/pkg_config/find_package.lua b/xmake/modules/package/manager/pkgconfig/find_package.lua index 752307e34..a7dbf377a 100644 --- a/xmake/modules/package/manager/pkg_config/find_package.lua +++ b/xmake/modules/package/manager/pkgconfig/find_package.lua @@ -19,7 +19,7 @@ -- -- imports -import("lib.detect.pkg_config") +import("lib.detect.pkgconfig") import("lib.detect.find_library") import("package.manager.system.find_package", {alias = "find_package_from_system"}) @@ -34,10 +34,10 @@ function main(name, opt) opt = opt or {} -- get library info - local libinfo = pkg_config.libinfo(name, opt) + local libinfo = pkgconfig.libinfo(name, opt) if not libinfo and name:startswith("lib") then -- libxxx? attempt to find xxx without `lib` prefix - libinfo = pkg_config.libinfo(name:sub(4), opt) + libinfo = pkgconfig.libinfo(name:sub(4), opt) end if not libinfo then return diff --git a/xmake/modules/package/manager/portage/find_package.lua b/xmake/modules/package/manager/portage/find_package.lua new file mode 100644 index 000000000..9b2c21340 --- /dev/null +++ b/xmake/modules/package/manager/portage/find_package.lua @@ -0,0 +1,98 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_package.lua +-- + +-- imports +import("core.base.option") +import("lib.detect.find_file") +import("lib.detect.find_tool") +import("package.manager.pkgconfig.find_package", {alias = "find_package_from_pkgconfig"}) + +-- find package from the system directories +-- +-- @param name the package name +-- @param opt the options, e.g. {verbose = true, version = "1.12.x") +-- +function main(name, opt) + + -- init options + opt = opt or {} + + -- for msys2/mingw? mingw-w64-[i686|x86_64]-xxx + if opt.plat == "mingw" then + name = "mingw64-runtime" -- there is only one package for mingw + end + + -- get package contents file + local file = find_file("CONTENTS", "/var/db/pkg/*/" .. name .. "-*") + if not file then + return + end + + -- get package files list + local list = {} + local file_contents = io.readfile(file) + for _, entry in pairs(file_contents:split("\n")) do + -- the file path is the second element after being delimited by spaces + local split_entry = entry:split(" ")[2] + if split_entry then + table.insert(list, split_entry) + end + end + + -- parse package files list + local linkdirs = {} + local has_includes = false + local pkgconfig_files = {} + for _, line in ipairs(list) do + line = line:trim():split('%s+')[1] + if line:find("/pkgconfig/", 1, true) and line:endswith(".pc") then + pkgconfig_files[path.basename(line)] = line + end + if line:endswith(".so") or line:endswith(".a") or line:endswith(".lib") then + table.insert(linkdirs, path.directory(line)) + elseif line:find("/include/", 1, true) and (line:endswith(".h") or line:endswith(".hpp")) then + has_includes = true + end + end + + -- get pkgconfig file + local pkgconfig_file = pkgconfig_files[name] + if not pkgconfig_file then + for _, file in pairs(pkgconfig_files) do + pkgconfig_file = file + break + end + end + + -- find package + local result = nil + if pkgconfig_file then + local pkgconfig_dir = path.directory(pkgconfig_file) + local pkgconfig_name = path.basename(pkgconfig_file) + linkdirs = table.unique(linkdirs) + includedirs = table.unique(includedirs) + result = find_package_from_pkgconfig(pkgconfig_name, {configdirs = pkgconfig_dir, linkdirs = linkdirs}) + if not result and has_includes then + -- header only and hidden /usr/include? we need only return empty {} + result = {} + end + end + return result +end diff --git a/xmake/modules/package/manager/portage/install_package.lua b/xmake/modules/package/manager/portage/install_package.lua new file mode 100644 index 000000000..88b2aa61e --- /dev/null +++ b/xmake/modules/package/manager/portage/install_package.lua @@ -0,0 +1,74 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file install_package.lua +-- + +-- imports +import("core.base.option") +import("lib.detect.find_tool") +import("privilege.sudo") + +-- install package +-- +-- @param name the package name +-- @param opt the options, e.g. {verbose = true, emerge = "the package name"} +-- +-- @return true or false +-- +function main(name, opt) + + -- init options + opt = opt or {} + + -- find emerge + local emerge = find_tool("emerge") + if not emerge then + raise("emerge not found!") + end + + -- for msys2/mingw? mingw-w64-[i686|x86_64]-xxx + if opt.plat == "mingw" then + name = "mingw64-runtime" + end + + -- init argv + -- ask for confirmation, view tree of packages, verbose + -- it is set this way because Portage compiles from source + -- therefore it's better to have more info and ask for confirmation + -- that way the user can ensure they installed the package with the correct USE flags + local argv = {"-a", "-t", "-v", opt.emerge or name} + if opt.verbose or option.get("verbose") then + table.insert(argv, "-v") + end + + -- install package directly if the current user is root + if is_subhost("msys") or os.isroot() then + os.vrunv(emerge.program, argv) + -- install with administrator permission? + elseif sudo.has() then + + -- install it if be confirmed + local description = format("try installing %s with administrator permission", name) + local confirm = utils.confirm({default = true, description = description}) + if confirm then + sudo.vrunv(emerge.program, argv) + end + else + raise("cannot get administrator permission!") + end +end diff --git a/xmake/modules/package/manager/system/find_package.lua b/xmake/modules/package/manager/system/find_package.lua index 1298a3e5d..9bb04566d 100644 --- a/xmake/modules/package/manager/system/find_package.lua +++ b/xmake/modules/package/manager/system/find_package.lua @@ -22,7 +22,7 @@ import("lib.detect.find_file") import("lib.detect.find_path") import("lib.detect.find_library") -import("lib.detect.pkg_config") +import("lib.detect.pkgconfig") import("detect.sdks.find_xcode") import("core.project.config") @@ -148,7 +148,7 @@ function main(name, opt) local version = nil local links = table.wrap(opt.links) if #links == 0 then - pkginfo = pkg_config.libinfo(name) + pkginfo = pkgconfig.libinfo(name) if pkginfo then links = table.wrap(pkginfo.links) version = pkginfo.version diff --git a/xmake/modules/package/manager/vcpkg/find_package.lua b/xmake/modules/package/manager/vcpkg/find_package.lua index f9579fd66..e965ace73 100644 --- a/xmake/modules/package/manager/vcpkg/find_package.lua +++ b/xmake/modules/package/manager/vcpkg/find_package.lua @@ -22,41 +22,10 @@ import("lib.detect.find_file") import("lib.detect.find_library") import("lib.detect.find_tool") +import("core.base.option") import("core.project.config") import("core.project.target") - --- find vcpkg root directory -function _find_vcpkgdir() - local vcpkgdir = _g.vcpkgdir - if vcpkgdir == nil then - local vcpkg = find_tool("vcpkg") - if vcpkg then - local dir = path.directory(vcpkg.program) - if os.isdir(path.join(dir, "installed")) then - vcpkgdir = dir - elseif is_host("macosx", "linux") then - local brew = find_tool("brew") - if brew then - dir = try - { - function () - return os.iorunv(brew.program, {"--prefix", "vcpkg"}) - end - } - end - if dir then - dir = path.join(dir:trim(), "libexec") - if os.isdir(path.join(dir, "installed")) then - vcpkgdir = dir - end - end - - end - end - _g.vcpkgdir = vcpkgdir or false - end - return vcpkgdir or nil -end +import("detect.sdks.find_vcpkgdir") -- find package from the vcpkg package manager -- @@ -66,8 +35,11 @@ end function main(name, opt) -- attempt to find vcpkg directory - local vcpkgdir = _find_vcpkgdir() + local vcpkgdir = find_vcpkgdir() if not vcpkgdir then + if option.get("diagnosis") then + cprint("${color.warning}checkinfo: ${clear dim}vcpkg root directory not found, maybe you need set $VCPKG_ROOT!") + end return end @@ -79,12 +51,29 @@ function main(name, opt) local arch = opt.arch local plat = opt.plat local mode = opt.mode + + -- mapping plat if plat == "macosx" then plat = "osx" end - if arch == "x86_64" then - arch = "x64" - end + + -- archs mapping for vcpkg + local archs = { + x86_64 = "x64", + i386 = "x86", + + -- android: armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mip64 + -- Offers a doc: https://github.com/microsoft/vcpkg/blob/master/docs/users/android.md + ["armeabi-v7a"] = "arm", + ["arm64-v8a"] = "arm64", + + -- ios: arm64 armv7 armv7s i386 + armv7 = "arm", + armv7s = "arm", + arm64 = "arm64", + } + -- mapping arch + arch = archs[arch] or arch -- get the vcpkg installed directory local installdir = path.join(vcpkgdir, "installed") diff --git a/xmake/modules/package/manager/vcpkg/install_package.lua b/xmake/modules/package/manager/vcpkg/install_package.lua index d44c6e849..eaf28710e 100644 --- a/xmake/modules/package/manager/vcpkg/install_package.lua +++ b/xmake/modules/package/manager/vcpkg/install_package.lua @@ -41,12 +41,29 @@ function main(name, opt) local arch = opt.arch local plat = opt.plat local mode = opt.mode + + -- mapping plat if plat == "macosx" then plat = "osx" end - if arch == "x86_64" then - arch = "x64" - end + + -- archs mapping for vcpkg + local archs = { + x86_64 = "x64", + i386 = "x86", + + -- android: armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mip64 + -- Offers a doc: https://github.com/microsoft/vcpkg/blob/master/docs/users/android.md + ["armeabi-v7a"] = "arm", + ["arm64-v8a"] = "arm64", + + -- ios: arm64 armv7 armv7s i386 + armv7 = "arm", + armv7s = "arm", + arm64 = "arm64", + } + -- mapping arch + arch = archs[arch] or arch -- init triplet local triplet = arch .. "-" .. plat diff --git a/xmake/modules/package/manager/vcpkg/search_package.lua b/xmake/modules/package/manager/vcpkg/search_package.lua new file mode 100644 index 000000000..3073e2cd3 --- /dev/null +++ b/xmake/modules/package/manager/vcpkg/search_package.lua @@ -0,0 +1,57 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file search_package.lua +-- + +-- imports +import("core.base.option") +import("lib.detect.find_tool") + +-- search package using the vcpkg package manager +-- +-- @param name the package name with pattern +-- +function main(name) + + -- attempt to find vcpkg + local vcpkg = find_tool("vcpkg") + if not vcpkg then + raise("vcpkg not found!") + end + + -- search packages + local results = {} + local searchdata = os.iorunv(vcpkg.program, {"search", name}) + for _, line in ipairs(searchdata:split("\n", {plain = true})) do + local version + local splitinfo = line:split("%s+", {limit = 2}) + local packagename = splitinfo[1] + local description = splitinfo[2] + if description then + splitinfo = description:split("%s+", {limit = 2}) + if #splitinfo == 2 and splitinfo[1]:find('.', 1, true) then + version = splitinfo[1] + description = splitinfo[2] + end + end + if packagename:find(name) and not packagename:find('%[.*' .. name .. '.*%]') then + table.insert(results, {name = "vcpkg::" .. packagename, version = version, description = description}) + end + end + return results +end diff --git a/xmake/modules/package/manager/xmake/find_package.lua b/xmake/modules/package/manager/xmake/find_package.lua index f33a3c4e5..dab32de33 100644 --- a/xmake/modules/package/manager/xmake/find_package.lua +++ b/xmake/modules/package/manager/xmake/find_package.lua @@ -107,9 +107,11 @@ function _find_package_from_repo(name, opt) end if opt.plat == "windows" then for _, file in ipairs(os.files(path.join(installdir, "lib", "*.dll"))) do + result.shared = true table.insert(libfiles, file) end for _, file in ipairs(os.files(path.join(installdir, "bin", "*.dll"))) do + result.shared = true table.insert(libfiles, file) end end diff --git a/xmake/modules/package/manager/xmake/search_package.lua b/xmake/modules/package/manager/xmake/search_package.lua new file mode 100644 index 000000000..5b633852c --- /dev/null +++ b/xmake/modules/package/manager/xmake/search_package.lua @@ -0,0 +1,40 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file search_package.lua +-- + +-- imports +import("core.package.package", {alias = "core_package"}) +import("private.action.require.impl.repository") + +-- search package using the xmake package manager +-- +-- @param name the package name with pattern +-- +function main(name) + local results = {} + for _, packageinfo in ipairs(repository.searchdirs(name)) do + local package = core_package.load_from_repository(packageinfo.name, packageinfo.repo, packageinfo.packagedir) + if package then + local repo = package:repo() + local versions = package:versions() + table.insert(results, {name = package:name(), version = versions and versions[1], description = package:get("description"), reponame = repo and repo:name()}) + end + end + return results +end diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua index f715c041a..4536580ae 100644 --- a/xmake/modules/package/tools/autoconf.lua +++ b/xmake/modules/package/tools/autoconf.lua @@ -21,6 +21,8 @@ -- imports import("core.base.option") import("core.project.config") +import("core.tool.linker") +import("core.tool.compiler") -- translate path function _translate_path(package, p) @@ -39,6 +41,16 @@ function _translate_windows_bin_path(bin_path) end end +-- map compiler flags +function _map_compflags(package, langkind, name, values) + return compiler.map_flags(langkind, name, values, {target = package}) +end + +-- map linker flags +function _map_linkflags(package, targetkind, sourcekinds, name, values) + return linker.map_flags(targetkind, sourcekinds, name, values, {target = package}) +end + -- get configs function _get_configs(package, configs) @@ -89,7 +101,7 @@ function _get_configs(package, configs) elseif package:is_arch("arm.*") then host = "arm" end - host = host .. "-" .. package:os() + host = host .. "-" .. package:targetos() table.insert(configs, "--host=" .. host) end end @@ -122,11 +134,18 @@ function buildenvs(package, opt) envs.ASFLAGS = table.concat(asflags, ' ') envs.LDFLAGS = table.concat(ldflags, ' ') else - local cflags = table.join(table.wrap(package:build_getenv("cxflags")), package:build_getenv("cflags")) - local cxxflags = table.join(table.wrap(package:build_getenv("cxflags")), package:build_getenv("cxxflags")) - local asflags = table.copy(table.wrap(package:build_getenv("asflags"))) - local ldflags = table.copy(table.wrap(package:build_getenv("ldflags"))) - local shflags = table.copy(table.wrap(package:build_getenv("shflags"))) + local cflags = table.join(table.wrap(package:build_getenv("cxflags")), package:build_getenv("cflags")) + local cxxflags = table.join(table.wrap(package:build_getenv("cxflags")), package:build_getenv("cxxflags")) + local asflags = table.copy(table.wrap(package:build_getenv("asflags"))) + local ldflags = table.copy(table.wrap(package:build_getenv("ldflags"))) + local shflags = table.copy(table.wrap(package:build_getenv("shflags"))) + local arflags = table.copy(table.wrap(package:build_getenv("arflags"))) + local defines = package:build_getenv("defines") + local includedirs = package:build_getenv("includedirs") + local sysincludedirs = package:build_getenv("sysincludedirs") + local links = package:build_getenv("links") + local syslinks = package:build_getenv("syslinks") + local linkdirs = package:build_getenv("linkdirs") table.join2(cflags, opt.cflags) table.join2(cflags, opt.cxflags) table.join2(cxxflags, opt.cxxflags) @@ -134,6 +153,21 @@ function buildenvs(package, opt) table.join2(asflags, opt.asflags) table.join2(ldflags, opt.ldflags) table.join2(shflags, opt.shflags) + table.join2(cflags, _map_compflags(package, "c", "define", defines)) + table.join2(cflags, _map_compflags(package, "c", "includedir", includedirs)) + table.join2(cflags, _map_compflags(package, "c", "sysincludedir", sysincludedirs)) + table.join2(asflags, _map_compflags(package, "as", "define", defines)) + table.join2(asflags, _map_compflags(package, "as", "includedir", includedirs)) + table.join2(asflags, _map_compflags(package, "as", "sysincludedir", sysincludedirs)) + table.join2(cxxflags, _map_compflags(package, "cxx", "define", defines)) + table.join2(cxxflags, _map_compflags(package, "cxx", "includedir", includedirs)) + table.join2(cxxflags, _map_compflags(package, "cxx", "sysincludedir", sysincludedirs)) + table.join2(ldflags, _map_linkflags(package, "binary", {"cxx"}, "link", links)) + table.join2(ldflags, _map_linkflags(package, "binary", {"cxx"}, "syslink", syslinks)) + table.join2(ldflags, _map_linkflags(package, "binary", {"cxx"}, "linkdir", linkdirs)) + table.join2(shflags, _map_linkflags(package, "shared", {"cxx"}, "link", links)) + table.join2(shflags, _map_linkflags(package, "shared", {"cxx"}, "syslink", syslinks)) + table.join2(shflags, _map_linkflags(package, "shared", {"cxx"}, "linkdir", linkdirs)) envs.CC = package:build_getenv("cc") envs.AS = package:build_getenv("as") envs.AR = package:build_getenv("ar") @@ -144,7 +178,7 @@ function buildenvs(package, opt) envs.CFLAGS = table.concat(cflags, ' ') envs.CXXFLAGS = table.concat(cxxflags, ' ') envs.ASFLAGS = table.concat(asflags, ' ') - envs.ARFLAGS = table.concat(table.wrap(package:build_getenv("arflags")), ' ') + envs.ARFLAGS = table.concat(arflags, ' ') envs.LDFLAGS = table.concat(ldflags, ' ') envs.SHFLAGS = table.concat(shflags, ' ') if package:is_plat("mingw") then @@ -171,6 +205,9 @@ function buildenvs(package, opt) elseif package:is_plat("cross") then -- only for cross-toolchain envs.CXX = package:build_getenv("cxx") + if not envs.ARFLAGS or envs.ARFLAGS == "" then + envs.ARFLAGS = "-cr" + end end end local ACLOCAL_PATH = {} @@ -194,18 +231,46 @@ function buildenvs(package, opt) return envs end +-- get the autogen environments +function autogen_envs(package, opt) + opt = opt or {} + local envs = {NOCONFIGURE = "yes"} + local ACLOCAL_PATH = {} + local PKG_CONFIG_PATH = {} + for _, dep in ipairs(package:orderdeps()) do + local pkgconfig = path.join(dep:installdir(), "lib", "pkgconfig") + if os.isdir(pkgconfig) then + table.insert(PKG_CONFIG_PATH, pkgconfig) + end + pkgconfig = path.join(dep:installdir(), "share", "pkgconfig") + if os.isdir(pkgconfig) then + table.insert(PKG_CONFIG_PATH, pkgconfig) + end + local aclocal = path.join(dep:installdir(), "share", "aclocal") + if os.isdir(aclocal) then + table.insert(ACLOCAL_PATH, aclocal) + end + end + envs.ACLOCAL_PATH = path.joinenv(ACLOCAL_PATH) + envs.PKG_CONFIG_PATH = path.joinenv(PKG_CONFIG_PATH) + return envs +end + -- configure package function configure(package, configs, opt) -- init options opt = opt or {} + -- get envs + local envs = opt.envs or buildenvs(package, opt) + -- generate configure file if not os.isfile("configure") then if os.isfile("autogen.sh") then - os.vrunv("sh", {"./autogen.sh"}) + os.vrunv("sh", {"./autogen.sh"}, {envs = autogen_envs(package, opt)}) elseif os.isfile("configure.ac") then - os.vrun("autoreconf --install --symlink") + os.vrunv("sh", {"autoreconf", "--install", "--symlink"}, {envs = autogen_envs(package, opt)}) end end @@ -223,7 +288,7 @@ function configure(package, configs, opt) end -- do configure - os.vrunv("sh", argv, {envs = opt.envs or buildenvs(package, opt)}) + os.vrunv("sh", argv, {envs = envs}) end -- install package @@ -233,7 +298,8 @@ function install(package, configs, opt) configure(package, configs, opt) -- do make and install - local njob = tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + opt = opt or {} + local njob = opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) local argv = {"-j" .. njob} if option.get("verbose") then table.insert(argv, "V=1") diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index a126fe514..d924bfb6d 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -28,11 +28,55 @@ import("lib.detect.find_file") import("lib.detect.find_tool") import("package.tools.ninja") --- translate windows bin path -function _translate_windows_bin_path(bin_path) - if bin_path then +-- get the number of parallel jobs +function _get_parallel_njobs(opt) + return opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) +end + +-- translate paths +function _translate_paths(paths) + if is_host("windows") then + if type(paths) == "string" then + return (paths:gsub("\\", "/")) + elseif type(paths) == "table" then + local result = {} + for _, p in ipairs(paths) do + table.insert(result, (p:gsub("\\", "/"))) + end + return result + end + end + return paths +end + +-- translate bin path +function _translate_bin_path(bin_path) + if is_host("windows") and bin_path then return bin_path:gsub("\\", "/") .. ".exe" end + return bin_path +end + +-- map compiler flags +function _map_compflags(package, langkind, name, values) + return compiler.map_flags(langkind, name, values, {target = package}) +end + +-- map linker flags +function _map_linkflags(package, targetkind, sourcekinds, name, values) + return linker.map_flags(targetkind, sourcekinds, name, values, {target = package}) +end + +-- get msvc +function _get_msvc(package) + local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}) + assert(msvc:check(), "vs not found!") -- we need check vs envs if it has been not checked yet + return msvc +end + +-- get msvc run environments +function _get_msvc_runenvs(package) + return os.joinenvs(_get_msvc(package):runenvs()) end -- get cflags from package deps @@ -43,9 +87,9 @@ function _get_cflags_from_packagedeps(package, opt) if dep then local fetchinfo = dep:fetch({external = false}) if fetchinfo then - table.join2(result, compiler.map_flags("cxx", "define", fetchinfo.defines)) - table.join2(result, compiler.map_flags("cxx", "includedir", fetchinfo.includedirs)) - table.join2(result, compiler.map_flags("cxx", "sysincludedir", fetchinfo.sysincludedirs)) + table.join2(result, _map_compflags(package, "cxx", "define", fetchinfo.defines)) + table.join2(result, _translate_paths(_map_compflags(package, "cxx", "includedir", fetchinfo.includedirs))) + table.join2(result, _translate_paths(_map_compflags(package, "cxx", "sysincludedir", fetchinfo.sysincludedirs))) end end end @@ -60,9 +104,9 @@ function _get_ldflags_from_packagedeps(package, opt) if dep then local fetchinfo = dep:fetch({external = false}) if fetchinfo then - table.join2(result, linker.map_flags("binary", {"cxx"}, "linkdir", fetchinfo.linkdirs)) - table.join2(result, linker.map_flags("binary", {"cxx"}, "link", fetchinfo.links)) - table.join2(result, linker.map_flags("binary", {"cxx"}, "syslink", fetchinfo.syslinks)) + table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "linkdir", fetchinfo.linkdirs))) + table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "link", fetchinfo.links)) + table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "syslink", fetchinfo.syslinks))) end end end @@ -76,6 +120,9 @@ function _get_cflags(package, opt) if opt.cross then table.join2(result, package:build_getenv("cflags")) table.join2(result, package:build_getenv("cxflags")) + table.join2(result, _map_compflags(package, "c", "define", package:build_getenv("defines"))) + table.join2(result, _map_compflags(package, "c", "includedir", package:build_getenv("includedirs"))) + table.join2(result, _map_compflags(package, "c", "sysincludedir", package:build_getenv("sysincludedirs"))) end table.join2(result, package:config("cflags")) table.join2(result, package:config("cxflags")) @@ -87,7 +134,7 @@ function _get_cflags(package, opt) end table.join2(result, _get_cflags_from_packagedeps(package, opt)) if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end @@ -98,6 +145,9 @@ function _get_cxxflags(package, opt) if opt.cross then table.join2(result, package:build_getenv("cxxflags")) table.join2(result, package:build_getenv("cxflags")) + table.join2(result, _map_compflags(package, "cxx", "define", package:build_getenv("defines"))) + table.join2(result, _map_compflags(package, "cxx", "includedir", package:build_getenv("includedirs"))) + table.join2(result, _map_compflags(package, "cxx", "sysincludedir", package:build_getenv("sysincludedirs"))) end table.join2(result, package:config("cxxflags")) table.join2(result, package:config("cxflags")) @@ -109,7 +159,7 @@ function _get_cxxflags(package, opt) end table.join2(result, _get_cflags_from_packagedeps(package, opt)) if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end @@ -119,13 +169,16 @@ function _get_asflags(package, opt) local result = {} if opt.cross then table.join2(result, package:build_getenv("asflags")) + table.join2(result, _map_compflags(package, "as", "define", package:build_getenv("defines"))) + table.join2(result, _map_compflags(package, "as", "includedir", package:build_getenv("includedirs"))) + table.join2(result, _map_compflags(package, "as", "sysincludedir", package:build_getenv("sysincludedirs"))) end table.join2(result, package:config("asflags")) if opt.asflags then table.join2(result, opt.asflags) end if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end @@ -135,13 +188,16 @@ function _get_ldflags(package, opt) local result = {} if opt.cross then table.join2(result, package:build_getenv("ldflags")) + table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "link", package:build_getenv("links"))) + table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "syslink", package:build_getenv("syslinks"))) + table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "linkdir", package:build_getenv("linkdirs"))) end table.join2(result, _get_ldflags_from_packagedeps(package, opt)) if opt.ldflags then table.join2(result, opt.ldflags) end if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end @@ -151,13 +207,16 @@ function _get_shflags(package, opt) local result = {} if opt.cross then table.join2(result, package:build_getenv("shflags")) + table.join2(result, _map_linkflags(package, "shared", {"cxx"}, "link", package:build_getenv("links"))) + table.join2(result, _map_linkflags(package, "shared", {"cxx"}, "syslink", package:build_getenv("syslinks"))) + table.join2(result, _map_linkflags(package, "shared", {"cxx"}, "linkdir", package:build_getenv("linkdirs"))) end table.join2(result, _get_ldflags_from_packagedeps(package, opt)) if opt.shflags then table.join2(result, opt.shflags) end if #result > 0 then - return table.concat(result, ' ') + return os.args(result) end end @@ -183,6 +242,9 @@ function _get_configs_for_generic(package, configs, opt) if shflags then table.insert(configs, "-DCMAKE_SHARED_LINKER_FLAGS=" .. shflags) end + if package:config("pic") ~= false then + table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON") + end end -- get configs for windows @@ -196,6 +258,9 @@ function _get_configs_for_windows(package, configs, opt) table.insert(configs, "x64") end end + -- we maybe need patch `cmake_policy(SET CMP0091 NEW)` to enable this argument for some packages + -- @see https://cmake.org/cmake/help/latest/policy/CMP0091.html#policy:CMP0091 + -- https://github.com/xmake-io/xmake-repo/pull/303 local vs_runtime = package:config("vs_runtime") if vs_runtime == "MT" then table.insert(configs, "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded") @@ -271,26 +336,16 @@ end -- get configs for mingw function _get_configs_for_mingw(package, configs, opt) opt = opt or {} + opt.cross = true local envs = {} local sdkdir = package:build_getenv("mingw") or package:build_getenv("sdk") - if is_host("windows") then - envs.CMAKE_C_COMPILER = _translate_windows_bin_path(package:build_getenv("cc")) - envs.CMAKE_CXX_COMPILER = _translate_windows_bin_path(package:build_getenv("cxx")) - envs.CMAKE_ASM_COMPILER = _translate_windows_bin_path(package:build_getenv("as")) - envs.CMAKE_AR = _translate_windows_bin_path(package:build_getenv("ar")) - envs.CMAKE_LINKER = _translate_windows_bin_path(package:build_getenv("ld")) - envs.CMAKE_RANLIB = _translate_windows_bin_path(package:build_getenv("ranlib")) - envs.CMAKE_RC_COMPILER = _translate_windows_bin_path(package:build_getenv("mrc")) - else - envs.CMAKE_C_COMPILER = package:build_getenv("cc") - envs.CMAKE_CXX_COMPILER = package:build_getenv("cxx") - envs.CMAKE_ASM_COMPILER = package:build_getenv("as") - envs.CMAKE_AR = package:build_getenv("ar") - envs.CMAKE_LINKER = package:build_getenv("ld") - envs.CMAKE_RANLIB = package:build_getenv("ranlib") - envs.CMAKE_RC_COMPILER = package:build_getenv("mrc") - end - opt.cross = true + envs.CMAKE_C_COMPILER = _translate_bin_path(package:build_getenv("cc")) + envs.CMAKE_CXX_COMPILER = _translate_bin_path(package:build_getenv("cxx")) + envs.CMAKE_ASM_COMPILER = _translate_bin_path(package:build_getenv("as")) + envs.CMAKE_AR = _translate_bin_path(package:build_getenv("ar")) + envs.CMAKE_LINKER = _translate_bin_path(package:build_getenv("ld")) + envs.CMAKE_RANLIB = _translate_bin_path(package:build_getenv("ranlib")) + envs.CMAKE_RC_COMPILER = _translate_bin_path(package:build_getenv("mrc")) envs.CMAKE_C_FLAGS = _get_cflags(package, opt) envs.CMAKE_CXX_FLAGS = _get_cxxflags(package, opt) envs.CMAKE_ASM_FLAGS = _get_asflags(package, opt) @@ -316,15 +371,15 @@ end -- get configs for cross function _get_configs_for_cross(package, configs, opt) opt = opt or {} - local envs = {} - local sdkdir = package:build_getenv("sdk") opt.cross = true - envs.CMAKE_C_COMPILER = package:build_getenv("cc") - envs.CMAKE_CXX_COMPILER = package:build_getenv("cxx") - envs.CMAKE_ASM_COMPILER = package:build_getenv("as") - envs.CMAKE_AR = package:build_getenv("ar") - envs.CMAKE_LINKER = package:build_getenv("ld") - envs.CMAKE_RANLIB = package:build_getenv("ranlib") + local envs = {} + local sdkdir = _translate_paths(package:build_getenv("sdk")) + envs.CMAKE_C_COMPILER = _translate_bin_path(package:build_getenv("cc")) + envs.CMAKE_CXX_COMPILER = _translate_bin_path(package:build_getenv("cxx")) + envs.CMAKE_ASM_COMPILER = _translate_bin_path(package:build_getenv("as")) + envs.CMAKE_AR = _translate_bin_path(package:build_getenv("ar")) + envs.CMAKE_LINKER = _translate_bin_path(package:build_getenv("ld")) + envs.CMAKE_RANLIB = _translate_bin_path(package:build_getenv("ranlib")) envs.CMAKE_C_FLAGS = _get_cflags(package, opt) envs.CMAKE_CXX_FLAGS = _get_cxxflags(package, opt) envs.CMAKE_ASM_FLAGS = _get_asflags(package, opt) @@ -348,7 +403,7 @@ function _get_configs_for_cross(package, configs, opt) end -- get cmake generator for msvc -function _get_cmake_generator_for_msvc() +function _get_cmake_generator_for_msvc(package) local vsvers = { ["2019"] = "16", @@ -359,7 +414,7 @@ function _get_cmake_generator_for_msvc() ["2010"] = "10", ["2008"] = "9" } - local vs = config.get("vs") + local vs = _get_msvc(package):config("vs") or config.get("vs") assert(vsvers[vs], "Unknown Visual Studio version: '" .. tostring(vs) .. "' set in project.") return "Visual Studio " .. vsvers[vs] .. " " .. vs end @@ -371,10 +426,19 @@ function _get_configs_for_generator(package, configs, opt) local cmake_generator = opt.cmake_generator if cmake_generator then if cmake_generator:find("Visual Studio", 1, true) then - cmake_generator = _get_cmake_generator_for_msvc() + cmake_generator = _get_cmake_generator_for_msvc(package) end table.insert(configs, "-G") table.insert(configs, cmake_generator) + if cmake_generator:find("Ninja", 1, true) then + local jobs = _get_parallel_njobs(opt) + local linkjobs = opt.linkjobs or option.get("linkjobs") + if linkjobs then + table.insert(configs, "-DCMAKE_JOB_POOL_COMPILE:STRING=compile") + table.insert(configs, "-DCMAKE_JOB_POOL_LINK:STRING=link") + table.insert(configs, ("-DCMAKE_JOB_POOLS:STRING=compile=%s;link=%s"):format(jobs, linkjobs)) + end + end elseif package:is_plat("mingw") and is_subhost("msys") then table.insert(configs, "-G") table.insert(configs, "MSYS Makefiles") @@ -383,16 +447,29 @@ function _get_configs_for_generator(package, configs, opt) table.insert(configs, "MinGW Makefiles") elseif package:is_plat("windows") then table.insert(configs, "-G") - table.insert(configs, _get_cmake_generator_for_msvc()) + table.insert(configs, _get_cmake_generator_for_msvc(package)) else table.insert(configs, "-G") table.insert(configs, "Unix Makefiles") end end +-- get configs for installation +function _get_configs_for_install(package, configs, opt) + -- @see https://cmake.org/cmake/help/v3.14/module/GNUInstallDirs.html + -- LIBDIR: object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian) + -- + table.insert(configs, "-DCMAKE_INSTALL_PREFIX=" .. package:installdir()) + if not opt._configs_str:find("CMAKE_INSTALL_LIBDIR") then + table.insert(configs, "-DCMAKE_INSTALL_LIBDIR=" .. package:installdir("lib")) + end +end + -- get configs function _get_configs(package, configs, opt) configs = configs or {} + opt._configs_str = string.serialize(configs, {indent = false, strip = true}) + _get_configs_for_install(package, configs, opt) _get_configs_for_generator(package, configs, opt) if package:is_plat("windows") then _get_configs_for_windows(package, configs, opt) @@ -413,13 +490,12 @@ end -- get build environments function buildenvs(package, opt) - -- use ninja generator for windows platform? we need bind msvc environments manually + -- we need bind msvc environments manually -- @see https://github.com/xmake-io/xmake/issues/1057 opt = opt or {} local envs = {} - local cmake_generator = opt.cmake_generator - if cmake_generator and cmake_generator == "Ninja" and package:is_plat("windows") then - table.join2(envs, toolchain.load("msvc"):runenvs()) + if package:is_plat("windows") then + envs = _get_msvc_runenvs(package) end -- add environments for cmake/find_packages @@ -427,7 +503,7 @@ function buildenvs(package, opt) local CMAKE_INCLUDE_PATH = {} local CMAKE_PREFIX_PATH = {} for _, dep in ipairs(package:orderdeps()) do - if dep:isSys() then + if dep:is_system() then local fetchinfo = dep:fetch() if fetchinfo then table.join2(CMAKE_LIBRARY_PATH, fetchinfo.linkdirs) @@ -446,16 +522,20 @@ end -- do build for msvc function _build_for_msvc(package, configs, opt) + local jobs = _get_parallel_njobs(opt) local slnfile = assert(find_file("*.sln", os.curdir()), "*.sln file not found!") - local runenvs = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}):runenvs() + local runenvs = _get_msvc_runenvs(package) local msbuild = find_tool("msbuild", {envs = runenvs}) - os.vrunv(msbuild.program, {slnfile, "-nologo", "-t:Rebuild", "-m", "-p:Configuration=" .. (package:debug() and "Debug" or "Release"), "-p:Platform=" .. (package:is_arch("x64") and "x64" or "Win32")}, {envs = runenvs}) + os.vrunv(msbuild.program, {slnfile, "-nologo", "-t:Rebuild", + (jobs ~= nil and format("-m:%d", jobs) or "-m"), + "-p:Configuration=" .. (package:is_debug() and "Debug" or "Release"), + "-p:Platform=" .. (package:is_arch("x64") and "x64" or "Win32")}, {envs = runenvs}) end -- do build for make function _build_for_make(package, configs, opt) - local njob = tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) - local argv = {"-j" .. njob} + local jobs = _get_parallel_njobs(opt) + local argv = {"-j" .. jobs} if option.get("verbose") then table.insert(argv, "VERBOSE=1") end @@ -484,13 +564,17 @@ end -- do install for msvc function _install_for_msvc(package, configs, opt) + local jobs = _get_parallel_njobs(opt) local slnfile = assert(find_file("*.sln", os.curdir()), "*.sln file not found!") - local runenvs = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}):runenvs() - local msbuild = find_tool("msbuild", {envs = runenvs}) - os.vrunv(msbuild.program, {slnfile, "-nologo", "-t:Rebuild", "-m", "-p:Configuration=" .. (package:debug() and "Debug" or "Release"), "-p:Platform=" .. (package:is_arch("x64") and "x64" or "Win32")}, {envs = runenvs}) + local runenvs = _get_msvc_runenvs(package) + local msbuild = assert(find_tool("msbuild", {envs = runenvs}), "msbuild not found!") + os.vrunv(msbuild.program, {slnfile, "-nologo", "-t:Rebuild", + (jobs ~= nil and format("-m:%d", jobs) or "-m"), + "-p:Configuration=" .. (package:is_debug() and "Debug" or "Release"), + "-p:Platform=" .. (package:is_arch("x64") and "x64" or "Win32")}, {envs = runenvs}) local projfile = os.isfile("INSTALL.vcxproj") and "INSTALL.vcxproj" or "INSTALL.vcproj" if os.isfile(projfile) then - os.vrunv(msbuild.program, {projfile, "/property:configuration=" .. (package:debug() and "Debug" or "Release")}, {envs = runenvs}) + os.vrunv(msbuild.program, {projfile, "/property:configuration=" .. (package:is_debug() and "Debug" or "Release")}, {envs = runenvs}) os.trycp("install/bin", package:installdir()) os.trycp("install/lib", package:installdir()) -- perhaps only headers library os.trycp("install/share", package:installdir()) @@ -502,29 +586,10 @@ function _install_for_msvc(package, configs, opt) end end --- install files for cmake -function _install_files_for_cmake(package, opt) - - -- patch _IMPORT_PREFIX to the real path - -- - -- e.g. set(_IMPORT_PREFIX "/Users/ruki/.xmake/cache/packages/2009/x/xxx/master/source/xxx/build_C8AA35F0/install") - -- - for _, cmakefile in ipairs(os.files("install/lib/cmake/*/*.cmake")) do - vprint("patching %s ..", cmakefile) - local prefixdir_old = path.absolute("install") - local prefixdir_new = package:installdir() - io.replace(cmakefile, prefixdir_old, prefixdir_new, {plain = true}) - end - os.trycp("install/bin", package:installdir()) - os.trycp("install/lib", package:installdir()) - os.trycp("install/share", package:installdir()) - os.trycp("install/include", package:installdir()) -end - -- do install for make function _install_for_make(package, configs, opt) - local njob = tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) - local argv = {"-j" .. njob} + local jobs = _get_parallel_njobs(opt) + local argv = {"-j" .. jobs} if option.get("verbose") then table.insert(argv, "VERBOSE=1") end @@ -540,14 +605,12 @@ function _install_for_make(package, configs, opt) os.vrunv("make", argv) os.vrunv("make", {"install"}) end - _install_files_for_cmake(package, opt) end -- do install for ninja function _install_for_ninja(package, configs, opt) opt = opt or {} ninja.install(package, {}, {envs = opt.envs or buildenvs(package, opt)}) - _install_files_for_cmake(package, opt) end -- do install for cmake/build @@ -556,7 +619,6 @@ function _install_for_cmakebuild(package, configs, opt) local cmake = assert(find_tool("cmake"), "cmake not found!") os.vrunv(cmake.program, {"--build", os.curdir()}, {envs = opt.envs or buildenvs(package)}) os.vrunv(cmake.program, {"--install", os.curdir()}) - _install_files_for_cmake(package, opt) end -- build package @@ -570,13 +632,6 @@ function build(package, configs, opt) os.mkdir(path.join(buildir, "install")) local oldir = os.cd(buildir) - -- init arguments - -- - -- @see https://cmake.org/cmake/help/v3.14/module/GNUInstallDirs.html - -- LIBDIR: object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian) - -- - local argv = {"-DCMAKE_INSTALL_PREFIX=" .. path.absolute("install"), "-DCMAKE_INSTALL_LIBDIR=" .. path.absolute("install/lib")} - -- exists $CMAKE_GENERATOR? use it local cmake_generator_env = os.getenv("CMAKE_GENERATOR") if not opt.cmake_generator and cmake_generator_env then @@ -584,6 +639,7 @@ function build(package, configs, opt) end -- pass configurations + local argv = {} for name, value in pairs(_get_configs(package, configs, opt)) do value = tostring(value):trim() if type(name) == "number" then @@ -591,7 +647,7 @@ function build(package, configs, opt) table.insert(argv, value) end else - table.insert(argv, "--" .. name .. "=" .. value) + table.insert(argv, "-D" .. name .. "=" .. value) end end table.insert(argv, oldir) @@ -635,14 +691,8 @@ function install(package, configs, opt) os.mkdir(path.join(buildir, "install")) local oldir = os.cd(buildir) - -- init arguments - -- - -- @see https://cmake.org/cmake/help/v3.14/module/GNUInstallDirs.html - -- LIBDIR: object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian) - -- - local argv = {"-DCMAKE_INSTALL_PREFIX=" .. path.absolute("install"), "-DCMAKE_INSTALL_LIBDIR=" .. path.absolute("install/lib")} - -- pass configurations + local argv = {} for name, value in pairs(_get_configs(package, configs, opt)) do value = tostring(value):trim() if type(name) == "number" then @@ -650,7 +700,7 @@ function install(package, configs, opt) table.insert(argv, value) end else - table.insert(argv, "--" .. name .. "=" .. value) + table.insert(argv, "-D" .. name .. "=" .. value) end end table.insert(argv, oldir) diff --git a/xmake/modules/package/tools/gn.lua b/xmake/modules/package/tools/gn.lua index 3f0cbe1a9..362373c2c 100644 --- a/xmake/modules/package/tools/gn.lua +++ b/xmake/modules/package/tools/gn.lua @@ -39,11 +39,18 @@ function _get_configs(package, configs, opt) return configs end +-- get msvc +function _get_msvc(package) + local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}) + assert(msvc:check(), "vs not found!") -- we need check vs envs if it has been not checked yet + return msvc +end + -- get the build environments function buildenvs(package, opt) local envs = {} if package:is_plat("windows") then - table.join2(envs, toolchain.load("msvc"):runenvs()) + envs = os.joinenvs(_get_msvc(package):runenvs()) end return envs end @@ -61,7 +68,9 @@ function generate(package, configs, opt) table.insert(argv, _get_buildir(opt)) for name, value in pairs(_get_configs(package, configs, opt)) do if type(value) == "string" then - table.insert(args, name .. '=\"' .. value .. "\"") + table.insert(args, name .. "=\"" .. value .. "\"") + elseif type(value) == "table" then + table.insert(args, name .. "=[\"" .. table.concat(value, "\",\"") .. "\"]") else table.insert(args, name .. "=" .. tostring(value)) end diff --git a/xmake/modules/package/tools/make.lua b/xmake/modules/package/tools/make.lua index 0075ab723..b236b9da6 100644 --- a/xmake/modules/package/tools/make.lua +++ b/xmake/modules/package/tools/make.lua @@ -85,7 +85,7 @@ function build(package, configs, opt) opt = opt or {} -- pass configurations - local njob = tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + local njob = opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) local argv = {"-j" .. njob} if option.get("verbose") then table.insert(argv, "VERBOSE=1") @@ -112,26 +112,15 @@ end -- install package function install(package, configs, opt) - -- init options + -- do build opt = opt or {} + build(package, configs, opt) - -- pass configurations + -- do install local argv = {"install"} if option.get("verbose") then table.insert(argv, "VERBOSE=1") end - for name, value in pairs(configs) do - value = tostring(value):trim() - if value ~= "" then - if type(name) == "number" then - table.insert(argv, value) - else - table.insert(argv, name .. "=" .. value) - end - end - end - - -- do install if is_host("bsd") then os.vrunv("gmake", argv, {envs = opt.envs or buildenvs(package)}) else diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index c508b2de6..6361f2a0e 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -21,6 +21,7 @@ -- imports import("core.base.option") import("core.project.config") +import("core.tool.toolchain") import("package.tools.ninja") -- get build directory @@ -34,17 +35,50 @@ function _get_buildir(opt) end -- get configs -function _get_configs(package, configs) +function _get_configs(package, configs, opt) -- add prefix - local configs = configs or {} + configs = configs or {} table.insert(configs, "--prefix=" .. package:installdir()) + table.insert(configs, "--libdir=lib") + + -- set build type + table.insert(configs, "--buildtype=" .. (package:debug() and "debug" or "release")) + + -- add -fpic + if package:is_plat("linux") and package:config("pic") then + table.insert(configs, "-Db_staticpic=true") + end + + -- add vs_runtime flags + if package:is_plat("windows") then + table.insert(configs, "-Db_vscrt=" .. package:config("vs_runtime"):lower()) + end -- add build directory - table.insert(configs, _get_buildir()) + table.insert(configs, _get_buildir(opt)) return configs end +-- get msvc +function _get_msvc(package) + local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}) + assert(msvc:check(), "vs not found!") -- we need check vs envs if it has been not checked yet + return msvc +end + +-- get msvc run environments +function _get_msvc_runenvs(package) + return os.joinenvs(_get_msvc(package):runenvs()) +end + +-- fix libname on windows +function _fix_libname_on_windows(package) + for _, lib in ipairs(os.files(path.join(package:installdir("lib"), "lib*.a"))) do + os.mv(lib, lib:gsub("(.+)lib(.-)%.a", "%1%2.lib")) + end +end + -- get the build environments function buildenvs(package) local envs = {} @@ -54,6 +88,9 @@ function buildenvs(package) envs.CFLAGS = table.concat(cflags, ' ') envs.CXXFLAGS = table.concat(cxxflags, ' ') envs.ASFLAGS = table.concat(table.wrap(package:config("asflags")), ' ') + if package:is_plat("windows") then + envs = os.joinenvs(envs, _get_msvc_runenvs(package)) + end else local cflags = table.join(table.wrap(package:build_getenv("cxflags")), package:build_getenv("cflags")) local cxxflags = table.join(table.wrap(package:build_getenv("cxflags")), package:build_getenv("cxxflags")) @@ -100,7 +137,7 @@ function generate(package, configs, opt) -- pass configurations local argv = {} - for name, value in pairs(_get_configs(package, configs)) do + for name, value in pairs(_get_configs(package, configs, opt)) do value = tostring(value):trim() if value ~= "" then if type(name) == "number" then @@ -137,4 +174,9 @@ function install(package, configs, opt) -- do build and install local buildir = _get_buildir(opt) ninja.install(package, {}, {buildir = buildir, envs = opt.envs or buildenvs(package, opt)}) + + -- fix static libname on windows + if package:is_plat("windows") and not package:config("shared") then + _fix_libname_on_windows(package) + end end diff --git a/xmake/modules/package/tools/msbuild.lua b/xmake/modules/package/tools/msbuild.lua index 4c322c1f6..b9794a4e3 100644 --- a/xmake/modules/package/tools/msbuild.lua +++ b/xmake/modules/package/tools/msbuild.lua @@ -23,9 +23,16 @@ import("core.base.option") import("core.tool.toolchain") import("lib.detect.find_tool") +-- get msvc +function _get_msvc(package) + local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}) + assert(msvc:check(), "vs not found!") -- we need check vs envs if it has been not checked yet + return msvc +end + -- get the build environments function buildenvs(package, opt) - return table.copy(toolchain.load("msvc"):runenvs()) + return os.joinenvs(_get_msvc(package):runenvs()) end -- build package diff --git a/xmake/modules/package/tools/ninja.lua b/xmake/modules/package/tools/ninja.lua index dd3a279e5..e1feccc14 100644 --- a/xmake/modules/package/tools/ninja.lua +++ b/xmake/modules/package/tools/ninja.lua @@ -26,7 +26,7 @@ import("lib.detect.find_tool") function build(package, configs, opt) opt = opt or {} local buildir = opt.buildir or os.curdir() - local njob = tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + local njob = opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) local ninja = assert(find_tool("ninja"), "ninja not found!") local argv = {"-C", buildir} if option.get("verbose") then diff --git a/xmake/modules/package/tools/nmake.lua b/xmake/modules/package/tools/nmake.lua index 146058a98..c618531ce 100644 --- a/xmake/modules/package/tools/nmake.lua +++ b/xmake/modules/package/tools/nmake.lua @@ -24,13 +24,23 @@ import("core.project.config") import("core.tool.toolchain") import("lib.detect.find_tool") +-- get msvc +function _get_msvc(package) + local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()}) + assert(msvc:check(), "vs not found!") -- we need check vs envs if it has been not checked yet + return msvc +end + +-- get the build environments +function buildenvs(package, opt) + return os.joinenvs(_get_msvc(package):runenvs()) +end + -- build package function build(package, configs, opt) - -- init options - opt = opt or {} - -- pass configurations + opt = opt or {} local argv = {} if option.get("verbose") then table.insert(argv, "VERBOSE=1") @@ -47,15 +57,16 @@ function build(package, configs, opt) end -- do build - local runenvs = toolchain.load("msvc"):runenvs() + local runenvs = opt.envs or buildenvs(package, opt) local nmake = find_tool("nmake", {envs = runenvs}) os.vrunv(nmake.program, argv, {envs = runenvs}) end -- install package -function install(package, configs) +function install(package, configs, opt) -- pass configurations + opt = opt or {} local argv = {"install"} if option.get("verbose") then table.insert(argv, "VERBOSE=1") @@ -72,7 +83,7 @@ function install(package, configs) end -- do install - local runenvs = toolchain.load("msvc"):runenvs() + local runenvs = opt.envs or buildenvs(package, opt) local nmake = find_tool("nmake", {envs = runenvs}) os.vrunv(nmake.program, argv, {envs = runenvs}) end diff --git a/xmake/modules/package/tools/scons.lua b/xmake/modules/package/tools/scons.lua new file mode 100644 index 000000000..386645bba --- /dev/null +++ b/xmake/modules/package/tools/scons.lua @@ -0,0 +1,97 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author PucklaMotzer09 +-- @file scons.lua +-- + +-- imports +import("core.base.option") +import("core.tool.toolchain") +import("lib.detect.find_tool") + +-- get configs +function _get_configs(package, configs) + local configs = configs or {} + table.insert(configs, "target=" .. (package:is_debug() and "debug" or "release")) + table.insert(configs, "use_mingw=" .. (package:is_plat("mingw", "cygwin", "msys") and "yes" or "no")) + if package:is_plat("android") then + local scons_android_arch = "armv7" + if package:is_arch("arm64-v8a") then + scons_android_arch = "arm64v8" + end + table.insert(configs, "platform=android") + table.insert(configs, "android_arch=" .. scons_android_arch) + elseif package:is_plat("iphoneos") then + table.insert(configs, "platform=ios") + table.insert(configs, "ios_arch=" .. package:arch()) + elseif package:is_plat("macosx") then + table.insert(configs, "platform=osx") + elseif package:is_plat("windows", "mingw", "cygwin", "msys") then + table.insert(configs, "platform=windows") + elseif package:is_plat("linux") then + table.insert(configs, "platform=linux") + elseif package:is_plat("bsd") then + table.insert(configs, "platform=freebsd") + end + if package:is_plat("x86_64", "x86", "i386", "x64") then + table.insert("bits=" .. (package:is_arch("x86", "i386") and "32" or "64")) + end + return configs +end + +-- get the build environments +function buildenvs(package, opt) + opt = opt or {} + local envs = {} + if package:is_plat("android") then + local ndk = toolchain.load("ndk", {plat = package:plat(), arch = package:arch()}) + envs.ANDROID_NDK_ROOT = ndk:config("ndk") + end + local ACLOCAL_PATH = {} + local PKG_CONFIG_PATH = {} + for _, dep in ipairs(package:orderdeps()) do + local pkgconfig = path.join(dep:installdir(), "lib", "pkgconfig") + if os.isdir(pkgconfig) then + table.insert(PKG_CONFIG_PATH, pkgconfig) + end + pkgconfig = path.join(dep:installdir(), "share", "pkgconfig") + if os.isdir(pkgconfig) then + table.insert(PKG_CONFIG_PATH, pkgconfig) + end + local aclocal = path.join(dep:installdir(), "share", "aclocal") + if os.isdir(aclocal) then + table.insert(ACLOCAL_PATH, aclocal) + end + end + envs.ACLOCAL_PATH = path.joinenv(ACLOCAL_PATH) + envs.PKG_CONFIG_PATH = path.joinenv(PKG_CONFIG_PATH) + return envs +end + +-- build package +function build(package, configs, opt) + opt = opt or {} + local buildir = opt.buildir or os.curdir() + local njob = opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + local scons = assert(find_tool("scons"), "scons not found!") + local argv = {"-C", buildir, "-j", njob} + configs = _get_configs(package, configs) + if configs then + table.join2(argv, configs) + end + os.vrunv(scons.program, argv, {envs = opt.envs or buildenvs(package, opt)}) +end diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua index 115a5fbe8..e1e3ac4b0 100644 --- a/xmake/modules/package/tools/xmake.lua +++ b/xmake/modules/package/tools/xmake.lua @@ -20,7 +20,20 @@ -- imports import("core.base.option") +import("core.tool.toolchain") +import("core.project.project") import("core.package.repository") +import("private.action.require.impl.package", {alias = "require_package"}) + +-- get config from toolchains +function _get_config_from_toolchains(package, name) + for _, toolchain_inst in ipairs(package:toolchains()) do + local value = toolchain_inst:config(name) + if value ~= nil then + return value + end + end +end -- get configs function _get_configs(package, configs) @@ -30,34 +43,60 @@ function _get_configs(package, configs) local cxxflags = table.join(table.wrap(package:config("cxxflags")), get_config("cxxflags")) local asflags = table.join(table.wrap(package:config("asflags")), get_config("asflags")) local ldflags = table.join(table.wrap(package:config("ldflags")), get_config("ldflags")) + table.insert(configs, "--plat=" .. package:plat()) + table.insert(configs, "--arch=" .. package:arch()) + table.insert(configs, "--mode=" .. (package:is_debug() and "debug" or "release")) if package:is_plat("windows") then local vs_runtime = package:config("vs_runtime") if vs_runtime then table.insert(configs, "--vs_runtime=" .. vs_runtime) end end - table.insert(configs, "--mode=" .. (package:debug() and "debug" or "release")) - if cflags then + if package:is_plat("cross") then + local cross = _get_config_from_toolchains(package, "cross") or get_config("cross") + if cross then + table.insert(configs, "--cross=" .. cross) + end + local bindir = _get_config_from_toolchains(package, "bindir") or get_config("bin") + if cross then + table.insert(configs, "--bin=" .. bindir) + end + local sdkdir = _get_config_from_toolchains(package, "sdkdir") or get_config("sdk") + if cross then + table.insert(configs, "--sdk=" .. sdkdir) + end + else + local names = {"ndk", "ndk_sdkver", "vs", "mingw", "ld", "sh", "ar", "cc", "cxx", "mm", "mxx"} + for _, name in ipairs(names) do + local value = get_config(name) + if value ~= nil then + table.insert(configs, "--" .. name .. "=" .. tostring(value)) + end + end + end + if not package:is_plat("windows", "mingw") and package:config("pic") ~= false then + table.insert(cxflags, "-fPIC") + end + if cflags and #cflags > 0 then table.insert(configs, "--cflags=" .. table.concat(cflags, ' ')) end - if cxflags then + if cxflags and #cxflags > 0 then table.insert(configs, "--cxflags=" .. table.concat(cxflags, ' ')) end - if cxxflags then + if cxxflags and #cxxflags > 0 then table.insert(configs, "--cxxflags=" .. table.concat(cxxflags, ' ')) end - if asflags then + if asflags and #asflags > 0 then table.insert(configs, "--asflags=" .. table.concat(asflags, ' ')) end - if ldflags then + if ldflags and #ldflags > 0 then table.insert(configs, "--ldflags=" .. table.concat(ldflags, ' ')) end return configs end --- init arguments and inherit some global options from the parent xmake -function _init_argv(...) - local argv = {...} +-- set some builtin global options from the parent xmake +function _set_builtin_argv(argv) for _, name in ipairs({"diagnosis", "verbose", "quiet", "yes", "confirm", "root"}) do local value = option.get(name) if type(value) == "boolean" then @@ -66,28 +105,75 @@ function _init_argv(...) table.insert(argv, "--" .. name .. "=" .. value) end end - return argv +end + +-- get require info of package +function _get_package_requireinfo(packagename) + if os.isfile(os.projectfile()) then + local requires_str, requires_extra = project.requires_str() + local requireitems = require_package.load_requires(requires_str, requires_extra) + for _, requireitem in ipairs(requireitems) do + local requireinfo = requireitem.info or {} + local requirename = requireinfo.alias or requireitem.name + if requirename == packagename then + return requireinfo + end + end + end +end + +-- get the build environments +function buildenvs(package, opt) + opt = opt or {} + local envs = {} + -- pass toolchains + local toolchains = package:config("toolchains") + if toolchains then + local toolchain_packages = {} + for _, name in ipairs(toolchains) do + local toolchain_inst = toolchain.load(name, {plat = package:plat(), arch = package:arch()}) + if toolchain_inst then + table.join2(toolchain_packages, toolchain_inst:config("packages")) + end + end + local rcfile_path = os.tmpfile() .. ".lua" + local rcfile = io.open(rcfile_path, 'w') + if #toolchain_packages > 0 then + for _, packagename in ipairs(toolchain_packages) do + -- pass package configurations, {configs = {}} + local requireinfo = _get_package_requireinfo(packagename) + if requireinfo then + requireinfo.originstr = nil + rcfile:print("add_requires(\"%s\", %s)", packagename, string.serialize(requireinfo, {strip = true, indent = false})) + else + rcfile:print("add_requires(\"%s\")", packagename) + end + end + end + rcfile:print("add_toolchains(\"%s\")", table.concat(table.wrap(toolchains), '", "')) + rcfile:close() + envs.XMAKE_RCFILES = {} + table.insert(envs.XMAKE_RCFILES, rcfile_path) + table.join2(envs.XMAKE_RCFILES, os.getenv("XMAKE_RCFILES")) + end + return envs end -- install package -function install(package, configs) +function install(package, configs, opt) -- pass local repositories + opt = opt or {} for _, repo in ipairs(repository.repositories()) do - os.vrunv("xmake", {"repo", "--add", repo:name(), repo:url(), repo:branch()}) - end - - -- inherit builtin configs - local argv = _init_argv("f", "-y", "-c") - local names = {"plat", "arch", "ndk", "ndk_sdkver", "vs", "mingw", "sdk", "bin", "cross", "ld", "sh", "ar", "cc", "cxx", "mm", "mxx"} - for _, name in ipairs(names) do - local value = get_config(name) - if value ~= nil then - table.insert(argv, "--" .. name .. "=" .. tostring(value)) - end + local repo_argv = {"repo"} + _set_builtin_argv(repo_argv) + table.join2(repo_argv, {"--add", repo:name(), repo:directory()}) + os.vrunv("xmake", repo_argv) end -- pass configurations + local argv = {"f", "-y", "-c"} + _set_builtin_argv(argv) for name, value in pairs(_get_configs(package, configs)) do value = tostring(value):trim() if type(name) == "number" then @@ -98,13 +184,20 @@ function install(package, configs) table.insert(argv, "--" .. name .. "=" .. value) end end - os.vrunv("xmake", argv) + + -- get build environments + local envs = opt.envs or buildenvs(package) + + -- do configure + os.vrunv("xmake", argv, {envs = envs}) -- do build - argv = _init_argv() - os.vrunv("xmake", argv) + argv = {} + _set_builtin_argv(argv) + os.vrunv("xmake", argv, {envs = envs}) -- do install - argv = _init_argv("install", "-y", "-o", package:installdir()) - os.vrunv("xmake", argv) + argv = {"install", "-y", "-o", package:installdir()} + _set_builtin_argv(argv) + os.vrunv("xmake", argv, {envs = envs}) end diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua index 7a4e3620f..50397cda4 100644 --- a/xmake/modules/private/action/build/object.lua +++ b/xmake/modules/private/action/build/object.lua @@ -114,6 +114,6 @@ function main(target, batchjobs, sourcebatch, opt) batchjobs:addjob(sourcefile, function (index, total) local build_opt = table.join({objectfile = objectfile, dependfile = dependfile, sourcekind = sourcekind, progress = (index * 100) / total}, opt) _build_object(target, sourcefile, build_opt) - end, rootjob) + end, {rootjob = rootjob}) end end diff --git a/xmake/modules/private/action/require/check.lua b/xmake/modules/private/action/require/check.lua new file mode 100644 index 000000000..6b37eeb8b --- /dev/null +++ b/xmake/modules/private/action/require/check.lua @@ -0,0 +1,57 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file check.lua +-- + +-- imports +import("core.base.option") +import("private.async.runjobs") +import("private.action.require.impl.package") +import("private.action.require.impl.register_packages") +import("private.action.require.impl.utils.get_requires") + +-- install packages +function main(requires_raw) + + -- get requires and extra config + local requires_extra = nil + local requires, requires_extra = get_requires(requires_raw) + if not requires or #requires == 0 then + return + end + + -- install packages + local packages = package.load_packages(requires, {requires_extra = requires_extra}) + if packages then + + -- fetch and register packages (with system) from local first + runjobs("fetch_packages", function (index) + local instance = packages[index] + if instance and (not option.get("force") or (option.get("shallow") and not instance:is_toplevel())) then + local oldenvs = os.getenvs() + instance:envs_enter() + instance:fetch() + os.setenvs(oldenvs) + end + end, {total = #packages, isolate = true}) + + -- register all required root packages to local cache + register_packages(packages) + end +end + diff --git a/xmake/modules/private/action/require/clean.lua b/xmake/modules/private/action/require/clean.lua new file mode 100644 index 000000000..57b549810 --- /dev/null +++ b/xmake/modules/private/action/require/clean.lua @@ -0,0 +1,47 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file clean.lua +-- + +-- imports +import("core.base.option") +import("core.package.package") +import("core.cache.localcache") +import("private.action.require.impl.remove_packages") + +-- clean the given or all package caches +function main(package_names) + + -- trace + print("clearing packages ..") + + -- clear all unused packages + remove_packages(package_names, {clean = true}) + + -- trace + print("clearing caches ..") + + -- clear cache directory + os.rm(package.cachedir()) + + -- clear require cache + local require_cache = localcache.cache("package") + require_cache:clear() + require_cache:save() +end + diff --git a/xmake/actions/require/export.lua b/xmake/modules/private/action/require/export.lua index 76b53f29c..0906cf4aa 100644 --- a/xmake/actions/require/export.lua +++ b/xmake/modules/private/action/require/export.lua @@ -21,10 +21,10 @@ -- imports import("core.base.task") import("core.base.option") -import("impl.package") -import("impl.repository") -import("impl.environment") -import("impl.utils.get_requires") +import("private.action.require.impl.repository") +import("private.action.require.impl.environment") +import("private.action.require.impl.export_packages") +import("private.action.require.impl.utils.get_requires") -- export the given packages function main(requires_raw) @@ -45,24 +45,22 @@ function main(requires_raw) end -- export packages - local exportdir = option.get("exportdir") - local packages = package.export_packages(requires, {requires_extra = requires_extra, exportdir = exportdir}) - for _, instance in ipairs(packages) do - print("export: %s%s ok!", instance:name(), instance:version_str() and ("-" .. instance:version_str()) or "") - end + local packagedir = option.get("packagedir") + local nodeps = option.get("shallow") and true or false + local packages = export_packages(requires, {requires_extra = requires_extra, packagedir = packagedir, nodeps = nodeps}) if not packages or #packages == 0 then - cprint("${bright}packages(%s) not found, maybe they don’t exactly match the configuration.", table.concat(requires_raw, ", ")) - if os.getenv("XREPO_WORKING") then - print("please attempt to export them with `-f/--configs=` option, e.g.") - print(" - xrepo export -f \"name=value, ...\" package") - print(" - xrepo export -m debug -k shared -f \"name=value, ...\" package") - else - print("please attempt to export them with `--extra=` option, e.g.") - print(" - xmake require --export --extra=\"{configs={...}}\" package") - print(" - xmake require --export --extra=\"{debug=true,configs={shared=true}}\" package") + if requires_raw then + cprint("${bright}packages(%s) not found, maybe they don’t exactly match the configuration ", table.concat(requires_raw, ", ")) + if os.getenv("XREPO_WORKING") then + print("please attempt to export them with `-f/--configs=` option, e.g.") + print(" - xrepo export -f \"name=value, ...\" package") + print(" - xrepo export -m debug -k shared -f \"name=value, ...\" package") + else + print("please attempt to export them with `--extra=` option, e.g.") + print(" - xmake require --export --extra=\"{configs={...}}\" package") + print(" - xmake require --export --extra=\"{debug=true,configs={shared=true}}\" package") + end end - else - print("output: %s", exportdir) end -- leave environment diff --git a/xmake/actions/require/fetch.lua b/xmake/modules/private/action/require/fetch.lua index 2fd75d7b6..e64b7f0b0 100644 --- a/xmake/actions/require/fetch.lua +++ b/xmake/modules/private/action/require/fetch.lua @@ -25,9 +25,9 @@ import("core.project.project") import("core.package.package", {alias = "core_package"}) import("core.tool.linker") import("core.tool.compiler") -import("impl.package") -import("impl.repository") -import("impl.utils.get_requires") +import("private.action.require.impl.package") +import("private.action.require.impl.repository") +import("private.action.require.impl.utils.get_requires") -- fetch the given package info function main(requires_raw) @@ -85,7 +85,7 @@ function main(requires_raw) end end if #flags > 0 then - print(table.concat(flags, " ")) + print(os.args(flags)) else print(fetchinfos) end diff --git a/xmake/actions/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua index 3db3e2da9..abc017a70 100644 --- a/xmake/actions/require/impl/actions/download.lua +++ b/xmake/modules/private/action/require/impl/actions/download.lua @@ -1,4 +1,4 @@ ---!The Make-like download Utility based on Lua +--!A cross-platform build utility based on Lua -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -26,8 +26,10 @@ import("core.project.config") import("core.package.package", {alias = "core_package"}) import("lib.detect.find_file") import("lib.detect.find_directory") -import(".utils.filter") +import("private.action.require.impl.utils.filter") +import("private.action.require.impl..utils.url_filename") import("net.http") +import("net.proxy") import("devel.git") import("utils.archive") @@ -40,7 +42,7 @@ function _checkout(package, url, sourcedir, url_alias) not (option.get("force") and package:branch()) then -- we need disable cache if we force to clone from the given branch -- clean the previous build files - git.clean({repodir = packagedir, force = true}) + git.clean({repodir = packagedir, force = true, all = true}) -- reset the previous modified files git.reset({repodir = packagedir, hard = true}) tty.erase_line_to_start().cr() @@ -50,7 +52,9 @@ function _checkout(package, url, sourcedir, url_alias) -- we can use local package from the search directories directly if network is too slow local localdir = find_directory(package:name() .. archive.extension(url), core_package.searchdirs()) if localdir and os.isdir(localdir) then - git.clean({repodir = localdir, force = true}) + git.clean({repodir = localdir, force = true, all = true}) + git.reset({repodir = localdir, hard = true}) + os.cp(localdir, packagedir) tty.erase_line_to_start().cr() return end @@ -58,21 +62,30 @@ function _checkout(package, url, sourcedir, url_alias) -- remove temporary directory os.rm(sourcedir .. ".tmp") + -- we need enable longpaths on windows + local longpaths = package:policy("platform.longpaths") + -- download package from branches? packagedir = path.join(sourcedir .. ".tmp", package:name()) if package:branch() then -- only shadow clone this branch - git.clone(url, {depth = 1, recursive = true, branch = package:branch(), outputdir = packagedir}) + git.clone(proxy.mirror(url) or url, {depth = 1, recursive = true, longpaths = longpaths, branch = package:branch(), outputdir = packagedir}) -- download package from revision or tag? else -- clone whole history and tags - git.clone(url, {outputdir = packagedir, recursive = true}) + git.clone(proxy.mirror(url) or url, {longpaths = longpaths, outputdir = packagedir}) -- attempt to checkout the given version - git.checkout(package:revision(url_alias) or package:tag(), {repodir = packagedir}) + local revision = package:revision(url_alias) or package:tag() or package:version_str() + git.checkout(revision, {repodir = packagedir}) + + -- update all submodules + if os.isdir(".gitmodules") then + git.submodule.update({init = true, recursive = true, longpaths = longpaths, repodir = packagedir}) + end end -- move to source directory @@ -88,7 +101,7 @@ end function _download(package, url, sourcedir, url_alias, url_excludes) -- get package file - local packagefile = package:name() .. "-" .. package:version_str() .. archive.extension(url) + local packagefile = url_filename(url) -- get sourcehash from the given url -- @@ -97,10 +110,7 @@ function _download(package, url, sourcedir, url_alias, url_excludes) -- https://github.com/xmake-io/xmake/issues/1009 -- local sourcehash = package:sourcehash(url_alias) - if sourcehash then - sourcehash = sourcehash:lower() - end - assert(not package:verify() or not package:get("versions") or sourcehash, "cannot get source hash of %s in package(%s)", url, package:name()) + assert(not package:is_verify() or not package:get("versions") or sourcehash, "cannot get source hash of %s in package(%s)", url, package:name()) -- the package file have been downloaded? local cached = true @@ -113,14 +123,24 @@ function _download(package, url, sourcedir, url_alias, url_excludes) os.tryrm(packagefile) -- download or copy package file - local localfile = find_file(path.filename(packagefile), core_package.searchdirs()) if os.isfile(url) then os.cp(url, packagefile) - elseif localfile and os.isfile(localfile) then - -- we can use local package from the search directories directly if network is too slow - os.cp(localfile, packagefile) else - http.download(url, packagefile) + local localfile + local searchnames = {package:name() .. "-" .. package:version_str() .. archive.extension(url), + packagefile} + for _, searchname in ipairs(searchnames) do + localfile = find_file(searchname, core_package.searchdirs()) + if localfile then + break + end + end + if localfile and os.isfile(localfile) then + -- we can use local package from the search directories directly if network is too slow + os.cp(localfile, packagefile) + else + http.download(proxy.mirror(url) or url, packagefile) + end end -- check hash @@ -139,6 +159,7 @@ function _download(package, url, sourcedir, url_alias, url_excludes) -- create an empty source directory if do not extract package file os.tryrm(sourcedir) os.mkdir(sourcedir) + raise("cannot extract %s", packagefile) end -- save original file path @@ -159,7 +180,7 @@ function _urls(package) for _, url in ipairs(package:urls()) do if git.checkurl(url) then table.insert(urls[1], url) - elseif not package:verify() or not package:get("versions") or package:sourcehash(package:url_alias(url)) then + elseif not package:is_verify() or not package:get("versions") or package:sourcehash(package:url_alias(url)) then table.insert(urls[2], url) end end @@ -215,8 +236,6 @@ function main(package) else _download(package, url, sourcedir, url_alias, url_excludes) end - - -- ok return true end, catch @@ -238,18 +257,14 @@ function main(package) table.insert(urls_failed, url) -- failed? break it - if idx == #urls and not package:optional() then + if idx == #urls and not package:is_optional() then if #urls_failed > 0 then print("") print("we can also download these packages manually:") local searchnames = hashset.new() for _, url_failed in ipairs(urls_failed) do cprint(" ${yellow}- %s", url_failed) - if git.checkurl(url_failed) then - searchnames:insert(package:name() .. archive.extension(url_failed)) - else - searchnames:insert(package:name() .. "-" .. package:version_str() .. archive.extension(url_failed)) - end + searchnames:insert(url_filename(url_failed)) end cprint("to the local search directories: ${bright}%s", table.concat(table.wrap(core_package.searchdirs()), path.envsep())) cprint(" ${bright}- %s", table.concat(searchnames:to_array(), ", ")) diff --git a/xmake/actions/require/impl/actions/download_resources.lua b/xmake/modules/private/action/require/impl/actions/download_resources.lua index 6447b3ea2..5bf1f9a46 100644 --- a/xmake/actions/require/impl/actions/download_resources.lua +++ b/xmake/modules/private/action/require/impl/actions/download_resources.lua @@ -22,9 +22,57 @@ import("core.base.option") import("core.package.package", {alias = "core_package"}) import("lib.detect.find_file") +import("lib.detect.find_directory") import("net.http") +import("net.proxy") +import("devel.git") import("utils.archive") +-- checkout resources +function _checkout(package, resource_name, resource_url, resource_revision) + + -- trace + vprint("cloning resource(%s: %s) to %s-%s ..", resource_name, resource_revision, package:name(), package:version_str()) + + -- get the resource directory + local resourcedir = assert(package:resourcefile(resource_name), "invalid resource directory!") + + -- use previous resource directory if exists + if os.isdir(resourcedir) and not option.get("force") then + -- clean the previous build files + git.clean({repodir = resourcedir, force = true, all = true}) + -- reset the previous modified files + git.reset({repodir = resourcedir, hard = true}) + return + end + + -- we can use local package from the search directories directly if network is too slow + local localdir = find_directory(path.filename(resourcedir), core_package.searchdirs()) + if localdir and os.isdir(localdir) then + git.clean({repodir = localdir, force = true, all = true}) + git.reset({repodir = localdir, hard = true}) + os.cp(localdir, resourcedir) + return + end + + -- remove temporary directory + os.rm(resourcedir) + + -- we need enable longpaths on windows + local longpaths = package:policy("platform.longpaths") + + -- clone whole history and tags + git.clone(proxy.mirror(resource_url) or resource_url, {longpaths = longpaths, outputdir = resourcedir}) + + -- attempt to checkout the given version + git.checkout(resource_revision, {repodir = resourcedir}) + + -- update all submodules + if os.isdir(".gitmodules") then + git.submodule.update({init = true, recursive = true, longpaths = longpaths, repodir = resourcedir}) + end +end + -- download resources function _download(package, resource_name, resource_url, resource_hash) @@ -55,7 +103,7 @@ function _download(package, resource_name, resource_url, resource_hash) -- we can use local resource from the search directories directly if network is too slow os.cp(localfile, resource_file) elseif resource_url:find(string.ipattern("https-://")) or resource_url:find(string.ipattern("ftps-://")) then - http.download(resource_url, resource_file) + http.download(proxy.mirror(resource_url) or resource_url, resource_file) else raise("invalid resource url(%s)", resource_url) end @@ -75,12 +123,18 @@ function _download(package, resource_name, resource_url, resource_hash) os.mv(resourcedir_tmp, resourcedir) else os.tryrm(resourcedir_tmp) + raise("cannot extract %s", resource_file) end end -- download all resources of the given package function main(package) + -- we need not download it if we use the precompiled artifacts to install package + if not package:is_built() then + return + end + -- no resources? local resources = package:resources() if not resources then @@ -89,8 +143,10 @@ function main(package) -- download all resources for name, resourceinfo in pairs(resources) do - -- we use wrap to support urls table and only get the first url now - -- TODO maybe we will download resource from the multiple urls in the future - _download(package, name, table.wrap(resourceinfo.url)[1], resourceinfo.sha256) + if git.checkurl(resourceinfo.url) then + _checkout(package, name, resourceinfo.url, resourceinfo.sha256) + else + _download(package, name, resourceinfo.url, resourceinfo.sha256) + end end end diff --git a/xmake/actions/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua index 2410e8edb..81f93681e 100644 --- a/xmake/actions/require/impl/actions/install.lua +++ b/xmake/modules/private/action/require/impl/actions/install.lua @@ -1,4 +1,4 @@ ---!The Make-like install Utility based on Lua +--!A cross-platform build utility based on Lua -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -23,16 +23,16 @@ import("core.base.option") import("core.base.tty") import("core.project.target") import("lib.detect.find_file") -import("test") -import("patch_sources") -import("download_resources") -import(".utils.filter") +import("private.action.require.impl.actions.test") +import("private.action.require.impl.actions.patch_sources") +import("private.action.require.impl.actions.download_resources") +import("private.action.require.impl.utils.filter") -- patch pkgconfig if not exists function _patch_pkgconfig(package) -- only binary? need not pkgconfig - if package:kind() == "binary" then + if not package:is_library() then return end @@ -48,7 +48,7 @@ function _patch_pkgconfig(package) vprint("patching %s ..", pcfile) -- fetch package - local fetchinfo = package:fetchdeps() + local fetchinfo = package:fetch_linkdeps() if not fetchinfo then return end @@ -91,6 +91,15 @@ function _patch_pkgconfig(package) end end +-- check package toolchains +function _check_package_toolchains(package) + for _, toolchain_inst in pairs(package:toolchains()) do + if not toolchain_inst:check() then + raise("toolchain(\"%s\"): not found!", toolchain_inst:name()) + end + end +end + -- install the given package function main(package) @@ -123,22 +132,15 @@ function main(package) end -- install it + local oldenvs = os.getenvs() try { function () - -- the package scripts - local scripts = - { - package:script("install_before") - , package:script("install") - , package:script("install_after") - } - -- install the third-party package directly, e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable local installed_now = false - if package:is3rd() then - local script = package:script("install") + local script = package:script("install") + if package:is_thirdparty() then if script ~= nil then filter.call(script, package) end @@ -150,29 +152,27 @@ function main(package) -- clean install directory first os.tryrm(package:installdir()) - -- enter the environments of all package dependencies - for _, dep in ipairs(package:orderdeps()) do - dep:envs_enter() - end - -- download package resources download_resources(package) -- patch source codes of package patch_sources(package) + -- enter the environments of all package dependencies + for _, dep in ipairs(package:orderdeps()) do + dep:envs_enter() + end + + -- check package toolchains + _check_package_toolchains(package) + -- do install - for i = 1, 3 do - local script = scripts[i] - if script ~= nil then - filter.call(script, package) - end + if script ~= nil then + filter.call(script, package, {oldenvs = oldenvs}) end -- leave the environments of all package dependencies - for _, dep in irpairs(package:orderdeps()) do - dep:envs_leave() - end + os.setenvs(oldenvs) -- save the package info to the manifest file package:manifest_save() @@ -204,14 +204,11 @@ function main(package) end -- leave the package environments - package:envs_leave() - for _, dep in irpairs(package:orderdeps()) do - dep:envs_leave() - end + os.setenvs(oldenvs) -- trace tty.erase_line_to_start().cr() - cprint("${yellow} => ${clear}install %s %s .. ${color.success}${text.success}", package:name(), package:version_str() or "") + cprint("${yellow} => ${clear}install %s %s .. ${color.success}${text.success}", package:displayname(), package:version_str() or "") end, catch @@ -230,10 +227,10 @@ function main(package) -- trace tty.erase_line_to_start().cr() - cprint("${yellow} => ${clear}install %s %s .. ${color.failure}${text.failure}", package:name(), package:version_str() or "") + cprint("${yellow} => ${clear}install %s %s .. ${color.failure}${text.failure}", package:displayname(), package:version_str() or "") -- leave the package environments - package:envs_leave() + os.setenvs(oldenvs) -- copy the invalid package directory to cache local installdir = package:installdir() diff --git a/xmake/actions/require/impl/actions/patch_sources.lua b/xmake/modules/private/action/require/impl/actions/patch_sources.lua index 110330af0..23d46f3d3 100644 --- a/xmake/actions/require/impl/actions/patch_sources.lua +++ b/xmake/modules/private/action/require/impl/actions/patch_sources.lua @@ -21,6 +21,7 @@ -- imports import("core.base.option") import("net.http") +import("net.proxy") import("devel.git") -- check sha256 @@ -71,7 +72,7 @@ function _patch(package, patch_url, patch_hash) -- download the patch file if patch_url:find(string.ipattern("https-://")) or patch_url:find(string.ipattern("ftps-://")) then - http.download(patch_url, patch_file) + http.download(proxy.mirror(patch_url) or patch_url, patch_file) else -- copy the patch file if os.isfile(patch_url) then @@ -99,6 +100,11 @@ end -- patch the given package function main(package) + -- we need not patch it if we use the precompiled artifacts to install package + if not package:is_built() then + return + end + -- no patches? local patches = package:patches() if not patches then diff --git a/xmake/actions/require/impl/actions/test.lua b/xmake/modules/private/action/require/impl/actions/test.lua index 2cad6f689..b156caef9 100644 --- a/xmake/actions/require/impl/actions/test.lua +++ b/xmake/modules/private/action/require/impl/actions/test.lua @@ -20,19 +20,11 @@ -- imports import("core.base.option") -import(".utils.filter") +import("private.action.require.impl.utils.filter") -- test the given package function main(package) - -- the package scripts - local scripts = - { - package:script("test_before") - , package:script("test") - , package:script("test_after") - } - -- enter the test directory local testdir = path.join(os.tmpdir(), "pkgtest", package:name(), package:version_str() or "latest") if os.isdir(testdir) then @@ -44,11 +36,9 @@ function main(package) local oldir = os.cd(testdir) -- test it - for i = 1, 3 do - local script = scripts[i] - if script ~= nil then - filter.call(script, package) - end + local script = package:script("test") + if script ~= nil then + filter.call(script, package) end -- restore the current directory diff --git a/xmake/actions/require/impl/environment.lua b/xmake/modules/private/action/require/impl/environment.lua index 1d163df63..bf878876b 100644 --- a/xmake/actions/require/impl/environment.lua +++ b/xmake/modules/private/action/require/impl/environment.lua @@ -20,11 +20,9 @@ -- imports import("core.project.config") -import("core.platform.environment") -import("core.package.package", {alias = "core_package"}) import("lib.detect.find_tool") -import("private.action.require.packagenv") -import("package") +import("private.action.require.impl.packagenv") +import("private.action.require.impl.install_packages") -- enter environment -- @@ -34,47 +32,45 @@ import("package") -- function enter() - -- set search paths of toolchains - environment.enter("toolchains") - -- unzip or 7zip is necessary if not find_tool("unzip") and not find_tool("7z") then raise("unzip or 7zip not found! we need install it first") end - -- enter the environments of git and 7z - packagenv.enter("git", "7z") + -- enter the environments of git + _g._OLDENVS = packagenv.enter("git") -- git not found? install it first local packages = {} - if not find_tool("git") then - table.join2(packages, package.install_packages("git")) + local git = find_tool("git") + if not git then + table.join2(packages, install_packages("git")) end -- missing the necessary unarchivers for *.gz, *.7z? install them first, e.g. gzip, 7z, tar .. - if not ((find_tool("gzip") and find_tool("tar")) or find_tool("7z")) then - table.join2(packages, package.install_packages("7z")) + local zip = (find_tool("gzip") and find_tool("tar")) or find_tool("7z") + if not zip then + table.join2(packages, install_packages("7z")) end -- enter the environments of installed packages for _, instance in ipairs(packages) do instance:envs_enter() end - _g._PACKAGES = packages + + -- we need force to detect and flush detect cache after loading all environments + if not git then + find_tool("git", {force = true}) + end + if not zip then + find_tool("7z", {force = true}) + end end -- leave environment function leave() - - -- leave the environments of installed packages - for _, instance in irpairs(_g._PACKAGES) do - instance:envs_leave() + local oldenvs = _g._OLDENVS + if oldenvs then + os.setenvs(oldenvs) end - _g._PACKAGES = nil - - -- leave the environments of git and 7z - packagenv.leave("7z", "git") - - -- restore search paths of toolchains - environment.leave("toolchains") end diff --git a/xmake/modules/private/action/require/impl/export_packages.lua b/xmake/modules/private/action/require/impl/export_packages.lua new file mode 100644 index 000000000..381897045 --- /dev/null +++ b/xmake/modules/private/action/require/impl/export_packages.lua @@ -0,0 +1,48 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file export_packages.lua +-- + +-- imports +import("core.package.package", {alias = "core_package"}) +import("private.action.require.impl.package") + +-- export packages +function main(requires, opt) + opt = opt or {} + local packages = {} + local packagedir = assert(opt.packagedir) + for _, instance in ipairs(package.load_packages(requires, opt)) do + + -- get export path + local installdir = instance:installdir() + local rootdir = core_package.installdir() + local exportpath, count = installdir:replace(rootdir, packagedir, {plain = true}) + + -- export this package + if exportpath and count == 1 and instance:fetch({force = true}) then + print("exporting %s-%s %s", instance:displayname(), instance:version_str(), package.get_configs_str(instance)) + cprint(" ${yellow}->${clear} %s", exportpath) + os.cp(installdir, exportpath) + os.tryrm(path.join(exportpath, "references.txt")) + table.insert(packages, instance) + end + end + return packages +end + diff --git a/xmake/modules/private/action/require/impl/import_packages.lua b/xmake/modules/private/action/require/impl/import_packages.lua new file mode 100644 index 000000000..d01660aa1 --- /dev/null +++ b/xmake/modules/private/action/require/impl/import_packages.lua @@ -0,0 +1,48 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file import_packages.lua +-- + +-- imports +import("core.package.package", {alias = "core_package"}) +import("private.action.require.impl.package") + +-- import packages +function main(requires, opt) + opt = opt or {} + local packages = {} + local packagedir = assert(opt.packagedir) + for _, instance in ipairs(package.load_packages(requires, opt)) do + + -- get import path + local installdir = instance:installdir() + local rootdir = core_package.installdir() + local importpath, count = installdir:replace(rootdir, packagedir, {plain = true}) + + -- import this package + if importpath and count == 1 then + print("importing %s-%s %s", instance:displayname(), instance:version_str(), package.get_configs_str(instance)) + cprint(" ${yellow}<-${clear} %s", importpath) + os.tryrm(installdir) + os.cp(importpath, installdir) + table.insert(packages, instance) + end + end + return packages +end + diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua new file mode 100644 index 000000000..fb7647861 --- /dev/null +++ b/xmake/modules/private/action/require/impl/install_packages.lua @@ -0,0 +1,603 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file install_packages.lua +-- + +-- imports +import("core.base.option") +import("core.base.hashset") +import("core.base.scheduler") +import("core.project.project") +import("core.base.tty") +import("private.async.runjobs") +import("private.utils.progress") +import("actions.install", {alias = "action_install"}) +import("actions.download", {alias = "action_download"}) +import("net.fasturl") +import("private.action.require.impl.package") +import("private.action.require.impl.register_packages") + +-- sort packages urls +function _sort_packages_urls(packages) + + -- add all urls to fasturl and prepare to sort them together + for _, instance in pairs(packages) do + fasturl.add(instance:urls()) + end + + -- sort and update urls + for _, instance in pairs(packages) do + instance:urls_set(fasturl.sort(instance:urls())) + end +end + +-- replace modified package +function _replace_package(packages, instance, extinstance) + for idx, rawinstance in ipairs(packages) do + if rawinstance == instance then + packages[idx] = extinstance + end + local deps = rawinstance._DEPS + for name, dep in pairs(deps) do + if dep == instance then + deps[name] = nil + deps[extinstance:name()] = extinstance + break + end + end + local parents = rawinstance._PARENTS + for name, parent in pairs(parents) do + if parent == instance then + parents[name] = nil + parents[extinstance:name()] = extinstance + break + end + end + local orderdeps = rawinstance._ORDERDEPS + for depidx, dep in ipairs(orderdeps) do + if dep == instance then + orderdeps[depidx] = extinstance + break + end + end + local linkdeps = rawinstance._LINKDEPS + for depidx, dep in ipairs(linkdeps) do + if dep == instance then + linkdeps[depidx] = extinstance + break + end + end + local plaindeps = rawinstance._PLAINDEPS + for depidx, dep in ipairs(rawinstance._PLAINDEPS) do + if dep == instance then + plaindeps[depidx] = extinstance + break + end + end + end +end + +-- replace modified packages +function _replace_packages(packages, packages_modified) + for _, package_modified in ipairs(packages_modified) do + local instance = package_modified.instance + local extinstance = package_modified.extinstance + _replace_package(packages, instance, extinstance) + end +end + +-- get user confirm from 3rd package sources +-- @see https://github.com/xmake-io/xmake/issues/1140 +function _get_confirm_from_3rd(packages) + + -- get extpackages list + local extpackages_list = _g.extpackages_list + if not extpackages_list then + extpackages_list = {} + for _, instance in ipairs(packages) do + local extsources = instance:get("extsources") + local extsources_extra = instance:extraconf("extsources") + if extsources then + local extpackages = package.load_packages(extsources, extsources_extra) + for _, extinstance in ipairs(extpackages) do + table.insert(extpackages_list, {instance = instance, extinstance = extinstance}) + end + end + end + _g.extpackages_list = extpackages_list + end + + -- no extpackages? + if #extpackages_list == 0 then + print("no more packages!") + return + end + + -- get confirm result + local result = utils.confirm({description = function () + cprint("${bright color.warning}note: ${clear}select the following 3rd packages") + for idx, extinstance in ipairs(extpackages_list) do + local instance = extinstance.instance + local extinstance = extinstance.extinstance + cprint(" ${yellow}%d.${clear} %s ${yellow}->${clear} %s %s ${dim}%s", + idx, extinstance:name(), + instance:displayname(), + instance:version_str() or "", + package.get_configs_str(instance)) + end + end, answer = function () + cprint("please input number list: ${bright}n${clear} (1,2,..)") + io.flush() + return (io.read() or "n"):trim() + end}) + + -- get confirmed extpackages + local confirmed_extpackages = {} + if result and result ~= "n" then + for _, idx in ipairs(result:split(',')) do + idx = tonumber(idx) + if extpackages_list[idx] then + table.insert(confirmed_extpackages, extpackages_list[idx]) + end + end + end + + -- modify packages + if #confirmed_extpackages > 0 then + _replace_packages(packages, confirmed_extpackages) + return confirmed_extpackages + end +end + +-- get user confirm +function _get_confirm(packages) + + -- no confirmed packages? + if #packages == 0 then + return true + end + + local result + local packages_modified + while result == nil do + -- get confirm result + result = utils.confirm({default = true, description = function () + + -- get packages for each repositories + local packages_repo = {} + local packages_group = {} + for _, instance in ipairs(packages) do + -- achive packages by repository + local reponame = instance:repo() and instance:repo():name() or (instance:is_system() and "system" or "") + if instance:is_thirdparty() then + reponame = instance:name():lower():split("::")[1] + end + packages_repo[reponame] = packages_repo[reponame] or {} + table.insert(packages_repo[reponame], instance) + + -- achive packages by group + local group = instance:group() + if group then + packages_group[group] = packages_group[group] or {} + table.insert(packages_group[group], instance) + end + end + + -- show tips + cprint("${bright color.warning}note: ${clear}install or modify (m) these packages (pass -y to skip confirm)?") + for reponame, packages in pairs(packages_repo) do + if reponame ~= "" then + print("in %s:", reponame) + end + local packages_showed = {} + for _, instance in ipairs(packages) do + if not packages_showed[tostring(instance)] then + local group = instance:group() + if group and packages_group[group] and #packages_group[group] > 1 then + for idx, package_in_group in ipairs(packages_group[group]) do + cprint(" ${yellow}%s${clear} %s %s ${dim}%s", idx == 1 and "->" or " or", package_in_group:displayname(), package_in_group:version_str() or "", package.get_configs_str(package_in_group)) + packages_showed[tostring(package_in_group)] = true + end + packages_group[group] = nil + else + cprint(" ${yellow}->${clear} %s %s ${dim}%s", instance:displayname(), instance:version_str() or "", package.get_configs_str(instance)) + packages_showed[tostring(instance)] = true + end + end + end + end + end, answer = function () + cprint("please input: ${bright}y${clear} (y/n/m)") + io.flush() + return (io.read() or "false"):trim() + end}) + + -- modify to select 3rd packages? + if result == "m" then + packages_modified = _get_confirm_from_3rd(packages) + result = nil + else + -- get confirm result + result = option.boolean(result) + if type(result) ~= "boolean" then + result = true + end + end + end + return result, packages_modified +end + +-- install packages +function _install_packages(packages_install, packages_download, installdeps) + + -- we need hide wait characters if is not a tty + local show_wait = io.isatty() + + -- init installed packages + local packages_installed = {} + for _, instance in ipairs(packages_install) do + packages_installed[tostring(instance)] = false + end + + -- do install + local progress_helper = show_wait and progress.new() or nil + local packages_installing = {} + local packages_downloading = {} + local packages_pending = table.copy(packages_install) + local packages_in_group = {} + local working_count = 0 + local installing_count = 0 + local parallelize = true + runjobs("install_packages", function (index) + + -- fetch a new package + local instance = nil + while instance == nil and #packages_pending > 0 do + for idx, pkg in ipairs(packages_pending) do + + -- all dependences has been installed? we install it now + local ready = true + local dep_not_found = nil + for _, dep in pairs(installdeps[tostring(pkg)]) do + local installed = packages_installed[tostring(dep)] + if installed == false or (installed == nil and not dep:exists() and not dep:is_optional()) then + ready = false + dep_not_found = dep + break + end + end + local group = pkg:group() + if ready and group then + -- this group has been installed? skip it + local group_status = packages_in_group[group] + if group_status == 1 then + table.remove(packages_pending, idx) + break + -- this group is installing? wait it + elseif group_status == 0 then + ready = false + end + end + + -- get a package with the ready status + if ready then + instance = pkg + table.remove(packages_pending, idx) + break + elseif working_count == 0 then + if #packages_pending == 1 and dep_not_found then + raise("package(%s): cannot be installed, there are dependencies(%s) that cannot be installed!", pkg:displayname(), dep_not_found:displayname()) + elseif #packages_pending == 1 then + raise("package(%s): cannot be installed!", pkg:displayname()) + end + end + end + if instance == nil and #packages_pending > 0 then + scheduler.co_yield() + end + end + if instance then + + -- update working count + working_count = working_count + 1 + + -- only install the first package in same group + local group = instance:group() + if not group or not packages_in_group[group] then + + -- disable parallelize? + if not instance:is_parallelize() then + parallelize = false + end + if not parallelize then + while installing_count > 0 do + scheduler.co_yield() + end + end + installing_count = installing_count + 1 + + -- mark this group as 'installing' + if group then + packages_in_group[group] = 0 + end + + -- download this package first + local downloaded = true + if packages_download[tostring(instance)] then + packages_downloading[index] = instance + downloaded = action_download(instance) + packages_downloading[index] = nil + end + + -- install this package + packages_installing[index] = instance + if downloaded then + action_install(instance) + end + + -- register it to local cache if it is root required package + -- + -- @note we need to register the package in time, + -- because other packages may be used, e.g. toolchain/packages + if instance:is_toplevel() then + register_packages({instance}) + end + + -- mark this group as 'installed' or 'failed' + if group then + packages_in_group[group] = instance:exists() and 1 or -1 + end + + -- next + parallelize = true + installing_count = installing_count - 1 + packages_installing[index] = nil + packages_installed[tostring(instance)] = true + end + + -- update working count + working_count = working_count - 1 + end + packages_installing[index] = nil + packages_downloading[index] = nil + + end, {total = #packages_install, + comax = (option.get("verbose") or option.get("diagnosis")) and 1 or 4, + isolate = true, + on_timer = function (running_jobs_indices) + + -- do not print progress info if be verbose + if option.get("verbose") or not show_wait then + return + end + + -- make installing and downloading packages list + local installing = {} + local downloading = {} + for _, index in ipairs(running_jobs_indices) do + local instance = packages_installing[index] + if instance then + table.insert(installing, instance:displayname()) + end + local instance = packages_downloading[index] + if instance then + table.insert(downloading, instance:displayname()) + end + end + + -- get waitobjs tips + local tips = nil + local waitobjs = scheduler.co_group_waitobjs("install_packages") + if waitobjs:size() > 0 then + local names = {} + for _, obj in waitobjs:keys() do + if obj:otype() == scheduler.OT_PROC then + table.insert(names, obj:name()) + elseif obj:otype() == scheduler.OT_SOCK then + table.insert(names, "sock") + elseif obj:otype() == scheduler.OT_PIPE then + table.insert(names, "pipe") + end + end + names = table.unique(names) + if #names > 0 then + names = table.concat(names, ",") + if #names > 16 then + names = names:sub(1, 16) .. ".." + end + tips = string.format("(%d/%s)", waitobjs:size(), names) + end + end + + -- trace + progress_helper:clear() + tty.erase_line_to_start().cr() + cprintf("${yellow} => ") + if #downloading > 0 then + cprintf("downloading ${color.dump.string}%s", table.concat(downloading, ", ")) + end + if #installing > 0 then + cprintf("%sinstalling ${color.dump.string}%s", #downloading > 0 and ", " or "", table.concat(installing, ", ")) + end + cprintf(" .. %s", tips and ("${dim}" .. tips .. "${clear} ") or "") + progress_helper:write() + end, exit = function(errors) + if errors then + tty.erase_line_to_start().cr() + io.flush() + end + end}) +end + +-- only enable the first package in same group and root packages +function _disable_other_packages_in_group(packages) + local registered_in_group = {} + for _, instance in ipairs(packages) do + local group = instance:group() + if instance:is_toplevel() and group then + local required_package = project.required_package(instance:alias() or instance:name()) + if required_package then + if not registered_in_group[group] and required_package:enabled() then + registered_in_group[group] = true + elseif required_package:enabled() then + required_package:enable(false) + required_package:save() + end + end + end + end +end + +-- sort packages for installation dependencies +function _sort_packages_for_installdeps(packages, installdeps, order_packages) + for _, instance in ipairs(packages) do + local deps = installdeps[tostring(instance)] + if deps then + _sort_packages_for_installdeps(deps, installdeps, order_packages) + end + table.insert(order_packages, instance) + end +end + +-- get package installation dependencies +function _get_package_installdeps(packages) + local installdeps = {} + local packagesmap = {} + for _, instance in ipairs(packages) do + -- we need use alias name first for toolchain/packages + packagesmap[instance:alias() or instance:name()] = instance + end + for _, instance in ipairs(packages) do + local deps = {} + if instance:orderdeps() then + deps = table.copy(instance:orderdeps()) + end + -- patch toolchain/packages to installdeps, because we need install toolchain package first + for _, toolchain in ipairs(instance:toolchains()) do + for _, packagename in ipairs(toolchain:config("packages")) do + if packagesmap[packagename] ~= instance then -- avoid loop recursion + table.insert(deps, packagesmap[packagename]) + end + end + end + installdeps[tostring(instance)] = deps + end + return installdeps +end + +-- install packages +function main(requires, opt) + + -- init options + opt = opt or {} + + -- load packages + local packages = package.load_packages(requires, opt) + + -- get package installation dependencies + local installdeps = _get_package_installdeps(packages) + + -- sort packages for installdeps + local order_packages = {} + _sort_packages_for_installdeps(packages, installdeps, order_packages) + packages = table.unique(order_packages) + + -- fetch and register packages (with system) from local first + runjobs("fetch_packages", function (index) + local instance = packages[index] + if instance and (not option.get("force") or (option.get("shallow") and not instance:is_toplevel())) then + local oldenvs = os.getenvs() + instance:envs_enter() + instance:fetch() + os.setenvs(oldenvs) + end + end, {total = #packages, + comax = (option.get("verbose") or option.get("diagnosis")) and 1 or 4, + isolate = true}) + + -- register all installed root packages to local cache + register_packages(packages) + + -- filter packages + local packages_install = {} + local packages_download = {} + local packages_unsupported = {} + for _, instance in ipairs(packages) do + if package.should_install(instance) then + if instance:is_supported() then + if #instance:urls() > 0 then + packages_download[tostring(instance)] = instance + end + table.insert(packages_install, instance) + elseif not instance:is_optional() then + table.insert(packages_unsupported, instance) + end + end + end + + -- exists unsupported packages? + if #packages_unsupported > 0 then + -- show tips + cprint("${bright color.warning}note: ${clear}the following packages are unsupported for $(plat)/$(arch)!") + for _, instance in ipairs(packages_unsupported) do + print(" -> %s %s", instance:displayname(), instance:version_str() or "") + end + raise() + end + + -- get user confirm + local confirm, packages_modified = _get_confirm(packages_install) + if not confirm then + local packages_must = {} + for _, instance in ipairs(packages_install) do + if not instance:is_optional() then + table.insert(packages_must, instance:displayname()) + end + end + if #packages_must > 0 then + raise("packages(%s): must be installed!", table.concat(packages_must, ", ")) + else + -- continue other actions + return + end + end + + -- some packages are modified? we need fix packages list and all deps + if packages_modified then + order_packages = {} + _replace_packages(packages, packages_modified) + installdeps = _get_package_installdeps(packages) + _sort_packages_for_installdeps(packages, installdeps, order_packages) + packages = table.unique(order_packages) + end + + -- sort package urls + _sort_packages_urls(packages_download) + + -- install all required packages from repositories + _install_packages(packages_install, packages_download, installdeps) + + -- disable other packages in same group + _disable_other_packages_in_group(packages) + + -- re-register and refresh all root packages to local cache, + -- because there may be some missing optional dependencies reinstalled + register_packages(packages) + return packages +end + diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua new file mode 100644 index 000000000..844847558 --- /dev/null +++ b/xmake/modules/private/action/require/impl/package.lua @@ -0,0 +1,866 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file package.lua +-- + +-- imports +import("core.base.semver") +import("core.base.option") +import("core.base.global") +import("core.base.hashset") +import("private.utils.progress") +import("core.cache.memcache") +import("core.project.project") +import("core.package.package", {alias = "core_package"}) +import("devel.git") +import("private.action.require.impl.repository") + +-- get memcache +function _memcache() + return memcache.cache("require.impl.package") +end + +-- +-- parse require string +-- +-- basic +-- - add_requires("zlib") +-- +-- semver +-- - add_requires("tbox >=1.5.1", "zlib >=1.2.11") +-- - add_requires("tbox", {version = ">=1.5.1"}) +-- +-- git branch/tag +-- - add_requires("zlib master") +-- +-- with the given repository +-- - add_requires("xmake-repo@tbox >=1.5.1") +-- +-- with the given configs +-- - add_requires("aaa_bbb_ccc >=1.5.1 <1.6.0", {optional = true, alias = "mypkg", debug = true}) +-- - add_requires("tbox", {config = {coroutine = true, abc = "xxx"}}) +-- +-- with namespace and the 3rd package manager +-- - add_requires("xmake::xmake-repo@tbox >=1.5.1") +-- - add_requires("vcpkg::ffmpeg") +-- - add_requires("conan::OpenSSL/1.0.2n@conan/stable") +-- - add_requires("conan::openssl/1.1.1g") -- new +-- - add_requires("brew::pcre2/libpcre2-8 10.x", {alias = "pcre2"}) +-- +-- clone as a standalone package with the different configs +-- we can install and use these three packages at the same time. +-- - add_requires("zlib") +-- - add_requires("zlib~debug", {debug = true}) +-- - add_requires("zlib~shared", {configs = {shared = true}, alias = "zlib_shared"}) +-- +-- - add_requires("zlib~label1") +-- - add_requires("zlib", {label = "label2"}) +-- +-- private package, only for installation, do not export any links/includes and environments to target +-- - add_requires("zlib", {private = true}) +-- +-- {system = nil/true/false}: +-- nil: get remote or system packages +-- true: only get system package +-- false: only get remote packages +-- +-- {build = true}: always build packages, we do not use the precompiled artifacts +-- +function _parse_require(require_str) + + -- split package and version info + local splitinfo = require_str:split('%s+') + assert(splitinfo and #splitinfo > 0, "require(\"%s\"): invalid!", require_str) + + -- get package info + local packageinfo = splitinfo[1] + + -- get version + -- + -- e.g. + -- + -- latest + -- >=1.5.1 <1.6.0 + -- master || >1.4 + -- ~1.2.3 + -- ^1.1 + -- + local version = "latest" + if #splitinfo > 1 then + version = table.concat(table.slice(splitinfo, 2), " ") + end + assert(version, "require(\"%s\"): unknown version!", require_str) + + -- require third-party packages? e.g. brew::pcre2/libpcre2-8 + local reponame = nil + local packagename = nil + if require_str:find("::", 1, true) then + packagename = packageinfo + else + + -- get repository name, package name and package url + local pos = packageinfo:lastof('@', true) + if pos then + packagename = packageinfo:sub(pos + 1) + reponame = packageinfo:sub(1, pos - 1) + else + packagename = packageinfo + end + end + + -- check package name + assert(packagename, "require(\"%s\"): the package name not found!", require_str) + return packagename, version, reponame +end + +-- load require info +function _load_require(require_str, requires_extra, parentinfo) + + -- parse require + local packagename, version, reponame = _parse_require(require_str) + + -- get require extra + local require_extra = {} + if requires_extra then + require_extra = requires_extra[require_str] or {} + end + + -- get required building configurations + local require_build_configs = require_extra.configs or require_extra.config + if require_extra.debug then + require_build_configs = require_build_configs or {} + require_build_configs.debug = true + end + + -- require packge in the current host platform + if require_extra.host then + require_extra.plat = os.host() + require_extra.arch = os.arch() + end + + -- init required item + local required = {} + parentinfo = parentinfo or {} + required.packagename = packagename + required.requireinfo = + { + originstr = require_str, + reponame = reponame, + version = require_extra.version or version, + plat = require_extra.plat, -- require package in the given platform + arch = require_extra.arch, -- require package in the given architecture + targetos = require_extra.targetos, -- require package in the given target os + kind = require_extra.kind, -- default: library, set package kind, e.g. binary, library, we can set `kind = "binary"` to only detect binary program and ignore library. + alias = require_extra.alias, -- set package alias name + group = require_extra.group, -- only uses the first package in same group + system = require_extra.system, -- default: true, we can set it to disable system package manually + option = require_extra.option, -- set and attach option + configs = require_build_configs, -- the required building configurations + default = require_extra.default, -- default: true, we can set it to disable package manually + optional = parentinfo.optional or require_extra.optional, -- default: false, inherit parentinfo.optional + verify = require_extra.verify, -- default: true, we can set false to ignore sha256sum and select any version + external = require_extra.external, -- default: true, we use sysincludedirs/-isystem instead of -I/xxx + private = require_extra.private, -- default: false, private package, only for installation, do not export any links/includes and environments + build = require_extra.build -- default: false, always build packages, we do not use the precompiled artifacts + } + return required.packagename, required.requireinfo +end + +-- load package package from system +function _load_package_from_system(packagename) + return core_package.load_from_system(packagename) +end + +-- load package package from project +function _load_package_from_project(packagename) + return core_package.load_from_project(packagename) +end + +-- load package package from repositories +function _load_package_from_repository(packagename, reponame) + local packagedir, repo = repository.packagedir(packagename, reponame) + if packagedir then + return core_package.load_from_repository(packagename, repo, packagedir) + end +end + +-- sort package deps +-- +-- e.g. +-- +-- a.deps = b +-- b.deps = c +-- +-- orderdeps: c -> b -> a +-- +function _sort_packagedeps(package, onlylink) + -- we must use native deps list instead of package:deps() to generate correct linkdeps + local orderdeps = {} + for _, dep in ipairs(package:plaindeps()) do + if dep and (onlylink ~= true or (dep:is_library() and not dep:is_private())) then + table.join2(orderdeps, _sort_packagedeps(dep, onlylink)) + table.insert(orderdeps, dep) + end + end + return orderdeps +end + +-- add some builtin configurations to package +function _add_package_configurations(package) + -- we can define configs to override it and it's default value in package() + if package:extraconf("configs", "debug", "default") == nil then + package:add("configs", "debug", {builtin = true, description = "Enable debug symbols.", default = false, type = "boolean"}) + end + if package:extraconf("configs", "shared", "default") == nil then + package:add("configs", "shared", {builtin = true, description = "Build shared library.", default = false, type = "boolean"}) + end + if package:extraconf("configs", "pic", "default") == nil then + package:add("configs", "pic", {builtin = true, description = "Enable the position independent code.", default = true, type = "boolean"}) + end + if package:extraconf("configs", "vs_runtime", "default") == nil then + package:add("configs", "vs_runtime", {builtin = true, description = "Set vs compiler runtime.", values = {"MT", "MTd", "MD", "MDd"}}) + end + if package:extraconf("configs", "toolchains", "default") == nil then + package:add("configs", "toolchains", {builtin = true, description = "Set package toolchains only for cross-compilation."}) + end + package:add("configs", "cflags", {builtin = true, description = "Set the C compiler flags."}) + package:add("configs", "cxflags", {builtin = true, description = "Set the C/C++ compiler flags."}) + package:add("configs", "cxxflags", {builtin = true, description = "Set the C++ compiler flags."}) + package:add("configs", "asflags", {builtin = true, description = "Set the assembler flags."}) +end + +-- select package version +function _select_package_version(package, requireinfo) + + -- exists urls? otherwise be phony package (only as package group) + if #package:urls() > 0 then + + -- has git url? + local has_giturl = false + for _, url in ipairs(package:urls()) do + if git.checkurl(url) then + has_giturl = true + break + end + end + + -- select package version + local source = nil + local version = nil + local require_version = requireinfo.version + local require_verify = requireinfo.verify + if (not package:get("versions") or require_verify == false) and semver.is_valid(require_version) then + -- no version list in package() or need not verify sha256sum? try selecting this version directly + -- @see https://github.com/xmake-io/xmake/issues/930 + -- https://github.com/xmake-io/xmake/issues/1009 + version = require_version + source = "versions" + elseif #package:versions() > 0 then -- select version? + version, source = try { function () return semver.select(require_version, package:versions()) end } + end + if not version and has_giturl and not require_version:find('.', 1, true) then -- select branch? + version, source = require_version ~= "latest" and require_version or "master", "branches" + end + if not version then + raise("package(%s): version(%s) not found!", package:name(), require_version) + end + return version, source + end +end + +-- check the configurations of packages +-- +-- package("pcre2") +-- add_configs("bitwidth", {description = "Set the code unit width.", default = "8", values = {"8", "16", "32"}}) +-- add_configs("bitwidth", {type = "number", values = {8, 16, 32}}) +-- add_configs("bitwidth", {restrict = function(value) if tonumber(value) < 100 then return true end}) +-- +function _check_package_configurations(package) + local configs_defined = {} + for _, name in ipairs(package:get("configs")) do + configs_defined[name] = package:extraconf("configs", name) or {} + end + for name, value in pairs(package:configs()) do + local conf = configs_defined[name] + if conf then + local config_type = conf.type + if config_type ~= nil and type(value) ~= config_type then + raise("package(%s %s): invalid type(%s) for config(%s), need type(%s)!", package:displayname(), package:version_str(), type(value), name, config_type) + end + if conf.values then + local found = false + for _, config_value in ipairs(conf.values) do + if tostring(value) == tostring(config_value) then + found = true + break + end + end + if not found then + raise("package(%s %s): invalid value(%s) for config(%s), please run `xmake require --info %s` to get all valid values!", package:displayname(), package:version_str(), value, name, package:name()) + end + end + if conf.restrict then + if not conf.restrict(value) then + raise("package(%s %s): invalid value(%s) for config(%s)!", package:displayname(), package:version_str(), value, name) + end + end + else + raise("package(%s %s): invalid config(%s), please run `xmake require --info %s` to get all configurations!", package:displayname(), package:version_str(), name, package:name()) + end + end +end + +-- match require path +function _match_requirepath(requirepath, requireconf) + + -- get pattern + local function _get_pattern(pattern) + pattern = pattern:gsub("([%+%.%-%^%$%(%)%%])", "%%%1") + pattern = pattern:gsub("%*%*", "\001") + pattern = pattern:gsub("%*", "\002") + pattern = pattern:gsub("\001", ".*") + pattern = pattern:gsub("\002", "[^.]*") + pattern = string.ipattern(pattern, true) + return pattern + end + + -- get the excludes + local excludes = requireconf:match("|.*$") + if excludes then excludes = excludes:split("|", {plain = true}) end + + -- do match + local pattern = requireconf:gsub("|.*$", "") + pattern = _get_pattern(pattern) + if (requirepath:match('^' .. pattern .. '$')) then + -- exclude sub-deps, e.g. "libwebp.**|cmake|autoconf" + local splitinfo = requirepath:split(".", {plain = true}) + if #splitinfo > 0 then + local name = splitinfo[#splitinfo] + for _, exclude in ipairs(excludes) do + pattern = _get_pattern(exclude) + if (name:match('^' .. pattern .. '$')) then + return false + end + end + end + return true + end +end + +-- init requireinfo +function _init_requireinfo(requireinfo, package, opt) + -- pass root toolchains to top library package + requireinfo.configs = requireinfo.configs or {} + if opt.is_toplevel then + requireinfo.is_toplevel = true + if not package:is_headeronly() then + if package:is_cross() and package:is_library() then + requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains") or get_config("toolchain") + end + requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or project.get("target.runtimes") or get_config("vs_runtime") + end + end +end + +-- finish requireinfo +function _finish_requireinfo(requireinfo, package) + requireinfo.configs = requireinfo.configs or {} + if not package:is_headeronly() then + if requireinfo.configs.vs_runtime == nil and package:is_plat("windows") then + requireinfo.configs.vs_runtime = "MT" + end + end + -- we need ensure readonly configs + for _, name in ipairs(table.keys(requireinfo.configs)) do + if package:extraconf("configs", name, "readonly") then + -- package:config() will use default value after loading package + requireinfo.configs[name] = nil + end + end +end + +-- merge requireinfo from `add_requireconfs()` +-- +-- add_requireconfs("*", {system = false, configs = {vs_runtime = "MD"}}) +-- add_requireconfs("lib*", {system = false, configs = {vs_runtime = "MD"}}) +-- add_requireconfs("libwebp", {system = false, configs = {vs_runtime = "MD"}}) +-- add_requireconfs("libpng.zlib", {system = false, override = true, configs = {cxflags = "-DTEST1"}, version = "1.2.10"}) +-- add_requireconfs("libtiff.*", {system = false, configs = {cxflags = "-DTEST2"}}) +-- add_requireconfs("libwebp.**|cmake|autoconf", {system = false, configs = {cxflags = "-DTEST3"}}) -- recursive deps +-- +function _merge_requireinfo(requireinfo, requirepath) + + -- only for project + if not os.isfile(os.projectfile()) then + return + end + + -- find requireconf from the given requirepath + local requireconf_result = {} + local requireconfs, requireconfs_extra = project.requireconfs_str() + if requireconfs then + for _, requireconf in ipairs(requireconfs) do + if _match_requirepath(requirepath, requireconf) then + local requireconf_extra = requireconfs_extra[requireconf] + table.insert(requireconf_result, {requireconf = requireconf, requireconf_extra = requireconf_extra}) + end + end + end + + -- append requireconf_extra into requireinfo + -- and the configs of add_requires have a higher priority than add_requireconfs. + -- + -- e.g. + -- add_requireconfs("*", {configs = {debug = false}}) + -- add_requires("foo", "bar", {configs = {debug = true}}) + -- + -- foo and bar will be debug mode + -- + -- we can also override the configs of add_requires + -- + -- e.g. + -- add_requires("zlib 1.2.11") + -- add_requireconfs("zlib", {override = true, version = "1.2.10"}) + -- + -- we override the version of zlib to 1.2.10 + -- + if #requireconf_result == 1 then + local requireconf_extra = requireconf_result[1].requireconf_extra + if requireconf_extra then + -- preprocess requireconf_extra, (debug, override ..) + local override = requireconf_extra.override + requireconf_extra.override = nil + if requireconf_extra.debug then + requireconf_extra.configs = requireconf_extra.configs or {} + requireconf_extra.configs.debug = true + requireconf_extra.debug = nil + end + -- append or override configs and extra options + for k, v in pairs(requireconf_extra.configs) do + requireinfo.configs = requireinfo.configs or {} + if override or requireinfo.configs[k] == nil then + requireinfo.configs[k] = v + end + end + for k, v in pairs(requireconf_extra) do + if k ~= "configs" then + if override or requireinfo[k] == nil then + requireinfo[k] = v + end + end + end + end + elseif #requireconf_result > 1 then + local confs = {} + for _, item in ipairs(requireconf_result) do + table.insert(confs, item.requireconf) + end + raise("package(%s) will match multiple add_requireconfs(%s)!", requirepath, table.concat(confs, " ")) + end +end + +-- get package key +function _get_packagekey(packagename, requireinfo, version) + local key = packagename .. "/" .. (version or requireinfo.version) + if requireinfo.plat then + key = key .. "/" .. requireinfo.plat + end + if requireinfo.arch then + key = key .. "/" .. requireinfo.arch + end + if requireinfo.label then + key = key .. "/" .. requireinfo.label + end + local configs = requireinfo.configs + if configs then + local configs_order = {} + for k, v in pairs(configs) do + table.insert(configs_order, k .. "=" .. tostring(v)) + end + table.sort(configs_order) + key = key .. ":" .. string.serialize(configs_order, true) + end + return key +end + +-- inherit some builtin configs of parent package if these config values are not default value +-- e.g. add_requires("libpng", {configs = {vs_runtime = "MD", pic = false}}) +-- +function _inherit_parent_configs(requireinfo, package, parentinfo) + if package:is_library() then + local requireinfo_configs = requireinfo.configs or {} + local parentinfo_configs = parentinfo.configs or {} + if not requireinfo_configs.shared then + if requireinfo_configs.vs_runtime == nil then + requireinfo_configs.vs_runtime = parentinfo_configs.vs_runtime + end + if requireinfo_configs.pic == nil then + requireinfo_configs.pic = parentinfo_configs.pic + end + end + if parentinfo.plat then + requireinfo.plat = parentinfo.plat + end + if parentinfo.arch then + requireinfo.arch = parentinfo.arch + end + if parentinfo.private ~= nil then + requireinfo.private = parentinfo.private + end + requireinfo_configs.toolchains = requireinfo_configs.toolchains or parentinfo_configs.toolchains + requireinfo_configs.vs_runtime = requireinfo_configs.vs_runtime or parentinfo_configs.vs_runtime + requireinfo.configs = requireinfo_configs + end +end + +-- load required packages +function _load_package(packagename, requireinfo, opt) + + -- strip trailng ~tag, e.g. zlib~debug + local displayname + if packagename:find('~', 1, true) then + displayname = packagename + local splitinfo = packagename:split('~', {plain = true, limit = 2}) + packagename = splitinfo[1] + requireinfo.alias = requireinfo.alias or displayname + requireinfo.label = splitinfo[2] + end + + -- load package from project first + local package + if os.isfile(os.projectfile()) then + package = _load_package_from_project(packagename) + end + + -- load package from repositories + local from_repo = false + if not package then + package = _load_package_from_repository(packagename, requireinfo.reponame) + if package then + from_repo = true + end + end + + -- load package from system + local system = requireinfo.system + if system == nil then + system = opt.system + end + if not package and (system ~= false or packagename:find("::", 1, true)) then + package = _load_package_from_system(packagename) + end + + -- check + assert(package, "package(%s) not found!", packagename) + + -- init requireinfo + _init_requireinfo(requireinfo, package, {is_toplevel = not opt.parentinfo}) + + -- merge requireinfo from `add_requireconfs()` + _merge_requireinfo(requireinfo, opt.requirepath) + + -- inherit some builtin configs of parent package, e.g. vs_runtime, pic + if opt.parentinfo then + _inherit_parent_configs(requireinfo, package, opt.parentinfo) + end + + -- finish requireinfo + _finish_requireinfo(requireinfo, package) + + -- select package version + local version, source = _select_package_version(package, requireinfo) + if version then + package:version_set(version, source) + end + + -- get package key + local packagekey = _get_packagekey(packagename, requireinfo, version) + + -- get package from cache first + local package_cached = _memcache():get2("packages", packagekey) + if package_cached then + return package_cached + end + + -- save require info + package:requireinfo_set(requireinfo) + + -- save display name + if not displayname then + local packageid = _memcache():get2("packageids", packagename) + displayname = packagename + if packageid then + displayname = displayname .. "#" .. tostring(packageid) + end + _memcache():set2("packageids", packagename, (packageid or 0) + 1) + end + package:displayname_set(displayname) + + -- disable parallelize if the package cache directory conflicts + local cachedirs = _memcache():get2("cachedirs", package:cachedir()) + if cachedirs then + package:set("parallelize", false) + end + _memcache():set2("cachedirs", package:cachedir(), true) + + -- add some builtin configurations to package + _add_package_configurations(package) + + -- check package configurations + _check_package_configurations(package) + + -- save artifacts info, we need add it at last before buildhash need depend on package configurations + if from_repo and not option.get("build") and not requireinfo.build then + local artifacts_manifest = repository.artifacts_manifest(packagename, version) + if artifacts_manifest then + local buildid = package:plat() .. "-" .. package:arch() .. "-" .. package:buildhash() + local artifacts_info = artifacts_manifest[buildid] + if artifacts_info then + package:artifacts_set(artifacts_info) + end + end + end + + -- do load + local on_load = package:script("load") + if on_load then + on_load(package) + end + + -- load environments from the manifest to enable the environments of on_install() + package:envs_load() + + -- save this package package to cache + _memcache():set2("packages", packagekey, package) + return package +end + +-- load all required packages +function _load_packages(requires, opt) + + -- no requires? + if not requires or #requires == 0 then + return {} + end + + -- load packages + local packages = {} + local packages_nodeps = {} + for _, requireitem in ipairs(load_requires(requires, opt.requires_extra, opt)) do + + -- load package + local requireinfo = requireitem.info + local requirepath = opt.requirepath and (opt.requirepath .. "." .. requireitem.name) or requireitem.name + local package = _load_package(requireitem.name, requireinfo, table.join(opt, {requirepath = requirepath})) + + -- maybe package not found and optional + if package then + + -- load dependent packages and save them first of this package + if not package._DEPS then + if package:get("deps") and opt.nodeps ~= true then + + -- load dependent packages and do not load system/3rd packages for package/deps() + local packagedeps = {} + local deps, plaindeps = _load_packages(package:get("deps"), {requirepath = requirepath, + requires_extra = package:extraconf("deps") or {}, + parentinfo = requireinfo, + nodeps = opt.nodeps, + system = false}) + for _, dep in ipairs(deps) do + dep:parents_add(package) + table.insert(packages, dep) + packagedeps[dep:name()] = dep + end + package._DEPS = packagedeps + package._PLAINDEPS = plaindeps + package._ORDERDEPS = table.unique(_sort_packagedeps(package)) + package._LINKDEPS = table.unique(_sort_packagedeps(package, true)) + end + end + + -- save this package + table.insert(packages, package) + table.insert(packages_nodeps, package) + end + end + return packages, packages_nodeps +end + +-- get package parents string +function _get_parents_str(package) + local parents = package:parents() + if parents then + local parentnames = {} + for _, parent in pairs(parents) do + table.insert(parentnames, parent:displayname()) + end + if #parentnames == 0 then + return + end + return table.concat(parentnames, ",") + end +end + +-- check dependences conflicts +-- +-- It exists conflict for dependent packages for each root packages? resolve it first +-- e.g. +-- add_requires("foo") -> bar -> zlib 1.2.10 +-- -> xyz -> zlib 1.2.11 or other configs +-- +-- add_requires("ddd") -> zlib +-- +-- We assume that there is no conflict between `foo` and `ddd`. +-- +-- Of course, conflicts caused by `add_packages("foo", "ddd")` +-- cannot be detected at present and can only be resolved by the user +-- +function _check_package_depconflicts(package) + local packagekeys = {} + for _, dep in ipairs(package:linkdeps()) do + local key = _get_packagekey(dep:name(), dep:requireinfo()) + local prevkey = packagekeys[dep:name()] + if prevkey then + assert(key == prevkey, "package(%s): conflict dependences with package(%s)!", key, prevkey) + else + packagekeys[dep:name()] = key + end + end +end + +-- must depend on the given package? +function _must_depend_on(package, dep) + local manifest = package:manifest_load() + if manifest and manifest.linkdeps then + local linkdeps = hashset.from(manifest.linkdeps) + return linkdeps:has(dep:name()) + end +end + +-- the cache directory +function cachedir() + return path.join(global.directory(), "cache", "packages") +end + +-- this package should be install? +function should_install(package) + if package:exists() then + return false + end + -- we need not install it if this package need only be fetched + if package:is_fetchonly() then + return false + end + -- only get system package? e.g. add_requires("xxx", {system = true}) + local requireinfo = package:requireinfo() + if requireinfo and requireinfo.system then + return false + end + if package:parents() then + -- if all the packages that depend on it already exist, then there is no need to install it + for _, parent in pairs(package:parents()) do + if should_install(parent) and not parent:exists() then + return true + end + + -- if the existing parent package is already using it, + -- then even if it is an optional package, you must make sure to install it + -- + -- @see https://github.com/xmake-io/xmake/issues/1460 + -- + if parent:exists() and not option.get("force") and _must_depend_on(parent, package) then + -- mark this package as non-optional because parent package need it + local requireinfo = package:requireinfo() + if requireinfo.optional then + requireinfo.optional = nil + end + return true + end + end + else + return true + end +end + +-- get package configs string +function get_configs_str(package) + local configs = {} + if package:is_optional() then + table.insert(configs, "optional") + end + if package:is_private() then + table.insert(configs, "private") + end + local requireinfo = package:requireinfo() + if requireinfo then + if requireinfo.plat then + table.insert(configs, requireinfo.plat) + end + if requireinfo.arch then + table.insert(configs, requireinfo.arch) + end + for k, v in pairs(requireinfo.configs) do + if type(v) == "boolean" then + table.insert(configs, k .. ":" .. (v and "y" or "n")) + else + table.insert(configs, k .. ":" .. v) + end + end + end + local parents_str = _get_parents_str(package) + if parents_str then + table.insert(configs, "from:" .. parents_str) + end + local configs_str = #configs > 0 and "[" .. table.concat(configs, ", ") .. "]" or "" + local limitwidth = os.getwinsize().width * 2 / 3 + if #configs_str > limitwidth then + configs_str = configs_str:sub(1, limitwidth) .. " ..)" + end + return configs_str +end + +-- load requires +function load_requires(requires, requires_extra, opt) + opt = opt or {} + local requireitems = {} + for _, require_str in ipairs(requires) do + local packagename, requireinfo = _load_require(require_str, requires_extra, opt.parentinfo) + table.insert(requireitems, {name = packagename, info = requireinfo}) + end + return requireitems +end + +-- load all required packages +function load_packages(requires, opt) + opt = opt or {} + local unique = {} + local packages = {} + for _, package in ipairs((_load_packages(requires, opt))) do + if package:is_toplevel() then + _check_package_depconflicts(package) + end + local key = _get_packagekey(package:name(), package:requireinfo()) + if not unique[key] then + table.insert(packages, package) + unique[key] = true + end + end + return packages +end + diff --git a/xmake/modules/private/action/require/packagenv.lua b/xmake/modules/private/action/require/impl/packagenv.lua index 232670b54..12a98d36f 100644 --- a/xmake/modules/private/action/require/packagenv.lua +++ b/xmake/modules/private/action/require/impl/packagenv.lua @@ -23,18 +23,7 @@ import("core.package.package", {alias = "core_package"}) -- enter the package environments function _enter_package(package_name, envs, installdir) - - -- save the old environments - _g._OLDENVS = _g._OLDENVS or {} - local oldenvs = _g._OLDENVS[package_name] - if not oldenvs then - oldenvs = {} - _g._OLDENVS[package_name] = oldenvs - end - - -- add the new environments for name, values in pairs(envs) do - oldenvs[name] = oldenvs[name] or os.getenv(name) if name == "PATH" or name == "LD_LIBRARY_PATH" or name == "DYLD_LIBRARY_PATH" then for _, value in ipairs(values) do if path.is_absolute(value) then @@ -49,20 +38,9 @@ function _enter_package(package_name, envs, installdir) end end --- leave the package environments -function _leave_package(package_name) - _g._OLDENVS = _g._OLDENVS or {} - local oldenvs = _g._OLDENVS[package_name] - if oldenvs then - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end - _g._OLDENVS[package_name] = nil - end -end - -- enter environment of the given binary packages, git, 7z, .. function enter(...) + local oldenvs = os.getenvs() for _, name in ipairs({...}) do for _, manifest_file in ipairs(os.files(path.join(core_package.installdir(), name:sub(1, 1), name, "*", "*", "manifest.txt"))) do local manifest = io.load(manifest_file) @@ -71,11 +49,6 @@ function enter(...) end end end + return oldenvs end --- leave environment of the given binary packages, git, 7z, .. -function leave(...) - for _, name in ipairs({...}) do - _leave_package(name) - end -end diff --git a/xmake/modules/private/action/require/impl/register_packages.lua b/xmake/modules/private/action/require/impl/register_packages.lua new file mode 100644 index 000000000..4c326e770 --- /dev/null +++ b/xmake/modules/private/action/require/impl/register_packages.lua @@ -0,0 +1,132 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file register_packages.lua +-- + +-- imports +import("core.project.project") + +-- register required package environments +-- envs: bin path for *.dll, program .. +function _register_required_package_envs(instance, envs) + for name, values in pairs(instance:envs()) do + if name == "PATH" or name == "LD_LIBRARY_PATH" or name == "DYLD_LIBRARY_PATH" then + for _, value in ipairs(values) do + envs[name] = envs[name] or {} + if path.is_absolute(value) then + table.insert(envs[name], value) + else + table.insert(envs[name], path.join(instance:installdir(), value)) + end + end + else + envs[name] = envs[name] or {} + table.join2(envs[name], values) + end + end +end + +-- register required package libraries +-- libs: includedirs, links, linkdirs ... +function _register_required_package_libs(instance, required_package, is_deps) + if instance:is_library() then + local fetchinfo = instance:fetch() + if fetchinfo then + fetchinfo.name = nil + if is_deps then + -- we need only reserve license for root package + -- + -- @note the license compatibility between the root package and + -- its dependent packages is guaranteed by the root package itself + -- + fetchinfo.license = nil + + -- we need only some infos for root package + fetchinfo.version = nil + fetchinfo.static = nil + fetchinfo.shared = nil + end + required_package:add(fetchinfo) + end + end +end + +-- register the base info of required package +function _register_required_package_base(instance, required_package) + if not instance:is_system() and not instance:is_thirdparty() then + required_package:set("__installdir", instance:installdir()) + end +end + +-- register the required local package +function _register_required_package(instance, required_package) + + -- disable it if this package is missing + if not instance:exists() then + required_package:enable(false) + else + -- clear require info first + required_package:clear() + + -- add packages info with all dependencies + local envs = {} + _register_required_package_base(instance, required_package) + _register_required_package_libs(instance, required_package) + _register_required_package_envs(instance, envs) + local linkdeps = instance:linkdeps() + if linkdeps then + local total = #linkdeps + for idx, _ in ipairs(linkdeps) do + local dep = linkdeps[total + 1 - idx] + if dep then + if instance:is_library() then + _register_required_package_libs(dep, required_package, true) + end + end + end + end + for _, dep in ipairs(instance:orderdeps()) do + if not dep:is_private() then + _register_required_package_envs(dep, envs) + end + end + if #table.keys(envs) > 0 then + required_package:add({envs = envs}) + end + + -- enable this require info + required_package:enable(true) + end + + -- save this require info and flush the whole cache file + required_package:save() +end + +-- register all required root packages to local cache +function main(packages) + for _, instance in ipairs(packages) do + if instance:is_toplevel() then + local required_packagename = instance:alias() or instance:name() + local required_package = project.required_package(required_packagename) + if required_package then + _register_required_package(instance, required_package) + end + end + end +end + diff --git a/xmake/actions/require/clean.lua b/xmake/modules/private/action/require/impl/remove_packages.lua index fb93e6304..b65627256 100644 --- a/xmake/actions/require/clean.lua +++ b/xmake/modules/private/action/require/impl/remove_packages.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-present, TBOOX Open Source Group. -- -- @author ruki --- @file clean.lua +-- @file remove_packages.lua -- -- imports @@ -23,8 +23,29 @@ import("core.base.option") import("core.package.package") import("core.cache.localcache") --- clear the unused or invalid package directories -function _clear_packagedirs(packagedir) +-- get package configs string +function _get_package_configs_str(manifest_file) + local manifest = os.isfile(manifest_file) and io.load(manifest_file) + if manifest then + local configs = {} + for k, v in pairs(manifest.configs) do + if type(v) == "boolean" then + table.insert(configs, k .. ":" .. (v and "y" or "n")) + else + table.insert(configs, k .. ":" .. v) + end + end + local configs_str = #configs > 0 and "[" .. table.concat(configs, ", ") .. "]" or "" + local limitwidth = os.getwinsize().width * 2 / 3 + if #configs_str > limitwidth then + configs_str = configs_str:sub(1, limitwidth) .. " ..)" + end + return configs_str + end +end + +-- remove package directories +function _remove_packagedirs(packagedir, opt) -- clear them local package_name = path.filename(packagedir) @@ -52,8 +73,9 @@ function _clear_packagedirs(packagedir) elseif not os.isfile(manifest_file) then status = "invalid" end - if status then - local description = string.format("remove this ${magenta}%s-%s${clear}/${yellow}%s${clear} (${red}%s${clear})", package_name, version, hash, status) + if not opt.clean or status then + local configs_str = _get_package_configs_str(manifest_file) or "[]" + local description = string.format("remove ${color.dump.string}%s-%s${clear}/${yellow}%s${clear}\n -> ${dim}%s${clear} (${red}%s${clear})", package_name, version, hash, configs_str, status and status or "used") local confirm = utils.confirm({default = true, description = description}) if confirm then os.rm(hashdir) @@ -69,35 +91,25 @@ function _clear_packagedirs(packagedir) end end --- clean the given or all package caches -function main(package_names) - - -- trace - print("clearing packages ..") - - -- clear all unused packages +-- remove the given or all packages +-- +-- @param package_names the package names list, support lua pattern +-- @param opt the options, only clean unused packages if pass `{clean = true}` +-- +function main(package_names, opt) + opt = opt or {} local installdir = package.installdir() if package_names then for _, package_name in ipairs(package_names) do for _, packagedir in ipairs(os.dirs(path.join(installdir, package_name:sub(1, 1), package_name))) do - _clear_packagedirs(packagedir) + _remove_packagedirs(packagedir, opt) end end else for _, packagedir in ipairs(os.dirs(path.join(installdir, "*", "*"))) do - _clear_packagedirs(packagedir) + _remove_packagedirs(packagedir, opt) end end - - -- trace - print("clearing caches ..") - - -- clear cache directory - os.rm(package.cachedir()) - - -- clear require cache - local require_cache = localcache.cache("package") - require_cache:clear() - require_cache:save() end + diff --git a/xmake/actions/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua index 6fc72d49c..4dbf44e52 100644 --- a/xmake/actions/require/impl/repository.lua +++ b/xmake/modules/private/action/require/impl/repository.lua @@ -19,33 +19,29 @@ -- -- imports +import("core.base.global") import("core.package.repository") -- get all repositories function repositories() - - -- get it from cache it if _g._REPOSITORIES then return _g._REPOSITORIES end - -- get all repositories (local first) local repos = table.join(repository.repositories(false), repository.repositories(true)) - - -- save repositories _g._REPOSITORIES = repos - - -- ok return repos end -- the remote repositories have been pulled? function pulled() - for _, repo in ipairs(repositories()) do - -- repository not found? or xmake has been re-installed - local updatefile = path.join(repo:directory(), "updated") - if not os.isdir(repo:directory()) or (os.isfile(updatefile) and os.mtime(os.programfile()) > os.mtime(updatefile)) then - return false + if global.get("network") ~= "private" then + for _, repo in ipairs(repositories()) do + -- repository not found? or xmake has been re-installed + local updatefile = path.join(repo:directory(), "updated") + if not os.isdir(repo:directory()) or (os.isfile(updatefile) and os.mtime(os.programfile()) > os.mtime(updatefile)) then + return false + end end end return true @@ -55,6 +51,7 @@ end function packagedir(packagename, reponame) -- strip trailng ~tag, e.g. zlib~debug + packagename = packagename:lower() if packagename:find('~', 1, true) then packagename = packagename:gsub("~.+$", "") end @@ -68,27 +65,30 @@ function packagedir(packagename, reponame) -- find the package directory from repositories for _, repo in ipairs(repositories()) do - local dir = path.join(repo:directory(), "packages", packagename:sub(1, 1):lower(), packagename) - if os.isdir(dir) and (not reponame or reponame == repo:name()) then + local dir = path.join(repo:directory(), "packages", packagename:sub(1, 1), packagename) + if os.isdir(dir) and os.isfile(path.join(dir, "xmake.lua")) and (not reponame or reponame == repo:name()) then foundir = {dir, repo} break end end - - -- found? if foundir then - - -- save package directory packagedirs[packagename] = foundir - - -- update cache _g._PACKAGEDIRS = packagedirs - - -- ok return foundir[1], foundir[2] end end +-- get artifacts manifest from repositories +function artifacts_manifest(packagename, version) + packagename = packagename:lower() + for _, repo in ipairs(repositories()) do + local manifestfile = path.join(repo:directory(), "packages", packagename:sub(1, 1), packagename, version, "manifest.txt") + if os.isfile(manifestfile) then + return io.load(manifestfile) + end + end +end + -- search package directories from repositories function searchdirs(name) diff --git a/xmake/modules/private/action/require/impl/search_packages.lua b/xmake/modules/private/action/require/impl/search_packages.lua new file mode 100644 index 000000000..00cf1ffbf --- /dev/null +++ b/xmake/modules/private/action/require/impl/search_packages.lua @@ -0,0 +1,54 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file search_packages.lua +-- + +-- search packages from repositories +function _search_packages(name) + + -- get package manager name + local manager_name, package_name = unpack(name:split("::", {plain = true, strict = true})) + if package_name == nil then + package_name = manager_name + manager_name = "xmake" + else + manager_name = manager_name:lower():trim() + end + + -- search packages + local packages = {} + local result = import("package.manager." .. manager_name .. ".search_package", {anonymous = true})(package_name) + if result then + table.join2(packages, result) + end + return packages +end + +-- search packages +function main(names) + + -- search all names + local results = {} + for _, name in ipairs(names) do + local packages = _search_packages(name) + if packages then + results[name] = packages + end + end + return results +end diff --git a/xmake/modules/private/action/require/impl/uninstall_packages.lua b/xmake/modules/private/action/require/impl/uninstall_packages.lua new file mode 100644 index 000000000..a5185f868 --- /dev/null +++ b/xmake/modules/private/action/require/impl/uninstall_packages.lua @@ -0,0 +1,47 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file uninstall_packages.lua +-- + +-- imports +import("core.cache.localcache") +import("private.action.require.impl.package") + +-- uninstall packages +function main(requires, opt) + + -- init options + opt = opt or {} + + -- do not remove dependent packages + opt.nodeps = true + + -- clear the local cache + localcache.clear() + + -- remove all packages + local packages = {} + for _, instance in ipairs(package.load_packages(requires, opt)) do + if os.isfile(instance:manifest_file()) then + table.insert(packages, instance) + end + os.tryrm(instance:installdir()) + end + return packages +end + diff --git a/xmake/actions/require/impl/utils/filter.lua b/xmake/modules/private/action/require/impl/utils/filter.lua index 11bdf70de..75bba1d42 100644 --- a/xmake/actions/require/impl/utils/filter.lua +++ b/xmake/modules/private/action/require/impl/utils/filter.lua @@ -109,7 +109,7 @@ function _handler(package, strval) end -- attach filter to the given script and call it -function call(script, package) +function call(script, package, opt) -- get sandbox filter and handlers of the given script local sandbox_filter = sandbox.filter(script) @@ -122,7 +122,7 @@ function call(script, package) sandbox_filter:register("package", _handler(package)) -- call it - script(package) + script(package, opt) -- restore handlers sandbox_filter:set_handlers(sandbox_handlers) diff --git a/xmake/actions/require/impl/utils/get_requires.lua b/xmake/modules/private/action/require/impl/utils/get_requires.lua index 9a0ad76c1..9a0ad76c1 100644 --- a/xmake/actions/require/impl/utils/get_requires.lua +++ b/xmake/modules/private/action/require/impl/utils/get_requires.lua diff --git a/xmake/modules/private/action/require/impl/utils/url_filename.lua b/xmake/modules/private/action/require/impl/utils/url_filename.lua new file mode 100644 index 000000000..e17e8673b --- /dev/null +++ b/xmake/modules/private/action/require/impl/utils/url_filename.lua @@ -0,0 +1,25 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file url_filename.lua +-- + +-- get filename from url +function main(url) + local urlpath = url:split('?', {plain = true})[1] + return path.filename(urlpath) +end diff --git a/xmake/modules/private/action/require/import.lua b/xmake/modules/private/action/require/import.lua new file mode 100644 index 000000000..cf6cb85c7 --- /dev/null +++ b/xmake/modules/private/action/require/import.lua @@ -0,0 +1,68 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file import.lua +-- + +-- imports +import("core.base.task") +import("core.base.option") +import("private.action.require.impl.repository") +import("private.action.require.impl.environment") +import("private.action.require.impl.import_packages") +import("private.action.require.impl.utils.get_requires") + +-- import the given packages +function main(requires_raw) + + -- enter environment + environment.enter() + + -- pull all repositories first if not exists + if not repository.pulled() then + task.run("repo", {update = true}) + end + + -- get requires and extra config + local requires_extra = nil + local requires, requires_extra = get_requires(requires_raw) + if not requires or #requires == 0 then + return + end + + -- import packages + local packagedir = option.get("packagedir") + local packages = import_packages(requires, {requires_extra = requires_extra, packagedir = packagedir}) + if not packages or #packages == 0 then + if requires_raw then + cprint("${bright}packages(%s) cannot be imported, maybe they don’t exactly match the configuration.", table.concat(requires_raw, ", ")) + if os.getenv("XREPO_WORKING") then + print("please attempt to import them with `-f/--configs=` option, e.g.") + print(" - xrepo import -f \"name=value, ...\" package") + print(" - xrepo import -m debug -k shared -f \"name=value, ...\" package") + else + print("please attempt to import them with `--extra=` option, e.g.") + print(" - xmake require --import --extra=\"{configs={...}}\" package") + print(" - xmake require --import --extra=\"{debug=true,configs={shared=true}}\" package") + end + end + end + + -- leave environment + environment.leave() +end + diff --git a/xmake/actions/require/info.lua b/xmake/modules/private/action/require/info.lua index c5190a5fd..7a6c096c6 100644 --- a/xmake/actions/require/info.lua +++ b/xmake/modules/private/action/require/info.lua @@ -26,19 +26,20 @@ import("core.project.project") import("core.package.package", {alias = "core_package"}) import("devel.git") import("utils.archive") -import("impl.utils.filter") -import("impl.package") -import("impl.repository") -import("impl.environment") -import("impl.utils.get_requires") +import("private.action.require.impl.utils.filter") +import("private.action.require.impl.utils.url_filename") +import("private.action.require.impl.package") +import("private.action.require.impl.repository") +import("private.action.require.impl.environment") +import("private.action.require.impl.utils.get_requires") -- from xmake/system/remote? function _from(instance) local fetchinfo = instance:fetch() if fetchinfo then - if instance:is3rd() then + if instance:is_thirdparty() then return ", ${green}3rd${clear}" - elseif instance:isSys() then + elseif instance:is_system() then return ", ${green}system${clear}" else return "" @@ -46,8 +47,8 @@ function _from(instance) elseif #instance:urls() > 0 then local repo = instance:repo() local reponame = repo and repo:name() or "unknown" - return instance:supported() and format(", ${yellow}remote${clear}(in %s)", reponame) or format(", ${yellow}remote${clear}(${red}unsupported${clear} in %s)", reponame) - elseif instance:isSys() then + return instance:is_supported() and format(", ${yellow}remote${clear}(in %s)", reponame) or format(", ${yellow}remote${clear}(${red}unsupported${clear} in %s)", reponame) + elseif instance:is_system() then return ", ${red}missing${clear}" else return "" @@ -58,7 +59,7 @@ end function _info(instance) local info = instance:version_str() and instance:version_str() or "no version" info = info .. _from(instance) - info = info .. (instance:optional() and ", ${yellow}optional${clear}" or "") + info = info .. (instance:is_optional() and ", ${yellow}optional${clear}" or "") return info end @@ -88,35 +89,40 @@ function main(requires_raw) -- show package name local requireinfo = instance:requireinfo() or {} - cprint(" ${magenta}require${clear}(%s): ", requireinfo.originstr) + cprint(" ${color.dump.string_quote}require${clear}(%s): ", requireinfo.originstr) -- show description local description = instance:get("description") if description then - cprint(" -> ${magenta}description${clear}: %s", description) + cprint(" -> ${color.dump.string_quote}description${clear}: %s", description) end -- show version local version = instance:version_str() if version then - cprint(" -> ${magenta}version${clear}: %s", version) + cprint(" -> ${color.dump.string_quote}version${clear}: %s", version) end -- show license local license = instance:get("license") if license then - cprint(" -> ${magenta}license${clear}: %s", license) + cprint(" -> ${color.dump.string_quote}license${clear}: %s", license) end -- show urls local urls = instance:urls() if urls and #urls > 0 then - cprint(" -> ${magenta}urls${clear}:") + cprint(" -> ${color.dump.string_quote}urls${clear}:") for _, url in ipairs(urls) do print(" -> %s", filter.handle(url, instance)) - local sourcehash = instance:sourcehash(instance:url_alias(url)) - if sourcehash then - cprint(" -> ${yellow}%s", sourcehash) + if git.asgiturl(url) then + local url_alias = instance:url_alias(url) + cprint(" -> ${yellow}%s", instance:revision(url_alias) or instance:tag() or instance:version_str()) + else + local sourcehash = instance:sourcehash(instance:url_alias(url)) + if sourcehash then + cprint(" -> ${yellow}%s", sourcehash) + end end end end @@ -124,13 +130,13 @@ function main(requires_raw) -- show repository local repo = instance:repo() if repo then - cprint(" -> ${magenta}repo${clear}: %s %s %s", repo:name(), repo:url(), repo:branch() or "") + cprint(" -> ${color.dump.string_quote}repo${clear}: %s %s %s", repo:name(), repo:url(), repo:branch() or "") end -- show deps local deps = instance:orderdeps() if deps and #deps > 0 then - cprint(" -> ${magenta}deps${clear}:") + cprint(" -> ${color.dump.string_quote}deps${clear}:") for _, dep in ipairs(deps) do requireinfo = dep:requireinfo() or {} cprint(" -> %s", requireinfo.originstr) @@ -138,32 +144,33 @@ function main(requires_raw) end -- show cache directory - cprint(" -> ${magenta}cachedir${clear}: %s", instance:cachedir()) + cprint(" -> ${color.dump.string_quote}cachedir${clear}: %s", instance:cachedir()) -- show install directory - cprint(" -> ${magenta}installdir${clear}: %s", instance:installdir()) + cprint(" -> ${color.dump.string_quote}installdir${clear}: %s", instance:installdir()) -- show search directories and search names - cprint(" -> ${magenta}searchdirs${clear}: %s", table.concat(table.wrap(core_package.searchdirs()), path.envsep())) + cprint(" -> ${color.dump.string_quote}searchdirs${clear}: %s", table.concat(table.wrap(core_package.searchdirs()), path.envsep())) local searchnames = hashset.new() for _, url in ipairs(instance:urls()) do - if git.checkurl(url) then - searchnames:insert(instance:name() .. archive.extension(url)) - else - searchnames:insert(instance:name() .. "-" .. instance:version_str() .. archive.extension(url)) + url = filter.handle(url, instance) + local extension = archive.extension(url) + if extension then + searchnames:insert(instance:name() .. "-" .. instance:version_str() .. extension) end + searchnames:insert(url_filename(url)) end - cprint(" -> ${magenta}searchnames${clear}: %s", table.concat(searchnames:to_array(), ", ")) + cprint(" -> ${color.dump.string_quote}searchnames${clear}: %s", table.concat(searchnames:to_array(), ", ")) -- show fetch info - cprint(" -> ${magenta}fetchinfo${clear}: %s", _info(instance)) + cprint(" -> ${color.dump.string_quote}fetchinfo${clear}: %s", _info(instance)) local fetchinfo = instance:fetch() if fetchinfo then for name, info in pairs(fetchinfo) do if type(info) ~= "table" then info = tostring(info) end - cprint(" -> ${magenta}%s${clear}: %s", name, table.concat(table.wrap(info), " ")) + cprint(" -> ${color.dump.string_quote}%s${clear}: %s", name, table.concat(table.wrap(info), " ")) end end @@ -177,10 +184,10 @@ function main(requires_raw) else table.insert(platforms, "all") end - cprint(" -> ${magenta}platforms${clear}: %s", table.concat(platforms, ", ")) + cprint(" -> ${color.dump.string_quote}platforms${clear}: %s", table.concat(platforms, ", ")) -- show requires - cprint(" -> ${magenta}requires${clear}:") + cprint(" -> ${color.dump.string_quote}requires${clear}:") cprint(" -> ${cyan}plat${clear}: %s", instance:plat()) cprint(" -> ${cyan}arch${clear}: %s", instance:arch()) local configs_required = instance:configs() @@ -194,7 +201,7 @@ function main(requires_raw) -- show user configs local configs_defined = instance:get("configs") if configs_defined then - cprint(" -> ${magenta}configs${clear}:") + cprint(" -> ${color.dump.string_quote}configs${clear}:") for _, conf in ipairs(configs_defined) do local configs_extra = instance:extraconf("configs", conf) if configs_extra and not configs_extra.builtin then @@ -218,7 +225,7 @@ function main(requires_raw) -- show builtin configs local configs_defined = instance:get("configs") if configs_defined then - cprint(" -> ${magenta}configs (builtin)${clear}:") + cprint(" -> ${color.dump.string_quote}configs (builtin)${clear}:") for _, conf in ipairs(configs_defined) do local configs_extra = instance:extraconf("configs", conf) if configs_extra and configs_extra.builtin then @@ -242,7 +249,7 @@ function main(requires_raw) -- show references local references = instance:references() if references then - cprint(" -> ${magenta}references${clear}:") + cprint(" -> ${color.dump.string_quote}references${clear}:") for projectdir, refdate in pairs(references) do cprint(" -> %s: %s%s", refdate, projectdir, os.isdir(projectdir) and "" or " ${red}(not found)${clear}") end diff --git a/xmake/modules/private/action/require/install.lua b/xmake/modules/private/action/require/install.lua new file mode 100644 index 000000000..821991dee --- /dev/null +++ b/xmake/modules/private/action/require/install.lua @@ -0,0 +1,93 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file install.lua +-- + +-- imports +import("core.base.option") +import("core.base.task") +import("lib.detect.find_tool") +import("private.action.require.impl.package") +import("private.action.require.impl.repository") +import("private.action.require.impl.environment") +import("private.action.require.impl.install_packages") +import("private.action.require.impl.utils.get_requires") + +-- check missing packages +function _check_missing_packages(packages) + + -- get all missing packages + local packages_missing = {} + local optional_missing = {} + for _, instance in ipairs(packages) do + if package.should_install(instance) or (instance:is_fetchonly() and not instance:exists()) then + if instance:is_optional() then + optional_missing[instance:name()] = instance + else + table.insert(packages_missing, instance:name()) + end + end + end + + -- raise tips + if #packages_missing > 0 then + local cmd = "xmake repo -u" + if os.getenv("XREPO_WORKING") then + cmd = "xrepo update-repo" + end + raise("The packages(%s) not found, please run `%s` first!", table.concat(packages_missing, ", "), cmd) + end + + -- save the optional missing packages + _g.optional_missing = optional_missing +end + +-- install packages +function main(requires_raw) + + -- get requires and extra config + local requires_extra = nil + local requires, requires_extra = get_requires(requires_raw) + if not requires or #requires == 0 then + return + end + + -- find git + environment.enter() + local git = find_tool("git") + environment.leave() + + -- pull all repositories first if not exists + -- + -- attempt to install git from the builtin-packages first if git not found + -- + if git and not repository.pulled() then + task.run("repo", {update = true}) + end + + -- install packages + environment.enter() + local packages = install_packages(requires, {requires_extra = requires_extra}) + if packages then + + -- check missing packages + _check_missing_packages(packages) + end + environment.leave() +end + diff --git a/xmake/actions/require/list.lua b/xmake/modules/private/action/require/list.lua index da4f8001c..f24610d42 100644 --- a/xmake/actions/require/list.lua +++ b/xmake/modules/private/action/require/list.lua @@ -21,24 +21,24 @@ -- imports import("core.project.project") import("core.base.task") -import("impl.package") -import("impl.repository") -import("impl.environment") +import("private.action.require.impl.package") +import("private.action.require.impl.repository") +import("private.action.require.impl.environment") -- from xmake/system/remote? function _from(instance) local fetchinfo = instance:fetch() if fetchinfo then - if instance:is3rd() then + if instance:is_thirdparty() then return ", ${green}3rd${clear}" - elseif instance:isSys() then + elseif instance:is_system() then return ", ${green}system${clear}" else return "" end elseif #instance:urls() > 0 then - return instance:supported() and format(", ${yellow}remote${clear}(in %s)", instance:repo():name()) or format(", ${yellow}remote${clear}(${red}unsupported${clear} in %s)", instance:repo():name()) - elseif instance:isSys() then + return instance:is_supported() and format(", ${yellow}remote${clear}(in %s)", instance:repo():name()) or format(", ${yellow}remote${clear}(${red}unsupported${clear} in %s)", instance:repo():name()) + elseif instance:is_system() then return ", ${red}missing${clear}" else return "" @@ -49,7 +49,7 @@ end function _info(instance) local info = instance:version_str() and instance:version_str() or "no version" info = info .. _from(instance) - info = info .. (instance:optional() and ", ${yellow}optional${clear}" or "") + info = info .. (instance:is_optional() and ", ${yellow}optional${clear}" or "") return info end @@ -75,14 +75,18 @@ function main() -- list all required packages for _, instance in ipairs(package.load_packages(requires, {requires_extra = requires_extra})) do - cprint(" ${magenta}require${clear}(%s): %s", instance:requireinfo().originstr, _info(instance)) + cprint(" ${color.dump.string_quote}require${clear}(%s): %s", instance:requireinfo().originstr, _info(instance)) for _, dep in ipairs(instance:orderdeps()) do - cprint(" -> ${magenta}dep${clear}(%s): %s", dep:requireinfo().originstr, _info(dep)) + cprint(" -> ${color.dump.string_quote}dep${clear}(%s): %s", dep:requireinfo().originstr, _info(dep)) end local fetchinfo = instance:fetch() if fetchinfo then for name, info in pairs(fetchinfo) do - cprint(" -> ${magenta}%s${clear}: %s", name, table.concat(table.wrap(info), " ")) + if type(info) == "table" then + cprint(" -> ${color.dump.string_quote}%s${clear}: %s", name, table.concat(info, " ")) + else + cprint(" -> ${color.dump.string_quote}%s${clear}: %s", name, tostring(info)) + end end end end diff --git a/xmake/actions/require/scan.lua b/xmake/modules/private/action/require/scan.lua index a038f9f9e..d098cc22b 100644 --- a/xmake/actions/require/scan.lua +++ b/xmake/modules/private/action/require/scan.lua @@ -33,7 +33,7 @@ function _scan_package(packagedir) local package_name = path.filename(packagedir) for _, versiondir in ipairs(os.dirs(path.join(packagedir, "*"))) do local version = path.filename(versiondir) - cprint("${magenta}%s-%s${clear}:", package_name, version) + cprint("${color.dump.string}%s-%s${clear}:", package_name, version) -- show package hash for _, hashdir in ipairs(os.dirs(path.join(versiondir, "*"))) do diff --git a/xmake/actions/require/search.lua b/xmake/modules/private/action/require/search.lua index 0055d620e..3d8fb573c 100644 --- a/xmake/actions/require/search.lua +++ b/xmake/modules/private/action/require/search.lua @@ -20,10 +20,10 @@ -- imports import("core.base.task") -import("impl.utils.filter") -import("impl.package") -import("impl.repository") -import("impl.environment") +import("private.action.require.impl.utils.filter") +import("private.action.require.impl.repository") +import("private.action.require.impl.environment") +import("private.action.require.impl.search_packages") -- search the given packages function main(names) @@ -45,16 +45,19 @@ function main(names) print("The package names:") -- search packages - for name, packages in pairs(package.search_packages(names)) do + for name, packages in pairs(search_packages(names)) do if #packages > 0 then -- show name print(" %s: ", name) -- show packages - for _, instance in ipairs(packages) do - local repo = instance:repo() - cprint(" -> ${magenta}%s${clear}: %s %s", instance:name(), instance:get("description") or "", repo and ("(in " .. repo:name() .. ")") or "") + for _, result in ipairs(packages) do + local name = result.name + local version = result.version + local reponame = result.reponame + local description = result.description + cprint(" -> ${color.dump.string}%s%s${clear}: %s %s", name, version and ("-" .. version) or "", description or "", reponame and ("(in " .. reponame .. ")") or "") end end end diff --git a/xmake/actions/require/uninstall.lua b/xmake/modules/private/action/require/uninstall.lua index 4b2d9e198..b3c2d1bce 100644 --- a/xmake/actions/require/uninstall.lua +++ b/xmake/modules/private/action/require/uninstall.lua @@ -21,10 +21,10 @@ -- imports import("core.base.task") import("core.base.option") -import("impl.package") -import("impl.repository") -import("impl.environment") -import("impl.utils.get_requires") +import("private.action.require.impl.repository") +import("private.action.require.impl.environment") +import("private.action.require.impl.uninstall_packages") +import("private.action.require.impl.utils.get_requires") -- uninstall the given packages function main(requires_raw) @@ -45,7 +45,7 @@ function main(requires_raw) end -- uninstall packages - local packages = package.uninstall_packages(requires, {requires_extra = requires_extra}) + local packages = uninstall_packages(requires, {requires_extra = requires_extra}) for _, instance in ipairs(packages) do print("uninstall: %s%s ok!", instance:name(), instance:version_str() and ("-" .. instance:version_str()) or "") end diff --git a/xmake/modules/private/action/run/make_runenvs.lua b/xmake/modules/private/action/run/make_runenvs.lua index bb40e57f3..2ca69c033 100644 --- a/xmake/modules/private/action/run/make_runenvs.lua +++ b/xmake/modules/private/action/run/make_runenvs.lua @@ -49,7 +49,7 @@ function _make_runpath_on_windows(target) end end for _, dep in ipairs(target:orderdeps()) do - if dep:targetkind() == "shared" then + if dep:kind() == "shared" then insert(dep:targetdir()) end end diff --git a/xmake/modules/private/action/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua index ae0f532ae..14434f1c5 100644 --- a/xmake/modules/private/action/trybuild/autotools.lua +++ b/xmake/modules/private/action/trybuild/autotools.lua @@ -223,7 +223,7 @@ function build() if os.isfile("autogen.sh") then os.vexecv("sh", {"./autogen.sh"}) elseif os.isfile("configure.ac") then - os.vexec("autoreconf --install --symlink") + os.vexecv("sh", {"autoreconf", "--install", "--symlink"}) end end diff --git a/xmake/modules/private/async/jobpool.lua b/xmake/modules/private/async/jobpool.lua index eb7d5ffc1..299700534 100644 --- a/xmake/modules/private/async/jobpool.lua +++ b/xmake/modules/private/async/jobpool.lua @@ -39,10 +39,11 @@ end -- -- @param name the job name -- @param run the run command/script --- @param rootjob the root job node (optional) +-- @param opt the options (rootjob) -- -function jobpool:addjob(name, run, rootjob) - return self:add({name = name, run = run}, rootjob) +function jobpool:addjob(name, run, opt) + opt = opt or {} + return self:add({name = name, run = run}, opt.rootjob) end -- add job to the given job node diff --git a/xmake/modules/private/async/runjobs.lua b/xmake/modules/private/async/runjobs.lua index 69991578a..0361399dc 100644 --- a/xmake/modules/private/async/runjobs.lua +++ b/xmake/modules/private/async/runjobs.lua @@ -46,7 +46,7 @@ end -- for i = 1, 3 do -- local job = jobs:addjob("job/" .. i, function (idx, total) -- print(idx, total) --- end, root) +-- end, {rootjob = root}) -- end -- runjobs("test", jobs, {comax = 6, timeout = 1000, on_timer = function (running_jobs_indices) end}) -- @@ -56,7 +56,7 @@ function main(name, jobs, opt) -- init options op = opt or {} local total = opt.total or (type(jobs) == "table" and jobs:size()) or 1 - local comax = opt.comax or total + local comax = opt.comax or math.min(total, 4) local timeout = opt.timeout or 500 local group_name = name local jobs_cb = type(jobs) == "function" and jobs or nil @@ -73,59 +73,78 @@ function main(name, jobs, opt) progress_helper = progress.new(nil, opt) end + -- isolate environments + local is_isolated = false + local co_running = scheduler.co_running() + if co_running and opt.isolate then + is_isolated = co_running:is_isolated() + co_running:isolate(true) + end + -- run timer local stop = false - local running_jobs_indices + local running_jobs_indices = {} + local group_timer if opt.on_timer then - scheduler.co_start_named(name .. "/timer", function () - while not stop do - os.sleep(timeout) - if not stop then - opt.on_timer(running_jobs_indices) + group_timer = group_name .. "/timer" + scheduler.co_group_begin(group_timer, function (co_group) + scheduler.co_start_withopt({name = name .. "/timer", isolate = opt.isolate}, function () + while not stop do + os.sleep(timeout) + if not stop then + local indices + if running_jobs_indices then + indices = table.keys(running_jobs_indices) + end + opt.on_timer(indices) + end end - end + end) end) elseif showprogress then - scheduler.co_start_named(name .. "/tips", function () - while not stop do - os.sleep(timeout) - if not stop then + group_timer = group_name .. "/timer" + scheduler.co_group_begin(group_timer, function (co_group) + scheduler.co_start_withopt({name = name .. "/tips", isolate = opt.isolate}, function () + while not stop do + os.sleep(timeout) + if not stop then - -- show waitchars - local tips = nil - local waitobjs = scheduler.co_group_waitobjs(group_name) - if waitobjs:size() > 0 then - local names = {} - for _, obj in waitobjs:keys() do - if obj:otype() == scheduler.OT_PROC then - table.insert(names, obj:name()) - elseif obj:otype() == scheduler.OT_SOCK then - table.insert(names, "sock") - elseif obj:otype() == scheduler.OT_PIPE then - table.insert(names, "pipe") + -- show waitchars + local tips = nil + local waitobjs = scheduler.co_group_waitobjs(group_name) + if waitobjs:size() > 0 then + local names = {} + for _, obj in waitobjs:keys() do + if obj:otype() == scheduler.OT_PROC then + table.insert(names, obj:name()) + elseif obj:otype() == scheduler.OT_SOCK then + table.insert(names, "sock") + elseif obj:otype() == scheduler.OT_PIPE then + table.insert(names, "pipe") + end end - end - names = table.unique(names) - if #names > 0 then - names = table.concat(names, ",") - if #names > 16 then - names = names:sub(1, 16) .. ".." + names = table.unique(names) + if #names > 0 then + names = table.concat(names, ",") + if #names > 16 then + names = names:sub(1, 16) .. ".." + end + tips = string.format("(%d/%s)", waitobjs:size(), names) end - tips = string.format("(%d/%s)", waitobjs:size(), names) end - end - -- print back characters - progress_helper:clear() - _print_backchars(backnum) + -- print back characters + progress_helper:clear() + _print_backchars(backnum) - if tips then - cprintf("${dim}%s${clear} ", tips) - backnum = #tips + 1 + if tips then + cprintf("${dim}%s${clear} ", tips) + backnum = #tips + 1 + end + progress_helper:write() end - progress_helper:write() end - end + end) end) end @@ -137,7 +156,6 @@ function main(name, jobs, opt) local priority_curr = 0 local job_pending = nil while index < total do - running_jobs_indices = {} scheduler.co_group_begin(group_name, function (co_group) local freemax = comax - #co_group local max = math.min(index + freemax, total) @@ -178,11 +196,11 @@ function main(name, jobs, opt) -- start this job index = index + 1 - table.insert(running_jobs_indices, index) - scheduler.co_start_named(name .. '/' .. jobname, function(i) + scheduler.co_start_withopt({name = name .. '/' .. jobname, isolate = opt.isolate}, function(i) try { function() + running_jobs_indices[i] = i if jobfunc then if opt.curdir then os.cd(opt.curdir) @@ -190,6 +208,7 @@ function main(name, jobs, opt) jobfunc(count_as_index and count or i, total) count = count + 1 end + running_jobs_indices[i] = nil end, catch { @@ -218,7 +237,7 @@ function main(name, jobs, opt) end end) - -- need only one jobs exited if be same priority + -- need only one job exited if be same priority if priority_curr == priority_prev then scheduler.co_group_wait(group_name, {limit = 1}) else @@ -231,8 +250,16 @@ function main(name, jobs, opt) -- wait all jobs exited scheduler.co_group_wait(group_name) - -- stop timer - stop = true + -- wait timer job exited + if group_timer then + stop = true + scheduler.co_group_wait(group_timer) + end + + -- restore isolated environments + if co_running and opt.isolate then + co_running:isolate(is_isolated) + end -- remove wait charactor if showprogress then diff --git a/xmake/modules/private/detect/find_platform.lua b/xmake/modules/private/detect/find_platform.lua index 3a02fbd62..590ff9b11 100644 --- a/xmake/modules/private/detect/find_platform.lua +++ b/xmake/modules/private/detect/find_platform.lua @@ -83,7 +83,7 @@ function _find_arch(plat, arch) if not arch then if plat == "android" then arch = "armeabi-v7a" - elseif plat == "iphoneos" then + elseif plat == "iphoneos" or plat == "appletvos" then arch = "arm64" elseif plat == "watchos" then arch = "armv7k" diff --git a/xmake/modules/private/diagnosis/dump_targets.lua b/xmake/modules/private/diagnosis/dump_targets.lua index b9cc4be5f..c992a28f0 100644 --- a/xmake/modules/private/diagnosis/dump_targets.lua +++ b/xmake/modules/private/diagnosis/dump_targets.lua @@ -42,7 +42,7 @@ end function main(targetname) config.load() for _, target in ipairs(_get_targets(targetname)) do - cprint("${bright}target(%s):${clear} %s", target:name(), target:targetkind()) + cprint("${bright}target(%s):${clear} %s", target:name(), target:kind()) local deps = target:get("deps") if deps then cprint(" ${color.dump.string}deps:") diff --git a/xmake/modules/private/tools/codesign.lua b/xmake/modules/private/tools/codesign.lua index f74c36f5b..42ca094bc 100644 --- a/xmake/modules/private/tools/codesign.lua +++ b/xmake/modules/private/tools/codesign.lua @@ -48,16 +48,17 @@ function codesign_identities() local identities = _g.identities if identities == nil then identities = {} - local results = try { function() return os.iorun("/usr/bin/security find-identity -v -p codesigning") end } - if not results then - results = try { function() return os.iorun("/usr/bin/security find-identity") end } - if results then - local splitinfo = results:split("Valid identities only", {plain = true}) - if splitinfo and #splitinfo > 1 then - results = splitinfo[2] - end + local results = try { function() return os.iorun("/usr/bin/security find-identity") end } + if results then + local splitinfo = results:split("Valid identities only", {plain = true}) + if splitinfo and #splitinfo > 1 then + results = splitinfo[2] end end + if not results then + -- it may be slower + results = try { function() return os.iorun("/usr/bin/security find-identity -v -p codesigning") end } + end if results then for _, line in ipairs(results:split('\n', {plain = true})) do local sign, identity = line:match("%) (%w+) \"(.+)\"") diff --git a/xmake/modules/private/tools/gcc/parse_deps.lua b/xmake/modules/private/tools/gcc/parse_deps.lua index 0cb2ad4af..cb06d091c 100644 --- a/xmake/modules/private/tools/gcc/parse_deps.lua +++ b/xmake/modules/private/tools/gcc/parse_deps.lua @@ -60,10 +60,16 @@ function main(depsdata) local results = hashset.new() local projectdir = os.projectdir() local line = depsdata:rtrim() -- maybe there will be an empty newline at the end. so we trim it first - line = line:gsub("\\ ", space_placeholder) - for _, includefile in ipairs(line:split(' ', {plain = true})) do -- it will trim all internal spaces without `{strict = true}` + local plain = {plain = true} + line = line:replace("\\ ", space_placeholder, plain) + for _, includefile in ipairs(line:split(' ', plain)) do -- it will trim all internal spaces without `{strict = true}` + -- some gcc toolchains will some invalid paths (e.g. `d\:\xxx`), we need fix it + -- https://github.com/xmake-io/xmake/issues/1196 + if is_host("windows") and includefile:match("^%w\\:") then + includefile = includefile:replace("\\:", ":", plain) + end if not includefile:endswith(":") then -- ignore "xxx.o:" prefix - includefile = includefile:gsub(space_placeholder, ' ') + includefile = includefile:replace(space_placeholder, ' ', plain) if #includefile > 0 then includefile = _normailize_dep(includefile, projectdir) if includefile then diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua new file mode 100644 index 000000000..371735321 --- /dev/null +++ b/xmake/modules/private/utils/batchcmds.lua @@ -0,0 +1,343 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file batchcmds.lua +-- + +-- imports +import("core.base.option") +import("core.base.object") +import("core.base.tty") +import("core.base.colors") +import("core.project.depend") +import("core.theme.theme") +import("core.tool.linker") +import("core.tool.compiler") +import("core.language.language") +import("private.utils.progress", {alias = "progress_utils"}) + +-- define module +local batchcmds = batchcmds or object { _init = {"_TARGET", "_CMDS", "_DEPS", "_tip"}} + +-- show text +function _show(showtext, progress) + if option.get("verbose") then + cprint(showtext) + else + local is_scroll = _g.is_scroll + if is_scroll == nil then + is_scroll = theme.get("text.build.progress_style") == "scroll" + _g.is_scroll = is_scroll + end + if is_scroll then + cprint(showtext) + else + tty.erase_line_to_start().cr() + local msg = showtext + local msg_plain = colors.translate(msg, {plain = true}) + local maxwidth = os.getwinsize().width + if #msg_plain <= maxwidth then + cprintf(msg) + else + -- windows width is too small? strip the partial message in middle + local partlen = math.floor(maxwidth / 2) - 3 + local sep = msg_plain:sub(partlen + 1, #msg_plain - partlen - 1) + local split = msg:split(sep, {plain = true, strict = true}) + cprintf(table.concat(split, "...")) + end + if math.floor(progress) == 100 then + print("") + _g.showing_without_scroll = false + else + _g.showing_without_scroll = true + end + io.flush() + end + end +end + +-- run command: show +function _runcmd_show(cmd, opt) + local showtext = cmd.showtext + if showtext then + _show(showtext, cmd.progress) + end +end + +-- run command: os.runv +function _runcmd_runv(cmd, opt) + if cmd.program then + if not opt.dryrun then + os.runv(cmd.program, cmd.argv, cmd.opt) + end + end +end + +-- run command: os.vrunv +function _runcmd_vrunv(cmd, opt) + if cmd.program then + if opt.dryrun then + vprint(os.args(table.join(cmd.program, cmd.argv))) + else + os.vrunv(cmd.program, cmd.argv, cmd.opt) + end + end +end + +-- run command: os.execv +function _runcmd_execv(cmd, opt) + if cmd.program then + if opt.dryrun then + print(os.args(table.join(cmd.program, cmd.argv))) + else + os.execv(cmd.program, cmd.argv, cmd.opt) + end + end +end + +-- run command: os.mkdir +function _runcmd_mkdir(cmd, opt) + local dir = cmd.dir + if not opt.dryrun and not os.isdir(dir) then + os.mkdir(dir) + end +end + +-- run command: os.rm +function _runcmd_rm(cmd, opt) + local filepath = cmd.filepath + if not opt.dryrun then + os.tryrm(filepath) + end +end + +-- run command: os.cp +function _runcmd_cp(cmd, opt) + if not opt.dryrun then + os.cp(opt.srcpath, opt.dstpath, opt.opt) + end +end + +-- run command: os.mv +function _runcmd_mv(cmd, opt) + if not opt.dryrun then + os.mv(opt.srcpath, opt.dstpath, opt.opt) + end +end + +-- run command: os.ln +function _runcmd_ln(cmd, opt) + if not opt.dryrun then + os.ln(opt.srcpath, opt.dstpath, opt.opt) + end +end + +-- run command +function _runcmd(cmd, opt) + local kind = cmd.kind + local maps = _g.maps + if not maps then + maps = + { + show = _runcmd_show, + runv = _runcmd_runv, + vrunv = _runcmd_vrunv, + execv = _runcmd_execv, + mkdir = _runcmd_mkdir, + rm = _runcmd_rm, + cp = _runcmd_cp, + mv = _runcmd_mv, + ln = _runcmd_ln + } + _g.maps = maps + end + local script = maps[kind] + if script then + script(cmd, opt) + end +end + +-- run commands +function _runcmds(cmds, opt) + for _, cmd in ipairs(cmds) do + _runcmd(cmd, opt) + end +end + +-- is empty? no commands +function batchcmds:empty() + return #self:cmds() == 0 +end + +-- get commands +function batchcmds:cmds() + return self._CMDS +end + +-- add command: os.runv +function batchcmds:runv(program, argv, opt) + table.insert(self:cmds(), {kind = "runv", program = program, argv = argv, opt = opt}) + self:add_depvalues(program, argv) +end + +-- add command: os.vrunv +function batchcmds:vrunv(program, argv, opt) + table.insert(self:cmds(), {kind = "vrunv", program = program, argv = argv, opt = opt}) + self:add_depvalues(program, argv) +end + +-- add command: os.execv +function batchcmds:execv(program, argv, opt) + table.insert(self:cmds(), {kind = "execv", program = program, argv = argv, opt = opt}) + self:add_depvalues(program, argv) +end + +-- add command: compiler.compile +function batchcmds:compile(sourcefiles, objectfile, opt) + + -- bind target if exists + opt = opt or {} + opt.target = self._TARGET + + -- load compiler and get compilation command + local sourcekind = opt.sourcekind + if not sourcekind and type(sourcefiles) == "string" then + sourcekind = language.sourcekind_of(sourcefiles) + end + local compiler_inst = compiler.load(sourcekind, opt) + local program, argv = compiler_inst:compargv(sourcefiles, objectfile, opt) + + -- add compilation command and bind run environments of compiler + self:mkdir(path.directory(objectfile)) + self:vrunv(program, argv, {envs = table.join(compiler_inst:runenvs(), opt.envs)}) +end + +-- add command: linker.link +function batchcmds:link(objectfiles, targetfile, opt) + + -- bind target if exists + local target = self._TARGET + opt = opt or {} + opt.target = target + + -- load linker and get link command + local linker_inst = target and target:linker() or linker.load(opt.targetkind, opt.sourcekinds, opt) + local program, argv = linker_inst:linkargv(objectfiles, targetfile, opt) + + -- add link command and bind run environments of linker + self:mkdir(path.directory(targetfile)) + self:vrunv(program, argv, {envs = table.join(linker_inst:runenvs(), opt.envs)}) +end + +-- add command: os.mkdir +function batchcmds:mkdir(dir) + table.insert(self:cmds(), {kind = "mkdir", dir = dir}) +end + +-- add command: os.rm +function batchcmds:rm(filepath) + table.insert(self:cmds(), {kind = "rm", filepath = filepath}) +end + +-- add command: os.cp +function batchcmds:cp(srcpath, dstpath, opt) + table.insert(self:cmds(), {kind = "cp", srcpath = srcpath, dstpath = dstpath, opt = opt}) +end + +-- add command: os.mv +function batchcmds:mv(srcpath, dstpath, opt) + table.insert(self:cmds(), {kind = "mv", srcpath = srcpath, dstpath = dstpath, opt = opt}) +end + +-- add command: os.ln +function batchcmds:ln(srcpath, dstpath, opt) + table.insert(self:cmds(), {kind = "ln", srcpath = srcpath, dstpath = dstpath, opt = opt}) +end + +-- add command: show +function batchcmds:show(format, ...) + local showtext = string.format(format, ...) + table.insert(self:cmds(), {kind = "show", showtext = showtext}) +end + +-- add command: show progress +function batchcmds:show_progress(progress, format, ...) + if progress then + local showtext = progress_utils.text(progress, format, ...) + table.insert(self:cmds(), {kind = "show", showtext = showtext, progress = progress}) + end +end + +-- get deps +function batchcmds:deps() + return self._DEPS +end + +-- add dependent files +function batchcmds:add_depfiles(...) + local deps = self._DEPS or {} + deps.files = deps.files or {} + table.join2(deps.files, ...) + self._DEPS = deps +end + +-- add dependent values +function batchcmds:add_depvalues(...) + local deps = self._DEPS or {} + deps.values = deps.values or {} + table.join2(deps.values, ...) + self._DEPS = deps +end + +-- set the last mtime of dependent files and values +function batchcmds:set_depmtime(lastmtime) + local deps = self._DEPS or {} + deps.lastmtime = lastmtime + self._DEPS = deps +end + +-- set cache file of depend info +function batchcmds:set_depcache(cachefile) + local deps = self._DEPS or {} + deps.dependfile = cachefile + self._DEPS = deps +end + +-- run cmds +function batchcmds:runcmds(opt) + opt = opt or {} + if self:empty() then + return + end + local deps = self:deps() + if deps and deps.files then + depend.on_changed(function () + _runcmds(self:cmds(), opt) + end, self:deps()) + else + _runcmds(self:cmds(), opt) + end +end + +-- new a batch commands for rule/xx_xxcmd_xxx() +-- +-- @params opt options, e.g. {target = ..} +-- +function new(opt) + opt = opt or {} + return batchcmds {_TARGET = opt.target, _CMDS = {}} +end diff --git a/xmake/modules/private/utils/complete_helper.lua b/xmake/modules/private/utils/complete_helper.lua index 89b542d30..386f50194 100644 --- a/xmake/modules/private/utils/complete_helper.lua +++ b/xmake/modules/private/utils/complete_helper.lua @@ -42,7 +42,7 @@ function runable_targets() local targets = project.targets() local runable = {} for k, v in pairs(targets) do - if v:script("run") or v:get("kind") == "binary" then + if v:script("run") or v:is_binary() then table.insert(runable, k) end end diff --git a/xmake/modules/private/utils/progress.lua b/xmake/modules/private/utils/progress.lua index e00b4ab57..5c08cbf8f 100644 --- a/xmake/modules/private/utils/progress.lua +++ b/xmake/modules/private/utils/progress.lua @@ -111,6 +111,16 @@ function show(progress, format, ...) end end +-- get the message text with process +function text(progress, format, ...) + local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} " + if option.get("verbose") then + return string.format(progress_prefix .. "${dim}" .. format, progress, ...) + else + return string.format(progress_prefix .. format, progress, ...) + end +end + -- build a progress indicator -- @params stream - stream to write to, will use io.stdout if not provided -- @params opt - options diff --git a/xmake/modules/private/utils/trim_trailing_spaces.lua b/xmake/modules/private/utils/trim_trailing_spaces.lua new file mode 100644 index 000000000..b40371c39 --- /dev/null +++ b/xmake/modules/private/utils/trim_trailing_spaces.lua @@ -0,0 +1,13 @@ +function main(pattern) + for _, filepath in ipairs(os.files(pattern)) do + local filedata = io.readfile(filepath) + if filedata then + local filedata2 = {} + for _, line in ipairs(filedata:split('\n', {strict = true})) do + line = line:rtrim() + table.insert(filedata2, line) + end + io.writefile(filepath, table.concat(filedata2, "\n")) + end + end +end diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index f40dc3f6c..cb6936006 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -20,8 +20,14 @@ -- imports import("core.base.option") +import("core.base.task") +import("core.base.hashset") import("core.project.config") -import("actions.require.impl.package", {rootdir = os.programdir()}) +import("core.project.project") +import("core.tool.toolchain") +import("lib.detect.find_tool") +import("private.action.require.impl.package") +import("private.action.require.impl.utils.get_requires") -- get menu options function menu_options() @@ -46,11 +52,15 @@ function menu_options() {'b', "packages", "kv", nil, "Set the packages to be bound", "e.g.", " - xrepo env -b \"python 3.x\" python", + " - xrepo env -b \"llvm 11.x\" bash", + " $ clang --version", " - xrepo env -p android -b \"zlib,luajit 2.x\" luajit xx.lua"}, {}, {nil, "program", "v", nil, "Set the program name to be run", "e.g.", " - xrepo env", + " - xrepo env bash", + " - xrepo env shell (it will load bash/sh/cmd automatically)", " - xrepo env python", " - xrepo env -p android luajit xx.lua"}, {nil, "arguments", "vs", nil, "Set the program arguments to be run"} @@ -146,8 +156,26 @@ function _enter_project() config.load() end +-- remove repeat environment values +function _remove_repeat_pathenv(value) + if value then + local itemset = {} + local results = {} + for _, item in ipairs(path.splitenv(value)) do + if not itemset[item] then + table.insert(results, item) + itemset[item] = true + end + end + if #results > 0 then + value = path.joinenv(results) + end + end + return value +end + -- add values to environment variable -function _package_addenv(envs, name, ...) +function _addenvs(envs, name, ...) local values = {...} if #values > 0 then local oldenv = envs[name] @@ -164,57 +192,160 @@ end function _package_addenvs(envs, instance) -- only for xmake::package - if instance:isSys() then + if instance:is_system() then return end - -- add run envs, e.g. PATH, LD_LIBRARY_PATH, .. + -- add run envs, e.g. PATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH local installdir = instance:installdir() for name, values in pairs(instance:envs()) do if name == "PATH" or name == "LD_LIBRARY_PATH" or name == "DYLD_LIBRARY_PATH" then for _, value in ipairs(values) do if path.is_absolute(value) then - _package_addenv(envs, name, value) + _addenvs(envs, name, value) else - _package_addenv(envs, name, path.join(installdir, value)) + _addenvs(envs, name, path.join(installdir, value)) end end else - _package_addenv(envs, name, unpack(table.wrap(values))) + _addenvs(envs, name, unpack(table.wrap(values))) end end - -- add library envs, e.g. ACLOCAL_PATH, PKG_CONFIG_PATH .. - if instance:kind() ~= "binary" then + -- add library envs, e.g. ACLOCAL_PATH, PKG_CONFIG_PATH, CMAKE_PREFIX_PATH + if instance:is_library() then local pkgconfig = path.join(installdir, "lib", "pkgconfig") if os.isdir(pkgconfig) then - _package_addenv(envs, "PKG_CONFIG_PATH", pkgconfig) + _addenvs(envs, "PKG_CONFIG_PATH", pkgconfig) end pkgconfig = path.join(installdir, "share", "pkgconfig") if os.isdir(pkgconfig) then - _package_addenv(envs, "PKG_CONFIG_PATH", pkgconfig) + _addenvs(envs, "PKG_CONFIG_PATH", pkgconfig) end local aclocal = path.join(installdir, "share", "aclocal") if os.isdir(aclocal) then - _package_addenv(envs, "ACLOCAL_PATH", aclocal) + _addenvs(envs, "ACLOCAL_PATH", aclocal) + end + _addenvs(envs, "CMAKE_PREFIX_PATH", installdir) + end +end + +-- add toolcjhain environments +function _toolchain_addenvs(envs) + for _, name in ipairs(project.get("target.toolchains")) do + local toolchain_opt = project.extraconf("target.toolchains", name) + local toolchain_inst = toolchain.load(name, toolchain_opt) + if toolchain_inst then + for k, v in pairs(toolchain_inst:runenvs()) do + _addenvs(envs, k, unpack(path.splitenv(v))) + end end - _package_addenv(envs, "CMAKE_PREFIX_PATH", installdir) end end -- get package environments function _package_getenvs() local envs = os.getenvs() - local packages = option.get("packages") or option.get("program") - if packages then - _enter_project() - packages = packages:split(',', {plain = true}) - local requires, requires_extra = _get_requires(packages) + if os.isfile(os.projectfile()) and not option.get("packages") then + task.run("config", {target = "all"}, {disable_dump = true}) + _toolchain_addenvs(envs) + local requires, requires_extra = get_requires() for _, instance in ipairs(package.load_packages(requires, {requires_extra = requires_extra})) do _package_addenvs(envs, instance) end + else + local packages = option.get("packages") or option.get("program") + if packages then + _enter_project() + packages = packages:split(',', {plain = true}) + local requires, requires_extra = _get_requires(packages) + for _, instance in ipairs(package.load_packages(requires, {requires_extra = requires_extra})) do + _package_addenvs(envs, instance) + end + end + end + local results = {} + for k, v in pairs(envs) do + results[k] = _remove_repeat_pathenv(v) + end + return results +end + +-- get environment setting script +function _get_env_script(envs, shell, del) + local prefix = "" + local connector = "=" + local suffix = "" + local default = "" + if shell == "powershell" or shell == "pwsh" then + prefix = "[Environment]::SetEnvironmentVariable('" + connector = "','" + suffix = "')" + default = "$Null" + elseif shell == "cmd" then + prefix = "@set \"" + suffix = "\"" + end + local ret = "" + if del then + for name, _ in pairs(envs) do + ret = ret .. prefix .. name .. connector .. default .. suffix .. "\n" + end + else + for name, value in pairs(envs) do + ret = ret .. prefix .. name .. connector .. value .. suffix .. "\n" + end + end + return ret +end + +-- get information of current virtual environment +function info(key) + if key == "prompt" then + assert(os.isfile(os.projectfile()), "xmake.lua not found!") + print("[%s]", path.filename(os.projectdir())) + elseif key == "envfile" then + print(os.tmpfile()) + elseif key == "config" then + if os.isfile(os.projectfile()) then + task.run("config", {target = "all"}, {disable_dump = true}) + end + elseif key:startswith("script.") then + local shell = key:match("script%.(.+)") + print(_get_env_script(_package_getenvs(), shell, false)) + elseif key:startswith("backup.") then + local shell = key:match("backup%.(.+)") + + -- remove current environment variables first + print(_get_env_script(_package_getenvs(), shell, true)) + print(_get_env_script(os.getenvs(), shell, false)) + end +end + +-- run shell +function _run_shell(envs) + local shell = os.shell() + local projectname = path.filename(os.projectdir()) + if shell == "pwsh" or shell == "powershell" then + os.execv("pwsh", option.get("arguments"), {envs = envs}) + elseif shell:endswith("sh") then + local prompt = "[" .. projectname .. "] " + local ps1 = os.getenv("PS1") + if ps1 then + prompt = prompt .. ps1 + elseif is_host("macosx") then + prompt = prompt .. "\\W > " + else + prompt = prompt .. "> " + end + os.execv(shell, option.get("arguments"), {envs = table.join({PS1 = prompt}, envs)}) + elseif shell == "cmd" or is_host("windows") then + local prompt = "[" .. projectname .. "] $P$G" + local args = table.join({"/k", "set PROMPT=[" .. projectname .. "] $P$G"}, option.get("arguments")) + os.execv("cmd", args, {envs = envs}) + else + assert("shell not found!") end - return envs end -- main entry @@ -225,7 +356,11 @@ function main() if envs and envs.PATH then os.setenv("PATH", envs.PATH) end - os.execv(program, option.get("arguments"), {envs = envs}) + if program == "shell" then + _run_shell(envs) + else + os.execv(program, option.get("arguments"), {envs = envs}) + end else print(envs) end diff --git a/xmake/modules/private/xrepo/action/export.lua b/xmake/modules/private/xrepo/action/export.lua index 8295e962a..4c2e8c445 100644 --- a/xmake/modules/private/xrepo/action/export.lua +++ b/xmake/modules/private/xrepo/action/export.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.base.task") -- get menu options function menu_options() @@ -41,7 +42,8 @@ function menu_options() " - xrepo export -f \"vs_runtime=MD\" zlib", " - xrepo export -f \"regex=true,thread=true\" boost"}, {}, - {'o', "outputdir", "kv", "packages","Set the exported packages directory."}, + {nil, "shallow", "k", nil, "Does not export dependent packages."}, + {'o', "packagedir", "kv", "packages","Set the exported packages directory."}, {nil, "packages", "vs", nil, "The packages list.", "e.g.", " - xrepo export zlib boost", @@ -120,12 +122,15 @@ function _export_packages(packages) if option.get("diagnosis") then table.insert(require_argv, "-D") end - local outputdir = option.get("outputdir") - if outputdir and not path.is_absolute(outputdir) then - outputdir = path.absolute(outputdir, oldir) + if option.get("shallow") then + table.insert(require_argv, "--shallow") end - if outputdir then - table.insert(require_argv, "--exportdir=" .. outputdir) + local packagedir = option.get("packagedir") + if packagedir and not path.is_absolute(packagedir) then + packagedir = path.absolute(packagedir, oldir) + end + if packagedir then + table.insert(require_argv, "--packagedir=" .. packagedir) end local extra = {system = false} if mode == "debug" then @@ -153,11 +158,59 @@ function _export_packages(packages) os.vexecv("xmake", require_argv) end +-- export packages in current project +function _export_current_packages(packages) + + -- do export + local require_argv = {export = true} + if option.get("yes") then + require_argv.yes = true + end + if option.get("verbose") then + require_argv.verbose = true + end + if option.get("diagnosis") then + require_argv.diagnosis = true + end + local packagedir = option.get("packagedir") + if packagedir and not path.is_absolute(packagedir) then + packagedir = path.absolute(packagedir, oldir) + end + if packagedir then + require_argv.packagedir = packagedir + end + local extra = {system = false} + if mode == "debug" then + extra.debug = true + end + if kind == "shared" then + extra.configs = extra.configs or {} + extra.configs.shared = true + end + local configs = option.get("configs") + if configs then + extra.configs = extra.configs or {} + local extra_configs, errors = ("{" .. configs .. "}"):deserialize() + if extra_configs then + table.join2(extra.configs, extra_configs) + else + raise(errors) + end + end + if extra then + local extra_str = string.serialize(extra, {indent = false, strip = true}) + require_argv.extra = extra_str + end + task.run("require", require_argv) +end + -- main entry function main() local packages = option.get("packages") if packages then _export_packages(packages) + elseif os.isfile(os.projectfile()) then + _export_current_packages() else raise("please specify the packages to be exported.") end diff --git a/xmake/modules/private/xrepo/action/import.lua b/xmake/modules/private/xrepo/action/import.lua new file mode 100644 index 000000000..e3805135d --- /dev/null +++ b/xmake/modules/private/xrepo/action/import.lua @@ -0,0 +1,214 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file import.lua +-- + +-- imports +import("core.base.option") +import("core.base.task") + +-- get menu options +function menu_options() + + -- description + local description = "Import the given packages." + + -- menu options + local options = + { + {'k', "kind", "kv", nil, "Enable static/shared library.", + values = {"static", "shared"} }, + {'p', "plat", "kv", nil, "Set the given platform." }, + {'a', "arch", "kv", nil, "Set the given architecture." }, + {'m', "mode", "kv", nil, "Set the given mode.", + values = {"release", "debug"} }, + {'f', "configs", "kv", nil, "Set the given extra package configs.", + "e.g.", + " - xrepo import -f \"vs_runtime=MD\" zlib", + " - xrepo import -f \"regex=true,thread=true\" boost"}, + {}, + {'i', "packagedir", "kv", "packages","Set the imported packages directory."}, + {nil, "packages", "vs", nil, "The packages list.", + "e.g.", + " - xrepo import zlib boost", + " - xrepo import -p iphoneos -a arm64 \"zlib >=1.2.0\"", + " - xrepo import -p android -m debug \"pcre2 10.x\"", + " - xrepo import -p mingw -k shared zlib", + " - xrepo import conan::zlib/1.2.11 vcpkg::zlib"} + } + + -- show menu options + local function show_options() + + -- show usage + cprint("${bright}Usage: $${clear cyan}xrepo import [options] packages") + + -- show description + print("") + print(description) + + -- show options + option.show_options(options, "import") + end + return options, show_options, description +end + +-- import packages +function _import_packages(packages) + + -- enter working project directory + local oldir = os.curdir() + local workdir = path.join(os.tmpdir(), "xrepo", "working") + if not os.isdir(workdir) then + os.mkdir(workdir) + os.cd(workdir) + os.vrunv("xmake", {"create", "-P", "."}) + else + os.cd(workdir) + end + + -- do configure first + local config_argv = {"f", "-c"} + if option.get("verbose") then + table.insert(config_argv, "-v") + end + if option.get("diagnosis") then + table.insert(config_argv, "-D") + end + if option.get("plat") then + table.insert(config_argv, "-p") + table.insert(config_argv, option.get("plat")) + end + if option.get("arch") then + table.insert(config_argv, "-a") + table.insert(config_argv, option.get("arch")) + end + local mode = option.get("mode") + if mode then + table.insert(config_argv, "-m") + table.insert(config_argv, mode) + end + local kind = option.get("kind") + if kind then + table.insert(config_argv, "-k") + table.insert(config_argv, kind) + end + os.vrunv("xmake", config_argv) + + -- do import + local require_argv = {"require", "--import"} + if option.get("yes") then + table.insert(require_argv, "-y") + end + if option.get("verbose") then + table.insert(require_argv, "-v") + end + if option.get("diagnosis") then + table.insert(require_argv, "-D") + end + local packagedir = option.get("packagedir") + if packagedir and not path.is_absolute(packagedir) then + packagedir = path.absolute(packagedir, oldir) + end + if packagedir then + table.insert(require_argv, "--packagedir=" .. packagedir) + end + local extra = {system = false} + if mode == "debug" then + extra.debug = true + end + if kind == "shared" then + extra.configs = extra.configs or {} + extra.configs.shared = true + end + local configs = option.get("configs") + if configs then + extra.configs = extra.configs or {} + local extra_configs, errors = ("{" .. configs .. "}"):deserialize() + if extra_configs then + table.join2(extra.configs, extra_configs) + else + raise(errors) + end + end + if extra then + local extra_str = string.serialize(extra, {indent = false, strip = true}) + table.insert(require_argv, "--extra=" .. extra_str) + end + table.join2(require_argv, packages) + os.vexecv("xmake", require_argv) +end + +-- import packages in current project +function _import_current_packages(packages) + + -- do import + local require_argv = {import = true} + if option.get("yes") then + require_argv.yes = true + end + if option.get("verbose") then + require_argv.verbose = true + end + if option.get("diagnosis") then + require_argv.diagnosis = true + end + local packagedir = option.get("packagedir") + if packagedir and not path.is_absolute(packagedir) then + packagedir = path.absolute(packagedir, oldir) + end + if packagedir then + require_argv.packagedir = packagedir + end + local extra = {system = false} + if mode == "debug" then + extra.debug = true + end + if kind == "shared" then + extra.configs = extra.configs or {} + extra.configs.shared = true + end + local configs = option.get("configs") + if configs then + extra.configs = extra.configs or {} + local extra_configs, errors = ("{" .. configs .. "}"):deserialize() + if extra_configs then + table.join2(extra.configs, extra_configs) + else + raise(errors) + end + end + if extra then + local extra_str = string.serialize(extra, {indent = false, strip = true}) + require_argv.extra = extra_str + end + task.run("require", require_argv) +end + +-- main entry +function main() + local packages = option.get("packages") + if packages then + _import_packages(packages) + elseif os.isfile(os.projectfile()) then + _import_current_packages() + else + raise("please specify the packages to be imported.") + end +end + diff --git a/xmake/modules/private/xrepo/action/install.lua b/xmake/modules/private/xrepo/action/install.lua index 4fed2583c..ccd14c839 100644 --- a/xmake/modules/private/xrepo/action/install.lua +++ b/xmake/modules/private/xrepo/action/install.lua @@ -32,14 +32,20 @@ function menu_options() { {'k', "kind", "kv", nil, "Enable static/shared library.", values = {"static", "shared"} }, - {'p', "plat", "kv", nil, "Set the given platform." }, - {'a', "arch", "kv", nil, "Set the given architecture." }, + {'p', "plat", "kv", nil, "Set the given platform." }, + {'a', "arch", "kv", nil, "Set the given architecture." }, {'m', "mode", "kv", nil, "Set the given mode.", values = {"release", "debug"} }, {'f', "configs", "kv", nil, "Set the given extra package configs.", "e.g.", " - xrepo install -f \"vs_runtime=MD\" zlib", " - xrepo install -f \"regex=true,thread=true\" boost"}, + {'j', "jobs", "kv", tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)), + "Set the number of parallel compilation jobs."}, + {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs."}, + {nil, "includes", "kv", nil, "Includes extra lua configuration files.", + "e.g.", + " -- xrepo install -p cross --toolchain=mytool --includes='toolchain1.lua" .. path.envsep() .. "toolchain2.lua'"}, {category = "Visual Studio SDK Configuration" }, {nil, "vs", "kv", nil, "The Microsoft Visual Studio" , " e.g. --vs=2017" }, @@ -61,6 +67,7 @@ function menu_options() {category = "Other Configuration" }, {nil, "force", "k", nil, "Force to reinstall all package dependencies."}, {nil, "shallow", "k", nil, "Does not install dependent packages."}, + {nil, "build", "k", nil, "Always build and install packages from source."}, {}, {nil, "packages", "vs", nil, "The packages list.", "e.g.", @@ -164,7 +171,8 @@ function _install_packages(packages) if option.get("target_minver") then table.insert(config_argv, "--target_minver=" .. option.get("target_minver")) end - os.vrunv("xmake", config_argv) + local envs = {XMAKE_RCFILES = option.get("includes")} + os.vrunv("xmake", config_argv, {envs = envs}) -- do install local require_argv = {"require"} @@ -177,12 +185,22 @@ function _install_packages(packages) if option.get("diagnosis") then table.insert(require_argv, "-D") end + if option.get("jobs") then + table.insert(require_argv, "-j") + table.insert(require_argv, option.get("jobs")) + end + if option.get("linkjobs") then + table.insert(require_argv, "--linkjobs=" .. option.get("linkjobs")) + end if option.get("force") then table.insert(require_argv, "--force") end if option.get("shallow") then table.insert(require_argv, "--shallow") end + if option.get("build") then + table.insert(require_argv, "--build") + end local extra = {system = false} if mode == "debug" then extra.debug = true @@ -207,7 +225,7 @@ function _install_packages(packages) table.insert(require_argv, "--extra=" .. extra_str) end table.join2(require_argv, packages) - os.vexecv("xmake", require_argv) + os.vexecv("xmake", require_argv, {envs = envs}) end -- main entry diff --git a/xmake/modules/private/xrepo/action/remove.lua b/xmake/modules/private/xrepo/action/remove.lua index 4a6446c91..7624fa9cf 100644 --- a/xmake/modules/private/xrepo/action/remove.lua +++ b/xmake/modules/private/xrepo/action/remove.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("private.action.require.impl.remove_packages", {alias = "remove_all_packages"}) -- get menu options function menu_options() @@ -41,6 +42,12 @@ function menu_options() " - xrepo remove -f \"vs_runtime=MD\" zlib", " - xrepo remove -f \"regex=true,thread=true\" boost"}, {}, + {nil, "all", "k", nil, "Remove all packages and ignore extra package configs.", + "If `--all` is enabled, the package name parameter will support lua pattern", + "e.g.", + " - xrepo remove --all", + " - xrepo remove --all zlib boost", + " - xrepo remove --all zl* boo*"}, {nil, "packages", "vs", nil, "The packages list.", "e.g.", " - xrepo remove zlib boost", @@ -147,7 +154,9 @@ end -- main entry function main() local packages = option.get("packages") - if packages then + if option.get("all") then + remove_all_packages(packages) + elseif packages then _remove_packages(packages) else raise("please specify the packages to be removed.") diff --git a/xmake/modules/target/action/clean/main.lua b/xmake/modules/target/action/clean/main.lua index 443c3bd0a..8cbc9599c 100644 --- a/xmake/modules/target/action/clean/main.lua +++ b/xmake/modules/target/action/clean/main.lua @@ -26,7 +26,7 @@ import("private.action.clean.remove_files") function main(target) -- is phony? - if target:isphony() then + if target:is_phony() then return end diff --git a/xmake/modules/target/action/install/cmake_importfiles.lua b/xmake/modules/target/action/install/cmake_importfiles.lua new file mode 100644 index 000000000..7bfb5d636 --- /dev/null +++ b/xmake/modules/target/action/install/cmake_importfiles.lua @@ -0,0 +1,82 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file cmake_importfiles.lua +-- + +-- imports +import("core.project.project") + +-- get the builtin variables +function _get_builtinvars(target, installdir) + return {TARGETNAME = target:name(), + PROJECTNAME = project.name() or target:name(), + TARGETFILENAME = path.filename(target:targetfile()), + TARGETKIND = target:is_shared() and "SHARED" or "STATIC", + PACKAGE_VERSION = target:get("version") or "1.0.0"} +end + +-- install cmake import file +function _install_cmake_importfile(target, installdir, filename, opt) + + -- get import file path + local projectname = project.name() or target:name() + local importfile_src = path.join(os.programdir(), "scripts", "cmake_importfiles", filename) + local importfile_dst = path.join(installdir, opt and opt.libdir or "lib", "cmake", projectname, (filename:gsub("xxx", projectname))) + + -- trace + vprint("generating %s ..", importfile_dst) + + -- get the builtin variables + local builtinvars = _get_builtinvars(target, installdir) + + -- copy and replace builtin variables + local content = io.readfile(importfile_src) + if content then + content = content:gsub("(@(.-)@)", function(_, variable) + variable = variable:trim() + local value = builtinvars[variable] + return type(value) == "function" and value() or value + end) + io.writefile(importfile_dst, content) + end +end + +-- install .cmake import files +function main(target, opt) + + -- check + opt = opt or {} + assert(target:is_library(), 'cmake_importfiles: only support for library target(%s)!', target:name()) + + -- get install directory + local installdir = target:installdir() + if not installdir then + return + end + + -- do install + _install_cmake_importfile(target, installdir, "xxxConfig.cmake", opt) + _install_cmake_importfile(target, installdir, "xxxConfigVersion.cmake", opt) + _install_cmake_importfile(target, installdir, "xxxTargets.cmake", opt) + if is_mode("debug") then + _install_cmake_importfile(target, installdir, "xxxTargets-debug.cmake", opt) + else + _install_cmake_importfile(target, installdir, "xxxTargets-release.cmake", opt) + end +end + diff --git a/xmake/modules/target/action/install/main.lua b/xmake/modules/target/action/install/main.lua index 3754b71af..289d258f0 100644 --- a/xmake/modules/target/action/install/main.lua +++ b/xmake/modules/target/action/install/main.lua @@ -44,12 +44,12 @@ function main(target, opt) end -- trace - print("installing to %s ..", installdir) + print("installing %s to %s ..", target:name(), installdir) -- call script - if not target:isphony() then + if not target:is_phony() then local install_style = target:is_plat("windows", "mingw") and "windows" or "unix" - local script = import(install_style, {anonymous = true})["install_" .. target:targetkind()] + local script = import(install_style, {anonymous = true})["install_" .. target:kind()] if script then script(target, opt) end diff --git a/xmake/modules/target/action/install/pkgconfig_importfiles.lua b/xmake/modules/target/action/install/pkgconfig_importfiles.lua new file mode 100644 index 000000000..1187bb5e6 --- /dev/null +++ b/xmake/modules/target/action/install/pkgconfig_importfiles.lua @@ -0,0 +1,84 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file pkgconfig_importfiles.lua +-- + +-- install pkgconfig/.pc import files +function main(target, opt) + + -- check + opt = opt or {} + assert(target:is_library(), 'pkgconfig_importfiles: only support for library target(%s)!', target:name()) + + -- only for unix platform + local installdir = target:installdir() + if target:is_plat("windows") or not installdir then + return + end + + -- get pkgconfig/.pc file + local pcfile = path.join(installdir, opt and opt.libdir or "lib", "pkgconfig", opt.filename or (target:basename() .. ".pc")) + + -- get includedirs + local includedirs = opt.includedirs or {path.join(installdir, "include")} + + -- get links and linkdirs + local links = opt.links or target:basename() + local linkdirs = opt.linkdirs or {path.join(installdir, "lib")} + + -- get libs + local libs = "" + for _, linkdir in ipairs(linkdirs) do + libs = libs .. "-L" .. linkdir + end + libs = libs .. " -L${libdir}" + for _, link in ipairs(links) do + libs = libs .. " -l" .. link + end + + -- get cflags + local cflags = "" + for _, includedir in ipairs(includedirs) do + cflags = cflags .. "-I" .. includedir + end + cflags = cflags .. " -I${includedir}" + + -- trace + vprint("generating %s ..", pcfile) + + -- generate a *.pc file + local file = io.open(pcfile, 'w') + if file then + file:print("prefix=%s", installdir) + file:print("exec_prefix=${prefix}") + file:print("libdir=${exec_prefix}/lib") + file:print("includedir=${prefix}/include") + file:print("") + file:print("Name: %s", target:name()) + file:print("Description: %s", target:name()) + local version = target:get("version") + if version then + file:print("Version: %s", version) + end + file:print("Libs: %s", libs) + file:print("Libs.private: ") + file:print("Cflags: %s", cflags) + file:close() + end +end + diff --git a/xmake/modules/target/action/install/windows.lua b/xmake/modules/target/action/install/windows.lua index 548b4dfe4..73e8f5ee3 100644 --- a/xmake/modules/target/action/install/windows.lua +++ b/xmake/modules/target/action/install/windows.lua @@ -74,7 +74,7 @@ function install_binary(target, opt) -- install the dependent shared/windows (*.dll) target -- @see https://github.com/xmake-io/xmake/issues/961 for _, dep in ipairs(target:orderdeps()) do - if dep:targetkind() == "shared" then + if dep:kind() == "shared" then local depfile = dep:targetfile() if os.isfile(depfile) then os.vcp(depfile, binarydir) diff --git a/xmake/modules/target/action/uninstall/main.lua b/xmake/modules/target/action/uninstall/main.lua index ebf7d07c9..cc5feb3ac 100644 --- a/xmake/modules/target/action/uninstall/main.lua +++ b/xmake/modules/target/action/uninstall/main.lua @@ -36,12 +36,12 @@ function main(target, opt) end -- trace - print("uninstalling from %s ..", installdir) + print("uninstalling %s from %s ..", target:name(), installdir) -- call script - if not target:isphony() then + if not target:is_phony() then local install_style = target:is_plat("windows", "mingw") and "windows" or "unix" - local script = import(install_style, {anonymous = true})["uninstall_" .. target:targetkind()] + local script = import(install_style, {anonymous = true})["uninstall_" .. target:kind()] if script then script(target, opt) end diff --git a/xmake/modules/target/action/uninstall/windows.lua b/xmake/modules/target/action/uninstall/windows.lua index a9b09c43c..f45028303 100644 --- a/xmake/modules/target/action/uninstall/windows.lua +++ b/xmake/modules/target/action/uninstall/windows.lua @@ -59,7 +59,7 @@ function uninstall_binary(target, opt) -- remove the dependent shared/windows (*.dll) target -- @see https://github.com/xmake-io/xmake/issues/961 for _, dep in ipairs(target:orderdeps()) do - if dep:targetkind() == "shared" then + if dep:kind() == "shared" then os.vrm(path.join(binarydir, path.filename(dep:targetfile()))) end _uninstall_shared_for_packages(dep, binarydir) diff --git a/xmake/modules/utils/archive/extract.lua b/xmake/modules/utils/archive/extract.lua index a707f18dd..4e54bc4dc 100644 --- a/xmake/modules/utils/archive/extract.lua +++ b/xmake/modules/utils/archive/extract.lua @@ -26,6 +26,7 @@ import("detect.tools.find_7z") import("detect.tools.find_tar") import("detect.tools.find_gzip") import("detect.tools.find_unzip") +import("detect.tools.find_bzip2") import("extension", {alias = "get_archive_extension"}) -- extract archivefile using tar @@ -42,6 +43,11 @@ function _extract_using_tar(archivefile, outputdir, extension, opt) return false end + -- on msys2/cygwin? we need translate input path to cygwin-like path + if is_subhost("msys", "cygwin") and program:gsub("\\", "/"):find("/usr/bin") then + archivefile = path.cygwin_path(archivefile) + end + -- init argv local argv = {} if is_subhost("windows") then @@ -99,6 +105,11 @@ function _extract_using_7z(archivefile, outputdir, extension, opt) outputdir = os.tmpfile({ramdisk = false}) .. ".tar" end + -- on msys2/cygwin? we need translate input path to cygwin-like path + if is_subhost("msys", "cygwin") and program:gsub("\\", "/"):find("/usr/bin") then + archivefile = path.cygwin_path(archivefile) + end + -- init argv local argv = {"x", "-y", archivefile} @@ -276,7 +287,7 @@ function _extract_using_unzip(archivefile, outputdir, extension, opt) end -- init argv - local argv = {} + local argv = {"-o"} -- overwrite existing files without prompting if not option.get("verbose") then table.insert(argv, "-q") end @@ -314,6 +325,68 @@ function _extract_using_unzip(archivefile, outputdir, extension, opt) return true end +-- extract archivefile using bzip2 +function _extract_using_bzip2(archivefile, outputdir, extension, opt) + + -- find bzip2 + local program = find_bzip2() + if not program then + return false + end + + -- extract to *.tar file first + local outputdir_old = nil + if extension:startswith(".tar.") then + outputdir_old = outputdir + outputdir = os.tmpfile({ramdisk = false}) .. ".tar" + end + + -- on msys2/cygwin? we need translate input path to cygwin-like path + if is_subhost("msys", "cygwin") and program:gsub("\\", "/"):find("/usr/bin") then + archivefile = path.cygwin_path(archivefile) + end + + -- init temporary archivefile + local tmpfile = path.join(outputdir, path.filename(archivefile)) + + -- init argv + local argv = {"-d", "-f"} + if not option.get("verbose") then + table.insert(argv, "-q") + end + table.insert(argv, tmpfile) + + -- ensure output directory + if not os.isdir(outputdir) then + os.mkdir(outputdir) + end + + -- copy archivefile to outputdir first + if path.absolute(archivefile) ~= path.absolute(tmpfile) then + os.cp(archivefile, tmpfile) + end + + -- enter outputdir + local oldir = os.cd(outputdir) + + -- extract it + os.vrunv(program, argv) + + -- leave outputdir + os.cd(oldir) + + -- continue to extract *.tar file + if outputdir_old then + local tarfile = find_file("**.tar", outputdir) + if tarfile and os.isfile(tarfile) then + return _extract(tarfile, outputdir_old, ".tar", {_extract_using_7z, _extract_using_tar}, opt) + end + end + + -- ok + return true +end + -- extract archive file using extractors function _extract(archivefile, outputdir, extension, extractors, opt) @@ -343,19 +416,38 @@ function main(archivefile, outputdir, opt) opt = opt or {} -- init extractors - local extractors = - { - [".zip"] = {_extract_using_unzip, _extract_using_tar, _extract_using_7z} - , [".7z"] = {_extract_using_7z} - , [".gz"] = {_extract_using_gzip, _extract_using_tar, _extract_using_7z} - , [".xz"] = {_extract_using_xz, _extract_using_tar, _extract_using_7z} - , [".tgz"] = {_extract_using_tar, _extract_using_7z} - , [".bz2"] = {_extract_using_tar, _extract_using_7z} - , [".tar"] = {_extract_using_tar, _extract_using_7z} - , [".tar.gz"] = {_extract_using_tar, _extract_using_7z, _extract_using_gzip} - , [".tar.xz"] = {_extract_using_tar, _extract_using_7z, _extract_using_xz} - , [".tar.bz2"] = {_extract_using_tar, _extract_using_7z} - } + local extractors + if is_host("windows") then + -- we use 7z first, becase xmake package has builtin 7z program on windows + -- tar/windows can not extract .bz2 ... + extractors = + { + [".zip"] = {_extract_using_7z, _extract_using_unzip, _extract_using_tar} + , [".7z"] = {_extract_using_7z} + , [".gz"] = {_extract_using_7z, _extract_using_gzip, _extract_using_tar} + , [".xz"] = {_extract_using_7z, _extract_using_xz, _extract_using_tar} + , [".tgz"] = {_extract_using_7z, _extract_using_tar} + , [".bz2"] = {_extract_using_7z, _extract_using_bzip2} + , [".tar"] = {_extract_using_7z, _extract_using_tar} + , [".tar.gz"] = {_extract_using_7z, _extract_using_gzip} + , [".tar.xz"] = {_extract_using_7z, _extract_using_xz} + , [".tar.bz2"] = {_extract_using_7z, _extract_using_bzip2} + } + else + extractors = + { + [".zip"] = {_extract_using_unzip, _extract_using_tar, _extract_using_7z} + , [".7z"] = {_extract_using_7z} + , [".gz"] = {_extract_using_gzip, _extract_using_tar, _extract_using_7z} + , [".xz"] = {_extract_using_xz, _extract_using_tar, _extract_using_7z} + , [".tgz"] = {_extract_using_tar, _extract_using_7z} + , [".bz2"] = {_extract_using_bzip2, _extract_using_tar, _extract_using_7z} + , [".tar"] = {_extract_using_tar, _extract_using_7z} + , [".tar.gz"] = {_extract_using_tar, _extract_using_7z, _extract_using_gzip} + , [".tar.xz"] = {_extract_using_tar, _extract_using_7z, _extract_using_xz} + , [".tar.bz2"] = {_extract_using_tar, _extract_using_7z, _extract_using_bzip2} + } + end -- get extension local extension = opt.extension or get_archive_extension(archivefile) diff --git a/xmake/modules/utils/ci/packageskey.lua b/xmake/modules/utils/ci/packageskey.lua new file mode 100644 index 000000000..50e3e2d1b --- /dev/null +++ b/xmake/modules/utils/ci/packageskey.lua @@ -0,0 +1,60 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file packageskey.lua +-- + +-- imports +import("core.base.option") +import("private.action.require.impl.package") +import("private.action.require.impl.utils.get_requires") + +-- generate a hash key of all packages to cache packages on github/ci +-- +-- on windows.yml +-- +-- - name: Retrieve dependencies hash +-- id: packageskey +-- run: echo "::set-output name=hash::$(xmake l utils.ci.packageskey)" + +-- Cache xmake dependencies +-- - name: Retrieve cached xmake dependencies +-- uses: actions/cache@v2 +-- with: +-- path: ${{env.APPLOCALDATA}}\.xmake\packages +-- key: ${{ steps.packageskey.outputs.hash }} +-- +function main(requires_raw) + + -- get requires and extra config + local requires_extra = nil + local requires, requires_extra = get_requires(requires_raw) + if not requires or #requires == 0 then + return + end + + -- get keys + local keys = {} + for _, instance in ipairs(package.load_packages(requires, {requires_extra = requires_extra})) do + table.insert(keys, instance:installdir()) -- contain name/version/buildhash + end + table.sort(keys) + keys = table.concat(keys, ",") + print(hash.uuid4(keys):gsub('-', ''):lower()) +end + + diff --git a/xmake/modules/utils/platform/gnu2mslib.lua b/xmake/modules/utils/platform/gnu2mslib.lua new file mode 100644 index 000000000..f32da2060 --- /dev/null +++ b/xmake/modules/utils/platform/gnu2mslib.lua @@ -0,0 +1,113 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file gnu2mslib.lua +-- + +-- imports +import("core.base.option") +import("core.base.hashset") +import("core.project.config") +import("core.tool.toolchain") +import("lib.detect.find_tool") + +-- get .def file path from gnulib +function _get_defpath_from_gnulib(gnulib, msvc) + + -- check + assert(os.isfile(gnulib), "%s not found!", gnulib) + + -- get dumpbin.exe + local dumpbin = assert(find_tool("dumpbin", {envs = msvc:runenvs()}), "gnu2mslib(): dumpbin.exe not found!") + + -- get symbols + local symbols_exported = hashset.new() + local symbols = try {function() return os.iorunv(dumpbin.program, {"/linkermember", gnulib}) end} + if symbols then + local symbols_count + local symbols_index = 0 + for _, line in ipairs(symbols:split('\n', {plain = true})) do + if symbols_count == nil then + symbols_count = line:match("(%d+) public symbols") + if symbols_count then + symbols_count = tonumber(symbols_count) + end + else + local symbol = line:match("%s+[%dABCDEF]+%s+(.+)") + if symbol then + if not symbol:startswith("__") and not symbol:startswith("?") then + symbols_exported:insert(symbol) + end + symbols_index = symbols_index + 1 + if symbols_index >= symbols_count then + break + end + end + end + end + end + + -- generate .def file + if symbols_exported:size() > 0 then + local defpath = os.tmpfile() .. ".def" + local file = io.open(defpath, "w") + file:print("EXPORTS") + for _, symbol in ipairs(symbols_exported) do + file:print("%s", symbol) + end + file:close() + return defpath + end +end + +-- convert mingw/gnu xxx.dll.a to msvc xxx.lib +-- +-- gnu2mslib(mslib, gnulib_or_defpath, {arch = "x64", dllname = "foo.dll"} +-- +-- @see https://github.com/xmake-io/xmake/issues/1181 +-- +function main(mslib, gnulib_or_defpath, opt) + + -- check + opt = opt or {} + assert(is_host("windows"), "we can only run gnu2mslib() on windows!") + assert(mslib and gnulib_or_defpath, "invalid input parameters, usage: gnu2mslib(mslib, gnulib_or_defpath, {arch = \"x64\", dllname = \"foo.dll\"})") + + -- get msvc toolchain + local msvc = toolchain.load("msvc", {plat = opt.plat, arch = opt.arch}) + if not msvc:check() then + raise("we can not get msvc toolchain!") + end + + -- get lib.exe + local libtool = assert(find_tool("lib", {envs = msvc:runenvs()}), "gnu2mslib(): lib.exe not found!") + + -- get dll name + local dllname = opt.dllname or path.basename(mslib) .. ".dll" + + -- get def file path + local defpath = gnulib_or_defpath:endswith(".def") and gnulib_or_defpath or _get_defpath_from_gnulib(gnulib_or_defpath, msvc) + assert(defpath and os.isfile(defpath), "gnu2mslib(): convert failed, cannot get .def file!") + + -- generate mslib from gnulib + os.vrunv(libtool.program, {"/def:" .. defpath, "/name:" .. path.filename(dllname), "/out:" .. mslib}) + + -- remove temporary .def file + if not gnulib_or_defpath:endswith(".def") then + os.rm(defpath) + end +end diff --git a/xmake/platforms/appletvos/xmake.lua b/xmake/platforms/appletvos/xmake.lua new file mode 100644 index 000000000..c3f21f8f4 --- /dev/null +++ b/xmake/platforms/appletvos/xmake.lua @@ -0,0 +1,73 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- define platform +platform("appletvos") + + -- set os + set_os("ios") + + -- set hosts + set_hosts("macosx") + + -- set archs + if os.arch() == "arm64" then -- on apple m1 device + set_archs("arm64", "x86_64") + else + set_archs("arm64", "armv7", "armv7s", "i386", "x86_64") + end + + -- set formats + set_formats("static", "lib$(name).a") + set_formats("object", "$(name).o") + set_formats("shared", "lib$(name).dylib") + set_formats("symbol", "$(name).dSYM") + + -- set toolchains + set_toolchains("envs", "xcode") + + -- set menu + set_menu { + config = + { + {category = "XCode SDK Configuration" } + , {nil, "xcode", "kv", "auto", "The Xcode Application Directory" } + , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } + , {nil, "xcode_bundle_identifier", "kv", "auto", "The Bundle Identifier for Xcode" } + , {nil, "xcode_codesign_identity", "kv", "auto", "The Codesign Identity for Xcode" } + , {nil, "xcode_mobile_provision", "kv", "auto", "The Mobile Provision for Xcode" } + , {nil, "target_minver", "kv", "auto", "The Target Minimal Version" } + } + + , global = + { + {category = "XCode SDK Configuration" } + , {nil, "xcode", "kv", "auto", "The Xcode Application Directory" } + , {nil, "xcode_bundle_identifier", "kv", "auto", "The Bundle Identifier for Xcode" } + , {nil, "xcode_codesign_identity", "kv", "auto", "The Codesign Identity for Xcode" } + , {nil, "xcode_mobile_provision", "kv", "auto", "The Mobile Provision for Xcode" } + } + } + + + + + + diff --git a/xmake/platforms/iphoneos/xmake.lua b/xmake/platforms/iphoneos/xmake.lua index a5c97bd91..8677218fa 100644 --- a/xmake/platforms/iphoneos/xmake.lua +++ b/xmake/platforms/iphoneos/xmake.lua @@ -28,7 +28,11 @@ platform("iphoneos") set_hosts("macosx") -- set archs - set_archs("arm64", "armv7", "armv7s", "i386", "x86_64") + if os.arch() == "arm64" then -- on apple m1 device + set_archs("arm64", "x86_64") + else + set_archs("arm64", "armv7", "armv7s", "i386", "x86_64") + end -- set formats set_formats("static", "lib$(name).a") 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/plugins/plugin/main.lua b/xmake/plugins/plugin/main.lua index d2a8f263f..37ffa1050 100644 --- a/xmake/plugins/plugin/main.lua +++ b/xmake/plugins/plugin/main.lua @@ -23,7 +23,7 @@ import("core.base.option") import("core.base.global") import("devel.git") import("net.fasturl") -import("actions.require.impl.environment", {rootdir = os.programdir()}) +import("private.action.require.impl.environment") -- install plugins function _install() diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index ba257bb35..eb30a1ee4 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -20,8 +20,10 @@ -- imports import("core.tool.compiler") +import("core.project.rule") import("core.project.project") import("core.language.language") +import("private.utils.batchcmds") -- escape path function _escape_path(p) @@ -32,6 +34,7 @@ end -- https://github.com/xmake-io/xmake/issues/1050 function _translate_arguments(arguments) local args = {} + local is_msvc = path.basename(arguments[1]):lower() == "cl" for _, arg in ipairs(arguments) do if arg:find("-isystem", 1, true) then arg = arg:replace("-isystem", "-I") @@ -39,6 +42,15 @@ function _translate_arguments(arguments) arg = arg:gsub("[%-/]external:I", "-I") elseif arg:find("[%-/]external:W") or arg:find("[%-/]experimental:external") then arg = nil + -- escape '"' for the defines + -- https://github.com/xmake-io/xmake/issues/1506 + elseif arg:find("^-D") then + arg = arg:gsub("\"", "\\\"") + end + -- @see use msvc-style flags for msvc to support language-server better + -- https://github.com/xmake-io/xmake/issues/1284 + if is_msvc and arg and arg:startswith("-") then + arg = arg:gsub("^%-", "/") end if arg then table.insert(args, arg) @@ -47,20 +59,23 @@ function _translate_arguments(arguments) return args end --- make the object -function _make_object(jsonfile, target, sourcefile, objectfile) - - -- get the source file kind - local sourcekind = language.sourcekind_of(sourcefile) +-- make command +function _make_arguments(jsonfile, arguments, sourcefile) - -- make the object for the *.o/obj? ignore it directly - if sourcekind == "obj" or sourcekind == "lib" then - return + -- attempt to get source file from arguments + if not sourcefile then + for _, arg in ipairs(arguments) do + local sourcekind = try {function () return language.sourcekind_of(path.filename(arg)) end} + if sourcekind and os.isfile(arg) then + sourcefile = arg + break + end + end + if not sourcefile then + return + end end - -- get compile arguments - local arguments = table.join(compiler.compargv(sourcefile, objectfile, {target = target, sourcekind = sourcekind})) - -- translate some unsupported arguments arguments = _translate_arguments(arguments) @@ -82,16 +97,77 @@ function _make_object(jsonfile, target, sourcefile, objectfile) _g.firstline = false end +-- make commands for object rules +function _make_commands_for_objectrules(jsonfile, target, sourcebatch, suffix) + + -- get rule + local rulename = assert(sourcebatch.rulename, "unknown rule for sourcebatch!") + local ruleinst = assert(project.rule(rulename) or rule.rule(rulename), "unknown rule: %s", rulename) + + -- generate commands for xx_buildcmd_files + local scriptname = "buildcmd_files" .. (suffix and ("_" .. suffix) or "") + local script = ruleinst:script(scriptname) + if script then + local batchcmds_ = batchcmds.new({target = target}) + script(target, batchcmds_, sourcebatch, {}) + if not batchcmds_:empty() then + for _, cmd in ipairs(batchcmds_:cmds()) do + if cmd.program then + _make_arguments(jsonfile, table.join(cmd.program, cmd.argv)) + end + end + end + end + + -- generate commands for xx_buildcmd_file + if not script then + scriptname = "buildcmd_file" .. (suffix and ("_" .. suffix) or "") + script = ruleinst:script(scriptname) + if script then + local sourcekind = sourcebatch.sourcekind + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + local batchcmds_ = batchcmds.new({target = target}) + script(target, batchcmds_, sourcefile, {}) + if not batchcmds_:empty() then + for _, cmd in ipairs(batchcmds_:cmds()) do + if cmd.program then + _make_arguments(jsonfile, table.join(cmd.program, cmd.argv)) + end + end + end + end + end + end +end + +-- make commands for objects +function _make_commands_for_objects(jsonfile, target, sourcebatch) + local sourcekind = sourcebatch.sourcekind + if sourcekind then + for index, sourcefile in ipairs(sourcebatch.sourcefiles) do + local objectfile = sourcebatch.objectfiles[index] + local arguments = table.join(compiler.compargv(sourcefile, objectfile, {target = target, sourcekind = sourcekind})) + _make_arguments(jsonfile, arguments, sourcefile) + end + return true + end +end + -- make objects -function _make_objects(jsonfile, target, sourcekind, sourcebatch) - for index, objectfile in ipairs(sourcebatch.objectfiles) do - _make_object(jsonfile, target, sourcebatch.sourcefiles[index], objectfile) +function _make_objects(jsonfile, target, sourcebatch) + _make_commands_for_objectrules(jsonfile, target, sourcebatch, "before") + if not _make_commands_for_objects(jsonfile, target, sourcebatch) then + _make_commands_for_objectrules(jsonfile, target, sourcebatch) end + _make_commands_for_objectrules(jsonfile, target, sourcebatch, "after") end -- make target function _make_target(jsonfile, target) + -- enter package environments + local oldenvs = os.addenvs(target:pkgenvs()) + -- TODO -- disable precompiled header first target:set("pcheader", nil) @@ -99,11 +175,11 @@ function _make_target(jsonfile, target) -- build source batches for _, sourcebatch in pairs(target:sourcebatches()) do - local sourcekind = sourcebatch.sourcekind - if sourcekind then - _make_objects(jsonfile, target, sourcekind, sourcebatch) - end + _make_objects(jsonfile, target, sourcebatch) end + + -- restore package environments + os.setenvs(oldenvs) end -- make all @@ -115,7 +191,7 @@ function _make_all(jsonfile) -- make commands _g.firstline = true for _, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then _make_target(jsonfile, target) end end diff --git a/xmake/plugins/project/clang/compile_flags.lua b/xmake/plugins/project/clang/compile_flags.lua index 9662943e3..3f521b916 100644 --- a/xmake/plugins/project/clang/compile_flags.lua +++ b/xmake/plugins/project/clang/compile_flags.lua @@ -74,11 +74,9 @@ end -- make all function _make_all() - -- make flags _g.firstline = true for _, target in pairs(project.targets()) do - local isdefault = target:get("default") - if not target:isphony() and (isdefault == nil or isdefault == true) then + if not target:is_phony() and target:is_default() then _make_target(target) end end diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index c207863b2..6259effed 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -162,14 +162,6 @@ function _add_target_include_directories(cmakelists, target) end -- TODO deprecated - local headerdirs = target:get("headerdirs") - if headerdirs then - cmakelists:print("target_include_directories(%s PUBLIC", target:name()) - for _, headerdir in ipairs(headerdirs) do - cmakelists:print(" " .. _get_unix_path(headerdir)) - end - cmakelists:print(")") - end local includedirs_interface = target:get("includedirs", {interface = true}) if includedirs_interface then cmakelists:print("target_include_directories(%s INTERFACE", target:name()) @@ -476,8 +468,8 @@ function _add_target(cmakelists, target) cmakelists:print("# target") -- is phony target? - local targetkind = target:targetkind() - if target:isphony() then + local targetkind = target:kind() + if target:is_phony() then return _add_target_phony(cmakelists, target) elseif targetkind == "binary" then _add_target_binary(cmakelists, target) @@ -486,7 +478,7 @@ function _add_target(cmakelists, target) elseif targetkind == "shared" then _add_target_shared(cmakelists, target) else - raise("unknown target kind %s", target:targetkind()) + raise("unknown target kind %s", target:kind()) end -- TODO export target headers (deprecated) diff --git a/xmake/plugins/project/main.lua b/xmake/plugins/project/main.lua index 63c316f1f..90cdc0695 100644 --- a/xmake/plugins/project/main.lua +++ b/xmake/plugins/project/main.lua @@ -54,6 +54,7 @@ function makers() , vs2015 = vs.make(2015) , vs2017 = vs.make(2017) , vs2019 = vs.make(2019) + , vs2022 = vs.make(2022) , vs = vs.make() , vsxmake2010 = vsxmake.make(2010) , vsxmake2012 = vsxmake.make(2012) @@ -61,6 +62,7 @@ function makers() , vsxmake2015 = vsxmake.make(2015) , vsxmake2017 = vsxmake.make(2017) , vsxmake2019 = vsxmake.make(2019) + , vsxmake2022 = vsxmake.make(2022) , vsxmake = vsxmake.make() , compile_flags = compile_flags.make , compile_commands = compile_commands.make diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua index 68098563d..6b94cf992 100644 --- a/xmake/plugins/project/make/makefile.lua +++ b/xmake/plugins/project/make/makefile.lua @@ -214,19 +214,28 @@ end function _make_target(makefile, target, targetflags) -- is phony target? - if target:isphony() then + if target:is_phony() then return _make_phony(makefile, target) end -- make head local targetfile = target:targetfile() - makefile:print("%s: %s", target:name(), targetfile) - makefile:printf("%s:", targetfile) + local targetname = target:name() + + -- rules like `./target` and `target` are equivalent and can causes issues + -- for cases where targetdir is . + -- in these cases, the targetfile rule is not created + if targetfile == "./" .. targetname then + makefile:printf("%s:", targetname) + else + makefile:print("%s: %s", targetname, targetfile) + makefile:printf("%s:", targetfile) + end -- make dependence for the dependent targets for _, depname in ipairs(target:get("deps")) do local dep = project.target(depname) - makefile:write(" " .. (dep:isphony() and depname or dep:targetfile())) + makefile:write(" " .. (dep:is_phony() and depname or dep:targetfile())) end -- make dependence for objects @@ -359,7 +368,7 @@ function _make_all(makefile) -- make variables for target local targetflags = {} for targetname, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then -- make target linker local program = _get_program_from_target(target, target:linker():kind()) @@ -392,8 +401,7 @@ function _make_all(makefile) -- make all local default = "" for targetname, target in pairs(project.targets()) do - local isdefault = target:get("default") - if isdefault == nil or isdefault == true then + if target:is_default() then default = default .. " " .. targetname end end @@ -426,7 +434,7 @@ function _clean_target(makefile, target) makefile:print("") -- make body - if not target:isphony() then + if not target:is_phony() then -- remove the target file _remove(makefile, target:targetfile()) diff --git a/xmake/plugins/project/ninja/build_ninja.lua b/xmake/plugins/project/ninja/build_ninja.lua index 9ca2d8e42..72bb44a1d 100644 --- a/xmake/plugins/project/ninja/build_ninja.lua +++ b/xmake/plugins/project/ninja/build_ninja.lua @@ -228,7 +228,7 @@ end function _add_build_for_target(ninjafile, target) -- is phony target? - if target:isphony() then + if target:is_phony() then return _add_build_for_phony(ninjafile, target) end @@ -306,8 +306,7 @@ function _add_build_for_targets(ninjafile) -- build default local default = "" for targetname, target in pairs(project.targets()) do - local isdefault = target:get("default") - if isdefault == nil or isdefault == true then + if target:is_default() then default = default .. " " .. targetname end end diff --git a/xmake/plugins/project/vstudio/impl/vs200x.lua b/xmake/plugins/project/vstudio/impl/vs200x.lua index f9251dbe3..d1f220c8a 100644 --- a/xmake/plugins/project/vstudio/impl/vs200x.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x.lua @@ -44,7 +44,7 @@ function make(outputdir, vsinfo) -- make vsprojs for _, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then vs200x_vcproj.make(vsinfo, target) end end diff --git a/xmake/plugins/project/vstudio/impl/vs200x_solution.lua b/xmake/plugins/project/vstudio/impl/vs200x_solution.lua index f2585764c..48b10445f 100644 --- a/xmake/plugins/project/vstudio/impl/vs200x_solution.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_solution.lua @@ -36,7 +36,7 @@ function _make_projects(slnfile, vsinfo) -- make all targets for targetname, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then -- enter project slnfile:enter("Project(\"{%s}\") = \"%s\", \"%s\\%s.vcproj\", \"{%s}\"", vctool, targetname, targetname, targetname, hash.uuid4(targetname)) @@ -68,7 +68,7 @@ function _make_global(slnfile, vsinfo) -- add project configuration platforms slnfile:enter("GlobalSection(ProjectConfigurationPlatforms) = postSolution") for targetname, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then slnfile:print("{%s}.$(mode)|Win32.ActiveCfg = $(mode)|Win32", hash.uuid4(targetname)) slnfile:print("{%s}.$(mode)|Win32.Build.0 = $(mode)|Win32", hash.uuid4(targetname)) end diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua index a9e541bb3..5ddeeb7b0 100644 --- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua @@ -70,7 +70,7 @@ end function _make_linkflags(target, vcprojdir) -- make the linking flags - local linkflags = linker.linkflags(target:targetkind(), target:sourcekinds(), {target = target}) + local linkflags = linker.linkflags(target:kind(), target:sourcekinds(), {target = target}) -- replace -libpath:dir or /libpath:dir, -pdb:symbol.pdb or /pdb:symbol.pdb local flags = {} @@ -201,7 +201,7 @@ end function _make_VCLinkerTool(vcprojfile, vsinfo, target, vcprojdir) -- need not linker? - local kind = target:targetkind() + local kind = target:kind() if kind ~= "binary" and kind ~= "shared" then vcprojfile:enter("<Tool") vcprojfile:print("Name=\"VCLinkerTool\"") @@ -292,7 +292,7 @@ function _make_configurations(vcprojfile, vsinfo, target, vcprojdir) vcprojfile:print("Name=\"$(mode)|Win32\"") vcprojfile:print("OutputDirectory=\"%s\"", path.relative(path.absolute(target:targetdir()), vcprojdir)) vcprojfile:print("IntermediateDirectory=\"%s\"", path.relative(path.absolute(target:objectdir()), vcprojdir)) - vcprojfile:print("ConfigurationType=\"%d\"", assert(configuration_types[target:targetkind()])) + vcprojfile:print("ConfigurationType=\"%d\"", assert(configuration_types[target:kind()])) vcprojfile:print("CharacterSet=\"%d\"", unicode and 1 or 2) -- mbc: 2, wcs: 1 vcprojfile:print("UseOfMFC=\"%d\"", usemfc) vcprojfile:print(">") diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index 8980d0449..a66761d4d 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -31,10 +31,22 @@ import("vs201x_vcxproj") import("vs201x_vcxproj_filters") import("core.cache.memcache") import("core.cache.localcache") -import("actions.require.install", {alias = "install_requires", rootdir = os.programdir()}) +import("private.action.require.install", {alias = "install_requires"}) import("actions.config.configfiles", {alias = "generate_configfiles", rootdir = os.programdir()}) import("actions.config.configheader", {alias = "generate_configheader", rootdir = os.programdir()}) +-- clear cache configuration +function _clear_cacheconf() + config.clear() + config.save() + localcache.clear("config") + localcache.clear("detect") + localcache.clear("option") + localcache.clear("package") + localcache.clear("toolchain") + localcache.save() +end + -- make target info function _make_targetinfo(mode, arch, target) @@ -60,7 +72,7 @@ function _make_targetinfo(mode, arch, target) targetinfo.symbols = target:get("symbols") -- save target kind - targetinfo.targetkind = target:targetkind() + targetinfo.targetkind = target:kind() -- save target file targetinfo.targetfile = target:targetfile() @@ -96,7 +108,7 @@ function _make_targetinfo(mode, arch, target) end -- save linker flags - local linkflags = linker.linkflags(target:targetkind(), target:sourcekinds(), {target = target}) + local linkflags = linker.linkflags(target:kind(), target:sourcekinds(), {target = target}) targetinfo.linkflags = linkflags -- use mfc? save the mfc runtime kind @@ -122,7 +134,7 @@ end function _make_targetheaders(mode, arch, target, last) -- only for static and shared target - local kind = target:targetkind() + local kind = target:kind() if kind == "static" or kind == "shared" then -- TODO make headers, (deprecated) @@ -208,6 +220,29 @@ function _make_vsinfo_archs() return vsinfo_archs end +-- config target +function _config_target(target) + for _, rule in ipairs(target:orderules()) do + local on_config = rule:script("config") + if on_config then + on_config(target) + end + end + local on_config = target:script("config") + if on_config then + on_config(target) + end +end + +-- config targets +function _config_targets() + for _, target in ipairs(project.ordertargets()) do + if target:is_enabled() then + _config_target(target) + end + end +end + -- make vstudio project function make(outputdir, vsinfo) @@ -261,6 +296,9 @@ function make(outputdir, vsinfo) -- install and update requires install_requires() + -- config targets + _config_targets() + -- update config files generate_configfiles() generate_configheader() @@ -271,7 +309,7 @@ function make(outputdir, vsinfo) -- save targets for targetname, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then -- make target with the given mode and arch targets[targetname] = targets[targetname] or {} @@ -283,7 +321,7 @@ function make(outputdir, vsinfo) -- init target info _target.name = targetname - _target.kind = target:targetkind() + _target.kind = target:kind() _target.scriptdir = target:scriptdir() _target.info = _target.info or {} table.insert(_target.info, _make_targetinfo(mode, arch, target)) @@ -308,6 +346,9 @@ function make(outputdir, vsinfo) vs201x_vcxproj_filters.make(vsinfo, target) end + -- clear config and local cache + _clear_cacheconf() + -- leave project directory os.cd(oldir) end diff --git a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua index 45551e1da..c4628190f 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua @@ -42,21 +42,39 @@ function _make_projects(slnfile, vsinfo) -- make all targets local groups = {} + local targets = {} local vctool = "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942" for targetname, target in pairs(project.targets()) do - if not target:isphony() then - slnfile:enter("Project(\"{%s}\") = \"%s\", \"%s\\%s.vcxproj\", \"{%s}\"", vctool, targetname, targetname, targetname, hash.uuid4(targetname)) - for _, dep in ipairs(target:get("deps")) do - slnfile:enter("ProjectSection(ProjectDependencies) = postProject") - slnfile:print("{%s} = {%s}", hash.uuid4(dep), hash.uuid4(dep)) - slnfile:leave("EndProjectSection") - end - slnfile:leave("EndProject") - local group_path = target:get("group") - if group_path then - for _, group_name in ipairs(path.split(group_path)) do - groups[group_name] = hash.uuid4(group_name) + if not target:is_phony() then + -- we need set startup project for default or binary target + -- @see https://github.com/xmake-io/xmake/issues/1249 + if target:get("default") == true then + table.insert(targets, 1, target) + elseif target:is_binary() then + local first_target = targets[1] + if not first_target or first_target:is_default() then + table.insert(targets, 1, target) + else + table.insert(targets, target) end + else + table.insert(targets, target) + end + end + end + for _, target in ipairs(targets) do + local targetname = target:name() + slnfile:enter("Project(\"{%s}\") = \"%s\", \"%s\\%s.vcxproj\", \"{%s}\"", vctool, targetname, targetname, targetname, hash.uuid4(targetname)) + for _, dep in ipairs(target:get("deps")) do + slnfile:enter("ProjectSection(ProjectDependencies) = postProject") + slnfile:print("{%s} = {%s}", hash.uuid4(dep), hash.uuid4(dep)) + slnfile:leave("EndProjectSection") + end + slnfile:leave("EndProject") + local group_path = target:get("group") + if group_path then + for _, group_name in ipairs(path.split(group_path)) do + groups[group_name] = hash.uuid4(group_name) end end end @@ -87,7 +105,7 @@ function _make_global(slnfile, vsinfo) -- add project configuration platforms slnfile:enter("GlobalSection(ProjectConfigurationPlatforms) = postSolution") for targetname, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then for _, mode in ipairs(vsinfo.modes) do for _, arch in ipairs(vsinfo.archs) do local vs_arch = _vs_arch(arch) @@ -108,7 +126,7 @@ function _make_global(slnfile, vsinfo) slnfile:enter("GlobalSection(NestedProjects) = preSolution") local subgroups = {} for targetname, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then local group_path = target:get("group") if group_path then -- target -> group diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 9f9afc1fd..b1bd6f764 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -62,7 +62,11 @@ function _make_compcmd(compargv, sourcefile, objectfile, vcxprojdir) v = v:gsub("__objectfile__", objectfile) -- -Idir or /Idir v = v:gsub("([%-/]I)(.*)", function (I, dir) - dir = path.translate(dir:trim()) + dir = dir:trim() + if #dir == 0 then + return "" + end + dir = path.translate(dir) if not path.is_absolute(dir) then dir = path.relative(path.absolute(dir), vcxprojdir) end @@ -82,7 +86,11 @@ function _make_compflags(sourcefile, targetinfo, vcxprojdir) -- -Idir or /Idir flag = flag:gsub("[%-/]I(.*)", function (dir) - dir = path.translate(dir:trim()) + dir = dir:trim() + if #dir == 0 then + return "" + end + dir = path.translate(dir) if not path.is_absolute(dir) then dir = path.relative(path.absolute(dir), vcxprojdir) end @@ -110,7 +118,11 @@ function _make_linkflags(targetinfo, vcxprojdir) -- replace -libpath:dir or /libpath:dir flag = flag:gsub(string.ipattern("[%-/]libpath:(.*)"), function (dir) - dir = path.translate(dir:trim()) + dir = dir:trim() + if #dir == 0 then + return "" + end + dir = path.translate(dir) if not path.is_absolute(dir) then dir = path.relative(path.absolute(dir), vcxprojdir) end @@ -119,7 +131,11 @@ function _make_linkflags(targetinfo, vcxprojdir) -- replace -def:dir or /def:dir flag = flag:gsub(string.ipattern("[%-/]def:(.*)"), function (dir) - dir = path.translate(dir:trim()) + dir = dir:trim() + if #dir == 0 then + return "" + end + dir = path.translate(dir) if not path.is_absolute(dir) then dir = path.relative(path.absolute(dir), vcxprojdir) end @@ -435,6 +451,7 @@ function _make_common_item(vcxprojfile, vsinfo, target, targetinfo, vcxprojdir) if pcoutputfile then vcxprojfile:print("<PrecompiledHeaderOutputFile>%s</PrecompiledHeaderOutputFile>", path.relative(path.absolute(pcoutputfile), vcxprojdir)) end + vcxprojfile:print("<ForcedIncludeFiles>%s;%%(ForcedIncludeFiles)</ForcedIncludeFiles>", path.filename(pcheader)) end vcxprojfile:leave("</ClCompile>") diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua index d916dcd51..90253940b 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua @@ -38,6 +38,7 @@ function _make_header(filtersfile, vsinfo) , vs2015 = '14.0' , vs2017 = '15.0' , vs2019 = '16.0' + , vs2022 = '17.0' } -- make header diff --git a/xmake/plugins/project/vstudio/impl/vsinfo.lua b/xmake/plugins/project/vstudio/impl/vsinfo.lua index 754153cc6..9b6cc829c 100644 --- a/xmake/plugins/project/vstudio/impl/vsinfo.lua +++ b/xmake/plugins/project/vstudio/impl/vsinfo.lua @@ -85,9 +85,17 @@ local vsinfo = , toolset_version = "v142" , sdk_version = "10.0.17763.0" } +, [2022] = + { vstudio_version = "2022" + , project_version = "17" + , filters_version = "4.0" + , solution_version = "12" + , toolset_version = "v142" + , sdk_version = "10.0.19041.0" + } } function main(version) assert(version) return assert(vsinfo[version], "unsupported vs version (%d)", version); -end
\ No newline at end of file +end diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 17131d391..407e4cbe4 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -31,7 +31,7 @@ import("core.cache.memcache") import("core.cache.localcache") import("lib.detect.find_tool") import("private.action.run.make_runenvs") -import("actions.require.install", {alias = "install_requires", rootdir = os.programdir()}) +import("private.action.require.install", {alias = "install_requires"}) import("actions.config.configheader", {alias = "generate_configheader", rootdir = os.programdir()}) import("actions.config.configfiles", {alias = "generate_configfiles", rootdir = os.programdir()}) @@ -134,7 +134,10 @@ function _make_targetinfo(mode, arch, target) -- use target:get("xxx") rather than target:xxx() -- save target kind - targetinfo.kind = target:get("kind") + targetinfo.kind = target:kind() + + -- is default? + targetinfo.default = tostring(target:is_default()) -- save target file targetinfo.basename = _escape(target:get("basename")) @@ -149,6 +152,7 @@ function _make_targetinfo(mode, arch, target) targetinfo.includedirs = _make_dirs(table.join(_get_values_from_target(target, "includedirs") or {}, _get_values_from_target(target, "sysincludedirs"))) targetinfo.linkdirs = _make_dirs(_get_values_from_target(target, "linkdirs")) targetinfo.sourcedirs = _make_dirs(_get_values_from_target(target, "values.project.vsxmake.sourcedirs")) + targetinfo.pcheaderfile = target:pcheaderfile("cxx") or target:pcheaderfile("c") -- save defines targetinfo.defines = _make_arrs(_get_values_from_target(target, "defines")) @@ -161,7 +165,7 @@ function _make_targetinfo(mode, arch, target) end -- save subsystem - local linkflags = linker.linkflags(target:targetkind(), target:sourcekinds(), {target = target}) + local linkflags = linker.linkflags(target:kind(), target:sourcekinds(), {target = target}) for _, linkflag in ipairs(linkflags) do if linkflag:lower():find("[%-/]subsystem:windows") then targetinfo.subsystem = "windows" @@ -171,18 +175,19 @@ function _make_targetinfo(mode, arch, target) targetinfo.subsystem = "console" end - -- save config flags - local flags = {} - for k, v in pairs(localcache.get("config", "options_" .. target:name())) do - if k ~= "plat" and k ~= "mode" and k ~= "arch" and k ~= "clean" and k ~= "buildir" then - table.insert(flags, "--" .. k .. "=" .. tostring(v)); - end - end - targetinfo.configflags = os.args(flags) - -- save runenvs local runenvs = {} local addrunenvs, setrunenvs = make_runenvs(target) + for k, v in pairs(target:pkgenvs()) do + addrunenvs = addrunenvs or {} + addrunenvs[k] = table.join(table.wrap(addrunenvs[k]), path.splitenv(v)) + end + for _, dep in ipairs(target:orderdeps()) do + for k, v in pairs(dep:pkgenvs()) do + addrunenvs = addrunenvs or {} + addrunenvs[k] = table.join(table.wrap(addrunenvs[k]), path.splitenv(v)) + end + end for k, v in pairs(addrunenvs) do if k:upper() == "PATH" then runenvs[k] = format("%s;$([System.Environment]::GetEnvironmentVariable('%s'))", _make_dirs(v), k) @@ -269,7 +274,7 @@ function _make_vsinfo_groups() local groups = {} local group_deps = {} for targetname, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then local group_path = target:get("group") if group_path then local group_name = path.filename(group_path) @@ -290,6 +295,29 @@ function _make_vsinfo_groups() return groups, group_deps end +-- config target +function _config_target(target) + for _, rule in ipairs(target:orderules()) do + local on_config = rule:script("config") + if on_config then + on_config(target) + end + end + local on_config = target:script("config") + if on_config then + on_config(target) + end +end + +-- config targets +function _config_targets() + for _, target in ipairs(project.ordertargets()) do + if target:is_enabled() then + _config_target(target) + end + end +end + -- make vstudio project function main(outputdir, vsinfo) @@ -326,6 +354,15 @@ function main(outputdir, vsinfo) vsinfo._groups = groups vsinfo._group_deps = group_deps + -- init config flags + local flags = {} + for k, v in pairs(localcache.get("config", "options")) do + if k ~= "plat" and k ~= "mode" and k ~= "arch" and k ~= "clean" and k ~= "buildir" then + table.insert(flags, "--" .. k .. "=" .. tostring(v)) + end + end + vsinfo.configflags = os.args(flags) + -- load targets local targets = {} vsinfo._arch_modes = {} @@ -365,6 +402,9 @@ function main(outputdir, vsinfo) -- install and update requires install_requires() + -- config targets + _config_targets() + -- update config files generate_configfiles() generate_configheader() @@ -374,7 +414,7 @@ function main(outputdir, vsinfo) -- save targets for targetname, target in pairs(project.targets()) do - if not target:isphony() then + if not target:is_phony() then -- make target with the given mode and arch targets[targetname] = targets[targetname] or {} @@ -384,7 +424,7 @@ function main(outputdir, vsinfo) _target.target = targetname _target.vcxprojdir = path.join(vsinfo.solution_dir, targetname) _target.target_id = hash.uuid4(targetname) - _target.kind = target:targetkind() + _target.kind = target:kind() _target.scriptdir = path.relative(target:scriptdir(), _target.vcxprojdir) _target.projectdir = path.relative(project.directory(), _target.vcxprojdir) local targetdir = target:get("targetdir") @@ -437,7 +477,27 @@ function main(outputdir, vsinfo) target._deps[v] = targets[v] end end - vsinfo.targets = table.keys(targets) + + -- we need set startup project for default or binary target + -- @see https://github.com/xmake-io/xmake/issues/1249 + local targetnames = {} + for targetname, target in pairs(project.targets()) do + if not target:is_phony() then + if target:get("default") == true then + table.insert(targetnames, 1, targetname) + elseif target:is_binary() then + local first_target = targetnames[1] and project.target(targetnames[1]) + if not first_target or first_target:is_default() then + table.insert(targetnames, 1, targetname) + else + table.insert(targetnames, targetname) + end + else + table.insert(targetnames, targetname) + end + end + end + vsinfo.targets = targetnames vsinfo._targets = targets return vsinfo end diff --git a/xmake/plugins/project/vsxmake/render.lua b/xmake/plugins/project/vsxmake/render.lua index eb39402af..99be35197 100644 --- a/xmake/plugins/project/vsxmake/render.lua +++ b/xmake/plugins/project/vsxmake/render.lua @@ -22,9 +22,9 @@ function _fill(opt, parmas) return function(match) local imp = match:match("^Import%((.+)%)$") if imp then - local func, overload = os.files(path.join(opt.templatedir, imp .. "(*)")) - assert(overload == 1) - func = func[1] + local funcs = os.files(path.join(opt.templatedir, imp .. "(*)")) + assert(#funcs == 1) + local func = funcs[1] local args = path.filename(func):match("%((.+)%)$"):split(",") return _render(func, opt, args) end diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.props b/xmake/plugins/project/vsxmake/vsproj/Xmake.props index eaa8472c4..a783c8ebc 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.props +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -100,6 +100,9 @@ <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('gnuxx1z'))">stdcpp17</LanguageStandard> <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('gnuxx20'))">stdcpplatest</LanguageStandard> <LanguageStandard Condition="'%(LanguageStandard)' == '' And $(XmakeLanguages.Contains('gnuxx2a'))">stdcpplatest</LanguageStandard> + <PrecompiledHeader Condition="'%(PrecompiledHeader)' == '' And $(XmakePrecompiledHeader.Contains('.h'))">Use</PrecompiledHeader> + <PrecompiledHeaderFile Condition="'%(PrecompiledHeaderFile)' == '' And $(XmakePrecompiledHeader.Contains('.h'))">$(XmakeProjectDir)\$(XmakePrecompiledHeader)</PrecompiledHeaderFile> + <ForcedIncludeFiles Condition="'%(ForcedIncludeFiles)' == '' And $(XmakePrecompiledHeader.Contains('.h'))">$(XmakeProjectDir)\$(XmakePrecompiledHeader);%(ForcedIncludeFiles)</ForcedIncludeFiles> </ClCompile> <Link> diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 6ec266f11..9a23799c1 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -94,14 +94,19 @@ Text="$(XmakeProjectFile) not found at '$(XmakeProjectDirResolved)', please set XmakeProjectDir in vcxproj file" /> </Target> <Target Name="_XmakeConfig" DependsOnTargets="_XmakeProjCheck"> - <Message Text="$xmake config $(_XmakeCommonFlags) $(_XmakeConfigFlags)" Importance="High" /> + <Message Text="$xmake config $(_XmakeCommonFlags) $(_XmakeConfigFlags)" Importance="High" Condition="'$(XmakeDefault)' != 'false'" /> <Exec StdOutEncoding="utf-8" StdErrEncoding="utf-8" Command="$(_XmakeEnv) - $(_XmakeExecutable) config $(_XmakeCommonFlags) $(_XmakeConfigFlags)" EchoOff="true" /> + $(_XmakeExecutable) config $(_XmakeCommonFlags) $(_XmakeConfigFlags)" EchoOff="true" Condition="'$(XmakeDefault)' != 'false'" /> </Target> <Target Name="_XmakeBuild" DependsOnTargets="_XmakeProjCheck"> - <Message Text="$xmake build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" Importance="High" /> + <Message Text="$xmake build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" Importance="High" Condition="'$(XmakeDefault)' != 'false'" /> <Exec StdOutEncoding="utf-8" StdErrEncoding="utf-8" Command="$(_XmakeEnv) - $(_XmakeExecutable) build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" EchoOff="true" /> + $(_XmakeExecutable) build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" EchoOff="true" Condition="'$(XmakeDefault)' != 'false'" /> + </Target> + <Target Name="_XmakeRebuild" DependsOnTargets="_XmakeProjCheck"> + <Message Text="$xmake build -r $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" Importance="High" Condition="'$(XmakeDefault)' != 'false'" /> + <Exec StdOutEncoding="utf-8" StdErrEncoding="utf-8" Command="$(_XmakeEnv) + $(_XmakeExecutable) build -r $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(XmakeTarget)" EchoOff="true" Condition="'$(XmakeDefault)' != 'false'" /> </Target> <Target Name="_XmakeBuildFile" DependsOnTargets="_XmakeProjCheck"> <ItemGroup> @@ -116,9 +121,9 @@ $(_XmakeExecutable) build $(_XmakeCommonFlags) $(_XmakeBuildFileFlags) $(FileFlag) $(XmakeTarget)" EchoOff="true" /> </Target> <Target Name="_XmakeClean" DependsOnTargets="_XmakeProjCheck"> - <Message Text="$xmake clean $(_XmakeCommonFlags) $(_XmakeCleanFlags) $(XmakeTarget)" Importance="High" /> + <Message Text="$xmake clean $(_XmakeCommonFlags) $(_XmakeCleanFlags) $(XmakeTarget)" Importance="High" Condition="'$(XmakeDefault)' != 'false'" /> <Exec StdOutEncoding="utf-8" StdErrEncoding="utf-8" Command="$(_XmakeEnv) - $(_XmakeExecutable) clean $(_XmakeCommonFlags) $(_XmakeCleanFlags) $(XmakeTarget)" EchoOff="true" /> + $(_XmakeExecutable) clean $(_XmakeCommonFlags) $(_XmakeCleanFlags) $(XmakeTarget)" EchoOff="true" Condition="'$(XmakeDefault)' != 'false'" /> </Target> <Target Name="Show"> @@ -130,6 +135,7 @@ MSBuild Properties: XmakeBasename: $(XmakeBasename) XmakeFilename: $(XmakeFilename) XmakeKind: $(XmakeKind) + XmakeDefault: $(XmakeDefault) XmakeCudaVersion: $(XmakeCudaVersion) XmakeWindowsSdkVersion: $(XmakeWindowsSdkVersion) XmakeMfcKind: $(XmakeMfcKind) @@ -139,6 +145,7 @@ MSBuild Properties: XmakeIncludeDirs: $(XmakeIncludeDirs) XmakeLinkDirs: $(XmakeLinkDirs) XmakeSourceDirs: $(XmakeSourceDirs) + XmakePrecompiledHeader: $(XmakePrecompiledHeader) XmakeRunEnvs: $(XmakeRunEnvs) Xmake Path: XmakeProgramDir: $(XmakeProgramDir) @@ -211,7 +218,7 @@ MSBuild Properties: <Target Name="Clean" Condition="'$(DesignTimeBuild)' != 'true'"> <CallTarget Targets="Show" Condition="$(XmakeDiagnosis)" /> <CallTarget Targets="BeforeClean" /> - <CallTarget Targets="_XmakeClean;_XmakeConfig" /> + <CallTarget Targets="_XmakeConfig;_XmakeClean" /> <CallTarget Targets="AfterClean" /> </Target> @@ -220,12 +227,7 @@ MSBuild Properties: <Target Name="Rebuild" Condition="'$(DesignTimeBuild)' != 'true'"> <CallTarget Targets="Show" Condition="$(XmakeDiagnosis)" /> <CallTarget Targets="BeforeRebuild" /> - <CallTarget Targets="BeforeClean" /> - <CallTarget Targets="_XmakeClean;_XmakeConfig" /> - <CallTarget Targets="AfterClean" /> - <CallTarget Targets="BeforeBuild" /> - <CallTarget Targets="_XmakeBuild" /> - <CallTarget Targets="AfterBuild" /> + <CallTarget Targets="_XmakeConfig;_XmakeRebuild" /> <CallTarget Targets="AfterRebuild" /> </Target> diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters index eb8dfdb75..02ae9b11b 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/#target#.vcxproj.filters @@ -45,6 +45,7 @@ </ItemGroup> <ItemGroup> #Import(File.rc)# +#Import(File.ui)# </ItemGroup> <Import Condition="Exists('$(MSBuildThisFileDirectory)\Xmake.Custom.files.filters')" Project="$(MSBuildThisFileDirectory)\Xmake.Custom.files.filters" /> diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.ui(fileui) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.ui(fileui) new file mode 100644 index 000000000..6588bbf15 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj.filters/File.ui(fileui) @@ -0,0 +1,3 @@ + <None Include="$(XmakeProjectDir)\#path#"> + <Filter>#dir#</Filter> + </None> diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj index 9083dc278..3574c7d4d 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/#target#.vcxproj @@ -45,6 +45,7 @@ </ItemGroup> <ItemGroup> #Import(File.rc)# +#Import(File.ui)# </ItemGroup> <!-- <ItemGroup> #Import(ProjectRef)# diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.ui(fileui) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.ui(fileui) new file mode 100644 index 000000000..3df4626b5 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/File.ui(fileui) @@ -0,0 +1 @@ + <None Include="$(XmakeProjectDir)\#path#" /> diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) index 8e1279b37..4832d8e93 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) +++ b/xmake/plugins/project/vsxmake/vsproj/templates/vcxproj/XmakeConfig(mode,arch) @@ -5,6 +5,7 @@ <XmakePlat>#plat#</XmakePlat> <XmakeArch>#arch#</XmakeArch> <XmakeKind>#kind#</XmakeKind> + <XmakeDefault>#default#</XmakeDefault> <XmakeDefines>#defines#</XmakeDefines> <XmakeLanguages>#languages#</XmakeLanguages> <XmakeSubSystem>#subsystem#</XmakeSubSystem> @@ -16,4 +17,5 @@ <XmakeIncludeDirs>#includedirs#</XmakeIncludeDirs> <XmakeLinkDirs>#linkdirs#</XmakeLinkDirs> <XmakeSourceDirs>#sourcedirs#</XmakeSourceDirs> + <XmakePrecompiledHeader>#pcheaderfile#</XmakePrecompiledHeader> </PropertyGroup> diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index 926533dbf..0055aaff2 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -24,6 +24,7 @@ import("vstudio.impl.vsinfo", { rootdir = path.directory(os.scriptdir()) }) import("render") import("getinfo") import("core.project.config") +import("core.cache.localcache") local template_root = path.join(os.scriptdir(), "vsproj", "templates") local template_sln = path.join(template_root, "sln", "vsxmake.sln") @@ -130,6 +131,9 @@ function _buildparams(info, target, default) elseif args.filerc then local files = info._targets[target].sourcefiles table.insert(r, _filter_files(files, {".rc"})) + elseif args.fileui then -- for qt/.ui + local files = info._targets[target].sourcefiles + table.insert(r, _filter_files(files, {".ui"})) elseif args.incc then local files = info._targets[target].headerfiles table.insert(r, _filter_files(files, nil, {".natvis"})) @@ -166,6 +170,17 @@ function _writefileifneeded(file, content) io.writefile(file, content) end +function _clear_cacheconf() + config.clear() + config.save() + localcache.clear("config") + localcache.clear("detect") + localcache.clear("option") + localcache.clear("package") + localcache.clear("toolchain") + localcache.save() +end + -- make function make(version) @@ -215,5 +230,8 @@ function make(version) _trycp(template_items, proj_dir) _trycp(template_itemfil, proj_dir) end + + -- clear config and local cache + _clear_cacheconf() end end diff --git a/xmake/plugins/project/xmake.lua b/xmake/plugins/project/xmake.lua index 78715393c..794cd62af 100644 --- a/xmake/plugins/project/xmake.lua +++ b/xmake/plugins/project/xmake.lua @@ -46,9 +46,8 @@ task("project") , " - xcode (need cmake)" , " - compile_flags" , " - compile_commands (clang compilation database with json format)" - , " - vs (auto detect), vs2002, vs2003, vs2005, vs2008" - , " - vs2010, vs2012, vs2013, vs2015, vs2017, vs2019" - , " - vsxmake (auto detect), vsxmake2010 ~ vsxmake2019" + , " - vs (auto detect), vs2002 - vs2022" + , " - vsxmake (auto detect), vsxmake2010 ~ vsxmake2022" , values = function (complete, opt) if not complete then return end @@ -58,10 +57,10 @@ task("project") end } , {'m', "modes", "kv" , nil , "Set the project modes." , " e.g. " - , " - xmake project -k vsxmake -m \"release" .. path.envsep() .. "debug\"" } + , " - xmake project -k vsxmake -m \"release,debug\"" } , {'a', "archs", "kv" , nil , "Set the project archs." , " e.g. " - , " - xmake project -k vsxmake -a \"x86" .. path.envsep() .. "x64\"" } + , " - xmake project -k vsxmake -a \"x86,x64\"" } , {nil, "outputdir", "v" , "." , "Set the output directory." } } } diff --git a/xmake/plugins/repo/main.lua b/xmake/plugins/repo/main.lua index f8bf1bd4d..a4ec01b90 100644 --- a/xmake/plugins/repo/main.lua +++ b/xmake/plugins/repo/main.lua @@ -26,7 +26,7 @@ import("core.platform.platform") import("core.package.repository") import("devel.git") import("private.async.runjobs") -import("actions.require.impl.environment", {rootdir = os.programdir()}) +import("private.action.require.impl.environment") -- add repository url function _add(name, url, branch, is_global) diff --git a/xmake/plugins/show/info/target.lua b/xmake/plugins/show/info/target.lua index 30462848a..fb99b31e4 100644 --- a/xmake/plugins/show/info/target.lua +++ b/xmake/plugins/show/info/target.lua @@ -33,7 +33,7 @@ function main(name) -- show target information print("The information of target(%s):", name) - cprint(" ${color.dump.string}kind${clear}: %s", target:targetkind()) + cprint(" ${color.dump.string}kind${clear}: %s", target:kind()) cprint(" ${color.dump.string}targetfile${clear}: %s", target:targetfile()) local deps = target:get("deps") if deps then diff --git a/xmake/plugins/show/lists/envs.lua b/xmake/plugins/show/lists/envs.lua index 63cad89f7..4092901fa 100644 --- a/xmake/plugins/show/lists/envs.lua +++ b/xmake/plugins/show/lists/envs.lua @@ -22,18 +22,23 @@ import("core.base.text") import("core.base.global") import("core.project.config") +import("core.project.project") -- show all toolchains function main() - local envs = { XMAKE_PROGRAM_DIR = {"Set the program scripts directory of xmake.", os.programdir()}, - XMAKE_CONFIGDIR = {"Set the local config directory of project.", config.directory()}, - XMAKE_GLOBALDIR = {"Set the global config directory of xmake.", global.directory()}, - XMAKE_COLORTERM = {"Set the color terminal environment.", os.getenv("XMAKE_COLORTERM") or os.getenv("COLORTERM")}, - XMAKE_LOGFILE = {"Set the log output file path.", os.getenv("XMAKE_LOGFILE")}, - XMAKE_ROOT = {"Allow xmake to run under root.", os.getenv("XMAKE_ROOT")}, - XMAKE_RAMDIR = {"Set the ramdisk directory.", os.getenv("XMAKE_RAMDIR")}, - XMAKE_TMPDIR = {"Set the temporary directory.", os.tmpdir()}} + local envs = { XMAKE_PROGRAM_DIR = {"Set the program scripts directory of xmake.", os.programdir()}, + XMAKE_CONFIGDIR = {"Set the local config directory of project.", config.directory()}, + XMAKE_GLOBALDIR = {"Set the global config directory of xmake.", global.directory()}, + XMAKE_COLORTERM = {"Set the color terminal environment.", os.getenv("XMAKE_COLORTERM") or os.getenv("COLORTERM")}, + XMAKE_LOGFILE = {"Set the log output file path.", os.getenv("XMAKE_LOGFILE")}, + XMAKE_ROOT = {"Allow xmake to run under root.", os.getenv("XMAKE_ROOT")}, + XMAKE_RAMDIR = {"Set the ramdisk directory.", os.getenv("XMAKE_RAMDIR")}, + XMAKE_RCFILES = {"Set the runtime configuration files.", path.joinenv(project.rcfiles())}, + XMAKE_TMPDIR = {"Set the temporary directory.", os.tmpdir()}, + XMAKE_PROFILE = {"Start profiler, e.g. perf, trace.", os.getenv("XMAKE_PROFILE")}, + XMAKE_PKG_CACHEDIR = {"Set the cache directory of packages.", os.getenv("XMAKE_PKG_CACHEDIR")}, + XMAKE_PKG_INSTALLDIR = {"Set the install directory of packages.", os.getenv("XMAKE_PACKAGEDIR")}} local width = 24 for name, env in pairs(envs) do cprint("${color.dump.string}%s${clear}%s%s", name, (" "):rep(width - #name), env[1]) diff --git a/xmake/rules/c++/xmake.lua b/xmake/rules/c++/xmake.lua index 1b188566a..14dc961d3 100644 --- a/xmake/rules/c++/xmake.lua +++ b/xmake/rules/c++/xmake.lua @@ -18,31 +18,26 @@ -- @file xmake.lua -- --- define rule: c.build.pcheader rule("c.build.pcheader") before_build(function (target, opt) import("private.action.build.pcheader")(target, "c", opt) end) --- define rule: c.build rule("c.build") set_sourcekinds("cc") add_deps("c.build.pcheader") on_build_files("private.action.build.object", {batch = true}) --- define rule: c++.build.pcheader rule("c++.build.pcheader") before_build(function (target, opt) import("private.action.build.pcheader")(target, "cxx", opt) end) --- define rule: c++.build rule("c++.build") set_sourcekinds("cxx") add_deps("c++.build.pcheader", "c++.build.modules") on_build_files("private.action.build.object", {batch = true}) --- define rule: cpp rule("c++") -- add build rules @@ -66,3 +61,6 @@ rule("c++") -- check licenses add_deps("utils.check.licenses") + + -- add platform rules + add_deps("platform.windows") diff --git a/xmake/rules/capnproto/capnp.lua b/xmake/rules/capnproto/capnp.lua new file mode 100644 index 000000000..5b37b0956 --- /dev/null +++ b/xmake/rules/capnproto/capnp.lua @@ -0,0 +1,93 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author wsw0108 +-- @file capnp.lua +-- + +-- imports +import("lib.detect.find_tool") + +-- get capnp +function _get_capnp(target) + + -- find capnp + local capnp = target:data("capnproto.capnp") + if not capnp then + capnp = find_tool("capnp") + if capnp and capnp.program then + target:data_set("capnproto.capnp", capnp.program) + end + end + + -- get capnp + return assert(target:data("capnproto.capnp"), "capnp not found!") +end + +-- generate build commands +function buildcmd(target, batchcmds, sourcefile_capnp, opt) + + -- get capnp + local capnp = _get_capnp(target) + + -- get c/c++ source file for capnproto + local prefixdir + local public + local fileconfig = target:fileconfig(sourcefile_capnp) + if fileconfig then + public = fileconfig.capnp_public + prefixdir = fileconfig.capnp_rootdir + end + local rootdir = path.join(target:autogendir(), "rules", "capnproto") + local filename = path.basename(sourcefile_capnp) .. ".capnp.c++" + local sourcefile_cx = target:autogenfile(sourcefile_capnp, {rootdir = rootdir, filename = filename}) + local sourcefile_dir = prefixdir and path.join(rootdir, prefixdir) or path.directory(sourcefile_cx) + + -- add includedirs + target:add("includedirs", sourcefile_dir, {public = public}) + + -- add objectfile + local objectfile = target:objectfile(sourcefile_cx) + table.insert(target:objectfiles(), objectfile) + + -- add commands + batchcmds:mkdir(sourcefile_dir) + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.capnp %s", sourcefile_capnp) + local capnproto = target:pkg("capnproto") + local includes = capnproto:get("sysincludedirs") + local argv = {"compile"} + for _, value in ipairs(includes) do + table.insert(argv, "-I" .. value) + end + table.insert(argv, "-I" .. (prefixdir and prefixdir or path.directory(sourcefile_capnp))) + if prefixdir then + table.insert(argv, "--src-prefix=" .. prefixdir) + end + table.insert(argv, "-o") + table.insert(argv, "c++:" .. sourcefile_dir) + table.insert(argv, sourcefile_capnp) + batchcmds:vrunv(capnp, argv) + local configs = {includedirs = sourcefile_dir, languages = "c++14"} + if target:is_plat("windows") then + configs.cxflags = "/TP" + end + batchcmds:compile(sourcefile_cx, objectfile, {sourcekind = "cxx", configs = configs}) + + -- add deps + batchcmds:add_depfiles(sourcefile_capnp) + batchcmds:set_depmtime(os.mtime(objectfile)) + batchcmds:set_depcache(target:dependfile(objectfile)) +end diff --git a/xmake/rules/capnproto/xmake.lua b/xmake/rules/capnproto/xmake.lua new file mode 100644 index 000000000..651c5bd47 --- /dev/null +++ b/xmake/rules/capnproto/xmake.lua @@ -0,0 +1,26 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author wsw0108 +-- @file xmake.lua +-- + +-- define rule: capnproto.cpp +rule("capnproto.cpp") + set_extensions(".capnp") + before_buildcmd_file(function (target, batchcmds, sourcefile_capnp, opt) + return import("capnp").buildcmd(target, batchcmds, sourcefile_capnp, opt) + end) diff --git a/xmake/rules/cuda/devlink/xmake.lua b/xmake/rules/cuda/devlink/xmake.lua index d44686b50..e92a0b779 100644 --- a/xmake/rules/cuda/devlink/xmake.lua +++ b/xmake/rules/cuda/devlink/xmake.lua @@ -42,7 +42,7 @@ rule("cuda.build.devlink") end -- only for binary/shared - local targetkind = target:targetkind() + local targetkind = target:kind() if targetkind ~= "binary" and targetkind ~= "shared" then return end diff --git a/xmake/rules/lex_yacc/lex/xmake.lua b/xmake/rules/lex_yacc/lex/xmake.lua index 0e28a2ad7..cbdb766e4 100644 --- a/xmake/rules/lex_yacc/lex/xmake.lua +++ b/xmake/rules/lex_yacc/lex/xmake.lua @@ -20,93 +20,32 @@ -- define rule: lex rule("lex") - - -- set extension set_extensions(".l", ".ll") - - -- load lex/flex - before_load(function (target) - import("core.project.config") - import("lib.detect.find_tool") - local lex = config.get("__lex") - if not lex then - lex = find_tool("flex") or find_tool("lex") - if lex and lex.program then - config.set("__lex", lex.program) - cprint("checking for Lex ... ${color.success}%s", lex.program) - else - cprint("checking for Lex ... ${color.nothing}${text.nothing}") - raise("lex/flex not found!") - end - end - end) - - -- build lex file - on_build_file(function (target, sourcefile_lex, opt) + on_buildcmd_file(function (target, batchcmds, sourcefile_lex, opt) -- imports - import("core.base.option") - import("core.theme.theme") - import("core.project.config") - import("core.project.depend") - import("core.tool.compiler") - import("private.utils.progress") + import("lib.detect.find_tool") -- get lex - local lex = assert(config.get("__lex"), "lex not found!") - - -- get extension: .l/.ll - local extension = path.extension(sourcefile_lex) + local lex = assert(find_tool("flex") or find_tool("lex"), "lex not found!") -- get c/c++ source file for lex + local extension = path.extension(sourcefile_lex) local sourcefile_cx = path.join(target:autogendir(), "rules", "lex_yacc", path.basename(sourcefile_lex) .. (extension == ".ll" and ".cpp" or ".c")) - local sourcefile_dir = path.directory(sourcefile_cx) - - -- get object file - local objectfile = target:objectfile(sourcefile_cx) - - -- load compiler - local compinst = compiler.load((extension == ".ll" and "cxx" or "cc"), {target = target}) - - -- get compile flags - local compflags = compinst:compflags({target = target, sourcefile = sourcefile_cx}) -- add objectfile + local objectfile = target:objectfile(sourcefile_cx) table.insert(target:objectfiles(), objectfile) - -- load dependent info - local dependfile = target:dependfile(objectfile) - local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {}) - - -- need build this object? - local depvalues = {compinst:program(), compflags} - if not depend.is_changed(dependinfo, {lastmtime = os.mtime(objectfile), values = depvalues}) then - return - end - - -- trace progress info - progress.show(opt.progress, "${color.build.object}compiling.lex %s", sourcefile_lex) - - -- ensure the source file directory - if not os.isdir(sourcefile_dir) then - os.mkdir(sourcefile_dir) - end - - -- compile lex - os.vrunv(lex, {"-o", sourcefile_cx, sourcefile_lex}) - - -- trace - if option.get("verbose") then - print(compinst:compcmd(sourcefile_cx, objectfile, {compflags = compflags})) - end - - -- compile c/c++ source file for lex - dependinfo.files = {} - assert(compinst:compile(sourcefile_cx, objectfile, {dependinfo = dependinfo, compflags = compflags})) + -- add commands + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.lex %s", sourcefile_lex) + batchcmds:mkdir(path.directory(sourcefile_cx)) + batchcmds:vrunv(lex.program, {"-o", sourcefile_cx, sourcefile_lex}) + batchcmds:compile(sourcefile_cx, objectfile) - -- update files and values to the dependent file - dependinfo.values = depvalues - table.insert(dependinfo.files, sourcefile_lex) - depend.save(dependinfo, dependfile) + -- add deps + batchcmds:add_depfiles(sourcefile_lex) + batchcmds:set_depmtime(os.mtime(objectfile)) + batchcmds:set_depcache(target:dependfile(objectfile)) end) diff --git a/xmake/rules/lex_yacc/yacc/xmake.lua b/xmake/rules/lex_yacc/yacc/xmake.lua index a93f458c0..f93db2ccb 100644 --- a/xmake/rules/lex_yacc/yacc/xmake.lua +++ b/xmake/rules/lex_yacc/yacc/xmake.lua @@ -20,96 +20,36 @@ -- define rule: yacc rule("yacc") - - -- set extension set_extensions(".y", ".yy") - - -- load yacc/bison - before_load(function (target) - import("core.project.config") - import("lib.detect.find_tool") - local yacc = config.get("__yacc") - if not yacc then - yacc = find_tool("bison") or find_tool("yacc") - if yacc and yacc.program then - config.set("__yacc", yacc.program) - cprint("checking for Yacc ... ${color.success}%s", yacc.program) - else - cprint("checking for Yacc ... ${color.nothing}${text.nothing}") - raise("yacc/bison not found!") - end - end - end) - - -- build yacc file - before_build_file(function (target, sourcefile_yacc, opt) + before_buildcmd_file(function (target, batchcmds, sourcefile_yacc, opt) -- imports - import("core.base.option") - import("core.theme.theme") - import("core.project.config") - import("core.project.depend") - import("core.tool.compiler") - import("private.utils.progress") + import("lib.detect.find_tool") -- get yacc - local yacc = assert(config.get("__yacc"), "yacc not found!") - - -- get extension: .l/.ll - local extension = path.extension(sourcefile_yacc) + local yacc = assert(find_tool("bison") or find_tool("yacc"), "yacc/bison not found!") -- get c/c++ source file for yacc - local sourcefile_cx = path.join(target:autogendir(), "rules", "lex_yacc", path.basename(sourcefile_yacc) .. ".tab" .. (extension == ".yy" and ".cpp" or ".c")) - local sourcefile_dir = path.directory(sourcefile_cx) - - -- get object file - local objectfile = target:objectfile(sourcefile_cx) - - -- load compiler - local compinst = compiler.load((extension == ".yy" and "cxx" or "cc"), {target = target}) - - -- get compile flags - local compflags = compinst:compflags({target = target, sourcefile = sourcefile_cx}) + local extension = path.extension(sourcefile_yacc) + local sourcefile_cx = path.join(target:autogendir(), "rules", "yacc_yacc", path.basename(sourcefile_yacc) .. ".tab" .. (extension == ".yy" and ".cpp" or ".c")) -- add objectfile + local objectfile = target:objectfile(sourcefile_cx) table.insert(target:objectfiles(), objectfile) -- add includedirs + local sourcefile_dir = path.directory(sourcefile_cx) target:add("includedirs", sourcefile_dir) - -- load dependent info - local dependfile = target:dependfile(objectfile) - local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {}) - - -- need build this object? - local depvalues = {compinst:program(), compflags} - if not depend.is_changed(dependinfo, {lastmtime = os.mtime(objectfile), values = depvalues}) then - return - end - - -- trace progress info - progress.show(opt.progress, "${color.build.object}compiling.yacc %s", sourcefile_yacc) - - -- ensure the source file directory - if not os.isdir(sourcefile_dir) then - os.mkdir(sourcefile_dir) - end - - -- compile yacc - os.vrunv(yacc, {"-d", "-o", sourcefile_cx, sourcefile_yacc}) - - -- trace - if option.get("verbose") then - print(compinst:compcmd(sourcefile_cx, objectfile, {compflags = compflags})) - end - - -- compile c/c++ source file for yacc - dependinfo.files = {} - assert(compinst:compile(sourcefile_cx, objectfile, {dependinfo = dependinfo, compflags = compflags})) + -- add commands + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.yacc %s", sourcefile_yacc) + batchcmds:mkdir(sourcefile_dir) + batchcmds:vrunv(yacc.program, {"-d", "-o", sourcefile_cx, sourcefile_yacc}) + batchcmds:compile(sourcefile_cx, objectfile) - -- update files and values to the dependent file - dependinfo.values = depvalues - table.insert(dependinfo.files, sourcefile_yacc) - depend.save(dependinfo, dependfile) + -- add deps + batchcmds:add_depfiles(sourcefile_yacc) + batchcmds:set_depmtime(os.mtime(objectfile)) + batchcmds:set_depcache(target:dependfile(objectfile)) end) diff --git a/xmake/rules/luarocks/module/xmake.lua b/xmake/rules/luarocks/module/xmake.lua new file mode 100644 index 000000000..e74080912 --- /dev/null +++ b/xmake/rules/luarocks/module/xmake.lua @@ -0,0 +1,76 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +rule("luarocks.module") + before_load(function (target) + + -- imports + import("core.cache.detectcache") + import("core.project.target", {alias = "project_target"}) + + -- set kind + if target:is_plat("macosx") then + target:set("kind", "binary") + target:add("ldflags", "-bundle", "-undefined dynamic_lookup", {force = true}) + else + target:set("kind", "shared") + end + + -- set library name + local modulename = target:name():split('.', {plain = true}) + modulename = modulename[#modulename] + if target:is_plat("windows", "mingw") then + target:set("basename", modulename) + else + target:set("filename", modulename .. ".so") + end + + -- export symbols + if target:is_plat("windows") then + local exported_name = target:name():gsub("%.", "_") + exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name + target:add("shflags", "/export:luaopen_" .. exported_name, {force = true}) + else + target:set("symbols", "none") + end + + -- add lua library + local has_lua = false + local includedirs = get_config("includedirs") -- pass lua library from luarocks-build-xmake/xmake.lua + if includedirs and includedirs:find("lua", 1, true) then + has_lua = true + end + if not has_lua then + -- user use `add_requires/add_packages` to add lua/luajit package + for _, pkg in ipairs(target:get("packages")) do + if pkg == "lua" or pkg == "luajit" then + has_lua = true + break + end + end + end + if not has_lua then + target:add(find_package("lua")) + end + end) + on_install(function (target) + local moduledir = path.directory((target:name():gsub('%.', '/'))) + import('target.action.install')(target, {libdir = path.join('lib', moduledir), bindir = path.join('lib', moduledir)}) + end) diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index b4bcdfe71..d68d8e42c 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -20,7 +20,7 @@ -- define rule: debug mode rule("mode.debug") - after_load(function (target) + on_config(function (target) -- is debug mode now? xmake f -m debug if is_mode("debug") then @@ -39,13 +39,13 @@ rule("mode.debug") -- define rule: release mode rule("mode.release") - after_load(function (target) + on_config(function (target) -- is release mode now? xmake f -m release if is_mode("release") then -- set the symbols visibility: hidden - if not target:get("symbols") and target:targetkind() ~= "shared" then + if not target:get("symbols") and target:kind() ~= "shared" then target:set("symbols", "hidden") end @@ -62,12 +62,15 @@ rule("mode.release") if not target:get("strip") then target:set("strip", "all") end + + -- enable NDEBUG macros to disables standard-C assertions + target:add("cxflags", "-DNDEBUG") end end) -- define rule: release with debug symbols mode rule("mode.releasedbg") - after_load(function (target) + on_config(function (target) -- is releasedbg mode now? xmake f -m releasedbg if is_mode("releasedbg") then @@ -90,12 +93,15 @@ rule("mode.releasedbg") if not target:get("strip") then target:set("strip", "all") end + + -- enable NDEBUG macros to disables standard-C assertions + target:add("cxflags", "-DNDEBUG") end end) -- define rule: release with minsize mode rule("mode.minsizerel") - after_load(function (target) + on_config(function (target) -- is minsizerel mode now? xmake f -m minsizerel if is_mode("minsizerel") then @@ -114,12 +120,15 @@ rule("mode.minsizerel") if not target:get("strip") then target:set("strip", "all") end + + -- enable NDEBUG macros to disables standard-C assertions + target:add("cxflags", "-DNDEBUG") end end) -- define rule: profile mode rule("mode.profile") - after_load(function (target) + on_config(function (target) -- is profile mode now? xmake f -m profile if is_mode("profile") then @@ -142,12 +151,15 @@ rule("mode.profile") target:add("cxflags", "-pg") target:add("mxflags", "-pg") target:add("ldflags", "-pg") + + -- enable NDEBUG macros to disables standard-C assertions + target:add("cxflags", "-DNDEBUG") end end) -- define rule: coverage mode rule("mode.coverage") - after_load(function (target) + on_config(function (target) -- is coverage mode now? xmake f -m coverage if is_mode("coverage") then @@ -171,7 +183,7 @@ rule("mode.coverage") -- define rule: asan mode rule("mode.asan") - after_load(function (target) + on_config(function (target) -- is asan mode now? xmake f -m asan if is_mode("asan") then @@ -200,7 +212,7 @@ rule("mode.asan") -- define rule: tsan mode rule("mode.tsan") - after_load(function (target) + on_config(function (target) -- is tsan mode now? xmake f -m tsan if is_mode("tsan") then @@ -229,7 +241,7 @@ rule("mode.tsan") -- define rule: msan mode rule("mode.msan") - after_load(function (target) + on_config(function (target) -- is msan mode now? xmake f -m msan if is_mode("msan") then @@ -258,7 +270,7 @@ rule("mode.msan") -- define rule: lsan mode rule("mode.lsan") - after_load(function (target) + on_config(function (target) -- is lsan mode now? xmake f -m lsan if is_mode("lsan") then @@ -287,7 +299,7 @@ rule("mode.lsan") -- define rule: ubsan mode rule("mode.ubsan") - after_load(function (target) + on_config(function (target) -- is ubsan mode now? xmake f -m ubsan if is_mode("ubsan") then @@ -316,7 +328,7 @@ rule("mode.ubsan") -- define rule: valgrind mode rule("mode.valgrind") - after_load(function (target) + on_config(function (target) -- is valgrind mode now? xmake f -m valgrind if is_mode("valgrind") then @@ -339,7 +351,7 @@ rule("mode.valgrind") -- define rule: check mode (deprecated) rule("mode.check") - after_load(function (target) + on_config(function (target) -- is check mode now? xmake f -m check if is_mode("check") then diff --git a/xmake/rules/objc++/xmake.lua b/xmake/rules/objc++/xmake.lua index 72f7c3609..0107690e7 100644 --- a/xmake/rules/objc++/xmake.lua +++ b/xmake/rules/objc++/xmake.lua @@ -23,12 +23,11 @@ rule("objc.build") set_sourcekinds("mm") add_deps("c.build.pcheader") after_load(function (target) - if target:values("objc.build.arc") ~= false then - target:add("mflags", "-fobjc-arc") - else + -- deprecated, we need only use `add_mflags("-fno-objc-arc")` to override it + if target:values("objc.build.arc") == false then target:add("mflags", "-fno-objc-arc") end - if is_plat("macosx", "iphoneos", "watchos") then + if target:is_plat("macosx", "iphoneos", "watchos") then target:add("frameworks", "Foundation", "CoreFoundation") end end) @@ -39,12 +38,11 @@ rule("objc++.build") set_sourcekinds("mxx") add_deps("c++.build.pcheader") after_load(function (target) - if target:values("objc++.build.arc") ~= false then - target:add("mxxflags", "-fobjc-arc") - else + -- deprecated, we need only use `add_mxxflags("-fno-objc-arc")` to override it + if target:values("objc++.build.arc") == false then target:add("mxxflags", "-fno-objc-arc") end - if is_plat("macosx", "iphoneos", "watchos") then + if target:is_plat("macosx", "iphoneos", "watchos") then target:add("frameworks", "Foundation", "CoreFoundation") end end) diff --git a/xmake/rules/platform/linux/bpf/xmake.lua b/xmake/rules/platform/linux/bpf/xmake.lua new file mode 100644 index 000000000..d2afd9160 --- /dev/null +++ b/xmake/rules/platform/linux/bpf/xmake.lua @@ -0,0 +1,58 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- add *.bpf.c for linux bpf program +-- @see https://github.com/xmake-io/xmake/issues/1274 +rule("platform.linux.bpf") + set_extensions(".bpf.c") + on_config(function (target) + assert(is_host("linux"), 'rule("platform.linux.bpf"): only supported on linux!') + local headerdir = path.join(target:autogendir(), "rules", "bpf") + if not os.isdir(headerdir) then + os.mkdir(headerdir) + end + target:add("includedirs", headerdir) + end) + before_buildcmd_file(function (target, batchcmds, sourcefile, opt) + local headerfile = path.join(target:autogendir(), "rules", "bpf", (path.filename(sourcefile):gsub("%.bpf%.c", ".skel.h"))) + local objectfile = path.join(target:autogendir(), "rules", "bpf", (path.filename(sourcefile):gsub("%.bpf%.c", ".bpf.o"))) + local targetarch + if target:is_arch("x86_64", "i386") then + targetarch = "__TARGET_ARCH_x86" + elseif target:is_arch("arm64", "arm64-v8a") then + targetarch = "__TARGET_ARCH_arm64" + elseif target:is_arch("arm.*") then + targetarch = "__TARGET_ARCH_arm" + elseif target:is_arch("mips64", "mips") then + targetarch = "__TARGET_ARCH_mips" + elseif target:is_arch("ppc64", "ppc") then + targetarch = "__TARGET_ARCH_powerpc" + end + target:add("includedirs", path.directory(headerfile)) + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.bpf %s", sourcefile) + batchcmds:mkdir(path.directory(objectfile)) + batchcmds:compile(sourcefile, objectfile, {configs = {force = {cxflags = {"-target bpf", "-g"}}, defines = targetarch}}) + batchcmds:mkdir(path.directory(headerfile)) + batchcmds:execv("bpftool", {"gen", "skeleton", objectfile}, {stdout = headerfile}) + batchcmds:add_depfiles(sourcefile) + batchcmds:set_depmtime(os.mtime(headerfile)) + batchcmds:set_depcache(target:dependfile(headerfile)) + end) + diff --git a/xmake/rules/platform/windows/def/xmake.lua b/xmake/rules/platform/windows/def/xmake.lua new file mode 100644 index 000000000..06e960380 --- /dev/null +++ b/xmake/rules/platform/windows/def/xmake.lua @@ -0,0 +1,36 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- add *.def for windows/dll +rule("platform.windows.def") + set_extensions(".def") + on_config("windows", function (target) + local _, toolname = target:tool("ld") + if toolname == "link" then + for _, sourcebatch in pairs(target:sourcebatches()) do + if sourcebatch.rulename == "platform.windows.def" then + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + target:add("shflags", "/def:" .. path.translate(sourcefile), {force = true}) + end + end + end + end + end) + diff --git a/xmake/rules/platform/windows/manifest/xmake.lua b/xmake/rules/platform/windows/manifest/xmake.lua new file mode 100644 index 000000000..efb750edd --- /dev/null +++ b/xmake/rules/platform/windows/manifest/xmake.lua @@ -0,0 +1,41 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- add *.manifest for windows +-- https://github.com/xmake-io/xmake/issues/1241 +rule("platform.windows.manifest") + set_extensions(".manifest") + on_config("windows", function (target) + local _, toolname = target:tool("ld") + if toolname == "link" then + local manifest = false + for _, sourcebatch in pairs(target:sourcebatches()) do + if sourcebatch.rulename == "platform.windows.manifest" then + for _, sourcefile in ipairs(sourcebatch.sourcefiles) do + target:add("ldflags", "/ManifestFile:" .. path.translate(sourcefile), {force = true}) + manifest = true + end + end + end + if manifest then + target:add("ldflags", "/manifest", {force = true}) + end + end + end) diff --git a/xmake/rules/platform/xmake.lua b/xmake/rules/platform/xmake.lua new file mode 100644 index 000000000..3b11a8047 --- /dev/null +++ b/xmake/rules/platform/xmake.lua @@ -0,0 +1,26 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +rule("platform.windows") + if is_host("windows") then + add_deps("platform.windows.def") + add_deps("platform.windows.manifest") + end + diff --git a/xmake/rules/plugin/vsxmake/xmake.lua b/xmake/rules/plugin/vsxmake/xmake.lua index 323ffb5dd..88693599f 100644 --- a/xmake/rules/plugin/vsxmake/xmake.lua +++ b/xmake/rules/plugin/vsxmake/xmake.lua @@ -28,28 +28,35 @@ -- @endcode -- rule("plugin.vsxmake.autoupdate") - before_build(function (target) + set_kind("project") + after_build(function (opt) -- imports + import("core.project.config") import("core.project.depend") import("core.project.project") import("core.base.task") -- run only once for all xmake process in vs - local tmpfile = os.tmpfile(path.join(os.projectdir(), "plugin.vsxmake.autoupdate")) + local tmpfile = path.join(config.buildir(), ".gens", "rules", "plugin.vsxmake.autoupdate") + local dependfile = tmpfile .. ".d" local lockfile = io.openlock(tmpfile .. ".lock") if lockfile:trylock() then if os.getenv("XMAKE_IN_VSTUDIO") then + local sourcefiles = {} + for _, target in pairs(project.targets()) do + table.join2(sourcefiles, target:sourcefiles(), target:headerfiles()) + end + table.sort(sourcefiles) depend.on_changed(function () -- we use task instead of os.exec("xmake") to avoid the project lock print("update vsxmake project ..") task.run("project", {kind = "vsxmake"}) print("update vsxmake project ok") - end, {dependfile = tmpfile .. ".d", + end, {dependfile = dependfile, files = project.allfiles(), - values = target:sourcefiles()}) + values = sourcefiles}) end lockfile:close() end end) - diff --git a/xmake/rules/protobuf/proto.lua b/xmake/rules/protobuf/proto.lua index f899e91c5..fd93546d6 100644 --- a/xmake/rules/protobuf/proto.lua +++ b/xmake/rules/protobuf/proto.lua @@ -19,16 +19,10 @@ -- -- imports -import("core.base.option") -import("core.theme.theme") -import("core.project.config") -import("core.project.depend") -import("core.tool.compiler") import("lib.detect.find_tool") -import("private.utils.progress") --- build protobuf file -function main(target, sourcekind, sourcefile_proto, opt) +-- get protoc +function _get_protoc(target, sourcekind) -- find protoc local protoc = target:data("protobuf.protoc") @@ -49,12 +43,21 @@ function main(target, sourcekind, sourcefile_proto, opt) end -- get protoc - protoc = assert(target:data(sourcekind == "cxx" and "protobuf.protoc" or "protobuf.protoc-c"), "protoc not found!") + return assert(target:data(sourcekind == "cxx" and "protobuf.protoc" or "protobuf.protoc-c"), "protoc not found!") +end + +-- generate build commands +function buildcmd(target, batchcmds, sourcefile_proto, opt, sourcekind) + + -- get protoc + local protoc = _get_protoc(target, sourcekind) -- get c/c++ source file for protobuf local prefixdir + local public local fileconfig = target:fileconfig(sourcefile_proto) if fileconfig then + public = fileconfig.proto_public prefixdir = fileconfig.proto_rootdir end local rootdir = path.join(target:autogendir(), "rules", "protobuf") @@ -63,66 +66,23 @@ function main(target, sourcekind, sourcefile_proto, opt) local sourcefile_dir = prefixdir and path.join(rootdir, prefixdir) or path.directory(sourcefile_cx) -- add includedirs - target:add("includedirs", sourcefile_dir) - - -- get object file - local objectfile = target:objectfile(sourcefile_cx) - - -- load compiler - local compinst = compiler.load(sourcekind, {target = target}) - - -- get compile flags - local configs = {includedirs = sourcefile_dir} - if sourcekind == "cxx" then - configs.languages = "c++11" - end - local compflags = compinst:compflags({target = target, sourcefile = sourcefile_cx, configs = configs}) + target:add("includedirs", sourcefile_dir, {public = public}) -- add objectfile + local objectfile = target:objectfile(sourcefile_cx) table.insert(target:objectfiles(), objectfile) - -- load dependent info - local dependfile = target:dependfile(objectfile) - local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {}) - - -- need build this object? - local depvalues = {compinst:program(), compflags} - if not depend.is_changed(dependinfo, {lastmtime = os.mtime(objectfile), values = depvalues}) then - return - end - - -- trace progress info - progress.show(opt.progress, "${color.build.object}compiling.proto %s", sourcefile_proto) - - -- ensure the source file directory - if not os.isdir(sourcefile_dir) then - os.mkdir(sourcefile_dir) - end - - -- get compilation flags - local argv = {sourcefile_proto} - if prefixdir then - table.insert(argv, "-I" .. prefixdir) - else - table.insert(argv, "-I" .. path.directory(sourcefile_proto)) - end - table.insert(argv, (sourcekind == "cxx" and "--cpp_out=" or "--c_out=") .. sourcefile_dir) - - -- do compile - os.vrunv(protoc, argv) - - -- trace - if option.get("verbose") then - print(compinst:compcmd(sourcefile_cx, objectfile, {compflags = compflags})) - end - - -- compile c/c++ source file for protobuf - dependinfo.files = {} - assert(compinst:compile(sourcefile_cx, objectfile, {dependinfo = dependinfo, compflags = compflags})) + -- add commands + batchcmds:mkdir(sourcefile_dir) + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.proto %s", sourcefile_proto) + batchcmds:vrunv(protoc, {sourcefile_proto, + "-I" .. (prefixdir and prefixdir or path.directory(sourcefile_proto)), + (sourcekind == "cxx" and "--cpp_out=" or "--c_out=") .. sourcefile_dir}) + batchcmds:compile(sourcefile_cx, objectfile, {configs = {includedirs = sourcefile_dir, languages = (sourcekind == "cxx" and "c++11")}}) - -- update files and values to the dependent file - dependinfo.values = depvalues - table.insert(dependinfo.files, sourcefile_proto) - depend.save(dependinfo, dependfile) + -- add deps + batchcmds:add_depfiles(sourcefile_proto) + batchcmds:set_depmtime(os.mtime(objectfile)) + batchcmds:set_depcache(target:dependfile(objectfile)) end diff --git a/xmake/rules/protobuf/xmake.lua b/xmake/rules/protobuf/xmake.lua index 1abaa2447..e28a9cbb6 100644 --- a/xmake/rules/protobuf/xmake.lua +++ b/xmake/rules/protobuf/xmake.lua @@ -20,23 +20,14 @@ -- define rule: protobuf.cpp rule("protobuf.cpp") - - -- set extension set_extensions(".proto") - - -- build protobuf file - before_build_file(function (target, sourcefile_proto, opt) - import("proto")(target, "cxx", sourcefile_proto, opt) + before_buildcmd_file(function (target, batchcmds, sourcefile_proto, opt) + return import("proto").buildcmd(target, batchcmds, sourcefile_proto, opt, "cxx") end) - -- define rule: protobuf.c rule("protobuf.c") - - -- set extension set_extensions(".proto") - - -- build protobuf file - before_build_file(function (target, sourcefile_proto, opt) - import("proto")(target, "cc", sourcefile_proto, opt) + before_buildcmd_file(function (target, batchcmds, sourcefile_proto, opt) + return import("proto").buildcmd(target, batchcmds, sourcefile_proto, opt, "cc") end) diff --git a/xmake/rules/qt/deploy/android.lua b/xmake/rules/qt/deploy/android.lua index b9ecdaa85..97f97ea7a 100644 --- a/xmake/rules/qt/deploy/android.lua +++ b/xmake/rules/qt/deploy/android.lua @@ -24,6 +24,7 @@ import("core.base.option") import("core.base.semver") import("core.project.config") import("core.project.depend") +import("core.tool.toolchain") import("private.utils.progress") -- escape path @@ -34,6 +35,9 @@ end -- deploy application package for android function main(target, opt) + -- get ndk toolchain + local toolchain_ndk = toolchain.load("ndk", {plat = target:plat(), arch = target:arch()}) + -- get target apk path local target_apk = path.join(target:targetdir(), target:basename() .. ".apk") @@ -52,8 +56,8 @@ function main(target, opt) local qt = target:data("qt") -- get ndk - local ndk = path.translate(assert(config.get("ndk"), "cannot get NDK!")) - local ndk_sdkver = assert(config.get("ndk_sdkver"), "cannot get the sdk version of NDK!") + local ndk = path.translate(assert(toolchain_ndk:config("ndk"), "cannot get NDK!")) + local ndk_sdkver = assert(toolchain_ndk:config("ndk_sdkver"), "cannot get the sdk version of NDK!") -- get ndk host local ndk_host = os.host() .. "-" .. os.arch() @@ -82,10 +86,10 @@ function main(target, opt) local java_home = assert(os.getenv("JAVA_HOME"), "please set $JAVA_HOME environment variable first!") -- get android sdk directory - local android_sdkdir = path.translate(assert(config.get("android_sdk"), "please run `xmake f --android_sdk=xxx` to set the android sdk directory!")) + local android_sdkdir = path.translate(assert(toolchain_ndk:config("android_sdk"), "please run `xmake f --android_sdk=xxx` to set the android sdk directory!")) -- get android build-tools version - local android_build_toolver = assert(config.get("build_toolver"), "please run `xmake f --build_toolver=xxx` to set the android build-tools version!") + local android_build_toolver = assert(toolchain_ndk:config("build_toolver"), "please run `xmake f --build_toolver=xxx` to set the android build-tools version!") -- get qt sdk version local qt_sdkver = config.get("qt_sdkver") @@ -131,12 +135,12 @@ function main(target, opt) -- get stdcpp path local stdcpp_path = path.join(ndk, "sources/cxx-stl/llvm-libc++/libs", target_arch, "libc++_shared.so") if qt_sdkver and qt_sdkver:ge("5.14") then - local toolchain = path.directory(assert(config.get("bin"), "toolchain/bin directory not found!")) - stdcpp_path = path.join(toolchain, "sysroot", "usr", "lib") + local ndk_sysroot = assert(toolchain_ndk:config("ndk_sysroot"), "NDK sysroot directory not found!") + stdcpp_path = path.join(ndk_sysroot, "usr", "lib") end -- get toolchain version - local ndk_toolchains_ver = config.get("ndk_toolchains_ver") or "4.9" + local ndk_toolchains_ver = toolchain_ndk:config("ndk_toolchains_ver") or "4.9" -- generate android-deployment-settings.json file local android_deployment_settings = path.join(workdir, "android-deployment-settings.json") diff --git a/xmake/rules/qt/env/xmake.lua b/xmake/rules/qt/env/xmake.lua index 38fd503fc..4cc39794c 100644 --- a/xmake/rules/qt/env/xmake.lua +++ b/xmake/rules/qt/env/xmake.lua @@ -18,11 +18,8 @@ -- @file xmake.lua -- --- define rule: environment rule("qt.env") - - -- before load - before_load(function (target) + on_load(function (target) -- imports import("detect.sdks.find_qt") @@ -33,11 +30,11 @@ rule("qt.env") qt = assert(find_qt(nil, {verbose = true}), "Qt SDK not found!") target:data_set("qt", qt) end - if is_plat("windows") or (is_plat("mingw") and is_host("windows")) then + if target:is_plat("windows") or (target:is_plat("mingw") and is_host("windows")) then target:add("runenvs", "PATH", qt.bindir) target:set("runenv", "QML2_IMPORT_PATH", qt.qmldir) target:set("runenv", "QML_IMPORT_TRACE", "1") - elseif is_plat("msys", "cygwin") then + elseif target:is_plat("msys", "cygwin") then raise("please run `xmake f -p mingw --mingw=/mingw64` to support Qt/Mingw64 on Msys!") end end) diff --git a/xmake/rules/qt/install/windows.lua b/xmake/rules/qt/install/windows.lua index a9b3db6b9..69d4c1c70 100644 --- a/xmake/rules/qt/install/windows.lua +++ b/xmake/rules/qt/install/windows.lua @@ -29,7 +29,7 @@ function main(target, opt) local targetfile = target:targetfile() local installfile = path.join(target:installdir(), "bin", path.filename(targetfile)) - + -- get qt sdk local qt = target:data("qt") @@ -68,6 +68,13 @@ function main(target, opt) else table.insert(argv, "--verbose=0") end + + if is_mode("debug") then + table.insert(argv, "--debug") + else + table.insert(argv, "--release") + end + if qmldir then table.insert(argv, "--qmldir=" .. qmldir) end diff --git a/xmake/rules/qt/load.lua b/xmake/rules/qt/load.lua index b7fc91408..407911fab 100644 --- a/xmake/rules/qt/load.lua +++ b/xmake/rules/qt/load.lua @@ -84,6 +84,15 @@ function _add_plugins(target, plugins) end end +-- add includedirs if exists +function _add_includedirs(target, includedirs) + for _, includedir in ipairs(includedirs) do + if os.isdir(includedir) then + target:add("sysincludedirs", includedir) + end + end +end + -- the main entry function main(target, opt) @@ -102,9 +111,11 @@ function main(target, opt) end -- add -fPIC - target:add("cxflags", "-fPIC") - target:add("mxflags", "-fPIC") - target:add("asflags", "-fPIC") + if not target:is_plat("windows", "mingw") then + target:add("cxflags", "-fPIC") + target:add("mxflags", "-fPIC") + target:add("asflags", "-fPIC") + end -- need c++11 at least local languages = target:get("languages") @@ -116,7 +127,13 @@ function main(target, opt) end end if not cxxlang then - target:add("languages", "cxx11") + -- Qt6 require at least '/std:c++17' + -- @see https://github.com/xmake-io/xmake/issues/1183 + if qt_sdkver:ge("6.0") then + target:add("languages", "c++17") + else + target:add("languages", "c++11") + end end -- add defines for the compile mode @@ -182,15 +199,15 @@ function main(target, opt) if is_plat("macosx") then local frameworkdir = path.join(qt.libdir, framework .. ".framework") if os.isdir(frameworkdir) then - target:add("includedirs", path.join(frameworkdir, "Headers", qt.sdkver)) - target:add("includedirs", path.join(frameworkdir, "Headers", qt.sdkver, private_dir)) + _add_includedirs(target, path.join(frameworkdir, "Headers", qt.sdkver)) + _add_includedirs(target, path.join(frameworkdir, "Headers", qt.sdkver, private_dir)) else - target:add("includedirs", path.join(qt.includedir, private_dir, qt.sdkver, private_dir)) - target:add("includedirs", path.join(qt.includedir, private_dir, qt.sdkver)) + _add_includedirs(target, path.join(qt.includedir, private_dir, qt.sdkver, private_dir)) + _add_includedirs(target, path.join(qt.includedir, private_dir, qt.sdkver)) end else - target:add("includedirs", path.join(qt.includedir, private_dir, qt.sdkver, private_dir)) - target:add("includedirs", path.join(qt.includedir, private_dir, qt.sdkver)) + _add_includedirs(target, path.join(qt.includedir, private_dir, qt.sdkver, private_dir)) + _add_includedirs(target, path.join(qt.includedir, private_dir, qt.sdkver)) end else -- add defines @@ -200,15 +217,24 @@ function main(target, opt) if is_plat("macosx") then local frameworkdir = path.join(qt.libdir, framework .. ".framework") if os.isdir(frameworkdir) and not framework:endswith("Support") then - target:add("includedirs", path.join(frameworkdir, "Headers")) + _add_includedirs(target, path.join(frameworkdir, "Headers")) + -- e.g. QtGui.framework/Headers/5.15.0/QtGui/qpa/qplatformopenglcontext.h + -- https://github.com/xmake-io/xmake/issues/1226 + _add_includedirs(target, path.join(frameworkdir, "Headers", qt.sdkver)) + _add_includedirs(target, path.join(frameworkdir, "Headers", qt.sdkver, framework)) useframeworks = true else target:add("syslinks", _link(qt.libdir, framework, qt_sdkver)) - target:add("includedirs", path.join(qt.includedir, framework)) + _add_includedirs(target, path.join(qt.includedir, framework)) + -- e.g. QtGui/5.15.0/QtGui/qpa/qplatformopenglcontext.h + _add_includedirs(target, path.join(qt.includedir, framework, qt.sdkver)) + _add_includedirs(target, path.join(qt.includedir, framework, qt.sdkver, framework)) end else target:add("syslinks", _link(qt.libdir, framework, qt_sdkver)) - target:add("includedirs", path.join(qt.includedir, framework)) + _add_includedirs(target, path.join(qt.includedir, framework)) + _add_includedirs(target, path.join(qt.includedir, framework, qt.sdkver)) + _add_includedirs(target, path.join(qt.includedir, framework, qt.sdkver, framework)) end end end @@ -243,7 +269,7 @@ function main(target, opt) target:add("rpathdirs", "@executable_path/Frameworks", qt.libdir) else target:add("rpathdirs", qt.libdir) - target:add("includedirs", qt.includedir) + _add_includedirs(target, qt.includedir) -- remove qt frameworks local frameworks = table.wrap(target:get("frameworks")) @@ -255,36 +281,36 @@ function main(target, opt) end target:set("frameworks", frameworks) end - target:add("includedirs", path.join(qt.mkspecsdir, "macx-clang")) + _add_includedirs(target, path.join(qt.mkspecsdir, "macx-clang")) target:add("linkdirs", qt.libdir) elseif is_plat("linux") then target:set("frameworks", nil) - target:add("includedirs", qt.includedir) - target:add("includedirs", path.join(qt.mkspecsdir, "linux-g++")) + _add_includedirs(target, qt.includedir) + _add_includedirs(target, path.join(qt.mkspecsdir, "linux-g++")) target:add("rpathdirs", qt.libdir) target:add("linkdirs", qt.libdir) elseif is_plat("windows") then target:set("frameworks", nil) - target:add("includedirs", qt.includedir) - target:add("includedirs", path.join(qt.mkspecsdir, "win32-msvc")) + _add_includedirs(target, qt.includedir) + _add_includedirs(target, path.join(qt.mkspecsdir, "win32-msvc")) target:add("linkdirs", qt.libdir) target:add("syslinks", "ws2_32", "gdi32", "ole32", "advapi32", "shell32", "user32", "OpenGL32", "imm32", "winmm", "iphlpapi") elseif is_plat("mingw") then target:set("frameworks", nil) - target:add("includedirs", qt.includedir) - target:add("includedirs", path.join(qt.mkspecsdir, "win32-g++")) + _add_includedirs(target, qt.includedir) + _add_includedirs(target, path.join(qt.mkspecsdir, "win32-g++")) target:add("linkdirs", qt.libdir) target:add("syslinks", "mingw32") elseif is_plat("android") then target:set("frameworks", nil) - target:add("includedirs", qt.includedir) - target:add("includedirs", path.join(qt.mkspecsdir, "android-clang")) + _add_includedirs(target, qt.includedir) + _add_includedirs(target, path.join(qt.mkspecsdir, "android-clang")) target:add("rpathdirs", qt.libdir) target:add("linkdirs", qt.libdir) elseif is_plat("wasm") then target:set("frameworks", nil) - target:add("includedirs", qt.includedir) - target:add("includedirs", path.join(qt.mkspecsdir, "wasm-emscripten")) + _add_includedirs(target, qt.includedir) + _add_includedirs(target, path.join(qt.mkspecsdir, "wasm-emscripten")) target:add("rpathdirs", qt.libdir) target:add("linkdirs", qt.libdir) target:add("ldflags", "-s WASM=1", "-s FETCH=1", "-s FULL_ES2=1", "-s FULL_ES3=1", "-s USE_WEBGL2=1", "--bind") diff --git a/xmake/rules/qt/moc/moc.lua b/xmake/rules/qt/moc/moc.lua deleted file mode 100644 index a6631b436..000000000 --- a/xmake/rules/qt/moc/moc.lua +++ /dev/null @@ -1,71 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-present, TBOOX Open Source Group. --- --- @author ruki --- @file moc.lua --- - --- make flags from target -function _make_flags_from_target(target) - local flags = {} - for _, define in ipairs(target:get("defines")) do - table.insert(flags, "-D" .. define) - end - for _, includedir in ipairs(target:get("includedirs")) do - table.insert(flags, "-I" .. os.args(includedir)) - end - for _, frameworkdir in ipairs(target:get("frameworkdirs")) do - table.insert(flags, "-F" .. os.args(frameworkdir)) - end - return flags -end - --- make flags -function _make_flags(target) - - -- attempt to get flags from cache first - local key = target:name() - local cache = _g._FLAGS or {} - if cache[key] then - return cache[key] - end - - -- make flags - local flags = _make_flags_from_target(target) - - -- save flags to cache - cache[key] = flags - _g._FLAGS = cache - - -- done - return flags -end - --- generate c++ source file from header file with Q_OBJECT -function generate(target, headerfile_moc, sourcefile_moc) - - -- get moc - local moc = assert(target:data("qt.moc"), "moc not found!") - - -- ensure the parent directory of source file - local sourcefile_dir = path.directory(sourcefile_moc) - if not os.isdir(sourcefile_dir) then - os.mkdir(sourcefile_dir) - end - - -- generate c++ source file for moc - os.vrunv(moc, table.join(_make_flags(target), headerfile_moc, "-o", sourcefile_moc)) -end diff --git a/xmake/rules/qt/moc/xmake.lua b/xmake/rules/qt/moc/xmake.lua index a8754a642..439a0b573 100644 --- a/xmake/rules/qt/moc/xmake.lua +++ b/xmake/rules/qt/moc/xmake.lua @@ -18,38 +18,18 @@ -- @file xmake.lua -- --- define rule: moc rule("qt.moc") - - -- add rule: qt environment add_deps("qt.env") - - -- set extensions set_extensions(".h", ".hpp") + before_buildcmd_file(function (target, batchcmds, sourcefile, opt) - -- before load - before_load(function (target) + -- imports + import("core.tool.compiler") -- get moc local moc = path.join(target:data("qt").bindir, is_host("windows") and "moc.exe" or "moc") assert(moc and os.isexec(moc), "moc not found!") - -- save moc - target:data_set("qt.moc", moc) - end) - - -- before build file (we need compile it first if exists Q_PRIVATE_SLOT) - before_build_file(function (target, sourcefile, opt) - - -- imports - import("moc") - import("core.base.option") - import("core.theme.theme") - import("core.project.config") - import("core.tool.compiler") - import("core.project.depend") - import("private.utils.progress") - -- get c++ source file for moc -- -- add_files("mainwindow.h") -> moc_MainWindow.cpp @@ -62,36 +42,23 @@ rule("qt.moc") end local sourcefile_moc = path.join(target:autogendir(), "rules", "qt", "moc", filename_moc) - -- get object file - local objectfile = target:objectfile(sourcefile_moc) - - -- load compiler - local compinst = compiler.load("cxx", {target = target}) - - -- get compile flags - local compflags = compinst:compflags({target = target, sourcefile = sourcefile_moc}) - -- add objectfile + local objectfile = target:objectfile(sourcefile_moc) table.insert(target:objectfiles(), objectfile) - -- load dependent info - local dependfile = target:dependfile(objectfile) - local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {}) - - -- need build this object? - local depvalues = {compinst:program(), compflags} - if not depend.is_changed(dependinfo, {lastmtime = os.mtime(objectfile), values = depvalues}) then - return - end - - -- trace progress info - progress.show(opt.progress, "${color.build.object}compiling.qt.moc %s", sourcefile) + -- add commands + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.moc %s", sourcefile) -- generate c++ source file for moc - moc.generate(target, sourcefile, sourcefile_moc) + local flags = {} + table.join2(flags, compiler.map_flags("cxx", "define", target:get("defines"))) + table.join2(flags, compiler.map_flags("cxx", "includedir", target:get("includedirs"))) + table.join2(flags, compiler.map_flags("cxx", "includedir", target:get("sysincludedirs"))) -- for now, moc process doesn't support MSVC external includes flags and will fail + table.join2(flags, compiler.map_flags("cxx", "frameworkdir", target:get("frameworkdirs"))) + batchcmds:mkdir(path.directory(sourcefile_moc)) + batchcmds:vrunv(moc, table.join(flags, sourcefile, "-o", sourcefile_moc)) -- we need compile this moc_xxx.cpp file if exists Q_PRIVATE_SLOT, @see https://github.com/xmake-io/xmake/issues/750 - dependinfo.files = {} local mocdata = io.readfile(sourcefile) if mocdata and mocdata:find("Q_PRIVATE_SLOT") or sourcefile_moc:endswith(".moc") then -- add includedirs of sourcefile_moc @@ -106,17 +73,12 @@ rule("qt.moc") end end else - -- trace - if option.get("verbose") then - print(compinst:compcmd(sourcefile_moc, objectfile, {compflags = compflags})) - end - -- compile c++ source file for moc - assert(compinst:compile(sourcefile_moc, objectfile, {dependinfo = dependinfo, compflags = compflags})) + batchcmds:compile(sourcefile_moc, objectfile) end - -- update files and values to the dependent file - dependinfo.values = depvalues - table.insert(dependinfo.files, sourcefile) - depend.save(dependinfo, dependfile) + -- add deps + batchcmds:add_depfiles(sourcefile) + batchcmds:set_depmtime(os.mtime(objectfile)) + batchcmds:set_depcache(target:dependfile(objectfile)) end) diff --git a/xmake/rules/qt/qrc/xmake.lua b/xmake/rules/qt/qrc/xmake.lua index 67d20bfa6..2529ef118 100644 --- a/xmake/rules/qt/qrc/xmake.lua +++ b/xmake/rules/qt/qrc/xmake.lua @@ -18,17 +18,10 @@ -- @file xmake.lua -- --- define rule: *.qrc rule("qt.qrc") - - -- add rule: qt environment add_deps("qt.env") - - -- set extensions set_extensions(".qrc") - - -- before load - before_load(function (target) + on_load(function (target) -- get rcc local rcc = path.join(target:data("qt").bindir, is_host("windows") and "rcc.exe" or "rcc") @@ -38,16 +31,7 @@ rule("qt.qrc") target:data_set("qt.rcc", rcc) end) - -- on build file - on_build_file(function (target, sourcefile_qrc, opt) - - -- imports - import("core.base.option") - import("core.theme.theme") - import("core.project.config") - import("core.project.depend") - import("core.tool.compiler") - import("private.utils.progress") + on_buildcmd_file(function (target, batchcmds, sourcefile_qrc, opt) -- get rcc local rcc = target:data("qt.rcc") @@ -56,51 +40,19 @@ rule("qt.qrc") local sourcefile_cpp = path.join(target:autogendir(), "rules", "qt", "qrc", path.basename(sourcefile_qrc) .. ".cpp") local sourcefile_dir = path.directory(sourcefile_cpp) - -- get object file - local objectfile = target:objectfile(sourcefile_cpp) - - -- load compiler - local compinst = compiler.load("cxx", {target = target}) - - -- get compile flags - local compflags = compinst:compflags({target = target, sourcefile = sourcefile_cpp}) - -- add objectfile + local objectfile = target:objectfile(sourcefile_cpp) table.insert(target:objectfiles(), objectfile) - -- load dependent info - local dependfile = target:dependfile(objectfile) - local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {}) - - -- need build this object? - local depvalues = {compinst:program(), compflags} - if not depend.is_changed(dependinfo, {lastmtime = os.mtime(objectfile), values = depvalues}) then - return - end - - -- trace progress info - progress.show(opt.progress, "${color.build.object}compiling.qt.qrc %s", sourcefile_qrc) - - -- ensure the source file directory - if not os.isdir(sourcefile_dir) then - os.mkdir(sourcefile_dir) - end - - -- compile qrc - os.vrunv(rcc, {"-name", path.basename(sourcefile_qrc), sourcefile_qrc, "-o", sourcefile_cpp}) - - -- trace - if option.get("verbose") then - print(compinst:compcmd(sourcefile_cpp, objectfile, {compflags = compflags})) - end - - -- compile c++ source file for qrc - dependinfo.files = {} - assert(compinst:compile(sourcefile_cpp, objectfile, {dependinfo = dependinfo, compflags = compflags})) + -- add commands + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.qrc %s", sourcefile_qrc) + batchcmds:mkdir(sourcefile_dir) + batchcmds:vrunv(rcc, {"-name", path.basename(sourcefile_qrc), sourcefile_qrc, "-o", sourcefile_cpp}) + batchcmds:compile(sourcefile_cpp, objectfile) - -- update files and values to the dependent file - dependinfo.values = depvalues - table.insert(dependinfo.files, sourcefile_qrc) - depend.save(dependinfo, dependfile) + -- add deps + batchcmds:add_depfiles(sourcefile_qrc) + batchcmds:set_depmtime(os.mtime(objectfile)) + batchcmds:set_depcache(target:dependfile(objectfile)) end) diff --git a/xmake/rules/qt/ui/xmake.lua b/xmake/rules/qt/ui/xmake.lua index d61e38830..b1ce103e5 100644 --- a/xmake/rules/qt/ui/xmake.lua +++ b/xmake/rules/qt/ui/xmake.lua @@ -18,65 +18,39 @@ -- @file xmake.lua -- --- define rule: *.ui rule("qt.ui") - - -- add rule: qt environment add_deps("qt.env") - - -- set extensions set_extensions(".ui") - - -- before load - before_load(function (target) + on_load(function (target) -- get uic local uic = path.join(target:data("qt").bindir, is_host("windows") and "uic.exe" or "uic") assert(uic and os.isexec(uic), "uic not found!") - -- save uic - target:data_set("qt.uic", uic) - end) - - -- before build file - before_build_file(function (target, sourcefile_ui, opt) - - -- imports - import("core.base.option") - import("core.theme.theme") - import("core.project.config") - import("core.project.depend") - import("private.utils.progress") - - -- get uic - local uic = target:data("qt.uic") - - -- get c++ header file for ui - local headerfile_ui = path.join(target:autogendir(), "rules", "qt", "ui", "ui_" .. path.basename(sourcefile_ui) .. ".h") - local headerfile_dir = path.directory(headerfile_ui) - - -- add includedirs - target:add("includedirs", path.absolute(headerfile_dir, os.projectdir())) - - -- need build this object? - local dependfile = target:dependfile(headerfile_ui) - local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {}) - if not depend.is_changed(dependinfo, {lastmtime = os.mtime(headerfile_ui)}) then - return - end - - -- trace progress info - progress.show(opt.progress, "${color.build.object}compiling.qt.ui %s", sourcefile_ui) - - -- ensure ui header file directory + -- add includedirs, @note we need create this directory first to suppress warning (file not found). + -- and we muse add it in load stage to ensure `depend.on_changed` work. + -- + -- @see https://github.com/xmake-io/xmake/issues/1180 + -- + local headerfile_dir = path.join(target:autogendir(), "rules", "qt", "ui") if not os.isdir(headerfile_dir) then os.mkdir(headerfile_dir) end + target:add("includedirs", path.absolute(headerfile_dir, os.projectdir())) - -- compile ui - os.vrunv(uic, {sourcefile_ui, "-o", headerfile_ui}) + -- save uic + target:data_set("qt.uic", uic) + end) - -- update files and values to the dependent file - dependinfo.files = {sourcefile_ui} - depend.save(dependinfo, dependfile) + before_buildcmd_file(function (target, batchcmds, sourcefile_ui, opt) + local uic = target:data("qt.uic") + local headerfile_dir = path.join(target:autogendir(), "rules", "qt", "ui") + local headerfile_ui = path.join(headerfile_dir, "ui_" .. path.basename(sourcefile_ui) .. ".h") + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.ui %s", sourcefile_ui) + batchcmds:mkdir(headerfile_dir) + batchcmds:vrunv(uic, {sourcefile_ui, "-o", headerfile_ui}) + batchcmds:add_depfiles(sourcefile_ui) + batchcmds:set_depmtime(os.mtime(headerfile_ui)) + batchcmds:set_depcache(target:dependfile(headerfile_ui)) end) + diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua index fd5b5a41e..ed4deedb7 100644 --- a/xmake/rules/qt/xmake.lua +++ b/xmake/rules/qt/xmake.lua @@ -41,11 +41,11 @@ rule("qt.static") add_deps("qt.qrc", "qt.ui", "qt.moc") -- we must set kind before target.on_load(), may we will use target in on_load() - before_load(function (target) + on_load(function (target) target:set("kind", "static") end) - after_load(function (target) + on_config(function (target) import("load")(target, {frameworks = {"QtCore"}}) end) @@ -54,11 +54,11 @@ rule("qt.shared") add_deps("qt.qrc", "qt.ui", "qt.moc") -- we must set kind before target.on_load(), may we will use target in on_load() - before_load(function (target) + on_load(function (target) target:set("kind", "shared") end) - after_load(function (target) + on_config(function (target) import("load")(target, {frameworks = {"QtCore"}}) end) @@ -67,11 +67,11 @@ rule("qt.console") add_deps("qt.qrc", "qt.ui", "qt.moc") -- we must set kind before target.on_load(), may we will use target in on_load() - before_load(function (target) + on_load(function (target) target:set("kind", "binary") end) - after_load(function (target) + on_config(function (target) import("load")(target, {frameworks = {"QtCore"}}) end) @@ -82,11 +82,11 @@ rule("qt.widgetapp") add_deps("qt.ui", "qt.moc", "qt._wasm_app", "qt.qrc") -- we must set kind before target.on_load(), may we will use target in on_load() - before_load(function (target) - target:set("kind", is_plat("android") and "shared" or "binary") + on_load(function (target) + target:set("kind", target:is_plat("android") and "shared" or "binary") end) - after_load(function (target) + on_config(function (target) import("load")(target, {gui = true, frameworks = {"QtGui", "QtWidgets", "QtCore"}}) end) @@ -103,11 +103,11 @@ rule("qt.widgetapp_static") add_deps("qt.ui", "qt.moc", "qt._wasm_app", "qt.qrc") -- we must set kind before target.on_load(), may we will use target in on_load() - before_load(function (target) - target:set("kind", is_plat("android") and "shared" or "binary") + on_load(function (target) + target:set("kind", target:is_plat("android") and "shared" or "binary") end) - after_load(function (target) + on_config(function (target) -- get qt sdk version local qt = target:data("qt") @@ -153,11 +153,11 @@ rule("qt.quickapp") add_deps("qt.qrc", "qt.moc", "qt._wasm_app") -- we must set kind before target.on_load(), may we will use target in on_load() - before_load(function (target) - target:set("kind", is_plat("android") and "shared" or "binary") + on_load(function (target) + target:set("kind", target:is_plat("android") and "shared" or "binary") end) - after_load(function (target) + on_config(function (target) import("load")(target, {gui = true, frameworks = {"QtGui", "QtQuick", "QtQml", "QtCore", "QtNetwork"}}) end) @@ -174,11 +174,11 @@ rule("qt.quickapp_static") add_deps("qt.qrc", "qt.moc", "qt._wasm_app") -- we must set kind before target.on_load(), may we will use target in on_load() - before_load(function (target) - target:set("kind", is_plat("android") and "shared" or "binary") + on_load(function (target) + target:set("kind", target:is_plat("android") and "shared" or "binary") end) - after_load(function (target) + on_config(function (target) -- get qt sdk version local qt = target:data("qt") diff --git a/xmake/rules/utils/compiler_runtime/xmake.lua b/xmake/rules/utils/compiler_runtime/xmake.lua index a00ef170e..f8e3d39d0 100644 --- a/xmake/rules/utils/compiler_runtime/xmake.lua +++ b/xmake/rules/utils/compiler_runtime/xmake.lua @@ -20,7 +20,7 @@ -- define rule: utils.compiler.runtime rule("utils.compiler.runtime") - after_load(function (target) + on_config(function (target) -- set vs runtime local vs_runtime = get_config("vs_runtime") diff --git a/xmake/rules/utils/inherit_links/inherit_links.lua b/xmake/rules/utils/inherit_links/inherit_links.lua index 52d64fd4c..97c585ded 100644 --- a/xmake/rules/utils/inherit_links/inherit_links.lua +++ b/xmake/rules/utils/inherit_links/inherit_links.lua @@ -26,6 +26,26 @@ function _get_values_from_target(target, name) return values end +-- @note we cannot directly set `{interface = true}`, because it will overwrite the previous configuration +-- https://github.com/xmake-io/xmake/issues/1465 +function _add_export_value(target, name, value) + local has_private = false + local private_values = target:get(name) + if private_values then + for _, v in ipairs(private_values) do + if v == value then + has_private = true + break + end + end + end + if has_private then + target:add(name, value, {public = true}) + else + target:add(name, value, {interface = true}) + end +end + -- main entry function main(target) @@ -35,26 +55,35 @@ function main(target) end -- export links and linkdirs - local targetkind = target:targetkind() + local targetkind = target:kind() if targetkind == "shared" or targetkind == "static" then local targetfile = target:targetfile() -- we need move target link to head - target:add("links", target:basename(), {interface = true}) + _add_export_value(target, "links", target:linkname()) local links = target:get("links", {rawref = true}) if links and type(links) == "table" and #links > 1 then - table.swap(links, 1, #links) + table.insert(links, 1, links[#links]) + table.remove(links, #links) end - target:add("linkdirs", path.directory(targetfile), {interface = true}) + _add_export_value(target, "linkdirs", path.directory(targetfile)) if target:rule("go") then -- we need add includedirs to support import modules for golang - target:add("includedirs", path.directory(targetfile), {interface = true}) + _add_export_value(target, "includedirs", path.directory(targetfile)) end - for _, name in ipairs({"frameworkdirs", "frameworks", "linkdirs", "links", "syslinks"}) do - local values = _get_values_from_target(target, name) - if values and #values > 0 then - target:add(name, values, {public = true}) + + -- we export all links and linkdirs in self/packages/options to the parent target by default + -- + -- @note we only export links for static target, + -- and we need pass `{public = true}` to add_packages/add_links/... to export it if want to export links for shared target + -- + if targetkind == "static" then + for _, name in ipairs({"frameworkdirs", "frameworks", "linkdirs", "links", "syslinks"}) do + local values = _get_values_from_target(target, name) + if values and #values > 0 then + target:add(name, values, {public = true}) + end end end end @@ -64,7 +93,7 @@ function main(target) local targetdir = target:targetdir() for _, dep in ipairs(target:orderdeps()) do local depinherit = target:extraconf("deps", dep:name(), "inherit") - if dep:targetkind() == "shared" and (depinherit == nil or depinherit) then + if dep:kind() == "shared" and (depinherit == nil or depinherit) then local rpathdir = "@loader_path" local subdir = path.relative(path.directory(dep:targetfile()), targetdir) if subdir and subdir ~= '.' then diff --git a/xmake/rules/utils/inherit_links/xmake.lua b/xmake/rules/utils/inherit_links/xmake.lua index 1ba06ea3c..a6b13a9df 100644 --- a/xmake/rules/utils/inherit_links/xmake.lua +++ b/xmake/rules/utils/inherit_links/xmake.lua @@ -20,5 +20,5 @@ -- define rule: utils.inherit.links rule("utils.inherit.links") - after_load("inherit_links") + on_config("inherit_links") diff --git a/xmake/rules/utils/install_importfiles/xmake.lua b/xmake/rules/utils/install_importfiles/xmake.lua new file mode 100644 index 000000000..45e6616f8 --- /dev/null +++ b/xmake/rules/utils/install_importfiles/xmake.lua @@ -0,0 +1,31 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- install pkg-config/*.pc import files +rule("utils.install.pkgconfig_importfiles") + after_install(function (target, opt) + import("target.action.install.pkgconfig_importfiles")(target, opt) + end) + +-- install *.cmake import files +rule("utils.install.cmake_importfiles") + after_install(function (target, opt) + import("target.action.install.cmake_importfiles")(target, opt) + end) diff --git a/xmake/rules/utils/symbols/export_all/export_all.lua b/xmake/rules/utils/symbols/export_all/export_all.lua new file mode 100644 index 000000000..1a40e9820 --- /dev/null +++ b/xmake/rules/utils/symbols/export_all/export_all.lua @@ -0,0 +1,97 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file export_all.lua +-- + +-- imports +import("lib.detect.find_tool") +import("core.tool.toolchain") +import("core.base.option") +import("core.base.hashset") +import("core.project.depend") +import("private.utils.progress") + +-- export all symbols for dynamic library +function main (target, opt) + + -- @note it only supports windows/dll now + assert(target:is_shared(), 'rule("utils.symbols.export_all"): only for shared target(%s)!', target:name()) + if not target:is_plat("windows") or option.get("dry-run") then + return + end + + -- export all symbols + local allsymbols_filepath = path.join(target:autogendir(), "rules", "symbols", "export_all.def") + local dependfile = allsymbols_filepath .. ".d" + depend.on_changed(function () + + -- trace progress info + progress.show(opt.progress, "${color.build.target}exporting.$(mode) %s", path.filename(target:targetfile())) + + -- get dumpbin + local msvc = toolchain.load("msvc", {plat = target:plat(), arch = target:arch()}) + local dumpbin = assert(find_tool("dumpbin", {envs = msvc:runenvs()}), "dumpbin not found!") + + -- export c++ class? + local export_classes = target:extraconf("rules", "utils.symbols.export_all", "export_classes") + + -- get all symbols from object files + local allsymbols = hashset.new() + for _, objectfile in ipairs(target:objectfiles()) do + local objectsymbols = try { function () return os.iorunv(dumpbin.program, {"/symbols", "/nologo", objectfile}) end } + if objectsymbols then + for _, line in ipairs(objectsymbols:split('\n', {plain = true})) do + -- 008 00000000 SECT3 notype () External | add + if line:find("External") then + local symbol = line:match(".*External%s+| (.*)") + if symbol then + symbol = symbol:split('%s')[1] + if not symbol:startswith("__") then + if target:is_arch("x86") and symbol:startswith("_") then + symbol = symbol:sub(2) + end + if export_classes or not symbol:startswith("?") then + if export_classes then + if not symbol:startswith("??_G") and not symbol:startswith("??_E") then + allsymbols:insert(symbol) + end + else + allsymbols:insert(symbol) + end + end + end + end + end + end + end + end + + -- export all symbols + if allsymbols:size() > 0 then + local allsymbols_file = io.open(allsymbols_filepath, 'w') + allsymbols_file:print("EXPORTS") + for _, symbol in allsymbols:keys() do + allsymbols_file:print("%s", symbol) + end + allsymbols_file:close() + else + wprint('rule("utils.symbols.export_all"): no symbols are exported for target(%s)!', target:name()) + end + + end, {dependfile = dependfile, files = target:objectfiles()}) +end diff --git a/xmake/rules/utils/symbols/export_all/xmake.lua b/xmake/rules/utils/symbols/export_all/xmake.lua new file mode 100644 index 000000000..f804e3c3e --- /dev/null +++ b/xmake/rules/utils/symbols/export_all/xmake.lua @@ -0,0 +1,39 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- export all symbols for windows/dll +-- +-- @note: we don't need any export macros to a classes or functions! +-- and we can't use /GL (Whole Program Optimization) when use this approach! +-- +-- @see https://github.com/xmake-io/xmake/issues/1123 +-- +rule("utils.symbols.export_all") + before_load(function (target) + -- @note it only supports windows/dll now + assert(target:is_shared(), 'rule("utils.symbols.export_all"): only for shared target(%s)!', target:name()) + if target:is_plat("windows") then + assert(target:get("optimize") ~= "smallest", 'rule("utils.symbols.export_all"): does not support set_optimize("smallest") for target(%s)!', target:name()) + local allsymbols_filepath = path.join(target:autogendir(), "rules", "symbols", "export_all.def") + target:add("shflags", "/def:" .. allsymbols_filepath, {force = true}) + end + end) + before_link("export_all") + diff --git a/xmake/rules/utils/symbols/xmake.lua b/xmake/rules/utils/symbols/extract/xmake.lua index eba3f2a24..f78cab808 100644 --- a/xmake/rules/utils/symbols/xmake.lua +++ b/xmake/rules/utils/symbols/extract/xmake.lua @@ -27,7 +27,7 @@ rule("utils.symbols.extract") -- need generate symbols? local strip = target:get("strip") - local targetkind = target:targetkind() + local targetkind = target:kind() if target:get("symbols") == "debug" and (strip == "all" or strip == "debug") and (targetkind == "binary" or targetkind == "shared") and platform.tool("strip") then -- only for strip command target:data_set("utils.symbols.extract", true) @@ -49,7 +49,7 @@ rule("utils.symbols.extract") import("private.utils.progress") -- get strip - local strip = platform.tool("strip") + local strip = target:tool("strip") if not strip then return end @@ -57,7 +57,7 @@ rule("utils.symbols.extract") -- get dsymutil local dsymutil if is_plat("macosx", "iphoneos", "watchos") then - dsymutil = platform.tool("dsymutil") + dsymutil = target:tool("dsymutil") if not dsymutil then return end diff --git a/xmake/rules/wdk/load.lua b/xmake/rules/wdk/load.lua index 1a83f2d8b..d309dbb4e 100644 --- a/xmake/rules/wdk/load.lua +++ b/xmake/rules/wdk/load.lua @@ -71,6 +71,7 @@ function driver_kmdf(target) -- compile as kernel driver target:add("cxflags", "-kernel", {force = true}) target:add("ldflags", "-kernel", "-driver", {force = true}) + target:add("ldflags", "-nodefaultlib", {force = true}) -- add subsystem target:add("ldflags", "-subsystem:native," .. os_winver.subsystem(winver), {force = true}) @@ -111,6 +112,7 @@ function driver_wdm(target) -- compile as kernel driver target:add("cxflags", "-kernel", {force = true}) target:add("ldflags", "-kernel", "-driver", {force = true}) + target:add("ldflags", "-nodefaultlib", {force = true}) -- add subsystem target:add("ldflags", "-subsystem:native," .. os_winver.subsystem(winver), {force = true}) diff --git a/xmake/rules/wdk/sign/sign.lua b/xmake/rules/wdk/sign/sign.lua index 5fa3bcc10..bd46af76a 100644 --- a/xmake/rules/wdk/sign/sign.lua +++ b/xmake/rules/wdk/sign/sign.lua @@ -56,11 +56,13 @@ function main(target, filepath, mode) -- get signtool local signtool = _get_tool(target, "signtool") - -- get timestamp - local timestamp = target:values("wdk.sign.timestamp") or "http://timestamp.verisign.com/scripts/timestamp.dll" - -- init arguments - local argv = {"sign", "/v", "/t", timestamp} + local argv = {"sign", "/v"} + local timestamp = target:values("wdk.sign.timestamp") + if timestamp then + table.insert(argv, "/t") + table.insert(argv, timestamp) + end local company = target:values("wdk.sign.company") if company then table.insert(argv, "/n") @@ -77,8 +79,6 @@ function main(target, filepath, mode) table.insert(argv, thumbprint) end local store = target:values("wdk.sign.store") - if not store and mode == "test" then - end if store then table.insert(argv, "/a") table.insert(argv, "/s") diff --git a/xmake/rules/winsdk/xmake.lua b/xmake/rules/winsdk/xmake.lua index a6a639dd3..0a3b105cc 100644 --- a/xmake/rules/winsdk/xmake.lua +++ b/xmake/rules/winsdk/xmake.lua @@ -20,7 +20,7 @@ -- define rule: win.sdk.resource rule("win.sdk.resource") - set_extensions(".rc") + set_sourcekinds("mrc") on_build_files("private.action.build.object", {batch = true}) -- define rule: application diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua index 0ba319bfa..786f5da89 100644 --- a/xmake/rules/xcode/application/build.lua +++ b/xmake/rules/xcode/application/build.lua @@ -48,7 +48,7 @@ function main (target, opt) -- copy dependent dynamic libraries, TODO copy frameworks for _, dep in ipairs(target:orderdeps()) do - if dep:targetkind() == "shared" then + if dep:kind() == "shared" then os.vcp(dep:targetfile(), binarydir) end end diff --git a/xmake/rules/xcode/framework/xmake.lua b/xmake/rules/xcode/framework/xmake.lua index ed3e4b6ec..b112dcaf1 100644 --- a/xmake/rules/xcode/framework/xmake.lua +++ b/xmake/rules/xcode/framework/xmake.lua @@ -147,7 +147,7 @@ rule("xcode.framework") os.cd(oldir) -- do codesign, only for dynamic library - if target:targetkind() == "shared" then + if target:kind() == "shared" then local codesign_identity = target:values("xcode.codesign_identity") or get_config("xcode_codesign_identity") if target:is_plat("macosx") or (target:is_plat("iphoneos") and target:is_arch("x86_64", "i386")) then codesign_identity = nil diff --git a/xmake/rules/xmake_cli/xmake.lua b/xmake/rules/xmake_cli/xmake.lua index d98383e7a..2375c9e3b 100644 --- a/xmake/rules/xmake_cli/xmake.lua +++ b/xmake/rules/xmake_cli/xmake.lua @@ -35,7 +35,7 @@ rule("xmake.cli") -- install xmake-core lua scripts first local libxmake = target:pkg("libxmake") - local programdir = path.join(path.directory(libxmake:get("linkdirs")), "share", "xmake") + local programdir = path.join(libxmake:installdir(), "share", "xmake") local installdir = path.join(target:installdir(), "share", target:name()) assert(os.isdir(programdir), "%s not found!", programdir) if not os.isdir(installdir) then @@ -77,7 +77,7 @@ rule("xmake.cli") os.setenv("XMAKE_MODULES_DIR", scriptdir) end local libxmake = target:pkg("libxmake") - local programdir = path.join(path.directory(libxmake:get("linkdirs")), "share", "xmake") + local programdir = path.join(libxmake:installdir(), "share", "xmake") assert(os.isdir(programdir), "%s not found!", programdir) os.setenv("XMAKE_PROGRAM_DIR", programdir) end) diff --git a/xmake/scripts/cmake_importfiles/xxxConfig.cmake b/xmake/scripts/cmake_importfiles/xxxConfig.cmake new file mode 100644 index 000000000..c999bd76a --- /dev/null +++ b/xmake/scripts/cmake_importfiles/xxxConfig.cmake @@ -0,0 +1,28 @@ + +####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() ####### +####### Any changes to this file will be overwritten by the next CMake run #### +####### The input file was Config.cmake.in ######## + +get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) + +macro(set_and_check _var _file) + set(${_var} "${_file}") + if(NOT EXISTS "${_file}") + message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !") + endif() +endmacro() + +macro(check_required_components _NAME) + foreach(comp ${${_NAME}_FIND_COMPONENTS}) + if(NOT ${_NAME}_${comp}_FOUND) + if(${_NAME}_FIND_REQUIRED_${comp}) + set(${_NAME}_FOUND FALSE) + endif() + endif() + endforeach() +endmacro() + +#################################################################################### + +include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") +check_required_components("@TARGETNAME@") diff --git a/xmake/scripts/cmake_importfiles/xxxConfigVersion.cmake b/xmake/scripts/cmake_importfiles/xxxConfigVersion.cmake new file mode 100644 index 000000000..68ca4fbd6 --- /dev/null +++ b/xmake/scripts/cmake_importfiles/xxxConfigVersion.cmake @@ -0,0 +1,48 @@ +# This is a basic version file for the Config-mode of find_package(). +# It is used by write_basic_package_version_file() as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version. +# The variable CVF_VERSION must be set before calling configure_file(). + +set(PACKAGE_VERSION "@PACKAGE_VERSION@") + +if (PACKAGE_FIND_VERSION_RANGE) + # Package version must be in the requested version range + if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN) + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + endif() +else() + if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() + endif() +endif() + + +# if the installed project requested no architecture check, don't perform the check +if("FALSE") + return() +endif() + +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "") + return() +endif() + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8") + math(EXPR installedBits "8 * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/xmake/scripts/cmake_importfiles/xxxTargets-debug.cmake b/xmake/scripts/cmake_importfiles/xxxTargets-debug.cmake new file mode 100644 index 000000000..a6328bb79 --- /dev/null +++ b/xmake/scripts/cmake_importfiles/xxxTargets-debug.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Debug". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "@PROJECTNAME@::@TARGETNAME@" for configuration "Debug" +set_property(TARGET @PROJECTNAME@::@TARGETNAME@ APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(@PROJECTNAME@::@TARGETNAME@ PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "ASM_NASM;C" + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/@TARGETFILENAME@" + ) + +list(APPEND _IMPORT_CHECK_TARGETS @PROJECTNAME@::@TARGETNAME@ ) +list(APPEND _IMPORT_CHECK_FILES_FOR_@PROJECTNAME@::@TARGETNAME@ "${_IMPORT_PREFIX}/lib/@TARGETFILENAME@" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/xmake/scripts/cmake_importfiles/xxxTargets-release.cmake b/xmake/scripts/cmake_importfiles/xxxTargets-release.cmake new file mode 100644 index 000000000..c720fb79b --- /dev/null +++ b/xmake/scripts/cmake_importfiles/xxxTargets-release.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "@PROJECTNAME@::@TARGETNAME@" for configuration "Release" +set_property(TARGET @PROJECTNAME@::@TARGETNAME@ APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(@PROJECTNAME@::@TARGETNAME@ PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "ASM_NASM;C" + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/@TARGETFILENAME@" + ) + +list(APPEND _IMPORT_CHECK_TARGETS @PROJECTNAME@::@TARGETNAME@ ) +list(APPEND _IMPORT_CHECK_FILES_FOR_@PROJECTNAME@::@TARGETNAME@ "${_IMPORT_PREFIX}/lib/@TARGETFILENAME@" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/xmake/scripts/cmake_importfiles/xxxTargets.cmake b/xmake/scripts/cmake_importfiles/xxxTargets.cmake new file mode 100644 index 000000000..7ade9f919 --- /dev/null +++ b/xmake/scripts/cmake_importfiles/xxxTargets.cmake @@ -0,0 +1,93 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6...3.17) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget @PROJECTNAME@::@TARGETNAME@) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + +# The installation prefix configured by this project. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if (_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target @PROJECTNAME@::@TARGETNAME@ +add_library(@PROJECTNAME@::@TARGETNAME@ @TARGETKIND@ IMPORTED) + +set_target_properties(@PROJECTNAME@::@TARGETNAME@ PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" +) + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/@TARGETNAME@Targets-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/xmake/scripts/xrepo-hook.psm1 b/xmake/scripts/xrepo-hook.psm1 new file mode 100644 index 000000000..902ef3b16 --- /dev/null +++ b/xmake/scripts/xrepo-hook.psm1 @@ -0,0 +1,105 @@ + +## ENVIRONMENT MANAGEMENT ###################################################### + +<# + .SYNOPSIS + Enter a xrepo environment based on your current project. + + .EXAMPLE + Enter-XrepoEnvironment +#> +function Enter-XrepoEnvironment { + [CmdletBinding()] + param(); + + begin { + $script:xrepoOldEnvs = (Get-ChildItem -Path Env:); + + & $Env:XMAKE_EXE lua private.xrepo.action.env.info config; + if (-not $?) { + Exit 1; + } + + $xmakeColorTermBackup, $Env:XMAKE_COLORTERM = $Env:XMAKE_COLORTERM, "nocolor"; + $xrepoPrompt = (& $Env:XMAKE_EXE lua private.xrepo.action.env.info prompt | Out-String); + $Env:XMAKE_COLORTERM = $xmakeColorTermBackup; + if (-not $xrepoPrompt.StartsWith("[")) { + Write-Host $xrepoPrompt; + Exit 1; + } + + $activateCommand = (& $Env:XMAKE_EXE lua private.xrepo.action.env.info script.powershell | Out-String); + + Write-Verbose "[xrepo env script.powershell]`n$activateCommand"; + Invoke-Expression -Command $activateCommand; + + $Env:XMAKE_PROMPT_MODIFIER = $xrepoPrompt.Trim() + " "; + } + process {} + end {} +} + + +<# + .SYNOPSIS + Exit the current xrepo environment, if any. + + .EXAMPLE + Exit-XrepoEnvironment +#> +function Exit-XrepoEnvironment { + [CmdletBinding()] + param(); + + begin { + ForEach ($p in (Get-ChildItem Env:)) { + [Environment]::SetEnvironmentVariable($p.Name, $Null); + } + ForEach ($p in $script:xrepoOldEnvs) { + [Environment]::SetEnvironmentVariable($p.Name, $p.Value); + } + $Env:XMAKE_PROMPT_MODIFIER = ""; + } + process {} + end {} +} + + +if (Test-Path Function:\prompt) { + Rename-Item Function:\prompt XrepoPromptBackup +} else { + function XrepoPromptBackup() { + # Restore a basic prompt if the definition is missing. + "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "; + } +} + + +<# + .SYNOPSIS + Modifies the current prompt to show the current xmake project. + + .EXAMPLE + Add-XrepoEnvironmentToPrompt + + Causes the current session's prompt to display the current xmake project name. +#> +function Add-XrepoEnvironmentToPrompt() { + function global:prompt() { + if ($Env:XMAKE_PROMPT_MODIFIER) { + $Env:XMAKE_PROMPT_MODIFIER | Write-Host -NoNewline + } + XrepoPromptBackup; + } +} + + +## EXPORTS ################################################################### + +Export-ModuleMember ` + -Alias * ` + -Function ` + Add-XrepoEnvironmentToPrompt, ` + Enter-XrepoEnvironment, ` + Exit-XrepoEnvironment, ` + prompt diff --git a/xmake/templates/c++/tbox.shared/project/src/_demo/xmake.lua b/xmake/templates/c++/tbox.shared/project/src/_demo/xmake.lua index cbd73410b..fd2d629da 100644 --- a/xmake/templates/c++/tbox.shared/project/src/_demo/xmake.lua +++ b/xmake/templates/c++/tbox.shared/project/src/_demo/xmake.lua @@ -1,18 +1,7 @@ --- add target target("demo") - - -- set kind set_kind("binary") - - -- add deps add_deps("${TARGETNAME}") - - -- add defines add_defines("__tb_prefix__=\"demo\"") - - -- add files add_files("*.cpp") - - -- add packages add_packages("tbox") diff --git a/xmake/templates/c++/tbox.static/project/src/_demo/xmake.lua b/xmake/templates/c++/tbox.static/project/src/_demo/xmake.lua index cbd73410b..fd2d629da 100644 --- a/xmake/templates/c++/tbox.static/project/src/_demo/xmake.lua +++ b/xmake/templates/c++/tbox.static/project/src/_demo/xmake.lua @@ -1,18 +1,7 @@ --- add target target("demo") - - -- set kind set_kind("binary") - - -- add deps add_deps("${TARGETNAME}") - - -- add defines add_defines("__tb_prefix__=\"demo\"") - - -- add files add_files("*.cpp") - - -- add packages add_packages("tbox") diff --git a/xmake/templates/c/tbox.shared/project/src/_demo/xmake.lua b/xmake/templates/c/tbox.shared/project/src/_demo/xmake.lua index bd1a59ed6..4b852d481 100644 --- a/xmake/templates/c/tbox.shared/project/src/_demo/xmake.lua +++ b/xmake/templates/c/tbox.shared/project/src/_demo/xmake.lua @@ -1,18 +1,7 @@ --- add target target("demo") - - -- set kind set_kind("binary") - - -- add deps add_deps("${TARGETNAME}") - - -- add defines add_defines("__tb_prefix__=\"demo\"") - - -- add files add_files("*.c") - - -- add packages add_packages("tbox") diff --git a/xmake/templates/c/tbox.static/project/src/_demo/xmake.lua b/xmake/templates/c/tbox.static/project/src/_demo/xmake.lua index bd1a59ed6..4b852d481 100644 --- a/xmake/templates/c/tbox.static/project/src/_demo/xmake.lua +++ b/xmake/templates/c/tbox.static/project/src/_demo/xmake.lua @@ -1,18 +1,7 @@ --- add target target("demo") - - -- set kind set_kind("binary") - - -- add deps add_deps("${TARGETNAME}") - - -- add defines add_defines("__tb_prefix__=\"demo\"") - - -- add files add_files("*.c") - - -- add packages add_packages("tbox") diff --git a/xmake/templates/rust/static/project/xmake.lua b/xmake/templates/rust/static/project/xmake.lua index cbe81addf..a4761d2dc 100644 --- a/xmake/templates/rust/static/project/xmake.lua +++ b/xmake/templates/rust/static/project/xmake.lua @@ -1,25 +1,11 @@ --- add target target("interfaces") - - -- set kind set_kind("static") - - -- add files add_files("src/interfaces.rs") --- add target target("${TARGETNAME}_demo") - - -- set kind set_kind("binary") - - -- add deps add_deps("interfaces") - - -- add files add_files("src/main.rs") - - -- add link directory add_linkdirs("$(buildir)") ${FAQ} diff --git a/xmake/templates/zig/console/project/src/main.zig b/xmake/templates/zig/console/project/src/main.zig index fcfd5e0fa..259e332e6 100644 --- a/xmake/templates/zig/console/project/src/main.zig +++ b/xmake/templates/zig/console/project/src/main.zig @@ -1,6 +1,6 @@ const std = @import("std"); pub fn main() !void { - const stdout = std.io.getStdOut().outStream(); - try stdout.print("Hello, {}!\n", .{"world"}); + const stdout = std.io.getStdOut().writer(); + try stdout.print("Hello, {s}!\n", .{"world"}); } diff --git a/xmake/templates/zig/console/project/src/test.zig b/xmake/templates/zig/console/project/src/test.zig index 84804603e..605d168c4 100644 --- a/xmake/templates/zig/console/project/src/test.zig +++ b/xmake/templates/zig/console/project/src/test.zig @@ -1,6 +1,6 @@ const std = @import("std"); pub fn hello() !void { - const stdout = std.io.getStdOut().outStream(); - try stdout.print("Hello, {}!\n", .{"world"}); + const stdout = std.io.getStdOut().writer(); + try stdout.print("Hello, {s}!\n", .{"world"}); } diff --git a/xmake/templates/zig/shared/project/src/main.zig b/xmake/templates/zig/shared/project/src/main.zig index cee64b6b7..444a25407 100644 --- a/xmake/templates/zig/shared/project/src/main.zig +++ b/xmake/templates/zig/shared/project/src/main.zig @@ -3,6 +3,6 @@ const std = @import("std"); extern fn add(a: i32, b: i32) i32; pub fn main() !void { - const stdout = std.io.getStdOut().outStream(); - try stdout.print("Hello, {} - {}!\n", .{"world", add(1, 1)}); + const stdout = std.io.getStdOut().writer(); + try stdout.print("Hello, {s} - {d}!\n", .{"world", add(1, 1)}); } diff --git a/xmake/templates/zig/static/project/src/main.zig b/xmake/templates/zig/static/project/src/main.zig index cee64b6b7..444a25407 100644 --- a/xmake/templates/zig/static/project/src/main.zig +++ b/xmake/templates/zig/static/project/src/main.zig @@ -3,6 +3,6 @@ const std = @import("std"); extern fn add(a: i32, b: i32) i32; pub fn main() !void { - const stdout = std.io.getStdOut().outStream(); - try stdout.print("Hello, {} - {}!\n", .{"world", add(1, 1)}); + const stdout = std.io.getStdOut().writer(); + try stdout.print("Hello, {s} - {d}!\n", .{"world", add(1, 1)}); } diff --git a/xmake/themes/dark/xmake.lua b/xmake/themes/dark/xmake.lua index c9b47a3d7..d6e61d94e 100644 --- a/xmake/themes/dark/xmake.lua +++ b/xmake/themes/dark/xmake.lua @@ -53,10 +53,10 @@ theme("dark") set_color("build.target", "magenta") -- the spinner chars - if not is_subhost("msys", "cygwin") then - set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') - else + if (is_subhost("windows") and winos.version():lt("win10")) or is_subhost("msys", "cygwin") then set_text("spinner.chars", '\\', '-', '/', '|') + else + set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') end -- color dump diff --git a/xmake/themes/default/xmake.lua b/xmake/themes/default/xmake.lua index 93be14266..31c42eeab 100644 --- a/xmake/themes/default/xmake.lua +++ b/xmake/themes/default/xmake.lua @@ -50,13 +50,17 @@ theme("default") set_color("build.object", "") -- the building target file - set_color("build.target", "magenta bright") + if is_subhost("windows") and (os.term() == "powershell" or os.term() == "pwsh") then + set_color("build.target", "cyan bright") + else + set_color("build.target", "magenta bright") + end -- the spinner chars - if not is_subhost("msys", "cygwin") then - set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') - else + if (is_subhost("windows") and winos.version():lt("win10")) or is_subhost("msys", "cygwin") then set_text("spinner.chars", '\\', '-', '/', '|') + else + set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') end -- color dump @@ -70,15 +74,25 @@ theme("default") set_color("dump.default", "red") set_color("dump.udata", "yellow") set_color("dump.table", "bright") - set_color("dump.string", "magenta bright") - set_color("dump.string_quote", "magenta") + if is_subhost("windows") and (os.term() == "powershell" or os.term() == "pwsh") then + set_color("dump.string", "red bright") + set_color("dump.string_quote", "red") + else + set_color("dump.string", "magenta bright") + set_color("dump.string_quote", "magenta") + end set_color("dump.keyword", "blue") set_color("dump.number", "green bright") set_color("dump.function", "cyan") -- menu - set_color("menu.main.task.name", "magenta") - set_color("menu.option.name", "green") + if is_subhost("windows") and (os.term() == "powershell" or os.term() == "pwsh") then + set_color("menu.main.task.name", "cyan bright") + set_color("menu.option.name", "green bright") + else + set_color("menu.main.task.name", "magenta") + set_color("menu.option.name", "green") + end set_color("menu.usage", "cyan") -- interactive mode diff --git a/xmake/themes/ninja/xmake.lua b/xmake/themes/ninja/xmake.lua index 3e4a0f9f2..84353e788 100644 --- a/xmake/themes/ninja/xmake.lua +++ b/xmake/themes/ninja/xmake.lua @@ -53,10 +53,10 @@ theme("ninja") set_color("build.target", "magenta bright") -- the spinner chars - if not is_subhost("msys", "cygwin") then - set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') - else + if (is_subhost("windows") and winos.version():lt("win10")) or is_subhost("msys", "cygwin") then set_text("spinner.chars", '\\', '-', '/', '|') + else + set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') end -- color dump diff --git a/xmake/themes/powershell/xmake.lua b/xmake/themes/powershell/xmake.lua index 3a79a2145..3210d7188 100644 --- a/xmake/themes/powershell/xmake.lua +++ b/xmake/themes/powershell/xmake.lua @@ -53,7 +53,11 @@ theme("powershell") set_color("build.target", "cyan bright") -- the spinner chars - set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') + if (is_subhost("windows") and winos.version():lt("win10")) or is_subhost("msys", "cygwin") then + set_text("spinner.chars", '\\', '-', '/', '|') + else + set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏') + end -- color dump set_text("dump.default_format", "%s") diff --git a/xmake/toolchains/cross/check.lua b/xmake/toolchains/cross/check.lua index 695c746d2..815b95fd7 100644 --- a/xmake/toolchains/cross/check.lua +++ b/xmake/toolchains/cross/check.lua @@ -29,16 +29,29 @@ function main(toolchain) local sdkdir = toolchain:sdkdir() local bindir = toolchain:bindir() local cross = toolchain:cross() - if not sdkdir and not bindir and not cross then + if not sdkdir and not bindir and not cross and not toolchain:packages() then return end - -- find cross toolchain + -- find cross toolchain from external envirnoment local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir, cross = cross}) + if not cross_toolchain then + -- find it from packages + for _, package in ipairs(toolchain:packages()) do + local installdir = package:installdir() + if installdir and os.isdir(installdir) then + cross_toolchain = find_cross_toolchain(installdir, {cross = cross}) + if cross_toolchain then + break + end + end + end + end if cross_toolchain then - config.set("cross", cross_toolchain.cross, {readonly = true, force = true}) - config.set("bin", cross_toolchain.bindir, {readonly = true, force = true}) - config.set("sdk", cross_toolchain.sdkdir, {readonly = true, force = true}) + toolchain:config_set("cross", cross_toolchain.cross) + toolchain:config_set("bindir", cross_toolchain.bindir) + toolchain:config_set("sdkdir", cross_toolchain.sdkdir) + toolchain:configs_save() -- init default target os if not config.get("target_os") then config.set("target_os", "linux", {readonly = true, force = true}) diff --git a/xmake/toolchains/cross/xmake.lua b/xmake/toolchains/cross/xmake.lua index 839c0caed..3ec12f1f4 100644 --- a/xmake/toolchains/cross/xmake.lua +++ b/xmake/toolchains/cross/xmake.lua @@ -24,8 +24,8 @@ toolchain("cross") -- set descrption set_description("Common cross compilation toolchain") - -- mark as standalone toolchain - set_kind("standalone") + -- mark as cross-compilation toolchain + set_kind("cross") -- check toolchain on_check("check") diff --git a/xmake/toolchains/cuda/xmake.lua b/xmake/toolchains/cuda/xmake.lua index f7bd54cd0..ca25dcb74 100644 --- a/xmake/toolchains/cuda/xmake.lua +++ b/xmake/toolchains/cuda/xmake.lua @@ -30,3 +30,14 @@ toolchain("cuda") set_toolset("culd", "nvcc") set_toolset("cu-ccbin", "$(env CXX)", "$(env CC)", "clang", "gcc") + -- bind msvc environments, because nvcc will call cl.exe + on_load(function (toolchain) + if toolchain:is_plat("windows") then + import("core.tool.toolchain", {alias = "core_toolchain"}) + local msvc = core_toolchain.load("msvc", {plat = toolchain:plat(), arch = toolchain:arch()}) + for name, values in pairs(msvc:runenvs()) do + toolchain:add("runenvs", name, values) + end + end + end) + diff --git a/xmake/toolchains/dlang/check.lua b/xmake/toolchains/dlang/check.lua index 782675351..fb0dc0aaa 100644 --- a/xmake/toolchains/dlang/check.lua +++ b/xmake/toolchains/dlang/check.lua @@ -31,9 +31,9 @@ function main(toolchain) end -- we need find ldc2 and gdc in the given toolchain sdk directory - local sdkdir = config.get("sdk") - local bindir = config.get("bin") - local cross = config.get("cross") + local sdkdir = toolchain:sdkdir() + local bindir = toolchain:bindir() + local cross = toolchain:cross() if not sdkdir and not bindir and not cross then return end @@ -41,9 +41,10 @@ function main(toolchain) -- find cross toolchain local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir, cross = cross}) if cross_toolchain then - config.set("cross", cross_toolchain.cross, {readonly = true, force = true}) - config.set("bin", cross_toolchain.bindir, {readonly = true, force = true}) - config.set("sdkdir", cross_toolchain.sdkdir, {readonly = true, force = true}) + toolchain:config_set("cross", cross_toolchain.cross) + toolchain:config_set("bindir", cross_toolchain.bindir) + toolchain:config_set("sdkdir", cross_toolchain.sdkdir) + toolchain:configs_save() else raise("cross toolchain not found!") end diff --git a/xmake/toolchains/dlang/xmake.lua b/xmake/toolchains/dlang/xmake.lua index f12fe9f99..17e5f36b1 100644 --- a/xmake/toolchains/dlang/xmake.lua +++ b/xmake/toolchains/dlang/xmake.lua @@ -35,7 +35,7 @@ toolchain("dlang") import("core.project.config") -- get cross prefix - local cross = config.get("cross") or "" + local cross = toolchain:cross() or "" -- set toolset toolchain:add("toolset", "dc", "$(env DC)", "dmd", "ldc2", cross .. "gdc") diff --git a/xmake/toolchains/gnu-rm/xmake.lua b/xmake/toolchains/gnu-rm/xmake.lua index 912cf8ff4..4a1751172 100644 --- a/xmake/toolchains/gnu-rm/xmake.lua +++ b/xmake/toolchains/gnu-rm/xmake.lua @@ -25,8 +25,8 @@ toolchain("gnu-rm") set_homepage("https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm") set_description("GNU Arm Embedded Toolchain") - -- mark as standalone toolchain - set_kind("standalone") + -- mark as cross-complation toolchain + set_kind("cross") -- on load on_load(function (toolchain) diff --git a/xmake/toolchains/llvm/check.lua b/xmake/toolchains/llvm/check.lua index eaebf8eaa..f63418cc8 100644 --- a/xmake/toolchains/llvm/check.lua +++ b/xmake/toolchains/llvm/check.lua @@ -20,6 +20,7 @@ -- imports import("core.project.config") +import("lib.detect.find_path") import("detect.sdks.find_xcode") import("detect.sdks.find_cross_toolchain") @@ -28,7 +29,7 @@ function _find_xcode(toolchain) -- find xcode local xcode_sdkver = toolchain:config("xcode_sdkver") or config.get("xcode_sdkver") - local xcode = find_xcode(config.get("xcode"), {force = true, verbose = true, + local xcode = find_xcode(toolchain:config("xcode") or config.get("xcode"), {force = true, verbose = true, find_codesign = false, sdkver = xcode_sdkver, plat = toolchain:plat(), @@ -40,7 +41,7 @@ function _find_xcode(toolchain) -- xcode found xcode_sdkver = xcode.sdkver - if toolchain:global() then + if toolchain:is_global() then config.set("xcode", xcode.sdkdir, {force = true, readonly = true}) cprint("checking for Xcode directory ... ${color.success}%s", xcode.sdkdir) end @@ -54,19 +55,37 @@ end function main(toolchain) -- get sdk directory - local sdkdir = config.get("sdk") - local bindir = config.get("bin") + local sdkdir = toolchain:sdkdir() + local bindir = toolchain:bindir() if not sdkdir and not bindir then - if toolchain:is_plat("linux") and os.isfile("/usr/bin/llvm-ar") then + if is_host("linux") and os.isfile("/usr/bin/llvm-ar") then sdkdir = "/usr" + elseif is_host("macosx") then + local bindir = find_path("llvm-ar", "/usr/local/Cellar/llvm/*/bin") + if bindir then + sdkdir = path.directory(bindir) + end end end - -- find cross toolchain + -- find cross toolchain from external envirnoment local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir}) + if not cross_toolchain then + -- find it from packages + for _, package in ipairs(toolchain:packages()) do + local installdir = package:installdir() + if installdir and os.isdir(installdir) then + cross_toolchain = find_cross_toolchain(installdir) + if cross_toolchain then + break + end + end + end + end if cross_toolchain then - config.set("cross", cross_toolchain.cross, {readonly = true, force = true}) - config.set("bin", cross_toolchain.bindir, {readonly = true, force = true}) + toolchain:config_set("cross", cross_toolchain.cross) + toolchain:config_set("bindir", cross_toolchain.bindir) + toolchain:configs_save() else raise("llvm toolchain not found!") end diff --git a/xmake/toolchains/llvm/xmake.lua b/xmake/toolchains/llvm/xmake.lua index 6b6598406..e08cb0e5d 100644 --- a/xmake/toolchains/llvm/xmake.lua +++ b/xmake/toolchains/llvm/xmake.lua @@ -48,7 +48,16 @@ toolchain("llvm") -- add march flags local march - if toolchain:is_arch("x86_64", "x64") then + if toolchain:is_plat("windows") and not is_host("windows") then + -- cross-compilation for windows + if toolchain:is_arch("i386", "x86") then + march = "-target i386-pc-windows-msvc" + else + march = "-target x86_64-pc-windows-msvc" + end + toolchain:add("ldflags", "-fuse-ld=lld") + toolchain:add("shflags", "-fuse-ld=lld") + elseif toolchain:is_arch("x86_64", "x64") then march = "-m64" elseif toolchain:is_arch("i386", "x86") then march = "-m32" @@ -61,7 +70,7 @@ toolchain("llvm") toolchain:add("shflags", march) end - -- init flags for the xcode sdk directory + -- init flags for macOS if toolchain:is_plat("macosx") then local xcode_dir = get_config("xcode") local xcode_sdkver = toolchain:config("xcode_sdkver") @@ -69,9 +78,20 @@ toolchain("llvm") if xcode_dir and xcode_sdkver then xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk" toolchain:add("cxflags", "-isysroot " .. xcode_sdkdir) + toolchain:add("mxflags", "-isysroot " .. xcode_sdkdir) toolchain:add("ldflags", "-isysroot " .. xcode_sdkdir) toolchain:add("shflags", "-isysroot " .. xcode_sdkdir) + else + -- @see https://github.com/xmake-io/xmake/issues/1179 + local macsdk = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" + if os.exists(macsdk) then + toolchain:add("cxflags", "-isysroot " .. macsdk) + toolchain:add("mxflags", "-isysroot " .. macsdk) + toolchain:add("ldflags", "-isysroot " .. macsdk) + toolchain:add("shflags", "-isysroot " .. macsdk) + end end + toolchain:add("mxflags", "-fobjc-arc") end -- add bin search library for loading some dependent .dll files windows diff --git a/xmake/toolchains/mingw/check.lua b/xmake/toolchains/mingw/check.lua index 7800315c1..22a13fadd 100644 --- a/xmake/toolchains/mingw/check.lua +++ b/xmake/toolchains/mingw/check.lua @@ -24,11 +24,23 @@ import("detect.sdks.find_mingw") -- check the mingw toolchain function main(toolchain) - local mingw = find_mingw(config.get("mingw"), {verbose = true, bindir = config.get("bin"), cross = config.get("cross")}) + local mingw = find_mingw(toolchain:config("mingw") or config.get("mingw"), {verbose = true, bindir = toolchain:bindir(), cross = toolchain:cross()}) + if not mingw then + for _, package in ipairs(toolchain:packages()) do + local installdir = package:installdir() + if installdir and os.isdir(installdir) then + mingw = find_mingw(installdir, {verbose = true, cross = toolchain:cross()}) + if mingw then + break + end + end + end + end if mingw then - config.set("mingw", mingw.sdkdir, {force = true, readonly = true}) - config.set("cross", mingw.cross, {readonly = true, force = true}) - config.set("bin", mingw.bindir, {readonly = true, force = true}) + toolchain:config_set("mingw", mingw.sdkdir) + toolchain:config_set("cross", mingw.cross) + toolchain:config_set("bindir", mingw.bindir) + toolchain:configs_save() else -- failed cprint("${bright color.error}please run:") diff --git a/xmake/toolchains/mingw/xmake.lua b/xmake/toolchains/mingw/xmake.lua index 3007093ea..3ddd5c103 100644 --- a/xmake/toolchains/mingw/xmake.lua +++ b/xmake/toolchains/mingw/xmake.lua @@ -48,7 +48,7 @@ toolchain("mingw") elseif toolchain:is_arch("armv7", "arm.*") then cross = "armv7-w64-mingw32-" else - cross = config.get("cross") or "" + cross = toolchain:cross() or "" end -- add bin search library for loading some dependent .dll files windows diff --git a/xmake/toolchains/msvc/check.lua b/xmake/toolchains/msvc/check.lua index 84596634f..634249232 100644 --- a/xmake/toolchains/msvc/check.lua +++ b/xmake/toolchains/msvc/check.lua @@ -79,7 +79,7 @@ end function _check_vstudio(toolchain) local vs = _check_vsenv(toolchain) if vs then - if toolchain:global() then + if toolchain:is_global() then config.set("vs", vs, {force = true, readonly = true}) end toolchain:config_set("vs", vs) @@ -87,12 +87,6 @@ function _check_vstudio(toolchain) cprint("checking for Microsoft Visual Studio (%s) version ... ${color.success}%s", toolchain:arch(), vs) else cprint("checking for Microsoft Visual Studio (%s) version ... ${color.nothing}${text.nothing}", toolchain:arch()) - if toolchain:is_plat("windows") then - print("please run:") - print(" - xmake config --vs=xxx [--vs_toolset=xxx]") - print("or - xmake global --vs=xxx") - raise() - end end return vs end diff --git a/xmake/toolchains/msvc/xmake.lua b/xmake/toolchains/msvc/xmake.lua index 2b9f4eb1e..a79cb4268 100644 --- a/xmake/toolchains/msvc/xmake.lua +++ b/xmake/toolchains/msvc/xmake.lua @@ -18,7 +18,17 @@ -- @file xmake.lua -- --- define toolchain +-- msvc toolchain +-- +-- @param vs the vs version +-- +-- @code +-- target("test") +-- ... +-- set_toolchains("msvc") +-- set_toolchains("msvc", {vs = "2019"}) +-- @endcode +-- toolchain("msvc") -- set homepage diff --git a/xmake/toolchains/musl/xmake.lua b/xmake/toolchains/muslcc/xmake.lua index 2bcf5ce22..4c8de24ac 100644 --- a/xmake/toolchains/musl/xmake.lua +++ b/xmake/toolchains/muslcc/xmake.lua @@ -19,14 +19,14 @@ -- -- define toolchain -toolchain("musl") +toolchain("muslcc") -- set homepage set_homepage("https://musl.cc/") set_description("The musl-based cross-compilation toolchains") - -- mark as standalone toolchain - set_kind("standalone") + -- mark as cross-compilation toolchain + set_kind("cross") -- on load on_load(function (toolchain) @@ -40,6 +40,5 @@ toolchain("musl") toolchain:add("ldflags", "-march=armv7-a", "-msoft-float", {force = true}) toolchain:add("syslinks", "atomic") -- fix undefined reference to `__atomic_fetch_add_8' end - toolchain:add("ldflags", "--static", {force = true}) toolchain:add("syslinks", "gcc", "c") end) diff --git a/xmake/toolchains/nasm/xmake.lua b/xmake/toolchains/nasm/xmake.lua index 584b2506e..9ab739744 100644 --- a/xmake/toolchains/nasm/xmake.lua +++ b/xmake/toolchains/nasm/xmake.lua @@ -30,11 +30,25 @@ toolchain("nasm") -- on load on_load(function (toolchain) + local asflags = "" -- maybe 16bits if no flags if toolchain:is_plat("macosx") then - toolchain:add("nasm.asflags", "-f", toolchain:is_arch("x86_64") and "macho64" or "macho32") - elseif toolchain:is_plat("linux", "bsd") then - toolchain:add("nasm.asflags", "-f", toolchain:is_arch("x86_64") and "elf64" or "elf32") + if toolchain:is_arch("x86_64") then + asflags = "-f macho64" + elseif toolchain:is_arch("i386") then + asflags = "-f macho32" + end + elseif toolchain:is_plat("linux", "android", "bsd") then + if toolchain:is_arch("x86_64") then + asflags = "-f elf64" + elseif toolchain:is_arch("i386") then + asflags = "-f elf32" + end elseif toolchain:is_plat("windows", "mingw", "msys", "cygwin") then - toolchain:add("nasm.asflags", "-f", toolchain:is_arch("x64") and "win64" or "win32") + if toolchain:is_arch("x64", "x86_64") then + asflags = "-f win64" + elseif toolchain:is_arch("x86", "i386") then + asflags = "-f win32" + end end + toolchain:add("nasm.asflags", asflags) end) diff --git a/xmake/toolchains/ndk/check.lua b/xmake/toolchains/ndk/check.lua index e5e36fbf7..aaf1d609a 100644 --- a/xmake/toolchains/ndk/check.lua +++ b/xmake/toolchains/ndk/check.lua @@ -19,38 +19,65 @@ -- -- imports +import("core.base.option") import("core.project.config") import("detect.sdks.find_ndk") import("detect.sdks.find_android_sdk") -- check the ndk toolchain -function _check_ndk() - local ndk = find_ndk(config.get("ndk"), {force = true, verbose = true}) +function _check_ndk(toolchain) + local ndk + for _, package in ipairs(toolchain:packages()) do + local installdir = package:installdir() + if installdir and os.isdir(installdir) then + ndk = find_ndk(installdir, {force = true, verbose = option.get("verbose"), + plat = toolchain:plat(), + arch = toolchain:arch(), + sdkver = toolchain:config("sdkver")}) + if ndk then + break + end + end + end + if not ndk then + ndk = find_ndk(toolchain:config("ndk") or config.get("ndk"), {force = true, verbose = true, + plat = toolchain:plat(), + arch = toolchain:arch(), + sdkver = toolchain:config("sdkver")}) + end if ndk then - config.set("ndk", ndk.sdkdir, {force = true, readonly = true}) - config.set("bin", ndk.bindir, {force = true, readonly = true}) - config.set("cross", ndk.cross, {force = true, readonly = true}) - config.set("gcc_toolchain", ndk.gcc_toolchain, {force = true, readonly = true}) + toolchain:config_set("ndk", ndk.sdkdir) + toolchain:config_set("bindir", ndk.bindir) + toolchain:config_set("cross", ndk.cross) + toolchain:config_set("gcc_toolchain", ndk.gcc_toolchain) + toolchain:config_set("ndkver", ndk.ndkver) + toolchain:config_set("ndk_sdkver", ndk.sdkver) + toolchain:config_set("ndk_toolchains_ver", ndk.toolchains_ver) + toolchain:config_set("ndk_sysroot", ndk.sysroot) + toolchain:configs_save() + return true else + --[[TODO we need also add this tips when use remote ndk toolchain -- failed cprint("${bright color.error}please run:") cprint(" - xmake config --ndk=xxx") cprint("or - xmake global --ndk=xxx") - raise() + raise()]] end end -- check the android sdk -function _check_android_sdk() - local sdk = find_android_sdk(config.get("android_sdk"), {force = true, verbose = true}) +function _check_android_sdk(toolchain) + local sdk = find_android_sdk(toolchain:config("android_sdk") or config.get("android_sdk"), {force = true, verbose = toolchain:is_global()}) if sdk then - config.set("sdk", sdk.sdkdir, {force = true, readonly = true}) + toolchain:config_set("android_sdk", sdk.sdkdir) + toolchain:config_set("build_toolver", sdk.build_toolver) + toolchain:configs_save() end end -- main entry function main(toolchain) - _check_android_sdk() - _check_ndk() - return true + _check_android_sdk(toolchain) + return _check_ndk(toolchain) end diff --git a/xmake/toolchains/ndk/load.lua b/xmake/toolchains/ndk/load.lua index c4e53ced2..29e88d7ad 100644 --- a/xmake/toolchains/ndk/load.lua +++ b/xmake/toolchains/ndk/load.lua @@ -21,6 +21,43 @@ -- imports import("core.project.config") +-- get triple +function _get_triple(arch) + local triples = + { + ["armv5te"] = "arm-linux-androideabi" -- deprecated + , ["armv7-a"] = "arm-linux-androideabi" -- deprecated + , ["armeabi"] = "arm-linux-androideabi" -- removed in ndk r17 + , ["armeabi-v7a"] = "arm-linux-androideabi" + , ["arm64-v8a"] = "aarch64-linux-android" + , i386 = "i686-linux-android" -- deprecated + , x86 = "i686-linux-android" + , x86_64 = "x86_64-linux-android" + , mips = "mips-linux-android" -- removed in ndk r17 + , mips64 = "mips64-linux-android" -- removed in ndk r17 + } + return triples[arch] +end + +-- get target +function _get_target(arch, ndk_sdkver) + local targets = + { + ["armv5te"] = "armv5te-none-linux-androideabi" -- deprecated + , ["armeabi"] = "armv5te-none-linux-androideabi" -- removed in ndk r17 + , ["armv7-a"] = "armv7-none-linux-androideabi" -- deprecated + , ["armeabi-v7a"] = "armv7-none-linux-androideabi" + , ["arm64-v8a"] = "aarch64-none-linux-android" + , ["i386"] = "i686-none-linux-android" -- deprecated + , ["x86"] = "i686-none-linux-android" + , ["x86_64"] = "x86_64-none-linux-android" + , ["mips"] = "mipsel-none-linux-android" -- removed in ndk r17 + , ["mips64"] = "mips64el-none-linux-android" -- removed in ndk r17 + } + assert(targets[arch], "unknown arch(%s) for android!", arch) + return targets[arch] .. (ndk_sdkver or "") +end + -- load ndk toolchain -- -- some extra configuration for target @@ -30,15 +67,20 @@ import("core.project.config") function main(toolchain) -- get cross - local cross = config.get("cross") or "" + local cross = toolchain:cross() or "" -- get gcc toolchain bin directory local gcc_toolchain_bin = nil - local gcc_toolchain = config.get("gcc_toolchain") + local gcc_toolchain = toolchain:config("gcc_toolchain") if gcc_toolchain then gcc_toolchain_bin = path.join(gcc_toolchain, "bin") end + -- get ndk and version + local ndk = toolchain:config("ndk") + local ndkver = toolchain:config("ndkver") + local ndk_sdkver = toolchain:config("ndk_sdkver") + -- set toolset toolchain:set("toolset", "cc", "clang", cross .. "gcc") toolchain:set("toolset", "cxx", "clang++", cross .. "g++") @@ -62,7 +104,7 @@ function main(toolchain) -- use llvm directory? e.g. android-ndk/toolchains/llvm/prebuilt/darwin-x86_64/bin local isllvm = false - local bindir = config.get("bin") + local bindir = toolchain:bindir() if bindir and bindir:find("llvm", 1, true) then isllvm = true end @@ -70,28 +112,15 @@ function main(toolchain) -- init architecture if isllvm then - -- add target - local targets = - { - ["armv5te"] = "armv5te-none-linux-androideabi" -- deprecated - , ["armeabi"] = "armv5te-none-linux-androideabi" -- removed in ndk r17 - , ["armv7-a"] = "armv7-none-linux-androideabi" -- deprecated - , ["armeabi-v7a"] = "armv7-none-linux-androideabi" - , ["arm64-v8a"] = "aarch64-none-linux-android" - , ["i386"] = "i686-none-linux-android" -- deprecated - , ["x86"] = "i686-none-linux-android" - , ["x86_64"] = "x86_64-none-linux-android" - , ["mips"] = "mipsel-none-linux-android" -- removed in ndk r17 - , ["mips64"] = "mips64el-none-linux-android" -- removed in ndk r17 - } - assert(targets[arch], "unknown arch(%s) for android!", arch) - toolchain:add("cxflags", "-target " .. targets[arch]) - toolchain:add("asflags", "-target " .. targets[arch]) - toolchain:add("ldflags", "-target " .. targets[arch]) - toolchain:add("shflags", "-target " .. targets[arch]) + -- add ndk target + local ndk_target = _get_target(arch, ndk_sdkver) + toolchain:add("cxflags", "-target " .. ndk_target) + toolchain:add("asflags", "-target " .. ndk_target) + toolchain:add("ldflags", "-target " .. ndk_target) + toolchain:add("shflags", "-target " .. ndk_target) -- add gcc toolchain - local gcc_toolchain = config.get("gcc_toolchain") + local gcc_toolchain = toolchain:config("gcc_toolchain") if gcc_toolchain then toolchain:add("cxflags", "-gcc-toolchain " .. gcc_toolchain) toolchain:add("asflags", "-gcc-toolchain " .. gcc_toolchain) @@ -116,9 +145,6 @@ function main(toolchain) toolchain:add("binary.cxflags", "-fPIE", "-pie") -- add flags for the sdk directory of ndk - local ndk = config.get("ndk") - local ndkver = config.get("ndkver") - local ndk_sdkver = config.get("ndk_sdkver") if ndk and ndk_sdkver then -- the sysroot archs @@ -137,59 +163,30 @@ function main(toolchain) } local sysroot_arch = sysroot_archs[arch] - -- add sysroot - -- - -- @see https://android.googlesource.com/platform/ndk/+/master/docs/UnifiedHeaders.md - -- - -- Before NDK r14, we had a set of libc headers for each API version. - -- In many cases these headers were incorrect. Many exposed APIs that didn‘t exist, and others didn’t expose APIs that did. - -- - -- In NDK r14 (as an opt in feature) we unified these into a single set of headers, called unified headers. - -- This single header path is used for every platform level. API level guards are handled with #ifdef. - -- These headers can be found in prebuilts/ndk/headers. - -- - -- Unified headers are built directly from the Android platform, so they are up to date and correct (or at the very least, - -- any bugs in the NDK headers will also be a bug in the platform headers, which means we're much more likely to find them). - -- - -- In r15 unified headers are used by default. In r16, the old headers have been removed. - -- - local ndk_sdkdir = path.translate(format("%s/platforms/android-%d", ndk, ndk_sdkver)) - local ndk_sysroot_be_r14 = path.join(ndk, "sysroot") - if os.isdir(ndk_sysroot_be_r14) then - - -- the triples - local triples = - { - ["armv5te"] = "arm-linux-androideabi" -- deprecated - , ["armv7-a"] = "arm-linux-androideabi" -- deprecated - , ["armeabi"] = "arm-linux-androideabi" -- removed in ndk r17 - , ["armeabi-v7a"] = "arm-linux-androideabi" - , ["arm64-v8a"] = "aarch64-linux-android" - , i386 = "i686-linux-android" -- deprecated - , x86 = "i686-linux-android" - , x86_64 = "x86_64-linux-android" - , mips = "mips-linux-android" -- removed in ndk r17 - , mips64 = "mips64-linux-android" -- removed in ndk r17 - } + -- add sysroot flags + local ndk_sysroot = toolchain:config("ndk_sysroot") + if ndk_sysroot and os.isdir(ndk_sysroot) then + local triple = _get_triple(arch) toolchain:add("cxflags", "-D__ANDROID_API__=" .. ndk_sdkver) toolchain:add("asflags", "-D__ANDROID_API__=" .. ndk_sdkver) - toolchain:add("cflags", "--sysroot=" .. ndk_sysroot_be_r14) - toolchain:add("cxxflags","--sysroot=" .. ndk_sysroot_be_r14) - toolchain:add("asflags", "--sysroot=" .. ndk_sysroot_be_r14) - toolchain:add("cflags", "-isystem " .. path.join(ndk_sysroot_be_r14, "usr", "include", triples[arch])) - toolchain:add("cxxflags","-isystem " .. path.join(ndk_sysroot_be_r14, "usr", "include", triples[arch])) - toolchain:add("asflags", "-isystem " .. path.join(ndk_sysroot_be_r14, "usr", "include", triples[arch])) + toolchain:add("cflags", "--sysroot=" .. ndk_sysroot) + toolchain:add("cxxflags","--sysroot=" .. ndk_sysroot) + toolchain:add("asflags", "--sysroot=" .. ndk_sysroot) + toolchain:add("cflags", "-isystem " .. path.join(ndk_sysroot, "usr", "include", triple)) + toolchain:add("cxxflags","-isystem " .. path.join(ndk_sysroot, "usr", "include", triple)) + toolchain:add("asflags", "-isystem " .. path.join(ndk_sysroot, "usr", "include", triple)) else - if sysroot_arch then - toolchain:add("cflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) - toolchain:add("cxxflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) - toolchain:add("asflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) + local ndk_sdkdir = path.translate(format("%s/platforms/android-%d", ndk, ndk_sdkver)) + if os.isdir(ndk_sdkdir) then + if sysroot_arch then + toolchain:add("cflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) + toolchain:add("cxxflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) + toolchain:add("asflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) + toolchain:add("ldflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) + toolchain:add("shflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) + end end end - if sysroot_arch then - toolchain:add("ldflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) - toolchain:add("shflags", format("--sysroot=%s/%s", ndk_sdkdir, sysroot_arch)) - end -- add "-fPIE -pie" to ldflags toolchain:add("ldflags", "-fPIE") @@ -200,8 +197,8 @@ function main(toolchain) -- get gnu c++ stl sdk directory local cxxstl_sdkdir_gnustl = nil - if config.get("ndk_toolchains_ver") then - cxxstl_sdkdir_gnustl = path.translate(format("%s/sources/cxx-stl/gnu-libstdc++/%s", ndk, config.get("ndk_toolchains_ver"))) + if toolchain:config("ndk_toolchains_ver") then + cxxstl_sdkdir_gnustl = path.translate(format("%s/sources/cxx-stl/gnu-libstdc++/%s", ndk, toolchain:config("ndk_toolchains_ver"))) end -- get stlport c++ sdk directory @@ -254,6 +251,7 @@ function main(toolchain) toolchain:add("linkdirs", format("%s/libs/%s", cxxstl_sdkdir, toolchains_arch)) end if ndk_cxxstl:startswith("c++") or ndk_cxxstl:startswith("llvmstl") then + toolchain:add("cxxflags", "-nostdinc++") toolchain:add("sysincludedirs", format("%s/include", cxxstl_sdkdir)) if toolchains_arch then toolchain:add("sysincludedirs", format("%s/libs/%s/include", cxxstl_sdkdir, toolchains_arch)) @@ -267,11 +265,13 @@ function main(toolchain) toolchain:add("sysincludedirs", after_r13) end elseif ndk_cxxstl:startswith("gnustl") then + toolchain:add("cxxflags", "-nostdinc++") toolchain:add("sysincludedirs", format("%s/include", cxxstl_sdkdir)) if toolchains_arch then toolchain:add("sysincludedirs", format("%s/libs/%s/include", cxxstl_sdkdir, toolchains_arch)) end elseif ndk_cxxstl:startswith("stlport") then + toolchain:add("cxxflags", "-nostdinc++") toolchain:add("sysincludedirs", format("%s/stlport", cxxstl_sdkdir)) end diff --git a/xmake/toolchains/ndk/xmake.lua b/xmake/toolchains/ndk/xmake.lua index 099deeae9..609efb4a2 100644 --- a/xmake/toolchains/ndk/xmake.lua +++ b/xmake/toolchains/ndk/xmake.lua @@ -18,7 +18,17 @@ -- @file xmake.lua -- --- define toolchain +-- android ndk toolchain +-- +-- @param sdkver the platform sdk version +-- +-- @code +-- target("test") +-- ... +-- set_toolchains("ndk") +-- set_toolchains("ndk", {sdkver = "23"}) +-- @endcode +-- toolchain("ndk") -- set homepage diff --git a/xmake/toolchains/sdcc/check.lua b/xmake/toolchains/sdcc/check.lua index 368b80cd8..18f9a7f99 100644 --- a/xmake/toolchains/sdcc/check.lua +++ b/xmake/toolchains/sdcc/check.lua @@ -24,12 +24,13 @@ import("detect.sdks.find_cross_toolchain") -- check the cross toolchain function main(toolchain) - local sdkdir = config.get("sdk") - local bindir = config.get("bin") + local sdkdir = toolchain:sdkdir() + local bindir = toolchain:bindir() local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir}) if cross_toolchain then - config.set("cross", cross_toolchain.cross, {readonly = true, force = true}) - config.set("bin", cross_toolchain.bindir, {readonly = true, force = true}) + toolchain:config_set("cross", cross_toolchain.cross) + toolchain:config_set("bindir", cross_toolchain.bindir) + toolchain:configs_save() else raise("sdcc toolchain not found!") end diff --git a/xmake/toolchains/tinyc/xmake.lua b/xmake/toolchains/tinycc/xmake.lua index 20d7eedf1..21bb7be08 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,21 @@ toolchain("tinyc") import("lib.detect.find_tool") -- find tcc - local sdkdir = config.get("sdk") - 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 + local paths = {toolchain:bindir()} + local sdkdir = toolchain:sdkdir() + 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 = config.get("bin") or sdkdir}) then - config.set("__tcc_sdkdir", sdkdir) + local tcc = find_tool("tcc", {paths = paths}) + if tcc then + toolchain:config_set("tcc", tcc.program) + toolchain:configs_save() return true end end) @@ -76,21 +76,19 @@ toolchain("tinyc") toolchain:add("shflags", march) end - -- init linkdirs and sysincludedirs - local sdkdir = config.get("__tcc_sdkdir") or 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) + -- 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) + + -- add includedirs and linkdirs + for _, package in ipairs(toolchain:packages()) do + local installdir = package:installdir() + if installdir then + toolchain:add("sysincludedirs", path.join(installdir, "include")) + toolchain:add("linkdirs", path.join(installdir, "lib")) end end end) diff --git a/xmake/toolchains/xcode/check.lua b/xmake/toolchains/xcode/check.lua index 0432f852a..ed0d917db 100644 --- a/xmake/toolchains/xcode/check.lua +++ b/xmake/toolchains/xcode/check.lua @@ -29,7 +29,7 @@ function main(toolchain) -- find xcode local xcode_sdkver = toolchain:config("xcode_sdkver") or config.get("xcode_sdkver") local xcode = find_xcode(config.get("xcode"), {force = true, verbose = true, - find_codesign = toolchain:global(), + find_codesign = toolchain:is_global(), sdkver = xcode_sdkver, plat = toolchain:plat(), arch = toolchain:arch()}) @@ -40,7 +40,7 @@ function main(toolchain) -- xcode found xcode_sdkver = xcode.sdkver - if toolchain:global() then + if toolchain:is_global() then config.set("xcode", xcode.sdkdir, {force = true, readonly = true}) config.set("xcode_mobile_provision", xcode.mobile_provision, {force = true, readonly = true}) config.set("xcode_codesign_identity", xcode.codesign_identity, {force = true, readonly = true}) @@ -59,6 +59,26 @@ function main(toolchain) end end + -- save xcode sysroot directory + local xcode_sysroot + if xcode.sdkdir and xcode_sdkver then + if toolchain:is_plat("macosx") then + xcode_sysroot = xcode.sdkdir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk" + elseif toolchain:is_plat("iphoneos") then + local platname = toolchain:is_arch("i386", "x86_64") and "iPhoneSimulator" or "iPhoneOS" + xcode_sysroot = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode.sdkdir, platname, platname, xcode_sdkver) + elseif toolchain:is_plat("watchos") then + local platname = toolchain:is_arch("i386", "x86_64") and "WatchSimulator" or "WatchOS" + xcode_sysroot = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode.sdkdir, platname, platname, xcode_sdkver) + elseif toolchain:is_plat("appletvos") then + local platname = toolchain:is_arch("i386", "x86_64") and "AppleTVSimulator" or "AppleTVOS" + xcode_sysroot = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode.sdkdir, platname, platname, xcode_sdkver) + end + end + if xcode_sysroot then + toolchain:config_set("xcode_sysroot", xcode_sysroot) + end + -- save target minver -- -- @note we need to differentiate the version for the system, @@ -69,7 +89,7 @@ function main(toolchain) -- target("test") -- set_toolchains("xcode", {plat = os.host(), arch = os.arch()}) -- - local target_minver = toolchain:config("target_minver") and config.get("target_minver") + local target_minver = toolchain:config("target_minver") or config.get("target_minver") if xcode_sdkver and not target_minver then target_minver = xcode_sdkver if toolchain:is_plat("macosx") then diff --git a/xmake/toolchains/xcode/load_appletvos.lua b/xmake/toolchains/xcode/load_appletvos.lua new file mode 100644 index 000000000..e9f8ef567 --- /dev/null +++ b/xmake/toolchains/xcode/load_appletvos.lua @@ -0,0 +1,54 @@ +--!A cross-toolchain build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file load_appletvos.lua +-- + +-- imports +import("core.project.config") + +-- main entry +function main(toolchain) + + -- init architecture + local arch = toolchain:arch() + local xcode_sdkver = toolchain:config("xcode_sdkver") + local xcode_sysroot = toolchain:config("xcode_sysroot") + + -- init target minimal version + local target_minver = toolchain:config("target_minver") + local target_minver_flags = (simulator and "-mappletv-simulator-version-min=" or "-mappletvos-version-min=") .. target_minver + + -- init flags for c/c++ + toolchain:add("cxflags", "-arch", arch, target_minver_flags, "-isysroot", xcode_sysroot) + toolchain:add("ldflags", "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sysroot) + toolchain:add("shflags", "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sysroot) + + -- init flags for objc/c++ + toolchain:add("mxflags", "-arch", arch, target_minver_flags, "-isysroot", xcode_sysroot) + -- we can use `add_mxflags("-fno-objc-arc")` to override it in xmake.lua + toolchain:add("mxflags", "-fobjc-arc") + + -- init flags for asm + toolchain:add("asflags", "-arch", arch, target_minver_flags, "-isysroot", xcode_sysroot) + + -- init flags for swift (with toolchain:add("ldflags and toolchain:add("shflags) + toolchain:add("scflags", format("-target %s-apple-tvos%s", arch, target_minver) , "-sdk " .. xcode_sysroot) + toolchain:add("scshflags", format("-target %s-apple-tvos%s", arch, target_minver) , "-sdk " .. xcode_sysroot) + toolchain:add("scldflags", format("-target %s-apple-tvos%s", arch, target_minver) , "-sdk " .. xcode_sysroot) +end + diff --git a/xmake/toolchains/xcode/load_iphoneos.lua b/xmake/toolchains/xcode/load_iphoneos.lua index 8c6313935..0fda9704c 100644 --- a/xmake/toolchains/xcode/load_iphoneos.lua +++ b/xmake/toolchains/xcode/load_iphoneos.lua @@ -26,10 +26,8 @@ function main(toolchain) -- init architecture local arch = toolchain:arch() - local simulator = (arch == "i386" or arch == "x86_64") - - -- init platform name - local platname = simulator and "iPhoneSimulator" or "iPhoneOS" + local xcode_sdkver = toolchain:config("xcode_sdkver") + local xcode_sysroot = toolchain:config("xcode_sysroot") -- init target minimal version local target_minver = toolchain:config("target_minver") @@ -38,25 +36,22 @@ function main(toolchain) end local target_minver_flags = (simulator and "-mios-simulator-version-min=" or "-miphoneos-version-min=") .. target_minver - -- init the xcode sdk directory - local xcode_dir = config.get("xcode") - local xcode_sdkver = toolchain:config("xcode_sdkver") - local xcode_sdkdir = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode_dir, platname, platname, xcode_sdkver) - -- init flags for c/c++ - toolchain:add("cxflags", "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir) - toolchain:add("ldflags", "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir) - toolchain:add("shflags", "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir) + toolchain:add("cxflags", "-arch", arch, target_minver_flags, "-isysroot", xcode_sysroot) + toolchain:add("ldflags", "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sysroot) + toolchain:add("shflags", "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sysroot) -- init flags for objc/c++ - toolchain:add("mxflags", "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir) + toolchain:add("mxflags", "-arch", arch, target_minver_flags, "-isysroot", xcode_sysroot) + -- we can use `add_mxflags("-fno-objc-arc")` to override it in xmake.lua + toolchain:add("mxflags", "-fobjc-arc") -- init flags for asm - toolchain:add("asflags", "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir) + toolchain:add("asflags", "-arch", arch, target_minver_flags, "-isysroot", xcode_sysroot) -- init flags for swift (with toolchain:add("ldflags and toolchain:add("shflags) - toolchain:add("scflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir) - toolchain:add("scshflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir) - toolchain:add("scldflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir) + toolchain:add("scflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot) + toolchain:add("scshflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot) + toolchain:add("scldflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot) end diff --git a/xmake/toolchains/xcode/load_macosx.lua b/xmake/toolchains/xcode/load_macosx.lua index f87a00c4f..d5e3d3b9a 100644 --- a/xmake/toolchains/xcode/load_macosx.lua +++ b/xmake/toolchains/xcode/load_macosx.lua @@ -27,50 +27,45 @@ function main(toolchain) -- init flags for architecture local arch = toolchain:arch() local target_minver = toolchain:config("target_minver") - - -- init flags for the xcode sdk directory - local xcode_dir = config.get("xcode") - local xcode_sdkver = toolchain:config("xcode_sdkver") - local xcode_sdkdir = nil - if xcode_dir and xcode_sdkver then - xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk" - end + local xcode_sysroot = toolchain:config("xcode_sysroot") -- init flags for c/c++ - toolchain:add("cxflags", "-arch " .. arch) - toolchain:add("ldflags", "-arch " .. arch) - toolchain:add("shflags", "-arch " .. arch) + toolchain:add("cxflags", "-arch", arch) + toolchain:add("ldflags", "-arch", arch) + toolchain:add("shflags", "-arch", arch) if target_minver then toolchain:add("cxflags", "-mmacosx-version-min=" .. target_minver) toolchain:add("mxflags", "-mmacosx-version-min=" .. target_minver) toolchain:add("ldflags", "-mmacosx-version-min=" .. target_minver) toolchain:add("shflags", "-mmacosx-version-min=" .. target_minver) end - if xcode_sdkdir then - toolchain:add("cxflags", "-isysroot " .. xcode_sdkdir) - toolchain:add("ldflags", "-isysroot " .. xcode_sdkdir) - toolchain:add("shflags", "-isysroot " .. xcode_sdkdir) + if xcode_sysroot then + toolchain:add("cxflags", "-isysroot", xcode_sysroot) + toolchain:add("ldflags", "-isysroot", xcode_sysroot) + toolchain:add("shflags", "-isysroot", xcode_sysroot) end toolchain:add("ldflags", "-stdlib=libc++") toolchain:add("shflags", "-stdlib=libc++") toolchain:add("syslinks", "z") -- init flags for objc/c++ (with ldflags and shflags) - toolchain:add("mxflags", "-arch " .. arch) - if xcode_sdkdir then - toolchain:add("mxflags", "-isysroot " .. xcode_sdkdir) + toolchain:add("mxflags", "-arch", arch) + if xcode_sysroot then + toolchain:add("mxflags", "-isysroot", xcode_sysroot) end + -- we can use `add_mxflags("-fno-objc-arc")` to override it in xmake.lua + toolchain:add("mxflags", "-fobjc-arc") -- init flags for asm - toolchain:add("asflags", "-arch " .. arch) - if xcode_sdkdir then - toolchain:add("asflags", "-isysroot " .. xcode_sdkdir) + toolchain:add("asflags", "-arch", arch) + if xcode_sysroot then + toolchain:add("asflags", "-isysroot", xcode_sysroot) end -- init flags for swift - if target_minver and xcode_sdkdir then - toolchain:add("scflags", format("-target %s-apple-macosx%s", arch, target_minver) , "-sdk " .. xcode_sdkdir) - toolchain:add("scshflags", format("-target %s-apple-macosx%s", arch, target_minver) , "-sdk " .. xcode_sdkdir) - toolchain:add("scldflags", format("-target %s-apple-macosx%s", arch, target_minver) , "-sdk " .. xcode_sdkdir) + if target_minver and xcode_sysroot then + toolchain:add("scflags", format("-target %s-apple-macosx%s", arch, target_minver) , "-sdk " .. xcode_sysroot) + toolchain:add("scshflags", format("-target %s-apple-macosx%s", arch, target_minver) , "-sdk " .. xcode_sysroot) + toolchain:add("scldflags", format("-target %s-apple-macosx%s", arch, target_minver) , "-sdk " .. xcode_sysroot) end end diff --git a/xmake/toolchains/xcode/load_watchos.lua b/xmake/toolchains/xcode/load_watchos.lua index 9384a4bd2..b5a47b259 100644 --- a/xmake/toolchains/xcode/load_watchos.lua +++ b/xmake/toolchains/xcode/load_watchos.lua @@ -26,34 +26,29 @@ function main(toolchain) -- init architecture local arch = toolchain:arch() - local simulator = arch == "i386" - - -- init platform name - local platname = simulator and "WatchSimulator" or "WatchOS" + local xcode_sdkver = toolchain:config("xcode_sdkver") + local xcode_sysroot = toolchain:config("xcode_sysroot") -- init target minimal version local target_minver = toolchain:config("target_minver") local target_minver_flags = (simulator and "-mwatchos-simulator-version-min=" or "-mwatchos-version-min=") .. target_minver - -- init the xcode sdk directory - local xcode_dir = config.get("xcode") - local xcode_sdkver = toolchain:config("xcode_sdkver") - local xcode_sdkdir = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode_dir, platname, platname, xcode_sdkver) - -- init flags for c/c++ - toolchain:add("cxflags", "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir) - toolchain:add("ldflags", "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir) - toolchain:add("shflags", "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir) + toolchain:add("cxflags", "-arch", arch, target_minver_flags, "-isysroot", xcode_sysroot) + toolchain:add("ldflags", "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sysroot) + toolchain:add("shflags", "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sysroot) -- init flags for objc/c++ - toolchain:add("mxflags", "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir) + toolchain:add("mxflags", "-arch", arch, target_minver_flags, "-isysroot", xcode_sysroot) + -- we can use `add_mxflags("-fno-objc-arc")` to override it in xmake.lua + toolchain:add("mxflags", "-fobjc-arc") -- init flags for asm - toolchain:add("asflags", "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir) + toolchain:add("asflags", "-arch", arch, target_minver_flags, "-isysroot", xcode_sysroot) -- init flags for swift (with toolchain:add("ldflags and toolchain:add("shflags) - toolchain:add("scflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir) - toolchain:add("scshflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir) - toolchain:add("scldflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir) + toolchain:add("scflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot) + toolchain:add("scshflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot) + toolchain:add("scldflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot) end diff --git a/xmake/toolchains/xcode/xmake.lua b/xmake/toolchains/xcode/xmake.lua index 67a58cbbb..b4d8c3d66 100644 --- a/xmake/toolchains/xcode/xmake.lua +++ b/xmake/toolchains/xcode/xmake.lua @@ -46,6 +46,10 @@ toolchain("xcode") arch = toolchain:arch() simulator = (arch == "i386") cross = simulator and "xcrun -sdk watchsimulator " or "xcrun -sdk watchos " + elseif toolchain:is_plat("appletvos") then + arch = toolchain:arch() + simulator = (arch == "i386" or arch == "x86_64") + cross = simulator and "xcrun -sdk appletvsimulator " or "xcrun -sdk appletvos " else raise("unknown platform for xcode!") end diff --git a/xmake/toolchains/zig/xmake.lua b/xmake/toolchains/zig/xmake.lua index e6e70012c..97dd940b7 100644 --- a/xmake/toolchains/zig/xmake.lua +++ b/xmake/toolchains/zig/xmake.lua @@ -25,30 +25,96 @@ toolchain("zig") set_homepage("https://ziglang.org/") set_description("Zig Programming Language Compiler") + -- on check + on_check(function (toolchain) + import("lib.detect.find_tool") + local paths = {} + for _, package in ipairs(toolchain:packages()) do + local envs = package:get("envs") + if envs then + table.join2(paths, envs.PATH) + end + end + local zig = get_config("zc") + if not zig then + zig = find_tool("zig", {force = true, paths = paths}) + if zig and zig.program then + zig = zig.program + end + end + if zig then + toolchain:config_set("zig", zig) + toolchain:configs_save() + return true + end + end) + -- on load on_load(function (toolchain) -- set toolset - local zig = get_config("zc") or "zig" + -- we patch target to `zig cc` to fix has_flags. see https://github.com/xmake-io/xmake/issues/955#issuecomment-766929692 + local zig = toolchain:config("zig") or "zig" + toolchain:set("toolset", "cc", zig .. " cc") + toolchain:set("toolset", "cxx", zig .. " c++") + toolchain:set("toolset", "ld", zig .. " c++") + toolchain:set("toolset", "sh", zig .. " c++") toolchain:set("toolset", "zc", "$(env ZC)", zig) toolchain:set("toolset", "zcar", "$(env ZC)", zig) toolchain:set("toolset", "zcld", "$(env ZC)", zig) toolchain:set("toolset", "zcsh", "$(env ZC)", zig) - -- init flags - local march - if toolchain:is_plat("macosx") then - -- FIXME - --march = toolchain:is_arch("x86") and "i386-macosx-gnu" or "x86_64-macosx-gnu" + -- init arch + if toolchain:is_arch("arm64", "arm64-v8a") then + arch = "aarch64" + elseif toolchain:is_arch("arm", "armv7") then + arch = "arm" + elseif toolchain:is_arch("i386", "x86") then + arch = "i386" + elseif toolchain:is_arch("riscv64") then + arch = "riscv64" + elseif toolchain:is_arch("mips.*") then + arch = toolchain:arch() + elseif toolchain:is_arch("ppc64") then + arch = "powerpc64" + elseif toolchain:is_arch("ppc") then + arch = "powerpc" + elseif toolchain:is_arch("s390x") then + arch = "s390x" + else + arch = "x86_64" + end + + -- init target + local target + if toolchain:is_plat("cross") then + -- xmake f -p cross --toolchain=zig --cross=mips64el-linux-gnuabi64 + target = toolchain:cross() + elseif toolchain:is_plat("macosx") then + target = arch .. "-macos-gnu" elseif toolchain:is_plat("linux") then - march = toolchain:is_arch("x86") and "i386-linux-gnu" or "x86_64-linux-gnu" + if arch == "arm" then + target = "arm-linux-gnueabi" + elseif arch == "mips64" or arch == "mips64el" then + target = arch .. "-linux-gnuabi64" + else + target = arch .. "-linux-gnu" + end elseif toolchain:is_plat("windows") then - march = toolchain:is_arch("x86") and "i386-windows-msvc" or "x86_64-windows-msvc" + target = arch .. "-windows-msvc" + elseif toolchain:is_plat("mingw") then + target = arch .. "-windows-gnu" end - if march then - toolchain:add("zcflags", "-target", march) - toolchain:add("zcldflags", "-target", march) - toolchain:add("zcshflags", "-target", march) + if target then + toolchain:add("zig_cc.cxflags", "-target", target) + toolchain:add("zig_cc.shflags", "-target", target) + toolchain:add("zig_cc.ldflags", "-target", target) + toolchain:add("zig_cxx.cxflags", "-target", target) + toolchain:add("zig_cxx.shflags", "-target", target) + toolchain:add("zig_cxx.ldflags", "-target", target) + toolchain:add("zcflags", "-target", target) + toolchain:add("zcldflags", "-target", target) + toolchain:add("zcshflags", "-target", target) end -- @see https://github.com/ziglang/zig/issues/5825 |
