* 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
This commit is contained in:
otavepto 2024-05-31 15:09:36 +03:00
parent 3b536044be
commit 2c0a28c8ea
4 changed files with 59 additions and 62 deletions

View File

@ -87,21 +87,13 @@ jobs:
ls -la ./build/deps/linux/gmake2/protobuf/install32/bin/*
ls -la ./build/deps/linux/gmake2/protobuf/install64/bin/*
### generate from .proto file
- name: Generate from .proto file
shell: bash
working-directory: ${{ github.workspace }}
run: |
sudo chmod 777 ./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5
./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5 --file=premake5.lua --os=linux genproto
### generate project files
- name: Generate project files
shell: bash
working-directory: ${{ github.workspace }}
run: |
sudo chmod 777 ./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5
./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5 --file=premake5.lua --emubuild=${{ github.sha }} --os=linux gmake2
./${{env.THIRD_PARTY_BASE_DIR}}/common/linux/premake/premake5 --file=premake5.lua --genproto --emubuild=${{ github.sha }} --os=linux gmake2
## mandatory Linux packages
- name: Install required packages

View File

@ -94,19 +94,12 @@ jobs:
dir /b /a build\deps\win\vs2022\protobuf\install32\bin\*
dir /b /a build\deps\win\vs2022\protobuf\install64\bin\*
### generate from .proto file
- name: Generate from .proto file
shell: cmd
working-directory: ${{ github.workspace }}
run: |
"${{env.THIRD_PARTY_BASE_DIR}}\common\win\premake\premake5.exe" --file=premake5.lua --os=windows genproto
### generate project files
- name: Generate project files
shell: cmd
working-directory: ${{ github.workspace }}
run: |
"${{env.THIRD_PARTY_BASE_DIR}}\common\win\premake\premake5.exe" --file=premake5.lua --emubuild=${{ github.sha }} --dosstub --winrsrc --winsign --os=windows vs2022
"${{env.THIRD_PARTY_BASE_DIR}}\common\win\premake\premake5.exe" --file=premake5.lua --genproto --emubuild=${{ github.sha }} --dosstub --winrsrc --winsign --os=windows vs2022
### build target
- name: Build target

View File

@ -178,7 +178,7 @@ This will:
Open CMD in the repo folder, then run the following
* For `MSYS2`
```shell
./third-party/common/win/premake/premake5.exe --file=premake5.lua --os=windows gmake2
./third-party/common/win/premake/premake5.exe --file=premake5.lua --genproto --os=windows gmake2
cd ./build/project/gmake2/win
```
@ -201,7 +201,7 @@ Open CMD in the repo folder, then run the following
```
* For `Visual Studio 2022`
```batch
third-party\common\win\premake\premake5.exe --file=premake5.lua --os=windows vs2022
third-party\common\win\premake\premake5.exe --file=premake5.lua --genproto --os=windows vs2022
```
You can then go to the folder `build\project\vs2022\win` and open the produced `.sln` file in Visual Studio.
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
### On Linux:
Open a terminal in the repo folder, then run the following
```shell
./third-party/common/linux/premake/premake5 --file=premake5.lua --os=linux gmake2
./third-party/common/linux/premake/premake5 --file=premake5.lua --genproto --os=linux gmake2
cd ./build/project/gmake2/linux
```
*(Optional)* You can use `Clang` compiler instead of `GCC` by running these 2 commands in the current terminal instance

View File

@ -74,79 +74,81 @@ end
local deps_dir = path.getabsolute(path.join('build', 'deps', os_iden, _ACTION), _MAIN_SCRIPT_DIR)
newaction {
trigger = "genproto",
description = "Generate .cpp/.h files from .proto file",
function genproto()
local deps_install_prefix = ''
if os.is64bit() then
deps_install_prefix = 'install64'
else
deps_install_prefix = 'install32'
end
local protoc_exe = path.join(deps_dir, 'protobuf', deps_install_prefix, 'bin', 'protoc')
onStart = function ()
local deps_install_prefix = ''
if os.is64bit() then
deps_install_prefix = 'install64'
else
deps_install_prefix = 'install32'
end
local protoc_exe = path.join(deps_dir, 'protobuf', deps_install_prefix, 'bin', 'protoc')
local out_dir = 'dll/proto_gen/' .. os_iden
local out_dir = 'dll/proto_gen/' .. os_iden
if os.host() == "windows" then
protoc_exe = protoc_exe .. '.exe'
end
if os.host() == "windows" then
protoc_exe = protoc_exe .. '.exe'
end
if not os.isfile(protoc_exe) then
error("protoc not found! " .. protoc_exe)
return
end
if not os.isfile(protoc_exe) then
error("protoc not found! " .. protoc_exe)
print("Generating from .proto file!")
local ok_mk, err_mk = os.mkdir(out_dir)
if not ok_mk then
error("Error: " .. err_mk)
return
end
if os.host() == "linux" then
local ok_chmod, err_chmod = os.chmod(protoc_exe, "777")
if not ok_chmod then
error("Error: " .. err_chmod)
return
end
print("Generating from .proto file!")
local ok_mk, err_mk = os.mkdir(out_dir)
if not ok_mk then
error("Error: " .. err_mk)
return
end
if os.host() == "linux" then
local ok_chmod, err_chmod = os.chmod(protoc_exe, "777")
if not ok_chmod then
error("Error: " .. err_chmod)
return
end
end
local ok_cmd = os.execute(protoc_exe .. ' dll/net.proto -I./dll/ --cpp_out=' .. out_dir)
if ok_cmd then
print("Success!")
else
error("protoc error")
end
end
return os.execute(protoc_exe .. ' dll/net.proto -I./dll/ --cpp_out=' .. out_dir)
end
newoption {
category = 'protobuf files',
trigger = "genproto",
description = "Generate .cc/.h files from .proto file",
}
newoption {
category = 'build',
trigger = "emubuild",
description = "Set the EMU_BUILD_STRING",
value = "your_string",
default = os.date("%Y_%m_%d-%H_%M_%S"),
}
-- windows options
if os.target() == 'windows' then
newoption {
category = "win build",
category = "build",
trigger = "dosstub",
description = "Change the DOS stub of the Windows builds",
}
newoption {
category = "win build",
category = "build",
trigger = "winsign",
description = "Sign Windows builds with a fake certificate",
}
newoption {
category = "win build",
category = "build",
trigger = "winrsrc",
description = "Add resources to Windows builds",
}
end
-- End windows options
-- common defines
@ -302,6 +304,16 @@ local x64_deps_overlay_libdir = {
path.join(deps_dir, "ingame_overlay/deps/mini_detour/install64/lib"),
}
-- generate proto
if _OPTIONS["genproto"] then
if genproto() then
print("Success!")
else
error("protoc error")
end
end
-- End generate proto
-- tokenization