├── .github └── workflows │ ├── ci.yml │ ├── package.yml │ ├── release.yml │ └── reusable-package.yml ├── .gitignore ├── .gitlint ├── .gitmodules ├── Build-LuaJIT.ps1 ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── WixPatch.xml └── config.lua /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push, pull_request] 3 | jobs: 4 | gitlint: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v4 8 | with: 9 | fetch-depth: 0 10 | - name: Install gitlint 11 | run: pip install gitlint 12 | - name: Validate current commit (last commit) with gitlint 13 | if: github.event_name == 'push' 14 | run: gitlint 15 | - name: Validate PR commits with gitlint 16 | if: github.event_name == 'pull_request' 17 | run: gitlint --commits ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }},${{ github.event.pull_request.head.sha }} 18 | -------------------------------------------------------------------------------- /.github/workflows/package.yml: -------------------------------------------------------------------------------- 1 | name: Package 2 | on: 3 | push: 4 | branches: 5 | - 'main' 6 | jobs: 7 | package: 8 | uses: ./.github/workflows/reusable-package.yml 9 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | workflow_dispatch: 4 | jobs: 5 | package: 6 | uses: ./.github/workflows/reusable-package.yml 7 | release: 8 | needs: package 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v4 13 | with: 14 | submodules: 'true' 15 | - name: Download artifacts 16 | uses: actions/download-artifact@v4 17 | - name: Create release 18 | run: | 19 | cd LuaJIT || exit 1 20 | VERSION="2.1" 21 | git checkout "v${VERSION}" 22 | COMMIT_TIME_SECONDS=$(git show -s --format=%ct) 23 | COMMIT_TIME_DAYS=$((COMMIT_TIME_SECONDS / 60 / 60 / 24)) 24 | cd .. || exit 2 25 | gh release create "v${VERSION}.${COMMIT_TIME_DAYS}" --notes "LuaJIT ${VERSION}.${COMMIT_TIME_SECONDS}" ./build/*.msi ./build/*.zip 26 | env: 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 28 | -------------------------------------------------------------------------------- /.github/workflows/reusable-package.yml: -------------------------------------------------------------------------------- 1 | name: Reusable package 2 | on: 3 | workflow_call: 4 | jobs: 5 | package: 6 | runs-on: windows-latest 7 | steps: 8 | - name: Checkout 9 | uses: actions/checkout@v4 10 | with: 11 | submodules: 'true' 12 | - name: Package 13 | shell: pwsh 14 | run: ./Build-LuaJIT.ps1 15 | - name: Upload artifacts 16 | uses: actions/upload-artifact@v4 17 | with: 18 | name: build 19 | path: | 20 | build/*.msi 21 | build/*.zip 22 | if-no-files-found: error 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeLists.txt.user 2 | CMakeCache.txt 3 | CMakeFiles 4 | CMakeScripts 5 | Testing 6 | Makefile 7 | cmake_install.cmake 8 | install_manifest.txt 9 | compile_commands.json 10 | CTestTestfile.cmake 11 | _deps 12 | 13 | build/ 14 | luarocks-*/ 15 | *.zip 16 | -------------------------------------------------------------------------------- /.gitlint: -------------------------------------------------------------------------------- 1 | [general] 2 | ignore=body-is-missing 3 | contrib=contrib-title-conventional-commits 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "LuaJIT"] 2 | path = LuaJIT 3 | url = https://github.com/LuaJIT/LuaJIT.git 4 | -------------------------------------------------------------------------------- /Build-LuaJIT.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = 'Stop' 2 | 3 | # https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-powershell 4 | function Start-VsDevCmd 5 | { 6 | $installationPath = ( 7 | & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" ` 8 | -prerelease -latest -property installationPath) 9 | $vsdevcmd = Join-Path ` 10 | -Path "$installationPath" ` 11 | -ChildPath Common7\Tools\VsDevCmd.bat ` 12 | -Resolve 13 | & "${env:COMSPEC}" /s /c "`"$vsdevcmd`" -no_logo -arch=amd64 && set" | 14 | ForEach-Object { 15 | $name, $value = $_ -split '=', 2 16 | Set-Item -Path env:\"$name" -Value $value 17 | } 18 | } 19 | 20 | if (-Not (Get-Command "cl" -ErrorAction "SilentlyContinue")) 21 | { 22 | Start-VsDevCmd 23 | } 24 | if (Test-Path -Path build -PathType Container) 25 | { 26 | Remove-Item -Recurse -Force -Path build 27 | } 28 | cmake -B build -G Ninja -D CMAKE_C_COMPILER=cl 29 | cmake --build build --target package 30 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.26) 2 | if(!WIN32) 3 | message(FATAL_ERROR "This is a Windows only project") 4 | endif() 5 | execute_process(COMMAND git show -s --format=%ct 6 | WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/LuaJIT 7 | OUTPUT_VARIABLE LUAJIT_COMMIT_TIME 8 | OUTPUT_STRIP_TRAILING_WHITESPACE) 9 | 10 | # Convert LuaJIT build from seconds to days 11 | # because MSI build version maximum value is 65535. 12 | math(EXPR VERSION_PATCH "${LUAJIT_COMMIT_TIME} / 60 / 60 / 24") 13 | 14 | string(CONCAT LUAJIT_VERSION "2.1." ${VERSION_PATCH}) 15 | project(LuaJIT 16 | VERSION ${LUAJIT_VERSION} 17 | DESCRIPTION "LuaJIT and LuaRocks packaged by DEVCOM" 18 | HOMEPAGE_URL https://github.com/DevelopersCommunity/cmake-luajit 19 | LANGUAGES C 20 | ) 21 | 22 | set (LUAJIT_SRC ${CMAKE_CURRENT_LIST_DIR}/LuaJIT/src) 23 | set (LUAJIT_JIT ${CMAKE_CURRENT_LIST_DIR}/LuaJIT/src/jit) 24 | 25 | find_program(MSVC cl) 26 | if(MSVC STREQUAL "MSVC-NOTFOUND") 27 | message(FATAL_ERROR "MSVC compiler not found") 28 | endif() 29 | set(LUAROCKS_VERSION 3.11.1) 30 | set(LUAROCKS_TARBALL luarocks-${LUAROCKS_VERSION}-windows-64.zip) 31 | 32 | if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${LUAROCKS_TARBALL}) 33 | file(DOWNLOAD http://luarocks.github.io/luarocks/releases/${LUAROCKS_TARBALL} 34 | ${CMAKE_CURRENT_LIST_DIR}/${LUAROCKS_TARBALL} 35 | ) 36 | file(ARCHIVE_EXTRACT INPUT ${CMAKE_CURRENT_LIST_DIR}/${LUAROCKS_TARBALL} 37 | DESTINATION ${CMAKE_CURRENT_LIST_DIR} 38 | ) 39 | endif() 40 | 41 | add_custom_command(OUTPUT ${LUAJIT_SRC}/luajit.exe ${LUAJIT_SRC}/lua51.dll ${LUAJIT_SRC}/lua51.lib 42 | COMMAND msvcbuild.bat 43 | WORKING_DIRECTORY ${LUAJIT_SRC} 44 | COMMENT "Compiling LuaJIT" 45 | ) 46 | add_custom_target(luajit ALL DEPENDS ${LUAJIT_SRC}/luajit.exe) 47 | add_custom_target(luadll ALL DEPENDS ${LUAJIT_SRC}/lua51.dll) 48 | add_custom_target(lualib ALL DEPENDS ${LUAJIT_SRC}/lua51.lib) 49 | 50 | install(PROGRAMS 51 | ${LUAJIT_SRC}/luajit.exe 52 | ${LUAJIT_SRC}/lua51.dll 53 | ${CMAKE_CURRENT_LIST_DIR}/luarocks-${LUAROCKS_VERSION}-windows-64/luarocks.exe 54 | ${CMAKE_CURRENT_LIST_DIR}/luarocks-${LUAROCKS_VERSION}-windows-64/luarocks-admin.exe 55 | TYPE BIN) 56 | install(FILES ${LUAJIT_SRC}/lua51.lib 57 | TYPE LIB) 58 | install(FILES ${LUAJIT_SRC}/lauxlib.h ${LUAJIT_SRC}/lua.h ${LUAJIT_SRC}/lua.hpp ${LUAJIT_SRC}/luaconf.h ${LUAJIT_SRC}/lualib.h 59 | TYPE INCLUDE) 60 | 61 | install(DIRECTORY ${LUAJIT_JIT} DESTINATION bin/lua 62 | FILES_MATCHING PATTERN *.lua) 63 | install(FILES ${CMAKE_CURRENT_LIST_DIR}/config.lua 64 | DESTINATION etc/luarocks) 65 | install(FILES ${LUAJIT_SRC}/../COPYRIGHT TYPE DOC) 66 | 67 | set(CPACK_GENERATOR ZIP WIX) 68 | set(CPACK_WIX_UPGRADE_GUID "6a62e303-6669-4f48-bce3-36052132be3b") 69 | list(APPEND CPACK_WIX_EXTENSIONS WixUtilExtension) 70 | list(APPEND CPACK_WIX_PATCH_FILE ${CMAKE_CURRENT_LIST_DIR}/WixPatch.xml) 71 | set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE) 72 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_LIST_DIR}/LICENSE.txt) 73 | set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CMAKE_PROJECT_NAME}) 74 | set(CPACK_PACKAGE_VENDOR DEVCOM) 75 | include(CPack) 76 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2005-2022 Mike Pall. All rights reserved. 2 | Copyright © 2007-2011, Kepler Project. 3 | Copyright © 2011-2022, the LuaRocks project authors. 4 | Copyright © 1994–2023 Lua.org, PUC-Rio. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LuaJIT installer for Windows 2 | 3 | This is a CMake-based project to package [LuaJIT](https://luajit.org/) and 4 | [LuaRocks](https://luarocks.org/). 5 | 6 | You can install this package with 7 | [`winget`](https://learn.microsoft.com/windows/package-manager/winget/). 8 | 9 | ```powershell 10 | winget install --id DEVCOM.LuaJIT 11 | 12 | ``` 13 | 14 | ## Build prerequisites 15 | 16 | - [Microsoft Visual 17 | C++](https://learn.microsoft.com/cpp/overview/visual-cpp-in-visual-studio) 18 | - [CMake](https://cmake.org/) 19 | - [WiX v3](https://wixtoolset.org/docs/wix3/) 20 | 21 | You can install the first two components with the following `winget` commands: 22 | 23 | ```powershell 24 | winget install --id Microsoft.VisualStudio.2022.Community 25 | winget install --id Kitware.CMake 26 | ``` 27 | 28 | After installing Visual Studio, open `Visual Studio Installer` and ensure that 29 | the "Desktop Development with C++" workload is installed. 30 | 31 | WiX v3 is available at . It 32 | requires .NET Framework 3.5, which can be installed with the following command: 33 | 34 | ```powershell 35 | Start-Process ` 36 | -FilePath pwsh ` 37 | -ArgumentList "-Command `"& {Enable-WindowsOptionalFeature -Online -FeatureName NetFx3}`"" ` 38 | -Wait ` 39 | -Verb RunAs 40 | ``` 41 | 42 | ## Build 43 | 44 | Use the [Build-LuaJIT.ps1](./Build-LuaJIT.ps1) script to generate the 45 | installation package in both ZIP and MSI formats. 46 | 47 | If successful, the ZIP and MSI files will be available in the `build` directory. 48 | -------------------------------------------------------------------------------- /WixPatch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 19 | 26 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | lua_version = "5.1" 2 | lua_interpreter = "luajit.exe" 3 | --------------------------------------------------------------------------------