From 8390d68837a8d538dffa19d00b56e33a940b50f6 Mon Sep 17 00:00:00 2001 From: Tri Tran Date: Thu, 8 Aug 2019 11:04:39 -0500 Subject: [PATCH] [discount] Add new package Discount (#7400) * [discount] Add new package Discount * [discount] Add new package Discount * New package [Discount](https://github.com/Orc/discount) * Static build only * [discount] Fix arm* and *uwp builds * Discount needs to run `mktags.exe` to generate `blocktags`. This fix copy generated `blocktags` to `SOURCE_PATH` for arm\* builds and \*uwp builds. * [discount] Fix UWP and ARM check * [discount] Another fix for blocktags * [discount] And another one * [discount] And another one. Please squash these PR commits. Sorry I don't have UWP or ARM compiler installed on my machine. * [discount] Use definitions in msvc/Makefile * [discount] Add homepage --- ports/discount/CONTROL | 4 ++ ports/discount/blocktags | 34 ++++++++++++++ ports/discount/cmake.patch | 27 +++++++++++ .../disable-deprecated-warnings.patch | 16 +++++++ .../discount/generate-blocktags-command.patch | 29 ++++++++++++ ports/discount/portfile.cmake | 45 +++++++++++++++++++ 6 files changed, 155 insertions(+) create mode 100644 ports/discount/CONTROL create mode 100644 ports/discount/blocktags create mode 100644 ports/discount/cmake.patch create mode 100644 ports/discount/disable-deprecated-warnings.patch create mode 100644 ports/discount/generate-blocktags-command.patch create mode 100644 ports/discount/portfile.cmake diff --git a/ports/discount/CONTROL b/ports/discount/CONTROL new file mode 100644 index 000000000..51c8b5e90 --- /dev/null +++ b/ports/discount/CONTROL @@ -0,0 +1,4 @@ +Source: discount +Version: 2.2.6 +Homepage: https://github.com/Orc/discount +Description: DISCOUNT is a implementation of John Gruber & Aaron Swartz's Markdown markup language. diff --git a/ports/discount/blocktags b/ports/discount/blocktags new file mode 100644 index 000000000..dfd3957c3 --- /dev/null +++ b/ports/discount/blocktags @@ -0,0 +1,34 @@ +static struct kw blocktags[] = { + { "P", 1, 0 }, + { "DL", 2, 0 }, + { "H1", 2, 0 }, + { "H2", 2, 0 }, + { "H3", 2, 0 }, + { "H4", 2, 0 }, + { "H5", 2, 0 }, + { "H6", 2, 0 }, + { "HR", 2, 1 }, + { "OL", 2, 0 }, + { "UL", 2, 0 }, + { "BDO", 3, 0 }, + { "DFN", 3, 0 }, + { "DIV", 3, 0 }, + { "MAP", 3, 0 }, + { "PRE", 3, 0 }, + { "WBR", 3, 0 }, + { "XMP", 3, 0 }, + { "FORM", 4, 0 }, + { "NOBR", 4, 0 }, + { "STYLE", 5, 0 }, + { "TABLE", 5, 0 }, + { "CENTER", 6, 0 }, + { "IFRAME", 6, 0 }, + { "OBJECT", 6, 0 }, + { "SCRIPT", 6, 0 }, + { "ADDRESS", 7, 0 }, + { "LISTING", 7, 0 }, + { "PLAINTEXT", 9, 0 }, + { "BLOCKQUOTE", 10, 0 }, +}; + +#define NR_blocktags 30 diff --git a/ports/discount/cmake.patch b/ports/discount/cmake.patch new file mode 100644 index 000000000..8a2278cf7 --- /dev/null +++ b/ports/discount/cmake.patch @@ -0,0 +1,27 @@ +diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt +index 3895fdb..a183836 100644 +--- a/cmake/CMakeLists.txt ++++ b/cmake/CMakeLists.txt +@@ -182,7 +182,10 @@ if(${PROJECT_NAME}_MAKE_INSTALL) + target_include_directories(libmarkdown INTERFACE + $ + ) +- set(_TARGETS libmarkdown markdown) ++ set(_TARGETS libmarkdown) ++ if(NOT ${PROJECT_NAME}_ONLY_LIBRARY) ++ set(_TARGETS ${_TARGETS} markdown) ++ endif() + if(${PROJECT_NAME}_INSTALL_SAMPLES) + list(APPEND _TARGETS mkd2html makepage) + endif() +diff --git a/cmake/config.h.in b/cmake/config.h.in +index e08220d..e630934 100644 +--- a/cmake/config.h.in ++++ b/cmake/config.h.in +@@ -74,4 +74,6 @@ + + #define TABSTOP @TABSTOP@ + ++#define DESTRUCTOR ++ + #endif /* _CONFIG_D */ diff --git a/ports/discount/disable-deprecated-warnings.patch b/ports/discount/disable-deprecated-warnings.patch new file mode 100644 index 000000000..e8f4f0fb7 --- /dev/null +++ b/ports/discount/disable-deprecated-warnings.patch @@ -0,0 +1,16 @@ +diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt +index 11fa675..34cc9ed 100644 +--- a/cmake/CMakeLists.txt ++++ b/cmake/CMakeLists.txt +@@ -20,6 +20,11 @@ set(${PROJECT_NAME}_INSTALL_SAMPLES OFF CACHE BOOL + set(${PROJECT_NAME}_ONLY_LIBRARY OFF CACHE BOOL + "Set to ON to only build markdown library (default is OFF)") + ++# MSVC deprecated warnings (C4996,strdup, ...) ++if(MSVC) ++ add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) ++endif() ++ + # Check headers + include(CheckIncludeFile) + check_include_file(libgen.h HAVE_LIBGEN_H) diff --git a/ports/discount/generate-blocktags-command.patch b/ports/discount/generate-blocktags-command.patch new file mode 100644 index 000000000..13d63a25d --- /dev/null +++ b/ports/discount/generate-blocktags-command.patch @@ -0,0 +1,29 @@ +diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt +index a183836..e9deef5 100644 +--- a/cmake/CMakeLists.txt ++++ b/cmake/CMakeLists.txt +@@ -113,12 +115,19 @@ configure_file("${_ROOT}/mkdio.h.in" + + include_directories("${_ROOT}") + +-add_executable(mktags +- "${_ROOT}/mktags.c") + +-add_custom_command(OUTPUT "${_ROOT}/blocktags" +- COMMAND mktags > blocktags +- WORKING_DIRECTORY "${_ROOT}") ++if(NOT GENERATE_BLOCKTAGS) ++ message(STATUS "Not generating blocktags") ++else() ++ message(STATUS "Using mktags to generate blocktags") ++ ++ add_executable(mktags ++ "${_ROOT}/mktags.c") ++ ++ add_custom_command(OUTPUT "${_ROOT}/blocktags" ++ COMMAND mktags > blocktags ++ WORKING_DIRECTORY "${_ROOT}") ++endif() + + add_library(libmarkdown + "${_ROOT}/mkdio.c" diff --git a/ports/discount/portfile.cmake b/ports/discount/portfile.cmake new file mode 100644 index 000000000..6a40d5105 --- /dev/null +++ b/ports/discount/portfile.cmake @@ -0,0 +1,45 @@ +include(vcpkg_common_functions) + +# No dynamic link for MSVC +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Orc/discount + REF v2.2.6 + SHA512 4c5956dea78aacd3a105ddac13f1671d811a5b2b04990cdf8485c36190c8872c4b1b9432a7236f669c34b07564ecd0096632dced54d67de9eaf4f23641417ecc + HEAD_REF master + PATCHES + cmake.patch + generate-blocktags-command.patch + disable-deprecated-warnings.patch +) + +set(GENERATE_BLOCKTAGS ON) +if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm" OR VCPKG_TARGET_ARCHITECTURE MATCHES "arm64" OR VCPKG_CMAKE_SYSTEM_NAME MATCHES "WindowsStore") + set(GENERATE_BLOCKTAGS OFF) +endif() + +if(NOT GENERATE_BLOCKTAGS) + configure_file("${CURRENT_PORT_DIR}/blocktags" "${SOURCE_PATH}/blocktags" COPYONLY) + message(STATUS "Copied blocktags") +endif() + +vcpkg_configure_cmake( + SOURCE_PATH "${SOURCE_PATH}/cmake" + PREFER_NINJA + DISABLE_PARALLEL_CONFIGURE + OPTIONS + -DDISCOUNT_ONLY_LIBRARY=ON + -DGENERATE_BLOCKTAGS=${GENERATE_BLOCKTAGS} +) + +vcpkg_install_cmake() +vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/discount) +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +# Handle copyright +file(INSTALL "${SOURCE_PATH}/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/discount" RENAME copyright) +