Skip to content

Commit

Permalink
Add Linux build workflow and fix Linux compatibility (#3)
Browse files Browse the repository at this point in the history
* Update Engine submodule and add Linux workflow files
* Add SetLibDirs to premake util
* Fix upper/lowercase issue in dependencies
* Define postgres library and include for libpq

---------

Co-authored-by: NixAJ <[email protected]>
  • Loading branch information
Foereaper and NixAJ authored Aug 11, 2024
1 parent 6ccd1c3 commit 60b2f12
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 16 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Linux Build

on:
workflow_call:

jobs:
linux-build:
runs-on: ubuntu-22.04

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4
with:
submodules: false
repository: novusengine/Servers

- name: Setup premake
uses: abel0b/[email protected]
with:
version: "5.0.0-beta1"

- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -yq clang libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libvulkan-dev
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 100
- name: Install Vulkan SDK
run: |
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list http://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
sudo apt update
sudo apt install vulkan-sdk
- name: Checkout submodules
run: |
git submodule update --init --recursive
- name: Run Premake
run: |
export VULKAN_SDK=/usr/include/vulkan
premake5 gmake2
- name: Build
run: |
cd Build
make -j 4 -k
12 changes: 12 additions & 0 deletions .github/workflows/on-label-linux-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: PR Linux Build

on:
workflow_dispatch:
pull_request:
types: [ labeled ]

jobs:
call-linux-build:
if: ${{ github.event.label.name == 'build-linux' }}
name: Linux Build
uses: ./.github/workflows/linux-build.yml
4 changes: 4 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ jobs:
name: Windows Build
uses: ./.github/workflows/win-build.yml

call-linux-build:
name: Linux Build
uses: ./.github/workflows/linux-build.yml

call-windows-deploy:
needs: call-windows-build
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch'
Expand Down
2 changes: 1 addition & 1 deletion Dependencies/Dependencies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Solution.Util.SetGroup(Solution.DependencyGroup)

local dependencies =
{
"Libpqxx/Libpqxx.lua"
"libpqxx/Libpqxx.lua"
}

for k,v in pairs(dependencies) do
Expand Down
29 changes: 21 additions & 8 deletions Dependencies/libpqxx/Libpqxx.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
local osEnvName = "POSTGRES_ROOT"
local postgresRoot = os.getenv(osEnvName)

if not postgresRoot then
Solution.Util.PrintError("Failed to find System Environment Variable '" .. osEnvName .. ". Please ensure Postgres is installed and that " .. osEnvName .. " have been properly configured")
local postgresRoot = ""
-- TODO: should probably not hardcode postgres dir for Linux but oh well
if os.target() == "windows" then
local osEnvName = "POSTGRES_ROOT"
postgresRoot = os.getenv(osEnvName)

if not postgresRoot then
Solution.Util.PrintError("Failed to find System Environment Variable '" .. osEnvName .. ". Please ensure Postgres is installed and that " .. osEnvName .. " have been properly configured")
end
end

local dep = Solution.Util.CreateDepTable("Libpqxx", {})
Expand All @@ -15,7 +19,13 @@ Solution.Util.CreateStaticLib(dep.Name, Solution.Projects.Current.BinDir, dep.De

local baseDir = dep.Path .. "/Libpqxx"
local sourceDir = baseDir .. "/src"
local includeDirs = { baseDir .. "/include", postgresRoot .. "/include" }
local pqinclude = iif(os.istarget("windows"), postgresRoot .. "/include", { "/usr/include/postgresql", "/usr/include/postgresql/14/server" })

if os.target() == "linux" then
Solution.Util.SetLibDirs({ "/usr/lib/x86_64-linux-gnu", "/usr/lib/postgresql/14/lib" })
end

local includeDirs = { baseDir .. "/include", pqinclude }
local files =
{
sourceDir .. "/**.cxx",
Expand All @@ -24,12 +34,15 @@ Solution.Util.CreateStaticLib(dep.Name, Solution.Projects.Current.BinDir, dep.De
Solution.Util.SetFiles(files)
Solution.Util.SetIncludes(includeDirs)
Solution.Util.SetDefines(defines)
Solution.Util.SetLinks({postgresRoot .. "/lib/libpq.lib"})

local libPath = iif(os.istarget("windows"), postgresRoot .. "/lib/libpq.lib", "pq")
Solution.Util.SetLinks(libPath)
end)

Solution.Util.CreateDep(dep.NameLow, dep.Dependencies, function()
local baseDir = dep.Path .. "/Libpqxx"

Solution.Util.SetIncludes({baseDir .. "/include"})
Solution.Util.SetLinks(dep.Name)
local libPath = iif(os.istarget("windows"), postgresRoot .. "/lib/libpq.lib", "pq")
Solution.Util.SetLinks({ dep.Name, libPath })
end)
15 changes: 9 additions & 6 deletions Source/Generate/Generate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ local currentProject = Solution.Projects.Current
local dependencies = { }
Solution.Util.CreateProject("Generate", "StaticLib", currentProject.BinDir, dependencies)

local solutionType = BuildSettings:Get("Solution Type")
postbuildcommands
{
"cd " .. currentProject.RootDir,
"premake5 " .. solutionType
}
-- TODO: This needs to be fixed to work properly on Linux. Dirty fix to make runner build properly.
if os.target() == "windows" then
local solutionType = BuildSettings:Get("Solution Type")
postbuildcommands
{
"cd " .. currentProject.RootDir,
"premake5 " .. solutionType
}
end
2 changes: 2 additions & 0 deletions Source/Server-Game/Server-Game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Solution.Util.CreateConsoleApp(mod.Name, Solution.Projects.Current.BinDir, mod.D
['*'] = { '**.*' }
}
end)

dependson {"Luau-Compiler", "Luau-VM"}
end)

Solution.Util.CreateDep(mod.NameLow, mod.Dependencies, function()
Expand Down
2 changes: 1 addition & 1 deletion Submodules/Engine

0 comments on commit 60b2f12

Please sign in to comment.