Skip to content

Commit 2c0a28c

Browse files
committed
* convert genproto into an option instead if an action because we need the action name for the deps folder
* disable windows specific options for other os + add category to all options * update readme
1 parent 3b53604 commit 2c0a28c

4 files changed

Lines changed: 59 additions & 62 deletions

File tree

‎.github/workflows/emu-build-all-linux.yml‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,13 @@ jobs:
8787
ls -la ./build/deps/linux/gmake2/protobuf/install32/bin/*
8888
ls -la ./build/deps/linux/gmake2/protobuf/install64/bin/*
8989
90-
### generate from .proto file
91-
- name: Generate from .proto file
92-
shell: bash
93-
working-directory: ${{ github.workspace }}
94-
run: |
95-
sudo chmod 777 ./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5
96-
./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5 --file=premake5.lua --os=linux genproto
97-
9890
### generate project files
9991
- name: Generate project files
10092
shell: bash
10193
working-directory: ${{ github.workspace }}
10294
run: |
10395
sudo chmod 777 ./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5
104-
./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5 --file=premake5.lua --emubuild=${{ github.sha }} --os=linux gmake2
96+
./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5 --file=premake5.lua --genproto --emubuild=${{ github.sha }} --os=linux gmake2
10597
10698
## mandatory Linux packages
10799
- name: Install required packages

‎.github/workflows/emu-build-all-win.yml‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,12 @@ jobs:
9494
dir /b /a build\deps\win\vs2022\protobuf\install32\bin\*
9595
dir /b /a build\deps\win\vs2022\protobuf\install64\bin\*
9696
97-
### generate from .proto file
98-
- name: Generate from .proto file
99-
shell: cmd
100-
working-directory: ${{ github.workspace }}
101-
run: |
102-
"${{env.THIRD_PARTY_BASE_DIR}}\common\win\premake\premake5.exe" --file=premake5.lua --os=windows genproto
103-
10497
### generate project files
10598
- name: Generate project files
10699
shell: cmd
107100
working-directory: ${{ github.workspace }}
108101
run: |
109-
"${{env.THIRD_PARTY_BASE_DIR}}\common\win\premake\premake5.exe" --file=premake5.lua --emubuild=${{ github.sha }} --dosstub --winrsrc --winsign --os=windows vs2022
102+
"${{env.THIRD_PARTY_BASE_DIR}}\common\win\premake\premake5.exe" --file=premake5.lua --genproto --emubuild=${{ github.sha }} --dosstub --winrsrc --winsign --os=windows vs2022
110103
111104
### build target
112105
- name: Build target

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ This will:
178178
Open CMD in the repo folder, then run the following
179179
* For `MSYS2`
180180
```shell
181-
./third-party/common/win/premake/premake5.exe --file=premake5.lua --os=windows gmake2
181+
./third-party/common/win/premake/premake5.exe --file=premake5.lua --genproto --os=windows gmake2
182182
183183
cd ./build/project/gmake2/win
184184
```
@@ -201,7 +201,7 @@ Open CMD in the repo folder, then run the following
201201
```
202202
* For `Visual Studio 2022`
203203
```batch
204-
third-party\common\win\premake\premake5.exe --file=premake5.lua --os=windows vs2022
204+
third-party\common\win\premake\premake5.exe --file=premake5.lua --genproto --os=windows vs2022
205205
```
206206
You can then go to the folder `build\project\vs2022\win` and open the produced `.sln` file in Visual Studio.
207207
Or, if you prefer to do it from command line, open the `Developer Command Prompt for VS 2022` inside the above folder, then:
@@ -219,7 +219,7 @@ This will build a release version of the emu in the folder `build\win\<toolchain
219219
### On Linux:
220220
Open a terminal in the repo folder, then run the following
221221
```shell
222-
./third-party/common/linux/premake/premake5 --file=premake5.lua --os=linux gmake2
222+
./third-party/common/linux/premake/premake5 --file=premake5.lua --genproto --os=linux gmake2
223223
cd ./build/project/gmake2/linux
224224
```
225225
*(Optional)* You can use `Clang` compiler instead of `GCC` by running these 2 commands in the current terminal instance

‎premake5.lua‎

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -74,79 +74,81 @@ end
7474

7575
local deps_dir = path.getabsolute(path.join('build', 'deps', os_iden, _ACTION), _MAIN_SCRIPT_DIR)
7676

77-
newaction {
78-
trigger = "genproto",
79-
description = "Generate .cpp/.h files from .proto file",
80-
81-
onStart = function ()
82-
local deps_install_prefix = ''
83-
if os.is64bit() then
84-
deps_install_prefix = 'install64'
85-
else
86-
deps_install_prefix = 'install32'
87-
end
88-
local protoc_exe = path.join(deps_dir, 'protobuf', deps_install_prefix, 'bin', 'protoc')
77+
function genproto()
78+
local deps_install_prefix = ''
79+
if os.is64bit() then
80+
deps_install_prefix = 'install64'
81+
else
82+
deps_install_prefix = 'install32'
83+
end
84+
local protoc_exe = path.join(deps_dir, 'protobuf', deps_install_prefix, 'bin', 'protoc')
8985

90-
local out_dir = 'dll/proto_gen/' .. os_iden
86+
local out_dir = 'dll/proto_gen/' .. os_iden
9187

92-
if os.host() == "windows" then
93-
protoc_exe = protoc_exe .. '.exe'
94-
end
88+
if os.host() == "windows" then
89+
protoc_exe = protoc_exe .. '.exe'
90+
end
9591

96-
if not os.isfile(protoc_exe) then
97-
error("protoc not found! " .. protoc_exe)
98-
return
99-
end
92+
if not os.isfile(protoc_exe) then
93+
error("protoc not found! " .. protoc_exe)
94+
return
95+
end
10096

101-
print("Generating from .proto file!")
102-
local ok_mk, err_mk = os.mkdir(out_dir)
103-
if not ok_mk then
104-
error("Error: " .. err_mk)
97+
print("Generating from .proto file!")
98+
local ok_mk, err_mk = os.mkdir(out_dir)
99+
if not ok_mk then
100+
error("Error: " .. err_mk)
101+
return
102+
end
103+
104+
if os.host() == "linux" then
105+
local ok_chmod, err_chmod = os.chmod(protoc_exe, "777")
106+
if not ok_chmod then
107+
error("Error: " .. err_chmod)
105108
return
106109
end
107-
108-
if os.host() == "linux" then
109-
local ok_chmod, err_chmod = os.chmod(protoc_exe, "777")
110-
if not ok_chmod then
111-
error("Error: " .. err_chmod)
112-
return
113-
end
114-
end
115-
116-
local ok_cmd = os.execute(protoc_exe .. ' dll/net.proto -I./dll/ --cpp_out=' .. out_dir)
117-
if ok_cmd then
118-
print("Success!")
119-
else
120-
error("protoc error")
121-
end
122110
end
111+
112+
return os.execute(protoc_exe .. ' dll/net.proto -I./dll/ --cpp_out=' .. out_dir)
113+
end
114+
115+
newoption {
116+
category = 'protobuf files',
117+
trigger = "genproto",
118+
description = "Generate .cc/.h files from .proto file",
123119
}
124120

125121
newoption {
122+
category = 'build',
126123
trigger = "emubuild",
127124
description = "Set the EMU_BUILD_STRING",
128125
value = "your_string",
129126
default = os.date("%Y_%m_%d-%H_%M_%S"),
130127
}
131128

129+
-- windows options
130+
if os.target() == 'windows' then
131+
132132
newoption {
133-
category = "win build",
133+
category = "build",
134134
trigger = "dosstub",
135135
description = "Change the DOS stub of the Windows builds",
136136
}
137137

138138
newoption {
139-
category = "win build",
139+
category = "build",
140140
trigger = "winsign",
141141
description = "Sign Windows builds with a fake certificate",
142142
}
143143

144144
newoption {
145-
category = "win build",
145+
category = "build",
146146
trigger = "winrsrc",
147147
description = "Add resources to Windows builds",
148148
}
149149

150+
end
151+
-- End windows options
150152

151153

152154
-- common defines
@@ -302,6 +304,16 @@ local x64_deps_overlay_libdir = {
302304
path.join(deps_dir, "ingame_overlay/deps/mini_detour/install64/lib"),
303305
}
304306

307+
-- generate proto
308+
if _OPTIONS["genproto"] then
309+
if genproto() then
310+
print("Success!")
311+
else
312+
error("protoc error")
313+
end
314+
end
315+
-- End generate proto
316+
305317

306318

307319
-- tokenization

0 commit comments

Comments
 (0)