Skip to content

Commit

Permalink
Update to latest, add features, force static only
Browse files Browse the repository at this point in the history
  • Loading branch information
JackBoosY committed Sep 22, 2022
1 parent ad00f26 commit ca5b872
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 63 deletions.
122 changes: 99 additions & 23 deletions ports/vlpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,113 @@ cmake_minimum_required(VERSION 3.3.0)
project(Vlpp VERSION 0.10.0.0 LANGUAGES CXX)

option(SKIP_HEADERS "Skip header installation" OFF)
option(WORKFLOW_LIBRARY "Use VlppWorkflowLibrary" OFF)
option(WORKFLOW_RUNTIME "Use VlppWorkflowRuntime" OFF)
option(WORKFLOW_COMPILER "Use VlppWorkflowCompiler" OFF)
option(GACUI "Use GacUI" OFF)
option(DARK_SKIN "Use DarkSkin" OFF)
option(REFLECTION "Use GacUIReflection or DarkSkinReflection" OFF)
cmake_dependent_option(GACUI_REFLECTION "Use GacUIReflection" ON "GACUI;REFLECTION" OFF)
cmake_dependent_option(DARK_SKIN_REFLECTION "Use GacUIReflection" ON "DARK_SKIN;REFLECTION" OFF)
option(BUILD_GACUI_COMPILER "Build GacUICompiler" OFF)

# Sources
set(SRCS
Import/Vlpp.cpp
Import/VlppWorkflowLibrary.cpp
Import/VlppWorkflowCompiler.cpp
Import/VlppWorkflowRuntime.cpp)
set(CMAKE_CXX_STANDARD 20)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
# library
set(CORE_HDRS
Import/Vlpp.h
Import/VlppOS.h
Import/VlppGlrParser.h
Import/VlppRegex.h
)
set(CORE_SRCS
Import/Vlpp.Linux.cpp
Import/VlppOS.cpp
Import/VlppGlrParser.cpp
Import/VlppRegex.cpp
)

if (WIN32)
list(APPEND CORE_SRCS Import/Vlpp.Windows.cpp Import/VlppOS.Windows.cpp)
else()
list(APPEND CORE_SRCS Import/Vlpp.Linux.cpp Import/VlppOS.Linux.cpp)
endif()

if (WORKFLOW_LIBRARY)
list(APPEND CORE_HDRS Import/VlppWorkflowLibrary.h)
list(APPEND CORE_SRCS Import/VlppWorkflowLibrary.cpp)
source_group("Vlpp workflow files" FILES Import/VlppWorkflowLibrary.cpp)
endif()

if (WORKFLOW_RUNTIME)
list(APPEND CORE_HDRS Import/VlppWorkflowRuntime.h)
list(APPEND CORE_SRCS Import/VlppWorkflowRuntime.cpp)
source_group("Vlpp workflow runtime files" FILES Import/VlppWorkflowRuntime.cpp)
endif()

if (WORKFLOW_COMPILER)
list(APPEND CORE_HDRS Import/VlppWorkflowCompiler.h)
list(APPEND CORE_SRCS Import/VlppWorkflowCompiler.cpp)
source_group("Vlpp workflow compiler files" FILES Import/VlppWorkflowCompiler.cpp)
endif()

if (GACUI)
set(GACUI_SRCS Import/GacUI.cpp Import/GacUI.Windows.cpp)
if (GACUI_REFLECTION)
list(APPEND CORE_HDRS Import/VlppReflection.h)
list(APPEND GACUI_SRCS Import/GacUIReflection.cpp Import/VlppReflection.cpp)
endif()
if (NOT GACUI_REFLECTION)
list(APPEND EXTRA_DEFINES VCZH_DEBUG_NO_REFLECTION)
endif()
list(APPEND CORE_SRCS ${GACUI_SRCS})
source_group("Vlpp Gac UI files" FILES ${GACUI_SRCS})
endif()

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
if (DARK_SKIN)
set(DARK_SKIN_SRCS Import/Skins/DarkSkin/DarkSkin.cpp)
if (DARK_SKIN_REFLECTION)
list(APPEND CORE_HDRS Import/VlppReflection.h)
list(APPEND DARK_SKIN_SRCS Import/Skins/DarkSkin/DarkSkinReflection.cpp Import/VlppReflection.cpp)
endif()
list(APPEND EXTRA_INCLUDES Import/Skins/DarkSkin)
if (NOT DARK_SKIN_REFLECTION)
list(APPEND EXTRA_DEFINES VCZH_DEBUG_NO_REFLECTION)
endif()
list(APPEND CORE_SRCS ${DARK_SKIN_SRCS})
source_group("Vlpp Dark Skin files" FILES ${DARK_SKIN_SRCS})
endif()

# Create and configure the target
add_library(Vlpp INTERFACE ${SRCS})
list(REMOVE_DUPLICATES CORE_HDRS)
list(REMOVE_DUPLICATES CORE_SRCS)

add_library(Vlpp STATIC ${CORE_SRCS})

source_group("Vlpp core files" FILES ${CORE_SRCS})

# target_compile_definitions
target_compile_definitions(Vlpp INTERFACE UNICODE)
target_compile_definitions(Vlpp INTERFACE _UNICODE)
target_compile_definitions(Vlpp PRIVATE UNICODE)
target_compile_definitions(Vlpp PRIVATE _UNICODE)

if (EXTRA_DEFINES)
target_compile_definitions(Vlpp PUBLIC ${EXTRA_DEFINES})
endif()

target_include_directories(Vlpp INTERFACE $<INSTALL_INTERFACE:Import>)
if(MSVC)
target_compile_options(Vlpp PRIVATE /bigobj)
endif()

if (EXTRA_INCLUDES)
target_include_directories(Vlpp PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/${EXTRA_INCLUDES}> $<INSTALL_INTERFACE:${EXTRA_INCLUDES}>)
endif()
target_include_directories(Vlpp PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Import> $<INSTALL_INTERFACE:Import>)

# Tool
if (BUILD_GACUI_COMPILER)
add_executable(GacGen Import/GacUICompiler.cpp)

install(TARGETS GacGen RUNTIME DESTINATION "bin")
endif()

# Install
install(
Expand All @@ -43,12 +126,5 @@ install(EXPORT unofficial-vlpp
)

if (NOT SKIP_HEADERS)
install(
FILES
Import/Vlpp.h
Import/VlppWorkflowLibrary.h
Import/VlppWorkflowCompiler.h
Import/VlppWorkflowRuntime.h
DESTINATION "include"
)
install(FILES ${CORE_HDRS} DESTINATION "include")
endif()
61 changes: 27 additions & 34 deletions ports/vlpp/fix-arm.patch
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
--- a/Import/Vlpp.h
+++ b/Import/Vlpp.h
@@ -50,13 +50,12 @@
#define abstract
#endif
-
+#include <stdlib.h>
#if defined VCZH_MSVC
#include <intrin.h>
#elif defined VCZH_GCC
-#include <x86intrin.h>
#include <stdint.h>
#include <stddef.h>
#include <wchar.h>
#define abstract
#define __thiscall
#define __forceinline inline
@@ -160,14 +159,14 @@
#define UI64TOA_S _ui64toa_s
#define UI64TOW_S _ui64tow_s
#if defined VCZH_MSVC
#define INCRC(x) (_InterlockedIncrement((volatile long*)(x)))
#define DECRC(x) (_InterlockedDecrement((volatile long*)(x)))
#elif defined VCZH_GCC
-#define INCRC(x) (__sync_add_and_fetch(x, 1))
-#define DECRC(x) (__sync_sub_and_fetch(x, 1))
+#define INCRC(x) (__atomic_add_fetch(x, 1, __ATOMIC_SEQ_CST))
+#define DECRC(x) (__atomic_sub_fetch(x, 1, __ATOMIC_SEQ_CST))
#endif
#endif

/***********************************************************************
Basic Types
***********************************************************************/
diff --git a/Import/Vlpp.h b/Import/Vlpp.h
index cf59b80..b00c9b8 100644
--- a/Import/Vlpp.h
+++ b/Import/Vlpp.h
@@ -49,10 +49,10 @@ static_assert(sizeof(wchar_t) == sizeof(char32_t), "wchar_t is not UTF-32.");
static_assert(false, "wchar_t configuration is not right.");
#endif

+#include <stdlib.h>
#if defined VCZH_MSVC
#include <intrin.h>
#elif defined VCZH_GCC
-#include <x86intrin.h>
#include <stdint.h>
#include <stddef.h>
#include <wchar.h>
@@ -149,8 +149,8 @@ x86 and x64 Compatbility
#define INCRC(x) (_InterlockedIncrement64(x))
#define DECRC(x) (_InterlockedDecrement64(x))
#elif defined VCZH_GCC
-#define INCRC(x) (__sync_add_and_fetch(x, 1))
-#define DECRC(x) (__sync_sub_and_fetch(x, 1))
+#define INCRC(x) (__atomic_add_fetch(x, 1, __ATOMIC_SEQ_CST))
+#define DECRC(x) (__atomic_sub_fetch(x, 1, __ATOMIC_SEQ_CST))
#endif
#else
#define ITOA_S _itoa_s
23 changes: 20 additions & 3 deletions ports/vlpp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO vczh-libraries/Release
REF 5dfe25c4f4997da2d7a23bdc80c2438e72d9813a # 0.11.0.0
SHA512 5d585e561246385b074c625a3644b79defa22328dab0ab14112c846cb917f384abb617a5f400971ca29e4ee5ac391b88b17ee65d594caf9ebf279806db669a4a
REF 0a7bf9b4f7e705f17efc2ada5aa2b089147234d4 # 1.1.0.0
SHA512 b70081495f2843a45ea2aea37a2d00327e336a3313acfa20421de4748c880905279353c03ecc50f45e9cda0aae34aad69ba44de81fa2fd4d4855be6002dd068f
HEAD_REF master
PATCHES fix-arm.patch
)

file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
workflowlibrary WORKFLOW_LIBRARY
workflowruntime WORKFLOW_RUNTIME
workflowcompiler WORKFLOW_COMPILER
gacui GACUI
darkskin DARK_SKIN
reflection REFLECTION
tool BUILD_GACUI_COMPILER
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS_DEBUG
${FEATURE_OPTIONS}
-DSKIP_HEADERS=ON
)

vcpkg_cmake_install()
vcpkg_copy_pdbs()

vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-vlpp)

if (BUILD_GACUI_COMPILER)
vcpkg_copy_tools(TOOL_NAMES GacGen)
endif()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug")

# Tools
Expand Down
28 changes: 25 additions & 3 deletions ports/vlpp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "vlpp",
"version": "0.11.0.0",
"port-version": 4,
"version": "1.1.0.0",
"description": "Common C++ construction, including string operation / generic container / linq / General-LR parser generator / multithreading / reflection for C++ / etc",
"homepage": "https://github.com/vczh-libraries/Release",
"license": null,
Expand All @@ -14,5 +13,28 @@
"name": "vcpkg-cmake-config",
"host": true
}
]
],
"features": {
"darkskin": {
"description": "Use DarkSkin"
},
"gacui": {
"description": "Use GacUI"
},
"reflection": {
"description": "Use GacUIReflection or DarkSkinReflection"
},
"tool": {
"description": "Build GacUICompiler"
},
"workflowcompiler": {
"description": "Use VlppWorkflowCompiler"
},
"workflowlibrary": {
"description": "Use VlppWorkflowLibrary"
},
"workflowruntime": {
"description": "Use VlppWorkflowRuntime"
}
}
}

0 comments on commit ca5b872

Please sign in to comment.