Skip to content

Commit

Permalink
v5.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dwenegar committed Apr 9, 2021
0 parents commit d64a223
Show file tree
Hide file tree
Showing 71 changed files with 17,468 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_size = 8
indent_style = tab

[*.{ps1,cmd,bat}]
end_of_line = crlf
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text eol=lf
*.ps1 eol=crlf
*.cmd eol=crlf
*.bat eol=crlf
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Versions
on:
push:
tags:
- 'v*'

jobs:
build:
strategy:
matrix:
os: [ 'windows-latest', 'ubuntu-latest', 'macos-latest' ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Build Binaries
run: |
cmake -E remove_directory build
cmake -E remove_directory dist
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=dist
cmake --build build --target install --config release
cmake --build build --target package --config release
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: lua-${{ matrix.os }}
path: artifacts/lua*.*

create-releases:
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Download Artifacts
id: download-artifacts
uses: actions/download-artifact@v2
with:
path: ~/artifacts
- name: Upload Assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create-release.outputs.id }}
assets_path: ${{ steps.download-artifacts.outputs.download-path }}/**/*

82 changes: 82 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
### https://raw.github.com/github/gitignore/c608298e61930c0d8f72b31921df7dcaed18a28a/C.gitignore

# Object files
*.o
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
*.def

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
*.exp

# Debug files
*.dSYM/
### macOS

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### VisualStudioCode

.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### Custom

.luacheckcache
build/
dist/
artifacts/

34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(lua VERSION 5.1.4)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "Not allowed to run in-source build!")
endif()

include(cmake/policy.cmake)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/macros")
include(CheckPlatform)

message(STATUS "Building Lua ${lua_VERSION}")

add_subdirectory(src)

if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(CPACK_SYSTEM_NAME "${CPACK_SYSTEM_NAME}-amd64")
else()
set(CPACK_SYSTEM_NAME "${CPACK_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()
string(TOLOWER "${CPACK_SYSTEM_NAME}" CPACK_SYSTEM_NAME)

set(CPACK_TOPLEVEL_TAG lua)
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_SOURCE_DIR}/artifacts")
include(CPack)

5 changes: 5 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake -E remove_directory build
cmake -E remove_directory dist
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=dist
cmake --build build --target install --config release
cmake --build build --target package --config release
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake -E remove_directory build
cmake -E remove_directory dist
cmake --verbose -H. -Bbuild -DCMAKE_INSTALL_PREFIX=dist
cmake --build build --target install --config release
cmake --build build --target package --config release
5 changes: 5 additions & 0 deletions cmake/macros/CheckPlatform.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(WIN32)
include("${CMAKE_SOURCE_DIR}/cmake/platform/windows.cmake")
elseif(UNIX)
include("${CMAKE_SOURCE_DIR}/cmake/platform/unix.cmake")
endif()
34 changes: 34 additions & 0 deletions cmake/macros/FindLibDL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# - Find libdl
# Find the native LIBDL includes and library
#
# Usage of this module as follows:
#
# find_package(Readline)
#
# Variables defined by this module:
#
# LIBDL_INCLUDE_DIR - where to find dlfcn.h, etc.
# LIBDL_LIBRARIES - List of libraries when using libdl.
# LIBDL_FOUND - True if libdl found.

include(FindPackageHandleStandardArgs)

# Already in cache, be silent
if(LIBDL_INCLUDE_DIR)
set(LIBDL_FIND_QUIETLY TRUE)
endif()

find_path(LIBDL_INCLUDE_DIR dlfcn.h)

set(LIBDL_NAMES dl libdl ltdl libltdl)
find_library(LIBDL_LIBRARY NAMES ${LIBDL_NAMES} )

find_package_handle_standard_args(LibDL DEFAULT_MSG LIBDL_LIBRARY LIBDL_INCLUDE_DIR)

if(LIBDL_FOUND)
set(LIBDL_LIBRARIES ${LIBDL_LIBRARY})
else()
set(LIBDL_LIBRARIES)
endif()

mark_as_advanced(LIBDL_LIBRARY LIBDL_INCLUDE_DIR)
18 changes: 18 additions & 0 deletions cmake/platform/unix.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
message(STATUS "UNIX: Detected C compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER}")

list(APPEND CMAKE_C_FLAGS -fPIC)
list(APPEND LUA_EXTERNAL_LIBS m)

if(APPLE)
add_definitions(-DLUA_USE_MACOSX)
else()
add_definitions(-DLUA_USE_LINUX)

find_package(LibDL REQUIRED)
include_directories(${LIBDL_INCLUDE_DIR})
list(APPEND LUA_EXTERNAL_LIBS ${LIBDL_LIBRARIES})
endif()

set(LUA_LIBLUA_NAME "lua")
set(CPACK_GENERATOR "TGZ")
set(CPACK_SYSTEM_NAME "${CMAKE_HOST_SYSTEM_NAME}")
8 changes: 8 additions & 0 deletions cmake/platform/windows.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
message(STATUS "Windows: Detected C compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER}")

add_compile_options(/MP /W4 /nologo /MD)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DLUA_BUILD_AS_DLL)
set(LUA_LIBLUA_NAME "lua${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}")
set(CPACK_SYSTEM_NAME "Windows")
set(CPACK_GENERATOR "ZIP")
11 changes: 11 additions & 0 deletions cmake/policy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_policy(SET CMP0025 NEW) # Compiler id for Apple Clang is now AppleClang
cmake_policy(SET CMP0005 NEW) # Preprocessor definition values are now escaped automatically.
if(POLICY CMP0053)
cmake_policy(SET CMP0053 NEW) # faster evaluation of variable references
endif()
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW) # Only interpret if() arguments as variables or keywords when unquoted
endif()
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW) # project() command manages VERSION variables.
endif()
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(lua)
41 changes: 41 additions & 0 deletions src/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
include(GenerateExportHeader)

set(_HEADERS
lua.h luaconf.h lualib.h lauxlib.h lua.hpp)

set(_SRCS
lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c
lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c
lundump.c lvm.c lzio.c
lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c ltablib.c
lstrlib.c loadlib.c linit.c
${_HEADERS})

install(
FILES ${_HEADERS}
DESTINATION "include")

add_library(liblua SHARED ${_SRCS})
generate_export_header(liblua)
set_target_properties(liblua PROPERTIES OUTPUT_NAME "${LUA_LIBLUA_NAME}")
set_target_properties(liblua PROPERTIES VERSION "${lua_VERSION}")
set_target_properties(liblua PROPERTIES SOVERSION "${lua_VERSION}")

if(APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
elseif(UNIX)
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()

install(
TARGETS liblua
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib")

add_executable(lua lua.c)
set_target_properties(lua PROPERTIES ENABLE_EXPORTS true)
target_link_libraries(lua liblua ${LUA_EXTERNAL_LIBS})
install(
TARGETS lua
RUNTIME DESTINATION "bin")
Loading

0 comments on commit d64a223

Please sign in to comment.