Skip to content

Commit

Permalink
refactor: make config.h private
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Oct 7, 2019
1 parent d827767 commit f9ecdb7
Show file tree
Hide file tree
Showing 30 changed files with 196 additions and 158 deletions.
4 changes: 2 additions & 2 deletions build/windows/LCUI/LCUI.vcxproj
Expand Up @@ -121,7 +121,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>LCUI_EXPORTS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)$(ProjectName)\;$(SolutionDir)..\..\include\;$(SolutionDir)..\..\lcpkg\installed\$(PlatformTarget)-windows\include\;$(SolutionDir)..\..\lcpkg\installed\$(PlatformTarget)-windows\include\libxml2-lite\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)$(ProjectName)\;$(SolutionDir)..\..\include\;$(SolutionDir)..\..\include\LCUI\;$(SolutionDir)..\..\lcpkg\installed\$(PlatformTarget)-windows\include\;$(SolutionDir)..\..\lcpkg\installed\$(PlatformTarget)-windows\include\libxml2-lite\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<DisableSpecificWarnings>4819;4244;4996;</DisableSpecificWarnings>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
Expand Down Expand Up @@ -155,7 +155,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>LCUI_EXPORTS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)$(ProjectName)\;$(SolutionDir)..\..\include\;$(SolutionDir)..\..\lcpkg\installed\$(PlatformTarget)-windows\include\;$(SolutionDir)..\..\lcpkg\installed\$(PlatformTarget)-windows\include\libxml2-lite\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)$(ProjectName)\;$(SolutionDir)..\..\include\;$(SolutionDir)..\..\include\LCUI\;$(SolutionDir)..\..\lcpkg\installed\$(PlatformTarget)-windows\include\;$(SolutionDir)..\..\lcpkg\installed\$(PlatformTarget)-windows\include\libxml2-lite\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<DisableSpecificWarnings>4819;4244;4996;</DisableSpecificWarnings>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
Expand Down
2 changes: 1 addition & 1 deletion include/LCUI/Makefile.am
Expand Up @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS=foreign
SUBDIRS=font draw gui util
##一些需要安装的头文件
# Headers which are installed to support the library
INSTINCLUDES=LCUI.h config.h types.h painter.h display.h graph.h draw.h \
INSTINCLUDES=LCUI.h types.h painter.h display.h graph.h draw.h \
font.h surface.h ime.h input.h thread.h util.h timer.h main.h cursor.h \
image.h worker.h
EXTRA_DIST=platform.h \
Expand Down
40 changes: 40 additions & 0 deletions include/LCUI/config.win32.h.in
@@ -0,0 +1,40 @@
/* Name of package */
#define PACKAGE "lcui"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "lc-soft@live.cn"

/* Define to the full name of this package. */
#define PACKAGE_NAME "LCUI"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "LCUI 1.3.0"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "lcui"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "1.3.0"

/* Define to 1 if you enabled LCUIBuilder function module. */
#define USE_LCUI_BUILDER 1

/* Define to 1 if you have the libjpeg */
#define USE_LIBJPEG 1

/* Define to 1 if you have the libpng. */
#define USE_LIBPNG 1

/* Version number of package */
#define VERSION "1.3.0"

#define LCUI_THREAD_WIN32
#define LCUI_VIDEO_DRIVER_WIN32
#define LCUI_FONT_ENGINE_FREETYPE
#define USE_LIBPNG
#define USE_LIBJPEG
#define USE_LCUI_BUILDER
#define ENABLE_TOUCH_SUPPORT
92 changes: 44 additions & 48 deletions include/LCUI/platform.h
Expand Up @@ -31,55 +31,51 @@
#ifndef LCUI_PLATFORM_H
#define LCUI_PLATFORM_H

#ifdef LCUI_BUILD_IN_WIN32
#ifdef WINAPI_FAMILY_APP
#define LCUI_CreateAppDriver() NULL
#define LCUI_DestroyAppDriver(X) NULL
#define LCUI_PreInitApp() NULL
#define LCUI_CreateDisplayDriver() NULL
#define LCUI_DestroyDisplayDriver(X) NULL
#define LCUI_InitMouseDriver()
#define LCUI_FreeMouseDriver()
#define LCUI_InitKeyboardDriver()
#define LCUI_FreeKeyboardDriver()
#ifdef _WIN32
#ifdef WINAPI_FAMILY_APP
#define LCUI_CreateAppDriver() NULL
#define LCUI_DestroyAppDriver(X) NULL
#define LCUI_PreInitApp() NULL
#define LCUI_CreateDisplayDriver() NULL
#define LCUI_DestroyDisplayDriver(X) NULL
#define LCUI_InitMouseDriver()
#define LCUI_FreeMouseDriver()
#define LCUI_InitKeyboardDriver()
#define LCUI_FreeKeyboardDriver()
#else
#define LCUI_CreateAppDriver LCUI_CreateWinAppDriver
#define LCUI_DestroyAppDriver LCUI_DestroyWinAppDriver
#define LCUI_PreInitApp LCUI_PreInitWinApp
#define LCUI_CreateDisplayDriver LCUI_CreateWinDisplay
#define LCUI_DestroyDisplayDriver LCUI_DestroyWinDisplay
#define LCUI_InitMouseDriver LCUI_InitWinMouse
#define LCUI_FreeMouseDriver LCUI_FreeWinMouse
#define LCUI_InitKeyboardDriver LCUI_InitWinKeyboard
#define LCUI_FreeKeyboardDriver LCUI_FreeWinKeyboard
#endif
#if defined(WINAPI_PARTITION_APP)
#define LCUI_APP_H <LCUI/platform/windows/uwp.h>
#else
#define LCUI_EVENTS_H <LCUI/platform/windows/windows_events.h>
#define LCUI_MOUSE_H <LCUI/platform/windows/windows_mouse.h>
#define LCUI_KEYBOARD_H <LCUI/platform/windows/windows_keyboard.h>
#define LCUI_DISPLAY_H <LCUI/platform/windows/windows_display.h>
#endif
#else
#define LCUI_CreateAppDriver LCUI_CreateWinAppDriver
#define LCUI_DestroyAppDriver LCUI_DestroyWinAppDriver
#define LCUI_PreInitApp LCUI_PreInitWinApp
#define LCUI_CreateDisplayDriver LCUI_CreateWinDisplay
#define LCUI_DestroyDisplayDriver LCUI_DestroyWinDisplay
#define LCUI_InitMouseDriver LCUI_InitWinMouse
#define LCUI_FreeMouseDriver LCUI_FreeWinMouse
#define LCUI_InitKeyboardDriver LCUI_InitWinKeyboard
#define LCUI_FreeKeyboardDriver LCUI_FreeWinKeyboard
#endif
#if defined(WINAPI_PARTITION_APP)
#define LCUI_APP_H <LCUI/platform/windows/uwp.h>
#else
#define LCUI_EVENTS_H <LCUI/platform/windows/windows_events.h>
#define LCUI_MOUSE_H <LCUI/platform/windows/windows_mouse.h>
#define LCUI_KEYBOARD_H <LCUI/platform/windows/windows_keyboard.h>
#define LCUI_DISPLAY_H <LCUI/platform/windows/windows_display.h>
#endif
#elif defined(LCUI_BUILD_IN_LINUX)
#define LCUI_CreateAppDriver LCUI_CreateLinuxAppDriver
#define LCUI_DestroyAppDriver LCUI_DestroyLinuxAppDriver
#define LCUI_PreInitApp LCUI_PreInitLinuxApp
#define LCUI_CreateDisplayDriver LCUI_CreateLinuxDisplayDriver
#define LCUI_DestroyDisplayDriver LCUI_DestroyLinuxDisplayDriver
#define LCUI_InitMouseDriver LCUI_InitLinuxMouse
#define LCUI_FreeMouseDriver LCUI_FreeLinuxMouse
#define LCUI_InitKeyboardDriver LCUI_InitLinuxKeyboard
#define LCUI_FreeKeyboardDriver LCUI_FreeLinuxKeyboard
#ifdef linux
#undef linux
#endif
#define LCUI_EVENTS_H <LCUI/platform/linux/linux_events.h>
#define LCUI_MOUSE_H <LCUI/platform/linux/linux_mouse.h>
#define LCUI_KEYBOARD_H <LCUI/platform/linux/linux_keyboard.h>
#define LCUI_DISPLAY_H <LCUI/platform/linux/linux_display.h>
#else
#error current platform is not supported.
#undef linux
#define LCUI_CreateAppDriver LCUI_CreateLinuxAppDriver
#define LCUI_DestroyAppDriver LCUI_DestroyLinuxAppDriver
#define LCUI_PreInitApp LCUI_PreInitLinuxApp
#define LCUI_CreateDisplayDriver LCUI_CreateLinuxDisplayDriver
#define LCUI_DestroyDisplayDriver LCUI_DestroyLinuxDisplayDriver
#define LCUI_InitMouseDriver LCUI_InitLinuxMouse
#define LCUI_FreeMouseDriver LCUI_FreeLinuxMouse
#define LCUI_InitKeyboardDriver LCUI_InitLinuxKeyboard
#define LCUI_FreeKeyboardDriver LCUI_FreeLinuxKeyboard
#define LCUI_EVENTS_H <LCUI/platform/linux/linux_events.h>
#define LCUI_MOUSE_H <LCUI/platform/linux/linux_mouse.h>
#define LCUI_KEYBOARD_H <LCUI/platform/linux/linux_keyboard.h>
#define LCUI_DISPLAY_H <LCUI/platform/linux/linux_display.h>
#endif

#endif
14 changes: 5 additions & 9 deletions include/LCUI/thread.h
Expand Up @@ -31,20 +31,16 @@
#ifndef LCUI_THREAD_H
#define LCUI_THREAD_H

#ifdef LCUI_THREAD_PTHREAD
#include <pthread.h>
typedef pthread_t LCUI_Thread;
typedef pthread_mutex_t LCUI_Mutex;
typedef pthread_cond_t LCUI_Cond;
#else
#ifdef LCUI_THREAD_WIN32
#ifdef _WIN32
#include <windows.h>
typedef HANDLE LCUI_Mutex;
typedef HANDLE LCUI_Cond;
typedef unsigned int LCUI_Thread;
#else
#error 'Need thread implementation for this platform'
#endif
#include <pthread.h>
typedef pthread_t LCUI_Thread;
typedef pthread_mutex_t LCUI_Mutex;
typedef pthread_cond_t LCUI_Cond;
#endif

LCUI_BEGIN_HEADER
Expand Down
9 changes: 3 additions & 6 deletions include/LCUI/util/dirent.h
Expand Up @@ -33,7 +33,7 @@

LCUI_BEGIN_HEADER

#if defined (LCUI_BUILD_IN_WIN32) || (_WIN32)
#ifdef _WIN32
#include <Windows.h>
typedef HANDLE LCUI_DirHandle;
typedef union LCUI_DirEntry_ {
Expand All @@ -42,8 +42,7 @@ typedef union LCUI_DirEntry_ {
} LCUI_DirEntry;

#define PATH_DELIMITER '\\'

#elif defined(LCUI_BUILD_IN_LINUX)
#else
#include <dirent.h>
#define LCUI_DIRENT_NAME_LEN 256

Expand All @@ -55,8 +54,6 @@ typedef struct LCUI_DirEntry_ {

#define PATH_DELIMITER '/'

#else
#error 'Does not support your platform!'
#endif

typedef struct LCUI_Dir_ {
Expand All @@ -65,7 +62,7 @@ typedef struct LCUI_Dir_ {
int cached;
} LCUI_Dir;

#if defined (LCUI_BUILD_IN_LINUX) || _UNICODE
#if defined(_UNICODE) || !defined(_WIN32)
#define LCUI_OpenDir LCUI_OpenDirW
#define LCUI_ReadDir LCUI_ReadDirW
#define LCUI_GetFileName LCUI_GetFileNameW
Expand Down
29 changes: 7 additions & 22 deletions include/LCUI_Build.h
Expand Up @@ -40,12 +40,19 @@
#define LCUI_API
#endif
#endif /* compiler */

#if defined(WIN32) && !defined(__cplusplus)
#define INLINE __inline
#else
#define INLINE static inline
#endif

#if defined(WIN32) || defined(_WIN32)
#define LCUI_BUILD_IN_WIN32
#else
#define LCUI_BUILD_IN_LINUX
#endif

#ifdef DEBUG
#define DEBUG_MSG _DEBUG_MSG
#else
Expand All @@ -56,28 +63,6 @@
Logger_Log(LOGGER_LEVEL_DEBUG, __FILE__ " %d: %s(): " format, \
__LINE__, __FUNCTION__, ##__VA_ARGS__)

#if defined(WIN32) || defined(_WIN32)
#define LCUI_BUILD_IN_WIN32
#define LCUI_THREAD_WIN32
#define LCUI_VIDEO_DRIVER_WIN32
#define LCUI_FONT_ENGINE_FREETYPE
#define USE_LIBPNG
#define USE_LIBJPEG
#define USE_LCUI_BUILDER
#define ENABLE_TOUCH_SUPPORT
#undef LCUI_THREAD_PTHREAD
#undef LCUI_VIDEO_DRIVER_FRAMEBUFFER
#define PACKAGE_VERSION "1.3.0"
#else
#include <LCUI/config.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#define LCUI_BUILD_IN_LINUX
#define LCUI_KEYBOARD_DRIVER_LINUX
#define LCUI_MOUSE_DRIVER_LINUX
#endif

#ifdef __cplusplus
#define LCUI_BEGIN_HEADER extern "C" {
#define LCUI_END_HEADER }
Expand Down
1 change: 1 addition & 0 deletions src/font/fontlibrary.c
Expand Up @@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 2 additions & 2 deletions src/font/freetype.c
@@ -1,7 +1,7 @@
/*
* freetype.c -- The FreeType font-engine support module.
*
* Copyright (c) 2018, Liu chao <lc-soft@live.cn> All rights reserved.
* Copyright (c) 2018-2019, Liu chao <lc-soft@live.cn> All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand All @@ -28,7 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/


#include "config.h"
#include <LCUI_Build.h>
#ifdef LCUI_FONT_ENGINE_FREETYPE
#include <LCUI/types.h>
Expand Down
1 change: 1 addition & 0 deletions src/gui/builder.c
Expand Up @@ -31,6 +31,7 @@
#include <stdio.h>
#include <string.h>
#include <LCUI_Build.h>
#include "config.h"
#include <LCUI/LCUI.h>
#include <LCUI/font.h>
#include <LCUI/gui/widget.h>
Expand Down
1 change: 1 addition & 0 deletions src/image/jpeg.c
Expand Up @@ -32,6 +32,7 @@
#include <stdlib.h>
#include <errno.h>
#include <LCUI_Build.h>
#include "config.h"
#include <LCUI/types.h>
#include <LCUI/util/logger.h>
#include <LCUI/graph.h>
Expand Down
1 change: 1 addition & 0 deletions src/image/png.c
Expand Up @@ -32,6 +32,7 @@
#include <stdlib.h>
#include <errno.h>
#include <LCUI_Build.h>
#include "config.h"
#include <LCUI/types.h>
#include <LCUI/util.h>

Expand Down
1 change: 1 addition & 0 deletions src/image/reader.c
Expand Up @@ -33,6 +33,7 @@
#include <string.h>
#include <stdlib.h>
#include <LCUI_Build.h>
#include "config.h"
#include <LCUI/types.h>
#include <LCUI/graph.h>
#include <LCUI/image.h>
Expand Down
1 change: 1 addition & 0 deletions src/main.c
Expand Up @@ -27,6 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#define LCUI_MAIN_C
#include "config.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion src/platform/linux/linux_display.c
Expand Up @@ -28,7 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/


#include "config.h"
#include <LCUI_Build.h>
#ifdef LCUI_BUILD_IN_LINUX
#include <LCUI/LCUI.h>
Expand Down
1 change: 1 addition & 0 deletions src/platform/linux/linux_events.c
Expand Up @@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include <LCUI_Build.h>
#ifdef LCUI_BUILD_IN_LINUX
#include <LCUI/LCUI.h>
Expand Down
1 change: 1 addition & 0 deletions src/platform/linux/linux_fbdisplay.c
Expand Up @@ -29,6 +29,7 @@
*/

#define LCUI_SURFACE_C
#include "config.h"
#include <LCUI_Build.h>

#if defined(LCUI_BUILD_IN_LINUX) && defined(LCUI_VIDEO_DRIVER_FRAMEBUFFER)
Expand Down
1 change: 1 addition & 0 deletions src/platform/linux/linux_ime.c
Expand Up @@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include <LCUI_Build.h>

#ifdef LCUI_BUILD_IN_LINUX
Expand Down
1 change: 1 addition & 0 deletions src/platform/linux/linux_keyboard.c
Expand Up @@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include <LCUI_Build.h>
#ifdef LCUI_BUILD_IN_LINUX
#include <unistd.h>
Expand Down
1 change: 1 addition & 0 deletions src/platform/linux/linux_mouse.c
Expand Up @@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include <LCUI_Build.h>
#ifdef LCUI_BUILD_IN_LINUX
#include <stdio.h>
Expand Down

0 comments on commit f9ecdb7

Please sign in to comment.