Skip to content

Commit 95c21ab

Browse files
authored
add linux build (#735)
1 parent bc80cec commit 95c21ab

3 files changed

Lines changed: 94 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ "master" ]
88

99
jobs:
10-
build:
10+
build-windows:
1111
runs-on: windows-2022
1212

1313
steps:
@@ -16,39 +16,46 @@ jobs:
1616
with:
1717
fetch-depth: 0
1818

19-
- name: Download dependencies
20-
run: |
21-
bash -c " \
22-
curl -Z --retry 5 --connect-timeout 30 --location \
23-
--create-dirs --output-dir temp --remote-name-all \
24-
https://www.lua.org/ftp/lua-5.4.7.tar.gz \
25-
https://github.com/premake/premake-core/releases/download/v5.0.0-beta5/premake-5.0.0-beta5-windows.zip \
26-
; exit 0"
19+
- name: Download lua
20+
id: lua
21+
uses: mercury233/action-cache-download-file@v1.0.0
22+
with:
23+
url: https://www.lua.org/ftp/lua-5.4.7.tar.gz
2724

2825
- name: Lua
2926
run: |
30-
tar -xzf temp/lua-5.4.7.tar.gz
27+
tar -xzf ${{ steps.lua.outputs.filepath }}
3128
move lua-5.4.7 lua
3229
30+
- name: Download premake
31+
id: premake
32+
uses: mercury233/action-cache-download-file@v1.0.0
33+
with:
34+
url: https://github.com/premake/premake-core/releases/download/v5.0.0-beta5/premake-5.0.0-beta5-windows.zip
35+
3336
- name: Premake
3437
run: |
3538
mkdir premake-5
36-
tar -C premake-5 -xzf temp/premake-5.0.0-beta5-windows.zip
39+
tar -C premake-5 -xzf ${{ steps.premake.outputs.filepath }}
3740
copy premake\lua.lua lua\premake5.lua
3841
copy premake\dll.lua dll.lua
3942
.\premake-5\premake5.exe vs2022 --file=dll.lua
4043
4144
- name: Add msbuild to PATH
4245
uses: microsoft/setup-msbuild@v2
4346

44-
- name: Build
47+
- name: Build x32
4548
run: |
4649
msbuild build\ocgcoredll.sln /t:Build /p:"Configuration=Release;Platform=Win32"
50+
51+
- name: Build x64
52+
run: |
4753
msbuild build\ocgcoredll.sln /t:Build /p:"Configuration=Release;Platform=x64"
4854
4955
- name: Upload build artifacts
5056
uses: actions/upload-artifact@v4
5157
with:
58+
name: ocgcore-windows
5259
path: |
5360
build\bin\x32\Release\ocgcore.dll
5461
build\bin\x64\Release\ocgcore.dll
@@ -63,3 +70,63 @@ jobs:
6370
title: "Development Build"
6471
files: |
6572
build/bin/x64/Release/ocgcore.dll
73+
74+
build-linux:
75+
runs-on: ubuntu-latest
76+
77+
steps:
78+
- name: Checkout
79+
uses: actions/checkout@v4
80+
with:
81+
fetch-depth: 0
82+
83+
- name: Install Dependencies
84+
run: |
85+
sudo apt-get update
86+
sudo apt-get install -y gcc-multilib g++-multilib
87+
88+
- name: Download lua
89+
id: lua
90+
uses: mercury233/action-cache-download-file@v1.0.0
91+
with:
92+
url: https://www.lua.org/ftp/lua-5.4.7.tar.gz
93+
94+
- name: Lua
95+
run: |
96+
tar -xzf ${{ steps.lua.outputs.filepath }}
97+
mv lua-5.4.7 lua
98+
99+
- name: Download premake
100+
id: premake
101+
uses: mercury233/action-cache-download-file@v1.0.0
102+
with:
103+
url: https://github.com/premake/premake-core/releases/download/v5.0.0-beta5/premake-5.0.0-beta5-linux.tar.gz
104+
105+
- name: Premake
106+
run: |
107+
mkdir premake-5
108+
tar -C premake-5 -xzf ${{ steps.premake.outputs.filepath }}
109+
cp premake/lua.lua lua/premake5.lua
110+
cp premake/dll.lua dll.lua
111+
chmod +x premake-5/premake5
112+
./premake-5/premake5 gmake --file=dll.lua
113+
114+
- name: Build x32
115+
run: |
116+
cd build
117+
make -j 4 config=release_x32
118+
cd ..
119+
120+
- name: Build x64
121+
run: |
122+
cd build
123+
make -j 4 config=release_x64
124+
cd ..
125+
126+
- name: Upload build artifacts
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: ocgcore-linux
130+
path: |
131+
build/bin/x32/Release/libocgcore.so
132+
build/bin/x64/Release/libocgcore.so

premake/dll.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ end
1212
workspace "ocgcoredll"
1313
location "build"
1414
language "C++"
15+
cppdialect "C++14"
1516

1617
configurations { "Release", "Debug" }
1718
platforms { "x32", "x64" }
@@ -47,6 +48,19 @@ workspace "ocgcoredll"
4748
buildoptions { "/utf-8" }
4849
defines { "_CRT_SECURE_NO_WARNINGS" }
4950

51+
filter "not action:vs*"
52+
buildoptions { }
53+
54+
filter "system:bsd"
55+
defines { "LUA_USE_POSIX" }
56+
57+
filter "system:macosx"
58+
defines { "LUA_USE_MACOSX" }
59+
60+
filter "system:linux"
61+
defines { "LUA_USE_LINUX" }
62+
buildoptions { "-fPIC" }
63+
5064
filter {}
5165

5266
include(LUA_DIR)

premake/lua.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ project "lua"
2222

2323
filter "system:linux"
2424
defines { "LUA_USE_LINUX" }
25+
buildoptions { "-fPIC" }

0 commit comments

Comments
 (0)