Skip to content

Commit

Permalink
Improve dll support (#1706)
Browse files Browse the repository at this point in the history
* Improve dll support

* Tidy header include path

* Fix android build & symbol dup issue

* Fix android compile error

* Fixup
  • Loading branch information
halx99 authored Feb 19, 2024
1 parent adbffdf commit 31da0f2
Show file tree
Hide file tree
Showing 21 changed files with 102 additions and 500 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: build

on:
on:
push:

branches: dev
paths-ignore:
- '**.md'
- '**/*.md.in'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/forward-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name: forward-push
# events but only for the master branch
on:
push:
branches: dev
paths-ignore:
- '.github/workflows/publish.yml'
- 'tools/ci/make-pkg.ps1'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/genbindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: genbindings

on:
push:
branches: dev
paths-ignore:
- '**.md'
- '**/*.md.in'
Expand Down
7 changes: 1 addition & 6 deletions cmake/Modules/AXConfigDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,7 @@ function(use_ax_compile_define target)
# PUBLIC GLAD_GLAPI_EXPORT
)
if(BUILD_SHARED_LIBS)
target_compile_definitions(${target}
PRIVATE _USRDLL
PRIVATE _USEGUIDLL # ui
)
else()
target_compile_definitions(${target} PUBLIC AX_STATIC)
target_compile_definitions(${target} PRIVATE AX_DLLEXPORT INTERFACE AX_DLLIMPORT)
endif()
endif()
endfunction()
Expand Down
6 changes: 2 additions & 4 deletions cmake/Modules/AXLinkHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ function(ax_link_cxx_prebuilt APP_NAME AX_ROOT_DIR AX_PREBUILT_DIR)
target_compile_definitions(${APP_NAME} PRIVATE AX_USE_SSE=1)
endif()

if (NOT BUILD_SHARED_LIBS)
target_compile_definitions(${APP_NAME}
PRIVATE AX_STATIC=1
)
if (BUILD_SHARED_LIBS)
target_compile_definitions(${APP_NAME} PRIVATE AX_DLLIMPORT=1)
endif()

target_include_directories(${APP_NAME}
Expand Down
5 changes: 0 additions & 5 deletions core/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ elseif(WINDOWS)
platform/win32/GL-win32.h
platform/win32/FileUtils-win32.h
platform/win32/StdC-win32.h
platform/win32/PlatformDefine-win32.h
platform/GLViewImpl.h
)
set(_AX_PLATFORM_SPECIFIC_SRC
Expand Down Expand Up @@ -67,7 +66,6 @@ elseif(APPLE)
set(_AX_PLATFORM_SPECIFIC_HEADER
${_AX_PLATFORM_SPECIFIC_HEADER}
platform/mac/StdC-mac.h
platform/mac/PlatformDefine-mac.h
platform/mac/Application-mac.h
platform/GLViewImpl.h
)
Expand All @@ -86,7 +84,6 @@ elseif(APPLE)
platform/ios/DirectorCaller-ios.h
platform/ios/EAGLView-ios.h
platform/ios/GLViewImpl-ios.h
platform/ios/PlatformDefine-ios.h
platform/ios/StdC-ios.h
platform/ios/InputView-ios.h
)
Expand Down Expand Up @@ -132,7 +129,6 @@ elseif(LINUX)
platform/linux/GL-linux.h
platform/linux/StdC-linux.h
platform/linux/FileUtils-linux.h
platform/linux/PlatformDefine-linux.h
platform/GLViewImpl.h
)
set(_AX_PLATFORM_SPECIFIC_SRC
Expand All @@ -152,7 +148,6 @@ elseif(EMSCRIPTEN)
platform/wasm/GL-wasm.h
platform/wasm/StdC-wasm.h
platform/wasm/FileUtils-wasm.h
platform/wasm/PlatformDefine-wasm.h
platform/GLViewImpl.h # wasm can share GLviewImpl-desktop based on GLFW
)
set(_AX_PLATFORM_SPECIFIC_SRC
Expand Down
48 changes: 34 additions & 14 deletions core/platform/PlatformDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
https://axmolengine.github.io/
Expand Down Expand Up @@ -29,18 +30,37 @@ THE SOFTWARE.

#include "platform/PlatformConfig.h"

#if AX_TARGET_PLATFORM == AX_PLATFORM_MAC
# include "platform/mac/PlatformDefine-mac.h"
#elif AX_TARGET_PLATFORM == AX_PLATFORM_IOS
# include "platform/ios/PlatformDefine-ios.h"
#elif AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID
# include "platform/android/PlatformDefine-android.h"
#elif AX_TARGET_PLATFORM == AX_PLATFORM_WIN32
# include "platform/win32/PlatformDefine-win32.h"
#elif AX_TARGET_PLATFORM == AX_PLATFORM_LINUX
# include "platform/linux/PlatformDefine-linux.h"
#elif AX_TARGET_PLATFORM == AX_PLATFORM_WINRT
# include "platform/winrt/PlatformDefine-winrt.h"
#elif AX_TARGET_PLATFORM == AX_PLATFORM_WASM
# include "platform/wasm/PlatformDefine-wasm.h"
#include <string.h>
#include <assert.h>

#if defined(__ANDROID__)
# include <android/log.h>
#endif

#define AX_ASSERT(cond) assert(cond)
#define AX_UNUSED_PARAM(unusedparam) (void)unusedparam

/* Define NULL pointer value */
#ifndef NULL
# ifdef __cplusplus
# define NULL 0
# else
# define NULL ((void*)0)
# endif
#endif

/* AX_API */
#if defined(_WIN32)
# if defined(AX_DLLEXPORT)
# define AX_API __declspec(dllexport)
# elif defined(AX_DLLIMPORT)
# define AX_API __declspec(dllimport)
# endif
#elif defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT)
# define AX_API __attribute__((visibility("default")))
#endif
#ifndef AX_API
# define AX_API
#endif

#define AX_DLL AX_API
57 changes: 0 additions & 57 deletions core/platform/android/PlatformDefine-android.h

This file was deleted.

43 changes: 0 additions & 43 deletions core/platform/ios/PlatformDefine-ios.h

This file was deleted.

43 changes: 0 additions & 43 deletions core/platform/linux/PlatformDefine-linux.h

This file was deleted.

47 changes: 0 additions & 47 deletions core/platform/mac/PlatformDefine-mac.h

This file was deleted.

43 changes: 0 additions & 43 deletions core/platform/wasm/PlatformDefine-wasm.h

This file was deleted.

Loading

0 comments on commit 31da0f2

Please sign in to comment.