Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- run: |
gh release create "${TAG}" --notes "Lua ${TAG}" ./build/*.zip
gh release create "${TAG}" --notes "Lua ${TAG}" ./build/*.msi ./build/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag }}
3 changes: 2 additions & 1 deletion .github/workflows/reusable-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install required tools
run: choco install ninja
run: choco install ninja ghostscript
- name: Generate Ninja build
run: cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_C_COMPILER=clang
- name: Package
Expand All @@ -16,5 +16,6 @@ jobs:
with:
name: build
path: |
build/*.msi
build/*.zip
if-no-files-found: error
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ lua-*/
luarocks-*/
*.gz
*.zip
lua-logo-nolabel.ps
22 changes: 20 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ if(WIN32)
DESTINATION ${CMAKE_CURRENT_LIST_DIR}
)
endif()

set(LUA_LOGO lua-logo-nolabel.ps)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${LUA_LOGO})
file(DOWNLOAD https://www.lua.org/images/${LUA_LOGO}
${CMAKE_CURRENT_LIST_DIR}/${LUA_LOGO}
)
endif()

add_custom_command(OUTPUT lua.ico
COMMAND magick ${CMAKE_CURRENT_LIST_DIR}/${LUA_LOGO} -resize 256x256 lua.ico
MAIN_DEPENDENCY ${CMAKE_CURRENT_LIST_DIR}/${LUA_LOGO}
COMMENT "Generating Lua icon"
)
add_custom_target(luaicon ALL DEPENDS lua.ico)
endif()

set(LUA_SRC lua-${CMAKE_PROJECT_VERSION}/src)
Expand Down Expand Up @@ -117,18 +131,22 @@ install(TARGETS lualib FILE_SET include)
install(FILES ${CMAKE_CURRENT_LIST_DIR}/LICENSE.txt TYPE DOC)

if(WIN32)
set(CPACK_GENERATOR ZIP)
set(CPACK_GENERATOR ZIP WIX)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/lua.pdb
${CMAKE_CURRENT_BINARY_DIR}/luac.pdb
${CMAKE_CURRENT_BINARY_DIR}/lua54.pdb
DESTINATION bin)
set(CPACK_WIX_UPGRADE_GUID "3e5a792d-9d31-41d5-a93f-629ab7c7683d")
set(CPACK_WIX_PRODUCT_ICON lua.ico)
list(APPEND CPACK_WIX_EXTENSIONS WixUtilExtension)
list(APPEND CPACK_WIX_PATCH_FILE ${CMAKE_CURRENT_LIST_DIR}/WixPatch.xml)
else()
install(FILES ${LUA_DOC}/lua.1 ${LUA_DOC}/luac.1
DESTINATION man/man1
)
endif()
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_LIST_DIR}/LICENSE.txt)
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CMAKE_PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR DEVCOM)
Expand Down
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,30 @@ winget install --id DEVCOM.Lua
[Clang](https://clang.llvm.org/))
- [CMake](https://cmake.org/)
- [Ninja](https://ninja-build.org/)
- [ImageMagick](https://imagemagick.org/)
- [GhostScript](https://www.ghostscript.com/)
- [WiX v3](https://wixtoolset.org/docs/wix3/)

You can install these components with the following
You can install the first five components with the following
[winget](https://learn.microsoft.com/windows/package-manager/winget/) commands:

```powershell
winget install --id LLVM.LLVM
winget install --id Kitware.CMake
winget install --id Ninja-build.Ninja
winget install --id ImageMagick.ImageMagick
winget install --id ArtifexSoftware.GhostScript
```

WiX v3 is available at <https://github.com/wixtoolset/wix3/releases/>. It
requires .NET Framework 3.5 that can be installed with the following command:

```powershell
Start-Process `
-FilePath pwsh `
-ArgumentList "-Command `"& {Enable-WindowsOptionalFeature -Online -FeatureName NetFx3}`"" `
-Wait `
-Verb RunAs
```

Update your path environment with `setx` (supposing you installed the tools in
Expand All @@ -47,14 +63,17 @@ Check if `PATH` was set correctly:
Get-Command clang
Get-Command cmake
Get-Command ninja
Get-Command magick
Get-Command gswin64
```

You may need to restart your Windows session if you can't find `ninja` even
after restarting your terminal.

## Build

Use the following commands to generate a ZIP package with Lua and LuaRocks:
Use the following commands to generate the installation package in both ZIP and
MSI formats:

```powershell
cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo
Expand All @@ -66,4 +85,4 @@ code and LuaRocks binaries.

For convenience, you can use the `Build-Lua.ps1` script to run these commands.

If successful, the ZIP file will be available in the `build` directory.
If successful, the ZIP and MSI files will be available in the `build` directory.
20 changes: 20 additions & 0 deletions WixPatch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<CPackWiXPatch>
<!-- Fragment ID is from [build/_CPack_Packages/win64/WIX/features.wxs] -->
<CPackWiXFragment Id="CM_CP_bin.lua.exe">
<Environment
Id='UpdatePath'
Name='PATH'
Action='set'
Permanent='no'
Part='last'
Value='[INSTALL_ROOT]bin'
/>
</CPackWiXFragment>

<!-- Allow installation by non-administrative users -->
<!-- https://learn.microsoft.com/windows/win32/msi/allusers -->
<CPackWiXFragment Id="#PRODUCT">
<Property Id="ALLUSERS" Value="2" />
<Property Id="MSIINSTALLPERUSER" Value="1" />
</CPackWiXFragment>
</CPackWiXPatch>