Skip to content

Commit

Permalink
Added files and documentation
Browse files Browse the repository at this point in the history
Added files and documentation for the build of lua for Windows
  • Loading branch information
alain-riedinger committed Apr 19, 2020
1 parent ab35897 commit 0352418
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# lua53
Simple lua build for Windows

Simple lua build for Windows

Simple said, I need **lua** and I need it under *Windows*. I need it precisely to be able to debug the *lua* scripted extensions and plugins that I realize under 2 of my favourite editors [SciTE](https://www.scintilla.org/SciTE.html) and [Textadept](https://foicica.com/textadept/).
To achieve this debugging, there are a lot of modules out there, all of them relying on a module called **luasocket**.

So far, so good, but when you work under *Windows* it becomes really difficult to get the binaries for this *luasocket* module, as it is **C** based:
- I need the module under *Windows*
- I need it in **Win32** and also **x64** release
- I have **Visual Studio 2017 Community Edition**

I searched and searched, stumbled on [LuaRocks - The Lua package manager](https://luarocks.org/), but never made it to correctly get this module, in the right release, compiled with **Visual Studio**...

So first step, is to build **lua**. I found this site:
[How to compile Lua 5.3.5 for Windows | The curse of Dennis D. Spreen](https://blog.spreendigital.de/2019/06/25/how-to-compile-lua-5-3-5-for-windows/)
It works correctly, and was a solid base for my needs.

I added some resource files to describe the versions, with a lua icon, and a build script, that enables to build on Windows, with **Visual Studio 2017** installed. The script produces the binaries and the includes for a usable **lua**, under those sub-directories:
- **Win32**
- **x64**

Each of those build sub-directory contains:
- **bin**, the executable binaries: "lua53.dll", "lua53.exe", "luac53.exe"
- **include**, the needed includes for compiling lua modules
- **lib**, the libraries "lua53.lib" (that matches "lua53.dll") and "lua53-static.lib" (that is a self contained library for a complete **lua**)

## lua building procedure

- Get the lua sources from [Lua: download area](http://www.lua.org/ftp/) and put them under **src** sub-directory
- If needed, edit the resource files to modify / adapt the version of **lua**
- In a DOS console, under the *lua\src* sub-directory, launch the build of the lua binaries:
```
Buid-lua.cmd Win32
Buid-lua.cmd x64
```
39 changes: 39 additions & 0 deletions src/Build-lua.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@ECHO OFF

SET TARGET=Win32
IF "%1"=="x64" SET TARGET=x64

ECHO Build lua for Windows (target platform is %TARGET%) ?
ECHO (must be launched from the lua "src" directory)
PAUSE

IF NOT EXIST ..\%TARGET%\bin MKDIR ..\%TARGET%\bin
IF NOT EXIST ..\%TARGET%\lib MKDIR ..\%TARGET%\lib

IF NOT EXIST ..\%TARGET%\include MKDIR ..\%TARGET%\include
COPY .\lualib.h ..\%TARGET%\include\
COPY .\lauxlib.h ..\%TARGET%\include\
COPY .\lua.h ..\%TARGET%\include\
COPY .\lua.hpp ..\%TARGET%\include\
COPY .\luaconf.h ..\%TARGET%\include\

IF "%TARGET%"=="Win32" (
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
) ELSE (
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
)

CL -MP -MD -O2 -c -DLUA_BUILD_AS_DLL *.c
MOVE /Y luac.obj luac.o
RC lua.rc
RC luac.rc
RC lua_dll.rc
LINK -subsystem:console -dll -implib:..\%TARGET%\lib\lua53.lib -out:..\%TARGET%\bin\lua53.dll *.obj lua_dll.res
LINK -out:..\%TARGET%\bin\lua53.exe lua.obj lua.res ..\%TARGET%\lib\lua53.lib
LIB -out:..\%TARGET%\lib\lua53-static.lib *.obj
LINK -out:..\%TARGET%\bin\luac53.exe luac.o luac.res ..\%TARGET%\lib\lua53-static.lib

DEL ..\%TARGET%\bin\*.lib
DEL ..\%TARGET%\bin\*.exp

PAUSE
Binary file added src/lua.ico
Binary file not shown.
23 changes: 23 additions & 0 deletions src/lua.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
0 ICON "lua.ico"

1 VERSIONINFO
FILEVERSION 5,3,5,0
PRODUCTVERSION 5,3,5,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "www.lua.org\0"
VALUE "CompanyName", "Lua.org\0"
VALUE "FileDescription", "Lua Console Standalone Interpreter\0"
VALUE "FileVersion", "5.3.5\0"
VALUE "LegalCopyright", "Copyright � 1994-2018 Lua.org, PUC-Rio.\0"
VALUE "OriginalFilename", "lua53.exe\0"
VALUE "ProductName", "Lua - The Programming Language\0"
VALUE "ProductVersion", "5.3.5\0"
VALUE "PrivateBuild", "Build by Tecgraf/PUC-Rio for LuaBinaries\0"
END
END
END

20 changes: 20 additions & 0 deletions src/lua_dll.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
1 VERSIONINFO
FILEVERSION 5,3,5,0
PRODUCTVERSION 5,3,5,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "www.lua.org\0"
VALUE "CompanyName", "Lua.org\0"
VALUE "FileDescription", "Lua Language Run Time\0"
VALUE "FileVersion", "5.3.5\0"
VALUE "LegalCopyright", "Copyright � 1994-2018 Lua.org, PUC-Rio.\0"
VALUE "OriginalFilename", "lua53.dll\0"
VALUE "ProductName", "Lua - The Programming Language\0"
VALUE "ProductVersion", "5.3.5\0"
VALUE "PrivateBuild", "Build by Tecgraf/PUC-Rio for LuaBinaries\0"
END
END
END
23 changes: 23 additions & 0 deletions src/luac.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
0 ICON "lua.ico"

1 VERSIONINFO
FILEVERSION 5,3,5,0
PRODUCTVERSION 5,3,5,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "www.lua.org\0"
VALUE "CompanyName", "Lua.org\0"
VALUE "FileDescription", "Lua Console Standalone Compiler\0"
VALUE "FileVersion", "5.3.5\0"
VALUE "LegalCopyright", "Copyright � 1994-2018 Lua.org, PUC-Rio.\0"
VALUE "OriginalFilename", "luac53.exe\0"
VALUE "ProductName", "Lua - The Programming Language\0"
VALUE "ProductVersion", "5.3.5\0"
VALUE "PrivateBuild", "Build by Tecgraf/PUC-Rio for LuaBinaries\0"
END
END
END

0 comments on commit 0352418

Please sign in to comment.