Skip to content

Commit

Permalink
GCC 10 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
complexlogic committed May 10, 2022
1 parent 6733536 commit e47cc0d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v2.0 (2022-5-8)
v2.0 (2022-5-10)
- Changed project name to rsgain
- Added "Easy Mode" with recursive directory scanning. Old command line syntax now known as "Custom Mode"
- Added multithreaded scanning
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ project(
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 20)
set(EXECUTABLE_TITLE "rsgain")

# GCC 9 and earlier are not supported due to C++20 features
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10)
message(FATAL_ERROR "GCC 10 and later supported only")
endif ()

configure_file(
"${PROJECT_SOURCE_DIR}/config/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
Expand Down Expand Up @@ -166,7 +172,7 @@ else ()
if (NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
endif()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libavcodec58 (>= 4.2.4), libavutil56 (>= 4.2.4), libswresample3 (>= 4.2.4), libavformat58 (>= 4.2.4), libtag1v5 (>= 1.11.1), libebur128-1 (>=1.2.4), libc6 (>=2.29)")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libavcodec58 (>= 4.2.4), libavutil56 (>= 4.2.4), libswresample3 (>= 4.2.4), libavformat58 (>= 4.2.4), libtag1v5 (>= 1.11.1), libebur128-1 (>=1.2.4), libc6 (>=2.29), libstdc++6 (>=10.2)")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "complexlogic")
set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar")
Expand Down
7 changes: 6 additions & 1 deletion docs/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ rsgain builds natively on Unix and Windows, and features a cross-platform CMake
+ libavutil
- inih

rsgain uses a few C++20 features, and as such requires a relatively modern compiler to build:
- On Windows, use Visual Studio 2022
- On Linux, use GCC 11 or later if possible. rsgain will also build with GCC 10, but the time elapsed statistical output will be disabled (no effect on core functionality). GCC versions 9 and earlier are not supported.
- On macOS, the latest available Xcode for your machine should work.

## Unix
Before starting, make sure you have the build tools Git, CMake, pkg-config, and GCC installed.
Before starting, make sure you have the build tools Git, CMake and pkg-config installed.

Install the required dependencies:

Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ if (WIN32)
add_executable(${EXECUTABLE_TITLE} "rsgain.c" "scan.cpp" "output.c" "tag.cpp" "easymode.cpp" "${PROJECT_BINARY_DIR}/rsgain.manifest")
else()
add_executable(${EXECUTABLE_TITLE} "rsgain.c" "scan.cpp" "output.c" "tag.cpp" "easymode.cpp")

# GCC 10 requires linking with pthread for some reason
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
target_link_libraries(${EXECUTABLE_TITLE} pthread)
endif ()
endif()
set (EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}")

Expand Down
6 changes: 5 additions & 1 deletion src/easymode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,8 @@ void scan_easy(const char *directory, const char *overrides_file)
}
output(COLOR_GREEN "Scanning Complete" COLOR_OFF "\n");

// Calculate time
// Calculate time (not available in GCC 10 and earlier)
#if CALC_TIME
std::string time_string;
std::chrono::hh_mm_ss elapsed(end_time - start_time);
int h = elapsed.hours().count();
Expand All @@ -625,14 +626,17 @@ void scan_easy(const char *directory, const char *overrides_file)
else {
time_string = std::to_string(s) + "s";
}
#endif

// Format file total string
std::stringstream ss;
ss.imbue(std::locale(""));
ss << std::fixed << total_files;

output(COLOR_YELLOW "Files Scanned:" COLOR_OFF " %s\n", ss.str().c_str());
#if CALC_TIME
output(COLOR_YELLOW "Time Elapsed:" COLOR_OFF " %s\n", time_string.c_str());
#endif
output("\n");

// Inform user of errors
Expand Down
11 changes: 11 additions & 0 deletions src/easymode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
#include <mutex>
#include <condition_variable>

#ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if GCC_VERSION > 110000
#define CALC_TIME 1
#else
#define CALC_TIME 0
#endif
#else
#define CALC_TIME 1
#endif

typedef enum {
INVALID = -1,
MP2,
Expand Down

0 comments on commit e47cc0d

Please sign in to comment.