Skip to content

Commit

Permalink
Merge pull request #19 from tedboudros/development-and-compilation-sc…
Browse files Browse the repository at this point in the history
…ripts

Development and compilation scripts
  • Loading branch information
tedboudros-design authored Aug 8, 2021
2 parents 6068cb2 + 8a01e8a commit 6f833a8
Show file tree
Hide file tree
Showing 20 changed files with 633 additions and 53 deletions.
72 changes: 52 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,87 @@ Aurora is a set of utilities aiming to take PC couch gaming to the next level!
- Update MSYS2 and install dependencies:

```sh
pacman -Syuu && pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_ttf
pacman -Syuu
pacman -S python3 python3-pip mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_ttf
```

- Install python dependencies

```sh
cd utilities
pip3 install -r requirements.txt
cd ../server
pip3 install -r requirements.txt
```

---

### Linux:

- Clone the repository
- Install dependencies:

```sh
sudo apt install cmake g++ gcc libsdl2-dev libsdl2-2.0-0 libsdl2-image-dev libsdl2-image-2.0-0 libsdl2-ttf-dev libsdl2-ttf-2.0-0
sudo apt install python3 python3-pip cmake g++ gcc libsdl2-dev libsdl2-2.0-0 libsdl2-image-dev libsdl2-image-2.0-0 libsdl2-ttf-dev libsdl2-ttf-2.0-0
```

- Install python dependencies

```sh
cd utilities
pip3 install -r requirements.txt
cd ../server
pip3 install -r requirements.txt
```

---

- **Fix for Ubuntu 21.04:**

```sh
sudo apt install libudev1=247.3-3ubuntu3.1
```

---

### Mac OS:

Sorry but you're out of luck...
If you really want to try Aurora try to run it in a virtual machine with Linux!
#### You are going to need to have [Homebrew](https://brew.sh/) installed

- Install dependencies

## :rocket: Compilation
```sh
brew install python3 sdl2 sdl2_image sdl2_ttf
```

#### To compile (and run) Aurora, you will have to use the `./compile.sh` script.
- Clone the repository
- Install python dependencies

```sh
cd aurora
./compile.sh <build-env> (args)
cd utilities
pip3 install -r requirements.txt
cd ../server
pip3 install -r requirements.txt
```

Build environments:
---

- `debug`
- `release`
## :rocket: Development

Arguments
```sh
./develop.sh <args>
```
#### This is just an alias to `python3 launcher/development.py`

- `-v` - Verbose mode (more debugging yay :cry:)
- `-dontRun` - By default, running the compile script will also run Aurora. If you want to stop that behaviour pass this argument.
- `-zip` - This will make a portable **.zip** file of the whole installation.

#### Example:
### Script Arguments:

Let's say you want to compile and run the debug environment with some extra info in case something breaks :boom:
| Argument | Short Argument | Description |
|----------|----------------|--------------|
|--verbose|-v|Verbose mode. Provides more debugging logs from mostly **cmake**|
|--port **PORT**|-p|The TCP port used for the internal server/client communication **(Default: 8000)**|
|--env **ENV**|-e|The environment to compile for. Mostly used for the client. Options: **"debug"** or **"release"**. **(Default: debug)**

```sh
./compile.sh debug -v
```

## :hammer_and_wrench: Support

Expand Down
16 changes: 14 additions & 2 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

file(GLOB_RECURSE SRC_LIST src/*.cpp src/*.c include/*.hpp include/*.h)

add_executable(${PROJECT_NAME} ${SRC_LIST})
target_include_directories(${PROJECT_NAME} PRIVATE "include")

# For mac os
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_include_directories(${PROJECT_NAME} PRIVATE "/usr/local/include")
endif()

# For windows networking
IF(WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE -lwsock32 -lWs2_32)
Expand All @@ -32,7 +37,14 @@ target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
target_compile_features(${PROJECT_NAME} PRIVATE c_std_11)

find_package(SDL2 REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2)

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(${PROJECT_NAME} PRIVATE ${SDL_LIBRARY})
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2)
endif()

# Fixes WinMain bug
add_definitions(-DSDL_MAIN_HANDLED)

Expand Down
9 changes: 7 additions & 2 deletions compile.sh → client/compile-deprecated.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
# Tested with (Ubuntu 21.04 w/ G++, Windows 10 w/ MSYS MinGW64)


# This script is old, please don't use it (Use the updated python one on ../launcher).
# I left it on purpose in the repo just to have as a guide if you're going down the path of trying to manually compile!
# On that note, good luck!

RED_COLOR='\033[0;31m'
GREEN_COLOR='\033[1;32m'
BLUE_COLOR='\033[1;34m'
Expand Down Expand Up @@ -42,11 +47,11 @@ fi

#clear

CLIENT_FOLDER_ENV="client/build-debug"
CLIENT_FOLDER_ENV="build-debug"
ENV="Debug"

if [[ "$1" == "release" ]]; then # Checks first argument: Compilation Environment - Release
CLIENT_FOLDER_ENV="client/build-release"
CLIENT_FOLDER_ENV="build-release"
ENV="Release"
fi

Expand Down
25 changes: 7 additions & 18 deletions client/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ int main(int argc, char* args[]) {
if(!TTF_WasInit() && TTF_Init() == -1) {
std::cout << "ERROR: TTF_Init has failed. TTF_ERROR: " << TTF_GetError() << std::endl;
}

RenderWindow window("Aurora v0.3.0", 1920, 1080);

//window.setFullScreen(true);
RenderWindow window("Aurora v0.3.1", 1280, 720);

int windowRefreshRate = window.getRefreshRate();

Expand All @@ -48,15 +46,6 @@ int main(int argc, char* args[]) {
int normalTransitionTime, spamTransitionTime, gameTitleFontSize;
std::string gameFontFamilyName;


auto createGameEntities = [&] (int num_of_entities) {
for (int i = 0; i < num_of_entities; i++) {
{

}
}
};

auto createGameEntity = [&] (int i, std::string name) {
const MultiSize normalGameDims(Size(i*(gameSizeNormal + (marginBetweenGames * 2) + selectedGameOffset) + gameOffset, SIZE_HEIGHT), Size(normalY, SIZE_HEIGHT), Size(gameSizeNormal, SIZE_HEIGHT), Size(gameSizeNormal, SIZE_HEIGHT) );
const MultiSize selectedGameDims(Size(gameOffset - selectedGameOffset, SIZE_HEIGHT), Size(normalY, SIZE_HEIGHT), Size(gameSizeSelected, SIZE_HEIGHT), Size(gameSizeSelected, SIZE_HEIGHT) );
Expand All @@ -69,7 +58,7 @@ int main(int argc, char* args[]) {

auto requestSteamGamesFromServer = [&] () {
try {
http::Request request{"http://127.0.0.1:8000/steam"};
http::Request request{"http://127.0.0.1:" + std::string(args[1]) + "/steam"};

const auto response = request.send("GET");
const std::string response_str = std::string{response.body.begin(), response.body.end()};
Expand Down Expand Up @@ -122,7 +111,7 @@ int main(int argc, char* args[]) {
int prevSelectedGame = 0;

Vector2f windowSize = window.getWindowDimensions();
std::cout << "Width: " << windowSize.x << ", Height: " << windowSize.y << std::endl << std::endl;
std::cout << "Width: " << windowSize.x << ", Height: " << windowSize.y << std::endl;

auto setGameTitleFont = [&] () {
font = TTF_OpenFont(gameFontFamilyName.c_str(), gameTitleFontSize);
Expand Down Expand Up @@ -188,10 +177,10 @@ int main(int argc, char* args[]) {
while(SDL_PollEvent(&event)){
switch(event.type) {
case SDL_QUIT:
readGameStyles();
animateGames();
setGameTitleFont();
//isGameRunning = false;
// readGameStyles();
// animateGames();
// setGameTitleFont();
isGameRunning = false;
break;

case SDL_JOYAXISMOTION:
Expand Down
10 changes: 8 additions & 2 deletions client/src/renderWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
#include "Text.hpp"
#include "Math.hpp"

#ifdef __APPLE__
#define RENDERING_ARGS NULL
#else
#define RENDERING_ARGS SDL_WINDOW_VULKAN
#endif

float calculateSize(Size value, Vector2f windowDimensions) {
return (value.val / 100) * (value.type == SIZE_HEIGHT ? windowDimensions.y : windowDimensions.x);
}

RenderWindow::RenderWindow(const char* p_title, int p_width, int p_height) :window(NULL), renderer(NULL), windowDims(Vector2f(p_width, p_height)) {
window = SDL_CreateWindow(p_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, p_width, p_height, SDL_WINDOW_SHOWN | SDL_WINDOW_VULKAN );//| SDL_WINDOW_FULLSCREEN_DESKTOP );
window = SDL_CreateWindow(p_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, p_width, p_height, SDL_WINDOW_SHOWN | RENDERING_ARGS );//| SDL_WINDOW_FULLSCREEN_DESKTOP );

if(window == NULL) {
std::cout << "Window has failed to init. Error: " << SDL_GetError() << std::endl;
Expand All @@ -32,7 +38,7 @@ RenderWindow::RenderWindow(const char* p_title, int p_width, int p_height) :wind
std::cout << "Fallback renderer has failed to init. Error: " << SDL_GetError() << std::endl;
}

SDL_ShowCursor(false); // Hides the cursor;
// SDL_ShowCursor(false); // Hides the cursor;
};

void RenderWindow::cleanUp() {
Expand Down
3 changes: 3 additions & 0 deletions develop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
python3 launcher/development.py "$@"

Loading

0 comments on commit 6f833a8

Please sign in to comment.