mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-26 04:17:50 +02:00
changes to the build system
This commit is contained in:
@ -6,20 +6,6 @@
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
#define DEV_BUILD
|
||||
|
||||
#define SDRPP_RESOURCE_DIR "/usr/local/"
|
||||
|
||||
#ifndef ROOT_DIR
|
||||
#ifdef DEV_BUILD
|
||||
#define ROOT_DIR "../root_dev"
|
||||
#elif _WIN32
|
||||
#define ROOT_DIR "."
|
||||
#else
|
||||
#define ROOT_DIR "/etc/sdrpp"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class ConfigManager {
|
||||
public:
|
||||
ConfigManager();
|
||||
@ -32,20 +18,11 @@ public:
|
||||
void aquire();
|
||||
void release(bool changed = false);
|
||||
|
||||
// static void setResourceDir(std::string path);
|
||||
// static std::string getResourceDir();
|
||||
|
||||
// static void setConfigDir(std::string path);
|
||||
// static std::string getConfigDir();
|
||||
|
||||
json conf;
|
||||
|
||||
private:
|
||||
static void autoSaveWorker(ConfigManager* _this);
|
||||
|
||||
//static std::string resDir;
|
||||
//static std::string configDir;
|
||||
|
||||
std::string path = "";
|
||||
bool changed = false;
|
||||
bool autoSaveEnabled = false;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <stb_image.h>
|
||||
#include <config.h>
|
||||
#include <core.h>
|
||||
#include <options.h>
|
||||
#include <duktape/duktape.h>
|
||||
#include <duktape/duk_console.h>
|
||||
|
||||
@ -63,16 +64,19 @@ duk_ret_t test_func(duk_context *ctx) {
|
||||
}
|
||||
|
||||
// main
|
||||
int sdrpp_main() {
|
||||
int sdrpp_main(int argc, char *argv[]) {
|
||||
#ifdef _WIN32
|
||||
//FreeConsole();
|
||||
// ConfigManager::setResourceDir("./res");
|
||||
// ConfigManager::setConfigDir(".");
|
||||
#endif
|
||||
|
||||
|
||||
spdlog::info("SDR++ v" VERSION_STR);
|
||||
|
||||
// Load default options and parse command line
|
||||
options::loadDefaults();
|
||||
if (!options::parse(argc, argv)) { return -1; }
|
||||
|
||||
// ======== DEFAULT CONFIG ========
|
||||
json defConfig;
|
||||
defConfig["bandColors"]["amateur"] = "#FF0000FF";
|
||||
@ -114,8 +118,8 @@ int sdrpp_main() {
|
||||
defConfig["windowSize"]["w"] = 1280;
|
||||
|
||||
// Load config
|
||||
spdlog::info("Loading config");
|
||||
core::configManager.setPath(ROOT_DIR "/config.json");
|
||||
spdlog::info("Loading config {0}");
|
||||
core::configManager.setPath(options::opts.root + "/config.json");
|
||||
core::configManager.load(defConfig);
|
||||
core::configManager.enableAutoSave();
|
||||
|
||||
@ -153,7 +157,7 @@ int sdrpp_main() {
|
||||
|
||||
// Load app icon
|
||||
GLFWimage icons[10];
|
||||
icons[0].pixels = stbi_load(((std::string)(ROOT_DIR "/res/icons/sdrpp.png")).c_str(), &icons[0].width, &icons[0].height, 0, 4);
|
||||
icons[0].pixels = stbi_load(((std::string)(options::opts.root + "/res/icons/sdrpp.png")).c_str(), &icons[0].width, &icons[0].height, 0, 4);
|
||||
icons[1].pixels = (unsigned char*)malloc(16 * 16 * 4); icons[1].width = icons[1].height = 16;
|
||||
icons[2].pixels = (unsigned char*)malloc(24 * 24 * 4); icons[2].width = icons[2].height = 24;
|
||||
icons[3].pixels = (unsigned char*)malloc(32 * 32 * 4); icons[3].width = icons[3].height = 32;
|
||||
@ -204,11 +208,11 @@ int sdrpp_main() {
|
||||
|
||||
LoadingScreen::show("Loading band plans");
|
||||
spdlog::info("Loading band plans");
|
||||
bandplan::loadFromDir(ROOT_DIR "/bandplans");
|
||||
bandplan::loadFromDir(options::opts.root + "/bandplans");
|
||||
|
||||
LoadingScreen::show("Loading band plan colors");
|
||||
spdlog::info("Loading band plans color table");
|
||||
bandplan::loadColorTable(ROOT_DIR "/band_colors.json");
|
||||
bandplan::loadColorTable(options::opts.root + "/band_colors.json");
|
||||
|
||||
windowInit();
|
||||
|
||||
|
@ -12,4 +12,4 @@ namespace core {
|
||||
void setInputSampleRate(double samplerate);
|
||||
};
|
||||
|
||||
int sdrpp_main();
|
||||
int sdrpp_main(int argc, char *argv[]);
|
@ -2,6 +2,7 @@
|
||||
#include <stdint.h>
|
||||
#include <GL/glew.h>
|
||||
#include <config.h>
|
||||
#include <options.h>
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include <imgui/stb_image.h>
|
||||
@ -31,13 +32,13 @@ namespace icons {
|
||||
}
|
||||
|
||||
void load() {
|
||||
LOGO = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/sdrpp.png");
|
||||
PLAY = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/play.png");
|
||||
STOP = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/stop.png");
|
||||
MENU = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/menu.png");
|
||||
MUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/muted.png");
|
||||
UNMUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/unmuted.png");
|
||||
NORMAL_TUNING = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/normal_tuning.png");
|
||||
CENTER_TUNING = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/center_tuning.png");
|
||||
LOGO = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/sdrpp.png");
|
||||
PLAY = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/play.png");
|
||||
STOP = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/stop.png");
|
||||
MENU = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/menu.png");
|
||||
MUTED = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/muted.png");
|
||||
UNMUTED = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/unmuted.png");
|
||||
NORMAL_TUNING = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/normal_tuning.png");
|
||||
CENTER_TUNING = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/center_tuning.png");
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@
|
||||
#include <filesystem>
|
||||
#include <signal_path/source.h>
|
||||
#include <gui/dialogs/loading_screen.h>
|
||||
#include <options.h>
|
||||
|
||||
// const int FFTSizes[] = {
|
||||
// 65536,
|
||||
@ -143,8 +144,8 @@ void windowInit() {
|
||||
spdlog::info("Loading modules");
|
||||
|
||||
// Load modules from /module directory
|
||||
if (std::filesystem::is_directory(ROOT_DIR "/modules")) {
|
||||
for (const auto & file : std::filesystem::directory_iterator(ROOT_DIR "/modules")) {
|
||||
if (std::filesystem::is_directory(options::opts.root + "/modules")) {
|
||||
for (const auto & file : std::filesystem::directory_iterator(options::opts.root + "/modules")) {
|
||||
std::string path = file.path().generic_string();
|
||||
if (file.path().extension().generic_string() != SDRPP_MOD_EXTENTSION) {
|
||||
continue;
|
||||
@ -595,7 +596,6 @@ void drawWindow() {
|
||||
gui::waterfall.setWaterfallMin(fftMin);
|
||||
gui::waterfall.setWaterfallMax(fftMax);
|
||||
|
||||
|
||||
ImGui::End();
|
||||
|
||||
if (showCredits) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <config.h>
|
||||
#include <options.h>
|
||||
|
||||
namespace style {
|
||||
ImFont* baseFont;
|
||||
@ -16,9 +17,9 @@ namespace style {
|
||||
ImGui::GetStyle().PopupRounding = 0.0f;
|
||||
ImGui::GetStyle().ScrollbarRounding = 0.0f;
|
||||
|
||||
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
|
||||
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 42.0f);
|
||||
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
||||
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
|
||||
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 42.0f);
|
||||
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
||||
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsLight();
|
||||
@ -36,9 +37,9 @@ namespace style {
|
||||
ImGui::GetStyle().PopupRounding = 0.0f;
|
||||
ImGui::GetStyle().ScrollbarRounding = 0.0f;
|
||||
|
||||
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
|
||||
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 42.0f);
|
||||
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(ROOT_DIR "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
||||
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
|
||||
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 42.0f);
|
||||
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
||||
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
|
@ -1,7 +1,29 @@
|
||||
#include <options.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
namespace options {
|
||||
void parse(char** argv, int argc) {
|
||||
|
||||
CMDLineOptions opts;
|
||||
|
||||
void loadDefaults() {
|
||||
#ifdef _WIN32
|
||||
opts.root = ".";
|
||||
#else
|
||||
opts.root = "~/.sdrpp/";
|
||||
#endif
|
||||
}
|
||||
|
||||
bool parse(int argc, char *argv[]) {
|
||||
for (int i = 1; i < argc; i++) {
|
||||
char* arg = argv[i];
|
||||
if (!strcmp(arg, "-r") || !strcmp(arg, "--root")) {
|
||||
if (i == argc - 1) { return false; }
|
||||
opts.root = argv[++i];
|
||||
}
|
||||
else {
|
||||
spdlog::error("Invalid command line option: {0}", arg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <new_module.h>
|
||||
|
||||
namespace options {
|
||||
struct CMDLineOptions {
|
||||
std::string root;
|
||||
bool help;
|
||||
};
|
||||
|
||||
CMDLineOptions opts;
|
||||
SDRPP_EXPORT CMDLineOptions opts;
|
||||
|
||||
void parse(char** argv, int argc);
|
||||
}
|
||||
void loadDefaults();
|
||||
bool parse(int argc, char *argv[]);
|
||||
}
|
Reference in New Issue
Block a user