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
23 changes: 21 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,27 @@ jobs:
fi
fi

# Note: We're using the internal Luau headers, not external Lua
echo "Using internal Luau headers - no need to install external Lua"
# Note: We're using standard Lua headers
echo "Using standard Lua headers - we'll look for them on the system"

# Install lua and luarocks with homebrew
brew install lua@5.4 || brew install lua || echo "Lua installation failed but we'll continue"
which lua || echo "Lua not found in PATH"

# Copy any headers found to our directory
mkdir -p /tmp/lua_include
find /opt/homebrew -name "lua.h" -exec cp {} /tmp/lua_include/ \; || echo "No lua.h found"
find /opt/homebrew -name "lauxlib.h" -exec cp {} /tmp/lua_include/ \; || echo "No lauxlib.h found"
find /opt/homebrew -name "lualib.h" -exec cp {} /tmp/lua_include/ \; || echo "No lualib.h found"

# Find and copy lua libraries
mkdir -p /tmp/lua_lib
find /opt/homebrew -name "liblua*.dylib" -exec cp {} /tmp/lua_lib/ \; || echo "No lua libraries found"
find /opt/homebrew -name "liblua*.a" -exec cp {} /tmp/lua_lib/ \; || echo "No lua libraries found"

# Set environment variables
echo "LUA_INCLUDE_DIR=/tmp/lua_include" >> $GITHUB_ENV
echo "LUA_LIBRARIES=/tmp/lua_lib/liblua.dylib" >> $GITHUB_ENV

# Create directories for project resources (only once)
mkdir -p Resources/AIData/LocalModels
Expand Down
36 changes: 21 additions & 15 deletions cmake/FindLuaFileSystem.cmake
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
# FindLuaFileSystem.cmake
# This module allows compilation of lfs.c specifically using our own Lua headers
# This module allows compilation of lfs.c specifically by finding external Lua

# Create a target for lfs.c that ensures it can find the Luau headers
# Create a target for lfs.c with external Lua
function(add_lfs_target)
# Don't add it twice
if(TARGET lfs_obj)
return()
endif()

message(STATUS "Setting up LuaFileSystem with native Luau headers")
message(STATUS "Setting up LuaFileSystem with external Lua headers")

# Create an object library for lfs.c
add_library(lfs_obj OBJECT ${CMAKE_SOURCE_DIR}/source/lfs.c)

# Set include directories for just this file
# The source directory is needed for relative includes like "cpp/luau/lua.h"
target_include_directories(lfs_obj PRIVATE
${CMAKE_SOURCE_DIR}/source # Main source directory for relative includes
${CMAKE_SOURCE_DIR}/source/cpp # For cpp/luau/lua.h path style
${CMAKE_SOURCE_DIR}/source/cpp/luau # For direct lua.h access
${CMAKE_SOURCE_DIR} # For absolute paths
# Look for lua in standard paths
find_path(LUA_INCLUDE_DIR lua.h
PATHS
/opt/homebrew/opt/lua/include
/opt/homebrew/include
/usr/local/include
/usr/include
PATH_SUFFIXES lua lua5.4 lua5.3 lua5.2 lua5.1
)

# Add a define to use the internal Luau headers
target_compile_definitions(lfs_obj PRIVATE
LFS_USE_INTERNAL_LUAU=1
LUAU_FASTFLAG_LUAERROR=1 # Handle missing dependencies
# Add include directories
target_include_directories(lfs_obj PRIVATE
${LUA_INCLUDE_DIR}
)

# Enable standard paths with quotes if needed
if(LUA_INCLUDE_DIR)
message(STATUS "Found Lua include directory: ${LUA_INCLUDE_DIR}")
target_compile_definitions(lfs_obj PRIVATE LFS_USE_INCLUDE_QUOTES)
endif()

# Ensure the compiler knows this is C
set_target_properties(lfs_obj PROPERTIES
C_STANDARD 99
POSITION_INDEPENDENT_CODE ON
)

message(STATUS "LFS using internal Luau headers from ${CMAKE_SOURCE_DIR}/source/cpp/luau")
message(STATUS "LFS using external Lua headers from: ${LUA_INCLUDE_DIR}")
endfunction()
16 changes: 9 additions & 7 deletions source/lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@
#include "lauxlib.h"
#include "lualib.h"
#else
// Use the Lua headers from our source tree
#include "cpp/luau/lua.h"
#include "cpp/luau/lualib.h"

// Define missing lauxlib symbols we need
#ifndef luaL_register
extern void luaL_register(lua_State* L, const char* libname, const luaL_Reg* l);
// Use standard Lua headers - we're going back to the original approach
#ifdef LFS_USE_INCLUDE_QUOTES
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#else
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#endif
#endif

Expand Down
Loading