Skip to content
Open
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
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(Lua VERSION 5.2.4 LANGUAGES C)
project(Lua VERSION 5.4.6 LANGUAGES C)

if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/luaconf.h")
message(FATAL_ERROR "Run \"cmake -P prepare-sources.cmake\" and change dirs.")
Expand All @@ -13,8 +13,8 @@ set(LUA_TO_INC lua.h luaconf.h lualib.h lauxlib.h lua.hpp)
set(LUA_CORE_SOURCES lapi.c lcode.c lctype.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)
set(LUA_LIB_SOURCES lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c
lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c)
set(LUA_LIB_SOURCES lauxlib.c lbaselib.c lcorolib.c ldblib.c liolib.c
lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c lutf8lib.c)
set(LUA_SOURCES)
foreach(_src IN LISTS LUA_CORE_SOURCES LUA_LIB_SOURCES)
list(APPEND LUA_SOURCES "src/${_src}")
Expand Down Expand Up @@ -107,10 +107,12 @@ else()
endif()

if(WIN32)
if(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32")
set(name lua-${PROJECT_VERSION}-unicode-win32)
elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
set(name lua-${PROJECT_VERSION}-unicode-win64)
if(CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
set(name lua-${PROJECT_VERSION}-unicode-x64-windows)
elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "arm64")
set(name lua-${PROJECT_VERSION}-unicode-arm64-windows)
elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32")
set(name lua-${PROJECT_VERSION}-unicode-x86-windows)
else()
message(FATAL_ERROR "Unexpected generator platform")
endif()
Expand Down
15 changes: 11 additions & 4 deletions build-all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
# Abort whenever a command fails.
$ErrorActionPreference = "Stop"

New-Item -Type Directory build64
Push-Location build64
New-Item -Type Directory build-x64
Push-Location build-x64
cmake .. -A x64
cmake --build . --target create-zip --config RelWithDebInfo
Move-Item *.zip ..
Pop-Location

New-Item -Type Directory build32
Push-Location build32
New-Item -Type Directory build-arm64
Push-Location build-arm64
cmake .. -A arm64
cmake --build . --target create-zip --config RelWithDebInfo
Move-Item *.zip ..
Pop-Location

New-Item -Type Directory build-x86
Push-Location build-x86
cmake .. -A Win32
cmake --build . --target create-zip --config RelWithDebInfo
Move-Item *.zip ..
Expand Down
4 changes: 2 additions & 2 deletions prepare-sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# (A subdirectory will be created for the sources.)

cmake_minimum_required(VERSION 3.5)
set(PROJECT_VERSION 5.2.4)
set(PROJECT_VERSION 5.4.6)

set(URL https://www.lua.org/ftp/lua-${PROJECT_VERSION}.tar.gz)
set(SHA256 b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b)
set(SHA256 7d5ea1b9cb6aa0b59ca3dde1c6adcb57ef83a1ba8e5432c0ecd06bf439b3ad88)

# Directory to store the source tarball and create the source directory.
if(NOT OUTPUT_DIR)
Expand Down
45 changes: 0 additions & 45 deletions src/utf8_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,6 @@ FILE *freopen_utf8(const char *pathname, const char *mode, FILE *stream) {
return _wfreopen(pathname_w, mode_w, stream);
}

int remove_utf8(const char *pathname) {
wchar_t pathname_w[MAX_PATH_SIZE];
if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, pathname, -1, pathname_w, MAX_PATH_SIZE)) {
errno = EINVAL;
return -1;
}
return _wremove(pathname_w);
}

int rename_utf8(const char *oldpath, const char *newpath) {
wchar_t oldpath_w[MAX_PATH_SIZE];
wchar_t newpath_w[MAX_PATH_SIZE];
if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, oldpath, -1, oldpath_w, MAX_PATH_SIZE) ||
!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, newpath, -1, newpath_w, MAX_PATH_SIZE)) {
errno = EINVAL;
return -1;
}
return _wrename(oldpath_w, newpath_w);
}

FILE *popen_utf8(const char *command, const char *mode) {
wchar_t command_w[MAX_CMD_SIZE];
wchar_t mode_w[MAX_MODE_SIZE];
Expand All @@ -73,29 +53,4 @@ FILE *popen_utf8(const char *command, const char *mode) {
return _wpopen(command_w, mode_w);
}

int system_utf8(const char *command) {
wchar_t command_w[MAX_CMD_SIZE];
if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, command, -1, command_w, MAX_CMD_SIZE)) {
errno = EINVAL;
return -1;
}
return _wsystem(command_w);
}

DWORD GetModuleFileNameA_utf8(HMODULE hModule, LPSTR lpFilename, DWORD nSize) {
wchar_t filename_w[MAX_PATH + 1];
if (!GetModuleFileNameW(hModule, filename_w, MAX_PATH + 1)) {
return 0;
}
return WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, filename_w, -1, lpFilename, nSize, NULL, NULL);
}

HMODULE LoadLibraryExA_utf8(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) {
wchar_t pathname_w[MAX_PATH_SIZE];
if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, lpLibFileName, -1, pathname_w, MAX_PATH_SIZE)) {
SetLastError(ERROR_INVALID_NAME);
return NULL;
}
return LoadLibraryExW(pathname_w, hFile, dwFlags);
}
#endif
17 changes: 1 addition & 16 deletions src/utf8_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,7 @@ FILE *popen_utf8(const char *command, const char *mode);
#define _popen popen_utf8
#endif

#ifdef loslib_c
int remove_utf8(const char *pathname);
int rename_utf8(const char *oldpath, const char *newpath);
int system_utf8(const char *command);
#define remove remove_utf8
#define rename rename_utf8
#define system system_utf8
#endif

#ifdef loadlib_c
DWORD GetModuleFileNameA_utf8(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
HMODULE LoadLibraryExA_utf8(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
#define GetModuleFileNameA GetModuleFileNameA_utf8
#define LoadLibraryExA LoadLibraryExA_utf8
#endif
#endif
#endif // _WIN32

#if defined(lua_c) || defined(luac_c)
int main_utf8(int argc, char *argv[]);
Expand Down