Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notcurses v3 #4059

Merged
merged 8 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions N/Notcurses/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using BinaryBuilder

name = "Notcurses"
version = v"3.0.0"
sources = [
GitSource("https://github.com/dankamongmen/notcurses",
"d49a0375b762c9ec60ffb9e35b973643acfd69ab"),
DirectorySource("./bundled"),
]

script = raw"""
cd ${WORKSPACE}/srcdir/notcurses*/
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/repent.patch
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/0001-add-an-option-to-not-build-binaries.patch
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/0001-check-__MINGW32__-instead-of-__MINGW64__.patch
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/0001-also-look-for-shared-libraries-on-Windows.patch
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/0001-fix-Secur32-library-to-be-lowercase.patch

if [[ $target == *mingw* ]]; then
export CFLAGS="${CFLAGS} -D_WIN32_WINNT=0x0600"
cp ${WORKSPACE}/srcdir/headers/pthread_time.h "/opt/${target}/${target}/sys-root/include/pthread_time.h"
fi

install_license COPYRIGHT

mkdir build && cd build

export CFLAGS="${CFLAGS} -I${includedir}"

FLAGS=(-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN}
-DCMAKE_INSTALL_PREFIX=${prefix}
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=ON
-DUSE_DOCTEST=off
-DUSE_PANDOC=off
-DUSE_STATIC=off
-DUSE_QRCODEGEN=off
-DBUILD_BINARIES=off
-DUSE_POC=off
-DUSE_MULTIMEDIA=none
-D_WIN32_WINNT=0x0602
)

cmake .. "${FLAGS[@]}"
make -j${nproc}
make install
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line.
platforms = supported_platforms(; experimental=true)

# The products that we will ensure are always built.
products = [
LibraryProduct("libnotcurses", :libnotcurses)
LibraryProduct("libnotcurses-core", :libnotcurses_core)
]

# Dependencies that must be installed before this package can be built.
dependencies = [
Dependency("Ncurses_jll"),
Dependency("libunistring_jll"),
Dependency("libdeflate_jll"),
]

build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version=v"7", julia_compat="1.6")
98 changes: 98 additions & 0 deletions N/Notcurses/bundled/headers/pthread_time.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
Copyright (c) 2011-2016 mingw-w64 project

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/

#include <sys/timeb.h>

#ifndef WIN_PTHREADS_TIME_H
#define WIN_PTHREADS_TIME_H

/* Posix timers are supported */
#ifndef _POSIX_TIMERS
#define _POSIX_TIMERS 200809L
#endif

/* Monotonic clocks are available. */
#ifndef _POSIX_MONOTONIC_CLOCK
#define _POSIX_MONOTONIC_CLOCK 200809L
#endif

/* CPU-time clocks are available. */
#ifndef _POSIX_CPUTIME
#define _POSIX_CPUTIME 200809L
#endif

/* Clock support in threads are available. */
#ifndef _POSIX_THREAD_CPUTIME
#define _POSIX_THREAD_CPUTIME 200809L
#endif

#ifndef __clockid_t_defined
typedef int clockid_t;
#define __clockid_t_defined 1
#endif /* __clockid_t_defined */

#ifndef TIMER_ABSTIME
#define TIMER_ABSTIME 1
#endif

#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
#endif

#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC 1
#endif

#ifndef CLOCK_PROCESS_CPUTIME_ID
#define CLOCK_PROCESS_CPUTIME_ID 2
#endif

#ifndef CLOCK_THREAD_CPUTIME_ID
#define CLOCK_THREAD_CPUTIME_ID 3
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Make sure we provide default for WINPTHREAD_API, if not defined. */
#pragma push_macro("WINPTHREAD_API")
#ifndef WINPTHREAD_API
#define WINPTHREAD_API
#endif

/* These should really be dllimport'ed if using winpthread dll */
int __cdecl WINPTHREAD_API nanosleep(const struct timespec *request, struct timespec *remain);

int __cdecl WINPTHREAD_API clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *request, struct timespec *remain);
int __cdecl WINPTHREAD_API clock_getres(clockid_t clock_id, struct timespec *res);
int __cdecl WINPTHREAD_API clock_gettime(clockid_t clock_id, struct timespec *tp);
int __cdecl WINPTHREAD_API clock_settime(clockid_t clock_id, const struct timespec *tp);

#pragma pop_macro("WINPTHREAD_API")

#ifdef __cplusplus
}
#endif

#endif /* WIN_PTHREADS_TIME_H */

Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
From cc46ede3e56e5973e55786e799f48c4890317920 Mon Sep 17 00:00:00 2001
From: KristofferC <kcarlsson89@gmail.com>
Date: Mon, 13 Dec 2021 11:41:29 +0100
Subject: [PATCH] add an option to not build binaries

---
CMakeLists.txt | 23 ++++++++++++++++++-----
INSTALL.md | 1 +
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b394f7ccc..6e890a6b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,7 @@ option(USE_DEFLATE "Use libdeflate instead of libz" ON)
option(USE_DOXYGEN "Build HTML cross reference with doxygen" OFF)
option(USE_GPM "Enable libgpm console mouse support" OFF)
option(USE_PANDOC "Build man pages and HTML reference with pandoc" ON)
+option(BUILD_BINARIES "Build binaries" ON)
option(USE_POC "Build small, uninstalled proof-of-concept binaries" ON)
option(USE_QRCODEGEN "Enable libqrcodegen QR code support" OFF)
option(USE_STATIC "Build static libraries (in addition to shared)" ON)
@@ -46,6 +47,10 @@ elseif(${USE_MULTIMEDIA} STREQUAL "oiio")
elseif(NOT ${USE_MULTIMEDIA} STREQUAL "none")
message(FATAL_ERROR "USE_MULTIMEDIA must be one of 'oiio', 'ffmpeg', 'none' (was '${USE_MULTIMEDIA}').")
endif()
+if (NOT BUILD_BINARIES AND USE_POC)
+ message(WARNING "Disabling USE_POC since BUILD_BINARIES=OFF")
+ set(USE_POC OFF)
+endif()

if(${USE_CXX})
enable_language(CXX)
@@ -554,6 +559,13 @@ if(${USE_CXX})
endif()
endif()

+# documentation source, processed by pandoc into XHTML and man pages. declare
+# them here so that we can filter out man pages for binaries which aren't
+# going to be installed.
+file(GLOB MANSOURCE1 CONFIGURE_DEPENDS doc/man/man1/*.md)
+file(GLOB MANSOURCE3 CONFIGURE_DEPENDS doc/man/man3/*.md)
+
+if(BUILD_BINARIES)
############################################################################
# notcurses-demo
file(GLOB DEMOSRCS CONFIGURE_DEPENDS src/demo/*.c)
@@ -684,11 +696,6 @@ target_link_libraries(ncneofetch
"${LIBRT}"
)

-# documentation source, processed by pandoc into XHTML and man pages. declare
-# them here so that we can filter out man pages for binaries which aren't
-# going to be installed.
-file(GLOB MANSOURCE1 CONFIGURE_DEPENDS doc/man/man1/*.md)
-file(GLOB MANSOURCE3 CONFIGURE_DEPENDS doc/man/man3/*.md)

# all further binaries require multimedia and C++ support
if(${USE_CXX})
@@ -731,6 +738,10 @@ target_link_libraries(ncplayer
)
endif()
endif()
+else()
+ # No binaries built
+ set(MANSOURCE1 "")
+endif() # BUILD_BINARIES

############################################################################
# testing
@@ -989,6 +1000,7 @@ file(GLOB MARKDOWN CONFIGURE_DEPENDS *.md)
list(FILTER MARKDOWN EXCLUDE REGEX "INSTALL.md")
install(FILES ${MARKDOWN} DESTINATION ${CMAKE_INSTALL_DOCDIR})

+if(BUILD_BINARIES)
install(TARGETS notcurses-demo DESTINATION bin)
install(TARGETS notcurses-info DESTINATION bin)
install(TARGETS ncneofetch DESTINATION bin)
@@ -1003,6 +1015,7 @@ install(TARGETS ncls DESTINATION bin)
install(TARGETS ncplayer DESTINATION bin)
endif()
endif()
+endif() # BUILD_BINARIES

LIST(APPEND INSTLIBS notcurses-core notcurses)
if(${USE_STATIC})
diff --git a/INSTALL.md b/INSTALL.md
index 652073479..f99b255de 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -123,6 +123,7 @@ but must be `Debug` for use of `USE_COVERAGE`.
* `DFSG_BUILD=off`: leave out all content considered non-free under the Debian Free
Software Guidelines
* `BUILD_TESTING=on`: build test targets
+* `BUILD_BINARIES=on`: build binary (executable) targets
* `USE_ASAN=off`: build with AddressSanitizer
* `USE_CXX=on`: build C++ code (requires a C++ compiler)
* `USE_COVERAGE=off`: build coverage support (for developers, requires use of Clang)
--
2.30.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 0bb184678bfa92ef77e9f1365ec3adc33cfdc3bf Mon Sep 17 00:00:00 2001
From: KristofferC <kcarlsson89@gmail.com>
Date: Mon, 13 Dec 2021 18:02:20 +0100
Subject: [PATCH] also look for shared libraries on Windows

---
CMakeLists.txt | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b394f7ccc..e974d8322 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,6 +59,11 @@ endif()
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_VISIBILITY_PRESET hidden)

+if(WIN32)
+ # Ensure on Windows we also look for shared libraries `*.dll`, instead of just import libraries
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".$ENV{dlext}" ${CMAKE_FIND_LIBRARY_SUFFIXES})
+endif()
+
message(STATUS "Requested multimedia engine: ${USE_MULTIMEDIA}")
message(STATUS "Requested build mode: ${CMAKE_BUILD_TYPE}")

--
2.30.2

Loading