Skip to content

Commit

Permalink
Merge pull request #96 from BeamMP/finalize-linux-merge
Browse files Browse the repository at this point in the history
Finalize linux merge
  • Loading branch information
lionkor authored Jun 18, 2024
2 parents 942cc78 + 25f28e7 commit e0e2607
Show file tree
Hide file tree
Showing 28 changed files with 2,535 additions and 1,310 deletions.
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
BasedOnStyle: WebKit
BreakBeforeBraces: Attach
SpaceAfterTemplateKeyword: false
...
42 changes: 42 additions & 0 deletions .github/workflows/cmake-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CMake Linux Build

on: [push, pull_request, workflow_dispatch]

env:
BUILD_TYPE: Release

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

steps:
- uses: actions/checkout@v2
with:
submodules: 'true'

- name: Restore artifacts, or run vcpkg, build and cache artifacts
uses: lukka/run-vcpkg@v7
id: runvcpkg
with:
vcpkgArguments: 'zlib nlohmann-json openssl cpp-httplib[openssl]'
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
vcpkgGitCommitId: '40616a5e954f7be1077ef37db3fbddbd5dcd1ca6'

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build-linux

- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build-linux
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE='${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake'

- name: Build
working-directory: ${{github.workspace}}/build-linux
shell: bash
run: cmake --build . --config $BUILD_TYPE

- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: BeamMP-Launcher
path: ${{github.workspace}}/build-linux/BeamMP-Launcher
4 changes: 2 additions & 2 deletions .github/workflows/cmake-windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CMake Windows Build

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

env:
BUILD_TYPE: Release
Expand All @@ -20,7 +20,7 @@ jobs:
with:
vcpkgArguments: 'discord-rpc zlib nlohmann-json openssl cpp-httplib[openssl]'
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
vcpkgGitCommitId: '16ee2ecb31788c336ace8bb14c21801efb6836e4'
vcpkgGitCommitId: '40616a5e954f7be1077ef37db3fbddbd5dcd1ca6'
vcpkgTriplet: 'x64-windows-static'

- name: Create Build Environment
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
body: |
Files included in this release:
- `BeamMP-Launcher.exe` windows build
- `BeamMP-Launcher` linux build
upload-release-files-windows:
name: Upload Windows Release Files
Expand Down Expand Up @@ -70,3 +71,34 @@ jobs:
asset_path: ${{github.workspace}}/build-windows/Release/BeamMP-Launcher.exe
asset_name: BeamMP-Launcher.exe
asset_content_type: application/vnd.microsoft.portable-executable

upload-release-files-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build-linux

- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build-linux
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE

- name: Build
working-directory: ${{github.workspace}}/build-linux
shell: bash
run: cmake --build . --config $BUILD_TYPE

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{github.workspace}}/build-linux/BeamMP-Launcher
asset_name: BeamMP-Launcher
asset_content_type: application/octet-stream
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ cmake-build-release
*.log
/*.sh
/*.obj
/*.exe
/*.exe
.cache/
.https_debug/
Launcher.cfg
Resources/
bin/
compile_commands.json
key
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(CMAKE_CXX_STANDARD 20)

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")

file(GLOB source_files "src/*.cpp" "src/*/*.cpp" "src/*/*.hpp" "include/*.h" "include/*/*.h" "include/*/*/*.h")
file(GLOB source_files "src/*.cpp" "src/*/*.cpp" "src/*/*.hpp" "include/*.h" "include/*/*.h" "include/*/*/*.h" "include/*.hpp" "include/*/*.hpp" "include/*/*/*.hpp")
find_package(httplib CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)

Expand All @@ -24,6 +24,11 @@ if (WIN32)
find_package(OpenSSL REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE
ZLIB::ZLIB OpenSSL::SSL OpenSSL::Crypto ws2_32 httplib::httplib nlohmann_json::nlohmann_json)
elseif (LINUX)
find_package(ZLIB REQUIRED)
find_package(OpenSSL REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE
ZLIB::ZLIB OpenSSL::SSL OpenSSL::Crypto)
else(WIN32) #MINGW
add_definitions("-D_WIN32_WINNT=0x0600")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s --static")
Expand Down
7 changes: 4 additions & 3 deletions include/Http.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
/// Created by Anonymous275 on 7/18/2020
///
#pragma once
#include <string>
#include "Logger.h"
#include <string>
class HTTP {
public:
static bool Download(const std::string &IP, const std::string &Path);
static bool Download(const std::string& IP, const std::string& Path);
static std::string Post(const std::string& IP, const std::string& Fields);
static std::string Get(const std::string &IP);
static std::string Get(const std::string& IP);
static bool ProgressBar(size_t c, size_t t);

public:
static bool isDownload;
};
2 changes: 1 addition & 1 deletion include/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
/// Created by Anonymous275 on 4/2/2020.
///
#pragma once
#include <string>
#include <iostream>
#include <string>
void InitLog();
void except(const std::string& toPrint);
void fatal(const std::string& toPrint);
Expand Down
18 changes: 12 additions & 6 deletions include/Network/network.h → include/Network/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
/// Created by Anonymous275 on 7/18/2020
///


#pragma once
#include <string>

#ifdef __linux__
#include "linuxfixes.h"
#include <bits/types/siginfo_t.h>
#include <cstdint>
#include <sys/ucontext.h>
#endif

void NetReset();
extern bool Dev;
extern int ping;
Expand Down Expand Up @@ -38,11 +45,10 @@ void GameSend(std::string Data);
void SendLarge(std::string Data);
std::string TCPRcv(uint64_t Sock);
void SyncResources(uint64_t TCPSock);
std::string GetAddr(const std::string&IP);
std::string GetAddr(const std::string& IP);
void ServerParser(const std::string& Data);
std::string Login(const std::string& fields);
void TCPSend(const std::string&Data,uint64_t Sock);
void TCPClientMain(const std::string& IP,int Port);
void UDPClientMain(const std::string& IP,int Port);
void TCPSend(const std::string& Data, uint64_t Sock);
void TCPClientMain(const std::string& IP, int Port);
void UDPClientMain(const std::string& IP, int Port);
void TCPGameServer(const std::string& IP, int Port);

2 changes: 1 addition & 1 deletion include/Security/Init.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#pragma once
#include <string>
void PreGame(const std::string& GamePath);
std::string CheckVer(const std::string &path);
std::string CheckVer(const std::string& path);
void InitGame(const std::string& Dir);
std::string GetGameDir();
void LegitimacyCheck();
Expand Down
4 changes: 2 additions & 2 deletions include/Startup.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
/// Created by Anonymous275 on 7/18/2020
///
#pragma once
#include <string>
#include <compare>
#include <string>
#include <vector>

void InitLauncher(int argc, char* argv[]);
std::string GetEP(char*P = nullptr);
std::string GetEP(char* P = nullptr);
std::string GetGamePath();
std::string GetVer();
std::string GetEN();
Expand Down
19 changes: 19 additions & 0 deletions include/linuxfixes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _LINUXFIXES_H
#define _LINUXFIXES_H

#include <stdint.h>

// Translate windows sockets stuff to linux sockets
#define SOCKET uint64_t
#define SOCKADDR sockaddr
#define SOCKADDR_IN sockaddr_in
#define WSAGetLastError() errno
#define closesocket close
#define SD_BOTH SHUT_RDWR
// We dont need wsacleanup
#define WSACleanup()
#define SOCKET_ERROR -1

#define ZeroMemory(mem, len) memset(mem, 0, len)

#endif
Loading

0 comments on commit e0e2607

Please sign in to comment.