diff --git a/Makefile b/Makefile index 08b3a0f..b53f567 100644 --- a/Makefile +++ b/Makefile @@ -25,11 +25,13 @@ LDFLAGS += -static -no-pie -Wl,--gc-sections endif LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a -ifeq ($(DEV_BUILD),1) +ifeq ($(TUI),1) LIBS += $(DEP)/lib/libnewt.a $(DEP)/lib/libpopt.a $(DEP)/lib/libslang.a ifeq ($(TARGET_OS),Linux) LIBS += $(DEP)/lib/libgpm.a endif +endif +ifeq ($(DEV_BUILD),1) CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer ifeq ($(ASAN),1) BUILD_STYLE=ASAN diff --git a/include/kerninfo.h b/include/kerninfo.h index 477cae6..2df1407 100644 --- a/include/kerninfo.h +++ b/include/kerninfo.h @@ -70,7 +70,7 @@ // palerain host options #define host_option_dfuhelper_only (1 << 0) /* dfuhelper only */ #define host_option_pongo_exit (1 << 1) /* boot to clean pongo shell */ -#ifdef DEV_BUILD +#ifdef TUI #define host_option_tui (1 << 2) /* use terminal user interface */ #else #define host_option_res1 (1 << 2) /* reserved */ diff --git a/include/palerain.h b/include/palerain.h index 91b8ae6..17527df 100644 --- a/include/palerain.h +++ b/include/palerain.h @@ -149,7 +149,7 @@ typedef unsigned char niarelap_file_t[]; extern unsigned int verbose; extern char* pongo_path; -#ifdef DEV_BUILD +#ifdef TUI extern bool tui_started; #endif @@ -226,7 +226,7 @@ void io_stop(stuff_t *stuff); void print_credits(void); -#ifdef DEV_BUILD +#ifdef TUI #include newtComponent get_tui_log(); newtComponent set_tui_log(newtComponent co); diff --git a/include/tui.h b/include/tui.h index 0a9a241..bc61094 100644 --- a/include/tui.h +++ b/include/tui.h @@ -11,6 +11,7 @@ #include #include #include +#include #define WIDTH 76 #define HEIGHT 19 diff --git a/src/Makefile b/src/Makefile index 5c3c567..38fed06 100644 --- a/src/Makefile +++ b/src/Makefile @@ -49,9 +49,11 @@ CFLAGS += -DNO_CUSTOM_PONGO BUILD_OPTIONS += NO_CUSTOM_PONGO endif -ifeq ($(DEV_BUILD),1) +ifeq ($(TUI),1) OBJECTS += tui_screen_enter_recovery.o tui_screen_enter_dfu.o tui_main.o OBJECTS += tui_screen_jailbreak.o tui_screen_main.o tui_screen_options.o +BUILD_OPTIONS += TUI +CFLAGS += -DTUI endif CHECKRA1N_VERSION ?= 0.1337.1 diff --git a/src/lock_vars.c b/src/lock_vars.c index 7d7c906..270e685 100644 --- a/src/lock_vars.c +++ b/src/lock_vars.c @@ -30,7 +30,7 @@ #include pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex; -#ifdef DEV_BUILD +#ifdef TUI #include pthread_mutex_t tui_log_mutex; newtComponent tui_log_output = NULL; @@ -89,7 +89,7 @@ uint64_t set_ecid_wait_for_dfu(uint64_t ecid) { return ecid; } -#ifdef DEV_BUILD +#ifdef TUI newtComponent get_tui_log() { pthread_mutex_lock(&tui_log_mutex); newtComponent ret = tui_log_output; diff --git a/src/log.c b/src/log.c index 92e22d6..5c286f8 100644 --- a/src/log.c +++ b/src/log.c @@ -11,7 +11,7 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, const char *__restrict format, ...) { if (verbose >= 5 -#ifdef DEV_BUILD +#ifdef TUI && !checkrain_option_enabled(host_flags, host_option_tui) #endif ) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname); @@ -23,7 +23,7 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna va_start(args, format); if (verbose < (loglevel - 3) && loglevel > LOG_INFO) { if (verbose >= 5 -#ifdef DEV_BUILD +#ifdef TUI && !tui_started #endif ) fprintf(stderr, "p1_log: hid log with high log level (%d < %d)\n", verbose, loglevel - 3); @@ -61,7 +61,7 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna colour[0] = '\0'; colour_bold[0] = '\0'; } -#ifdef DEV_BUILD +#ifdef TUI if (checkrain_option_enabled(host_flags, host_option_tui) && tui_started) { newtComponent co = get_tui_log(); if (co == NULL) { diff --git a/src/main.c b/src/main.c index 91d8e1e..6fc3dc2 100644 --- a/src/main.c +++ b/src/main.c @@ -93,7 +93,7 @@ int build_checks(void) { return 0; } -#ifdef DEV_BUILD +#ifdef TUI bool tui_started = false; #endif @@ -114,7 +114,7 @@ int palera1n(int argc, char *argv[]) { if ((ret = optparse(argc, argv))) goto cleanup; if (!checkrain_option_enabled(host_flags, host_option_device_info)) if (checkrain_option_enabled(host_flags, host_option_palerain_version)) goto normal_exit; -#ifdef DEV_BUILD +#ifdef TUI if (checkrain_option_enabled(host_flags, host_option_tui)) { ret = tui(); if (ret) goto cleanup; diff --git a/src/optparse.c b/src/optparse.c index 371d431..42f36da 100644 --- a/src/optparse.c +++ b/src/optparse.c @@ -51,6 +51,8 @@ static struct option longopts[] = { #ifdef DEV_BUILD {"test1", no_argument, NULL, '1'}, {"test2", no_argument, NULL, '2'}, +#endif +#ifdef TUI {"tui", no_argument, NULL, 't'}, #endif {NULL, 0, NULL, 0} @@ -60,12 +62,15 @@ static int usage(int e, char* prog_name) { fprintf(stderr, "Usage: %s [-" - "DEhpvVldsSLtRnPI" + "DEhpvVldsSLRnPI" #ifdef DEV_BUILD "12" #endif #ifdef ROOTFUL "cfB" +#endif +#ifdef TUI + "t" #endif "] [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n file]\n" "Copyright (C) 2023, palera1n team, All Rights Reserved.\n\n" @@ -106,7 +111,7 @@ static int usage(int e, char* prog_name) "\t\tThis option can be repeated for extra verbosity.\n" "\t-V, --verbose-boot\t\t\tVerbose boot\n" -#ifdef DEV_BUILD +#ifdef TUI "\t-t, --tui\t\t\t\tTerminal user interface\n" #endif "\nEnvironmental variables:\n" @@ -277,10 +282,12 @@ int optparse(int argc, char* argv[]) { case 'S': host_flags |= host_option_no_colors; break; -#ifdef DEV_BUILD +#ifdef TUI case 't': host_flags |= host_option_tui; break; +#endif +#ifdef DEV_BUILD case '1': palerain_flags |= palerain_option_test1; break;