From c9bbae7292ec02625ac61fd16f1ee7735a86b8fa Mon Sep 17 00:00:00 2001 From: idea4good Date: Mon, 19 Aug 2019 15:26:36 +0800 Subject: [PATCH] add shell for merging GuiLite to 1 header & 1 cpp file --- 1h-1cpp.sh | 81 ++++++++++++++++++++++++++++++++++++++ core/adapter/api_linux.cpp | 2 +- core/adapter/api_win.cpp | 4 +- core/display.cpp | 2 +- core/theme.cpp | 2 +- widgets/keyboard.cpp | 2 +- widgets/spinbox.cpp | 2 +- 7 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 1h-1cpp.sh diff --git a/1h-1cpp.sh b/1h-1cpp.sh new file mode 100644 index 0000000..a148b35 --- /dev/null +++ b/1h-1cpp.sh @@ -0,0 +1,81 @@ +echo "Merge GuiLite source code into: 1 hearder & 1 source file" +echo "" +echo "Choose 1: Build for Linux" +echo "Choose 2: Build for Windows" +echo "Choose 3: Build for None OS or any OS" +echo "Choose 4: exit" + +read -p "Please input:[1-3]:" input + +# build GuiLite.h +cd core_include +cat api.h cmd_target.h rect.h msg.h resource.h theme.h surface.h display.h word.h bitmap.h wnd.h audio.h > core.h +mv core.h ../ + +cd ../widgets_include +cat button.h dialog.h keyboard.h edit.h gesture.h label.h list_box.h slide_group.h spinbox.h table.h wave_buffer.h wave_ctrl.h > widgets.h +mv widgets.h ../ + +cd .. +cat core.h widgets.h > GuiLiteRaw.h +rm core.h widgets.h + +# build GuiLite.cpp +cd core +cat *.cpp > core.cpp +mv core.cpp ../ +cd adapter + +while : +do + case $input in + 1) + echo "Choose 1" + cat *linux*.cpp > adapter_linux.cpp + break + ;; + 2) + echo "Choose 2" + cat *win*.cpp > adapter_linux.cpp + break + ;; + 3) + echo "Choose 3" + cat *unknow*.cpp > adapter_linux.cpp + break + ;; + *) + rm ../../GuiLiteRaw.h ../../core.cpp + exit 0 + ;; + esac +done + +mv adapter_linux.cpp ../../ + +cd ../../widgets +cat *.cpp > widgets.cpp +mv widgets.cpp ../ + +cd .. +cat core.cpp adapter_linux.cpp widgets.cpp > GuiLiteRaw.cpp +rm core.cpp adapter_linux.cpp widgets.cpp + +# remove include core_include widgets_include from GuiLite.cpp +sed '/^#include.*core_include\|widgets_include.*/d' GuiLiteRaw.cpp > GuiLiteNoInclude.cpp + +# include GuiLite.h to GuiLite.cpp +sed -i '1s/^/#include "GuiLite.h" /' GuiLiteNoInclude.cpp + +# Delete empty lines or blank lines +sed '/^$/d' GuiLiteRaw.h > GuiLite.h +sed '/^$/d' GuiLiteNoInclude.cpp > GuiLite.cpp + +# Verify +gcc -c GuiLite.cpp + +# clean +rm GuiLiteRaw.h GuiLiteRaw.cpp GuiLiteNoInclude.cpp + +echo "Done!" +echo "You could find GuiLite.h/GuiLite.cpp in this folder" diff --git a/core/adapter/api_linux.cpp b/core/adapter/api_linux.cpp index b54a556..77bca59 100644 --- a/core/adapter/api_linux.cpp +++ b/core/adapter/api_linux.cpp @@ -46,7 +46,7 @@ void log_out(const char* log) } else { - printf(log); + printf("%s", log); fflush(stdout); } } diff --git a/core/adapter/api_win.cpp b/core/adapter/api_win.cpp index e9880ce..59e633c 100644 --- a/core/adapter/api_win.cpp +++ b/core/adapter/api_win.cpp @@ -30,7 +30,7 @@ void _assert(const char* file, int line) memset(s_buf, 0, sizeof(s_buf)); sprintf_s(s_buf, sizeof(s_buf), "vvvvvvvvvvvvvvvvvvvvvvvvvvvv\n\nAssert@ file = %s, line = %d\n\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", file, line); OutputDebugStringA(s_buf); - printf(s_buf); + printf("%s", s_buf); fflush(stdout); assert(false); } @@ -44,7 +44,7 @@ void log_out(const char* log) } else { - printf(log); + printf("%s", log); fflush(stdout); OutputDebugStringA(log); } diff --git a/core/display.cpp b/core/display.cpp index 5767770..e239426 100644 --- a/core/display.cpp +++ b/core/display.cpp @@ -189,4 +189,4 @@ int c_display::snap_shot(const char* file_name) int ret = build_bmp(file_name, width, height, (unsigned char*)p_bmp565_data); delete []p_bmp565_data; return ret; -} \ No newline at end of file +} diff --git a/core/theme.cpp b/core/theme.cpp index cdcc5d8..7278058 100644 --- a/core/theme.cpp +++ b/core/theme.cpp @@ -68,4 +68,4 @@ const unsigned int c_theme::get_color(COLOR_TYPE index) return 0; } return s_color_map[index]; -} \ No newline at end of file +} diff --git a/widgets/keyboard.cpp b/widgets/keyboard.cpp index d9923f0..d096031 100644 --- a/widgets/keyboard.cpp +++ b/widgets/keyboard.cpp @@ -295,4 +295,4 @@ void c_keyboard_button::on_paint() letter[0] = m_resource_id; } c_word::draw_string_in_rect(m_surface, m_z_order, letter, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_attr); -} \ No newline at end of file +} diff --git a/widgets/spinbox.cpp b/widgets/spinbox.cpp index 3becbf6..f9b77dd 100644 --- a/widgets/spinbox.cpp +++ b/widgets/spinbox.cpp @@ -1,4 +1,4 @@ -#include "../core_include/api.h" +#include "../core_include/api.h" #include "../core_include/rect.h" #include "../core_include/cmd_target.h" #include "../core_include/wnd.h"