Skip to content

Commit

Permalink
Migrate to abcg v3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hbatagelo committed Dec 26, 2023
1 parent 66bbc5a commit 5097057
Show file tree
Hide file tree
Showing 67 changed files with 13,546 additions and 9,876 deletions.
46 changes: 31 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get install cmake pkg-config
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
sudo apt-get install libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev libxcb-cursor-dev
sudo apt-get install python3 pip
pip install "conan<2.0"
- name: Install GCC
run: |
echo "CC=/usr/bin/gcc-12" >> $GITHUB_ENV
echo "CXX=/usr/bin/g++-12" >> $GITHUB_ENV
echo "CC=/usr/bin/gcc-13" >> $GITHUB_ENV
echo "CXX=/usr/bin/g++-13" >> $GITHUB_ENV
sudo update-alternatives --remove-all cc
sudo update-alternatives --remove-all c++
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get install -y gcc-12 g++-12
sudo update-alternatives --install /usr/bin/cc gcc /usr/bin/gcc-12 1000 \
--slave /usr/bin/c++ g++ /usr/bin/g++-12
sudo apt-get install -y gcc-13 g++-13
sudo update-alternatives --install /usr/bin/cc gcc /usr/bin/gcc-13 1000 \
--slave /usr/bin/c++ g++ /usr/bin/g++-13
- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
Expand All @@ -58,24 +58,40 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.11'
- run: |
python -m pip install --upgrade pip
pip install wheel
- name: Install dependencies
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
brew install glew sdl2 sdl2_image
- name: Install LLVM
run: |
echo "CC=/usr/local/cellar/llvm@16/16.0.6/bin/clang" >> $GITHUB_ENV
echo "CXX=/usr/local/cellar/llvm@16/16.0.6/bin/clang++" >> $GITHUB_ENV
brew install llvm@16
- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.60.1
version: 1.60.2

- name: Create default Conan profile
run: conan profile new default --detect

- name: Configure CMake with GCC
run: |
conan profile new default --detect
- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DCMAKE_C_COMPILER=${{env.CC}} -DCMAKE_CXX_COMPILER=${{env.CXX}} \
-DENABLE_UNIT_TESTING=ON
- name: Build
Expand Down Expand Up @@ -104,7 +120,7 @@ jobs:
- name: Install Conan
run: pip install "conan<2.0"

- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_UNIT_TESTING=ON
Expand All @@ -124,7 +140,7 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Install Emscripten
run: |
sudo apt-get install git cmake
Expand All @@ -135,7 +151,7 @@ jobs:
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
- name: Configure CMake
run: |
source ./emsdk/emsdk_env.sh
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![build workflow](https://github.com/hbatagelo/impvis2/actions/workflows/build.yml/badge.svg)
![build workflow](https://github.com/hbatagelo/impvis/actions/workflows/build.yml/badge.svg)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d27782d0396d4aeaa13dbe4abe9dd56a)](https://www.codacy.com/gh/hbatagelo/impvis/dashboard?utm_source=github.com\&utm_medium=referral\&utm_content=hbatagelo/impvis\&utm_campaign=Badge_Grade)
[![license](https://img.shields.io/github/license/hbatagelo/impvis)](https://github.com/hbatagelo/impvis/blob/main/LICENSE)

Expand Down Expand Up @@ -79,7 +79,7 @@ cd impvis

Make sure the following tools are installed and are reachable from the path:

* [Conan](https://conan.io/) 1.44 or later (not required for WebAssembly).
* [Conan](https://conan.io/) >=1.44, <2.0 (not required for WebAssembly). Conan 2.* is not supported yet.
* [CMake](https://cmake.org/) 3.18 or later.
* A C++ compiler with at least partial support to C++20 (tested with GCC 11, Clang 13, MSVC 17, and emcc 3.1).

Expand Down Expand Up @@ -119,6 +119,8 @@ cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
cmake --build . --config $BUILD_TYPE
```

**Note:** on macOS, if you encounter errors building with AppleClang, try Clang installed via HomeBrew.

### Building for WebAssembly

1. Install [Emscripten](https://emscripten.org/) and activate its environment variables.
Expand Down
46 changes: 23 additions & 23 deletions cmake/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(CONAN_IMPORTS "")

# fmt
set(CONAN_EXTRA_REQUIRES ${CONAN_EXTRA_REQUIRES} fmt/8.1.1)
set(CONAN_EXTRA_REQUIRES ${CONAN_EXTRA_REQUIRES} fmt/10.0.0)

# imGUI
set(CONAN_EXTRA_REQUIRES ${CONAN_EXTRA_REQUIRES} imgui/1.87)
set(CONAN_EXTRA_REQUIRES ${CONAN_EXTRA_REQUIRES} imgui/1.89.4)
set(CONAN_IMPORTS
${CONAN_IMPORTS} "./res/bindings, *.cpp -> ${CMAKE_SOURCE_DIR}/bindings"
"./res/bindings, *.h -> ${CMAKE_SOURCE_DIR}/bindings")
Expand All @@ -94,7 +94,7 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")

# SDL2
set(CONAN_EXTRA_REQUIRES ${CONAN_EXTRA_REQUIRES} sdl/2.26.5)
# set(CONAN_EXTRA_OPTIONS ${CONAN_EXTRA_OPTIONS} sdl*:alsa=False)
set(CONAN_EXTRA_OPTIONS ${CONAN_EXTRA_OPTIONS} sdl*:alsa=False)
set(CONAN_EXTRA_OPTIONS ${CONAN_EXTRA_OPTIONS} sdl*:pulse=False)
set(CONAN_EXTRA_OPTIONS ${CONAN_EXTRA_OPTIONS} sdl*:nas=False)
set(CONAN_EXTRA_OPTIONS ${CONAN_EXTRA_OPTIONS} sdl*:wayland=False)
Expand Down Expand Up @@ -172,26 +172,6 @@ if(ENABLE_MOLD)
endif()
endif()

# ccache
if(NOT MSVC)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten" OR NOT ${CMAKE_GENERATOR}
MATCHES "Ninja")
find_program(CCACHE ccache)
if(CCACHE)
message("Using ccache")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
else()
message("Not using ccache - not found")
endif()
else()
message("Not using ccache - disabled for Ninja builds with Emscripten")
endif()
elseif(${CMAKE_BUILD_TYPE} MATCHES "Debug")
# Silence warnings about linking the release DLL version of the CRT
# Third-party libraries are always compiled in release mode
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT")
endif()

# IPO
if(ENABLE_IPO)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.9)
Expand All @@ -213,5 +193,25 @@ if(ENABLE_IPO)
endif()
endif()

# ccache
if(NOT MSVC)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten" OR NOT ${CMAKE_GENERATOR}
MATCHES "Ninja")
find_program(CCACHE ccache)
if(CCACHE)
message("Using ccache")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
else()
message("Not using ccache - not found")
endif()
else()
message("Not using ccache - disabled for Ninja builds with Emscripten")
endif()
elseif(${CMAKE_BUILD_TYPE} MATCHES "Debug")
# Silence warnings about linking the release DLL version of the CRT
# Third-party libraries are always compiled in release mode
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT")
endif()

# ABCg
include(${CMAKE_CURRENT_LIST_DIR}/ABCg.cmake)
4 changes: 2 additions & 2 deletions external/abcg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(ABCG_FILES
abcgException.cpp
abcgImage.cpp
abcgTrackball.cpp
abcgUtil.cpp
abcgWindow.cpp
abcgOpenGLError.cpp
abcgOpenGLFunction.cpp
Expand Down Expand Up @@ -40,13 +41,12 @@ else()
set(IMGUI_BINDINGS_DIR "${CMAKE_SOURCE_DIR}/bindings")

add_library(
${PROJECT_NAME} ${ABCG_FILES} ${IMGUI_BINDINGS_DIR}/imgui_impl_sdl.cpp
${PROJECT_NAME} ${ABCG_FILES} ${IMGUI_BINDINGS_DIR}/imgui_impl_sdl2.cpp
${IMGUI_BINDINGS_DIR}/imgui_impl_opengl3.cpp)

target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${PROJECT_NAME} SYSTEM
PUBLIC ${IMGUI_BINDINGS_DIR})

target_link_libraries(
${PROJECT_NAME}
PUBLIC abcg_external
Expand Down
2 changes: 1 addition & 1 deletion external/abcg/abcg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* This file is part of ABCg (https://github.com/hbatagelo/abcg).
*
* @copyright (c) 2021--2022 Harlen Batagelo. All rights reserved.
* @copyright (c) 2021--2023 Harlen Batagelo. All rights reserved.
* This project is released under the MIT License.
*/

Expand Down
43 changes: 39 additions & 4 deletions external/abcg/abcgApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
*
* This file is part of ABCg (https://github.com/hbatagelo/abcg).
*
* @copyright (c) 2021--2022 Harlen Batagelo. All rights reserved.
* @copyright (c) 2021--2023 Harlen Batagelo. All rights reserved.
* This project is released under the MIT License.
*/

#include "abcgApplication.hpp"

#include <SDL_thread.h>
#include <SDL_image.h>

#include <span>

#include "SDL_image.h"
#include "abcgException.hpp"
#include "abcgWindow.hpp"

Expand Down Expand Up @@ -92,7 +92,7 @@ void abcg::Application::run(Window &window) {
auto done{false};
while (!done) {
mainLoopIterator(done);
};
}
#endif

m_window->templateDestroy();
Expand All @@ -103,6 +103,41 @@ void abcg::Application::run(Window &window) {
SDL_Quit();
}

/**
* @brief Returns the path to the application's assets directory, relative to
* the directory the executable is launched from.
*
* @return Path to the application's `assets` directory, relative to the
* location from which the application was launched. For example, the assets
* path will be `./app/assets/` if the application is located in `./app` and
* is launched from its parent directory. The assets path will be `./assets/`
* if the application is launched from the same directory of the executable.
*
* @remark The assets path is appended with the base path and ends with a
* forward slash.
*
* @sa abcg::Application::getBasePath
*/
std::string const &abcg::Application::getAssetsPath() noexcept {
return m_assetsPath;
}

/**
* @brief Returns the path to the application's directory, relative to the
* directory the executable is launched in.
*
* @return Path to the directory that contains the application executable,
* relative to the directory the executable is launched. For example, the base
* path will be `./app` if the executable is located in `./app` and is called
* from the parent directory. The base path will be `.` if the application is
* launched from the same directory of the executable.
*
* @remark The returned path does not end with a slash.
*/
std::string const &abcg::Application::getBasePath() noexcept {
return m_basePath;
}

void abcg::Application::mainLoopIterator([[maybe_unused]] bool &done) const {
SDL_Event event{};
while (SDL_PollEvent(&event) != 0) {
Expand Down
44 changes: 7 additions & 37 deletions external/abcg/abcgApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* This file is part of ABCg (https://github.com/hbatagelo/abcg).
*
* @copyright (c) 2021--2022 Harlen Batagelo. All rights reserved.
* @copyright (c) 2021--2023 Harlen Batagelo. All rights reserved.
* This project is released under the MIT License.
*/

Expand All @@ -14,8 +14,8 @@
#include <string>

#define ABCG_VERSION_MAJOR 3
#define ABCG_VERSION_MINOR 0
#define ABCG_VERSION_PATCH 0
#define ABCG_VERSION_MINOR 1
#define ABCG_VERSION_PATCH 1

/**
* @brief Root namespace.
Expand All @@ -40,38 +40,8 @@ class abcg::Application {

void run(Window &window);

/**
* @brief Returns the path to the application's assets directory, relative to
* the directory the executable is launched from.
*
* @return Path to the application's `assets` directory, relative to the
* location from which the application was launched. For example, the assets
* path will be `./app/assets/` if the application is located in `./app` and
* is launched from its parent directory. The assets path will be `./assets/`
* if the application is launched from the same directory of the executable.
*
* @remark The assets path is appended with the base path and ends with a
* forward slash.
*
* @sa abcg::Application::getBasePath
*/
[[nodiscard]] static std::string const &getAssetsPath() {
return m_assetsPath;
}

/**
* @brief Returns the path to the application's directory, relative to the
* directory the executable is launched in.
*
* @return Path to the directory that contains the application executable,
* relative to the directory the executable is launched. For example, the base
* path will be `./app` if the executable is located in `./app` and is called
* from the parent directory. The base path will be `.` if the application is
* launched from the same directory of the executable.
*
* @remark The returned path does not end with a slash.
*/
[[nodiscard]] static std::string const &getBasePath() { return m_basePath; }
static std::string const &getAssetsPath() noexcept;
static std::string const &getBasePath() noexcept;

private:
void mainLoopIterator(bool &done) const;
Expand All @@ -84,8 +54,8 @@ class abcg::Application {

// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
// See https://bugs.llvm.org/show_bug.cgi?id=48040
static inline std::string m_assetsPath{};
static inline std::string m_basePath{};
static inline std::string m_assetsPath;
static inline std::string m_basePath;
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
};

Expand Down
Loading

0 comments on commit 5097057

Please sign in to comment.