Skip to content

Commit

Permalink
Improved cmake info output
Browse files Browse the repository at this point in the history
  • Loading branch information
ducalex committed Aug 24, 2024
1 parent f8eba73 commit 2f3e994
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 72 deletions.
1 change: 0 additions & 1 deletion base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/components")

macro(rg_setup_compile_options)
set(RG_TARGET "RG_TARGET_${RG_BUILD_TARGET}")
message("Target: ${RG_TARGET}")

component_compile_options(
-D${RG_TARGET}
Expand Down
6 changes: 4 additions & 2 deletions build_sdl2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# Required: SDL2

CC="gcc"
CFLAGS="-no-pie -DRG_TARGET_SDL2 -DRETRO_GO -DCJSON_HIDE_SYMBOLS -DSDL_MAIN_HANDLED=1 -Dapp_main=SDL_Main $(sdl2-config --cflags)"
# BUILD_INFO="RG:$(git describe) / SDL:$(sdl2-config --version)"
CFLAGS="-no-pie -DRG_TARGET_SDL2 -DRETRO_GO -DCJSON_HIDE_SYMBOLS -DSDL_MAIN_HANDLED=1 -DRG_BUILD_INFO=\"SDL2\" -Dapp_main=SDL_Main $(sdl2-config --cflags)"
INCLUDES="-Icomponents/retro-go -Icomponents/retro-go/libs/cJSON -Icomponents/retro-go/libs/lodepng"
SRCFILES="components/retro-go/*.c components/retro-go/drivers/audio/*.c components/retro-go/fonts/*.c
components/retro-go/libs/cJSON/*.c components/retro-go/libs/lodepng/*.c"
Expand All @@ -26,6 +27,7 @@ $CC $CFLAGS $INCLUDES \
-Iretro-core/components/nofrendo \
-Iretro-core/components/pce-go \
-Iretro-core/components/snes9x \
-Iretro-core/components/snes9x/src \
-Iretro-core/components/smsplus \
-Iretro-core/main \
$SRCFILES \
Expand All @@ -38,7 +40,7 @@ $CC $CFLAGS $INCLUDES \
retro-core/components/nofrendo/nes/*.c \
retro-core/components/nofrendo/*.c \
retro-core/components/pce-go/*.c \
retro-core/components/snes9x/*.c \
retro-core/components/snes9x/src/*.c \
retro-core/components/smsplus/*.c \
retro-core/components/smsplus/cpu/*.c \
retro-core/components/smsplus/sound/*.c \
Expand Down
24 changes: 14 additions & 10 deletions components/retro-go/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
set(COMPONENT_SRCDIRS ". drivers/audio fonts libs/netplay libs/lodepng")
set(COMPONENT_ADD_INCLUDEDIRS ". libs/netplay libs/lodepng")

message(STATUS "ESP-IDF version: ${IDF_VER}")

if (IDF_VERSION_MAJOR EQUAL 5)
set(COMPONENT_REQUIRES "spi_flash fatfs app_update json nvs_flash esp_adc esp_timer esp_psram esp_wifi esp_http_client")
else() # esp-idf 4.1 - 4.4
Expand Down Expand Up @@ -36,19 +34,25 @@ if(RG_ENABLE_PROFILING)
component_compile_options(-DRG_ENABLE_PROFILING)
endif()

if(RG_BUILD_VERSION)
component_compile_options(-DRG_BUILD_VERSION="${RG_BUILD_VERSION}")
if(RG_PROJECT_VER)
component_compile_options(-DRG_PROJECT_VER="${RG_PROJECT_VER}")
endif()

if(RG_BUILD_RELEASE)
component_compile_options(-DRG_BUILD_RELEASE=1)
endif()

set(RG_TARGET "RG_TARGET_${RG_BUILD_TARGET}")
string(TIMESTAMP RG_TIME "%s")
if(RG_BUILD_TARGET)
component_compile_options(-D${RG_BUILD_TARGET})
endif()

set(RG_BUILD_INFO "${RG_BUILD_TARGET}-${RG_BUILD_RELEASE} GIT:${PROJECT_VER} SDK:${IDF_VER}")
string(TIMESTAMP RG_BUILD_TIME "%s")

message(STATUS "Target: ${RG_TARGET}")
message(STATUS "Time: ${RG_TIME}")
component_compile_options(-DRG_PROJECT_APP="${RG_PROJECT_APP}")
component_compile_options(-DRG_BUILD_INFO="${RG_BUILD_INFO}")
component_compile_options(-DRG_BUILD_TIME=${RG_BUILD_TIME})

component_compile_options(-DRG_BUILD_TIME=${RG_TIME})
component_compile_options(-D${RG_TARGET})
message(STATUS "RG_PROJECT_APP: ${RG_PROJECT_APP}")
message(STATUS "RG_PROJECT_VER: ${RG_PROJECT_VER}")
message(STATUS "RG_BUILD_INFO: ${RG_BUILD_INFO}")
70 changes: 33 additions & 37 deletions components/retro-go/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,16 @@
#define RG_TARGET_ODROID_GO
#endif

// #ifndef RG_ENABLE_NETPLAY
// #define RG_ENABLE_NETPLAY 0
// #endif

// #ifndef RG_ENABLE_PROFILING
// #define RG_ENABLE_PROFILING 0
// #endif

#ifndef RG_APP_LAUNCHER
#define RG_APP_LAUNCHER "launcher"
#endif

#ifndef RG_APP_FACTORY
#define RG_APP_FACTORY NULL
#endif

#ifndef RG_APP_UPDATER
#define RG_APP_UPDATER RG_APP_FACTORY
// #define RG_APP_UPDATER "updater"
#endif

#ifndef RG_PATH_MAX
#define RG_PATH_MAX 255
#endif

#ifndef RG_PROJECT_NAME
#define RG_PROJECT_NAME "Retro-Go"
#endif

#ifndef RG_PROJECT_APP
#define RG_PROJECT_APP "unknown"
#ifndef RG_PROJECT_WEBSITE
#define RG_PROJECT_WEBSITE "https://github.com/ducalex/retro-go"
#endif

#ifndef RG_PROJECT_VERSION
#define RG_PROJECT_VERSION RG_BUILD_VERSION
#ifndef RG_PROJECT_GITHUB_RELEASES
#define RG_PROJECT_GITHUB_RELEASES "https://api.github.com/repos/ducalex/retro-go/releases"
#endif

#ifndef RG_PROJECT_CREDITS
Expand All @@ -70,16 +45,16 @@
// What about targets/ports? Should we have a RG_TARGET_AUTHOR to append here?
#endif

#ifndef RG_PROJECT_WEBSITE
#define RG_PROJECT_WEBSITE "https://github.com/ducalex/retro-go"
#ifndef RG_PROJECT_APP
#define RG_PROJECT_APP "unknown"
#endif

#ifndef RG_PROJECT_RELEASES_URL
#define RG_PROJECT_RELEASES_URL "https://api.github.com/repos/ducalex/retro-go/releases"
#ifndef RG_PROJECT_VER
#define RG_PROJECT_VER "unknown"
#endif

#ifndef RG_BUILD_VERSION
#define RG_BUILD_VERSION "unknown"
#ifndef RG_BUILD_INFO
#define RG_BUILD_INFO "(none)"
#endif

#ifndef RG_BUILD_TIME
Expand All @@ -91,8 +66,29 @@
#define RG_BUILD_DATE __DATE__ " " __TIME__
#endif

#ifndef RG_BUILD_TOOL
#define RG_BUILD_TOOL "unknown"
// #ifndef RG_ENABLE_NETPLAY
// #define RG_ENABLE_NETPLAY 0
// #endif

// #ifndef RG_ENABLE_PROFILING
// #define RG_ENABLE_PROFILING 0
// #endif

#ifndef RG_APP_LAUNCHER
#define RG_APP_LAUNCHER "launcher"
#endif

#ifndef RG_APP_FACTORY
#define RG_APP_FACTORY NULL
#endif

#ifndef RG_APP_UPDATER
#define RG_APP_UPDATER RG_APP_FACTORY
// #define RG_APP_UPDATER "updater"
#endif

#ifndef RG_PATH_MAX
#define RG_PATH_MAX 255
#endif

#ifndef RG_RECOVERY_BTN
Expand Down
17 changes: 4 additions & 13 deletions components/retro-go/rg_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ rg_app_t *rg_system_init(int sampleRate, const rg_handlers_t *handlers, const rg

app = (rg_app_t){
.name = RG_PROJECT_APP,
.version = RG_PROJECT_VERSION,
.version = RG_PROJECT_VER,
.buildDate = RG_BUILD_DATE,
.buildTool = RG_BUILD_TOOL,
.buildInfo = RG_BUILD_INFO,
.configNs = RG_PROJECT_APP,
.bootArgs = NULL,
.bootFlags = 0,
Expand Down Expand Up @@ -376,22 +376,13 @@ rg_app_t *rg_system_init(int sampleRate, const rg_handlers_t *handlers, const rg
platform_init();

#if defined(ESP_PLATFORM)
const esp_app_desc_t *esp_app = esp_ota_get_app_description();
snprintf(app.name, sizeof(app.name), "%s", esp_app->project_name);
snprintf(app.version, sizeof(app.version), "%s", esp_app->version);
snprintf(app.buildDate, sizeof(app.buildDate), "%s %s", esp_app->date, esp_app->time);
snprintf(app.buildTool, sizeof(app.buildTool), "%s", esp_app->idf_ver);
esp_reset_reason_t r_reason = esp_reset_reason();
if (r_reason == ESP_RST_PANIC || r_reason == ESP_RST_TASK_WDT || r_reason == ESP_RST_INT_WDT)
app.bootType = RG_RST_PANIC;
else if (r_reason == ESP_RST_SW)
app.bootType = RG_RST_RESTART;
tasks[0] = (rg_task_t){.handle = xTaskGetCurrentTaskHandle(), .name = "main"};
#elif defined(RG_TARGET_SDL2)
SDL_version version;
SDL_GetVersion(&version);
snprintf(app.buildTool, sizeof(app.buildTool), "SDL2 %d.%d.%d / CC %s", version.major,
version.minor, version.patch, __VERSION__);
tasks[0] = (rg_task_t){.handle = SDL_ThreadID(), .name = "main"};
#endif

Expand Down Expand Up @@ -443,7 +434,7 @@ rg_app_t *rg_system_init(int sampleRate, const rg_handlers_t *handlers, const rg
app.bootFlags = rg_settings_get_number(NS_BOOT, SETTING_BOOT_FLAGS, 0);
app.saveSlot = (app.bootFlags & RG_BOOT_SLOT_MASK) >> 4;
app.romPath = app.bootArgs;
app.isLauncher = strcmp(app.name, "launcher") == 0; // Might be overriden after init
app.isLauncher = strcmp(app.name, RG_APP_LAUNCHER) == 0; // Might be overriden after init
app.indicatorsMask = rg_settings_get_number(NS_GLOBAL, SETTING_INDICATOR_MASK, app.indicatorsMask);

rg_display_init();
Expand Down Expand Up @@ -963,7 +954,7 @@ bool rg_system_save_trace(const char *filename, bool panic_trace)
fprintf(fp, "Application: %s (%s)\n", app.name, app.configNs);
fprintf(fp, "Version: %s\n", app.version);
fprintf(fp, "Build date: %s\n", app.buildDate);
fprintf(fp, "Toolchain: %s\n", app.buildTool);
fprintf(fp, "Build info: %s\n", app.buildInfo);
fprintf(fp, "Total memory: %d + %d\n", stats->totalMemoryInt, stats->totalMemoryExt);
fprintf(fp, "Free memory: %d + %d\n", stats->freeMemoryInt, stats->freeMemoryExt);
fprintf(fp, "Free block: %d + %d\n", stats->freeBlockInt, stats->freeBlockExt);
Expand Down
8 changes: 4 additions & 4 deletions components/retro-go/rg_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ typedef struct

typedef struct
{
char name[32];
char version[32];
char buildDate[32];
char buildTool[32];
const char *name;
const char *version;
const char *buildDate;
const char *buildInfo;
const char *configNs;
const char *bootArgs;
uint32_t bootFlags;
Expand Down
2 changes: 1 addition & 1 deletion gwenesis/components/gwenesis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(COMPONENT_SRCDIRS "src/bus src/cpus/M68K src/cpus/Z80 src/io src/savestate src/sound src/vdp")
set(COMPONENT_ADD_INCLUDEDIRS "src/bus src/cpus/M68K src/cpus/Z80 src/io src/savestate src/sound src/vdp")
set(COMPONENT_ADD_INCLUDEDIRS ". src/bus src/cpus/M68K src/cpus/Z80 src/io src/savestate src/sound src/vdp")
set(COMPONENT_REQUIRES "retro-go")
register_component()
rg_setup_compile_options(-O2 -Wno-incompatible-pointer-types)
2 changes: 1 addition & 1 deletion launcher/main/updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static rg_gui_event_t view_release_cb(rg_gui_option_t *option, rg_gui_event_t ev

void updater_show_dialog(void)
{
cJSON *releases_json = fetch_json(RG_PROJECT_RELEASES_URL);
cJSON *releases_json = fetch_json(RG_PROJECT_GITHUB_RELEASES);
if (!releases_json)
{
rg_gui_alert("Connection failed", "Make sure that you are online!");
Expand Down
6 changes: 3 additions & 3 deletions rg_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def build_app(app, device_type, with_profiling=False, no_networking=False, is_re
# To do: clean up if any of the flags changed since last build
print("Building app '%s'" % app)
args = [IDF_PY, "app"]
args.append(f"-DRG_BUILD_APP={app}")
args.append(f"-DRG_BUILD_VERSION={PROJECT_VER}")
args.append(f"-DRG_BUILD_TARGET={re.sub(r'[^A-Z0-9]', '_', device_type.upper())}")
args.append(f"-DRG_PROJECT_APP={app}")
args.append(f"-DRG_PROJECT_VER={PROJECT_VER}")
args.append(f"-DRG_BUILD_TARGET=RG_TARGET_{re.sub(r'[^A-Z0-9]', '_', device_type.upper())}")
args.append(f"-DRG_BUILD_RELEASE={1 if is_release else 0}")
args.append(f"-DRG_ENABLE_PROFILING={1 if with_profiling else 0}")
args.append(f"-DRG_ENABLE_NETWORKING={0 if no_networking else 1}")
Expand Down

0 comments on commit 2f3e994

Please sign in to comment.