[CMake] add USE_DEFLATE option, document it, reenable fedora drone #2348

dankamongmen/windows-tester
nick black 3 years ago
parent 50f6cf72b2
commit 717b4a40c1
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -21,31 +21,30 @@ steps:
- LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include python3 setup.py sdist build install
- env LD_LIBRARY_PATH=/usr/local/lib ./notcurses-pydemo > /dev/null
- env LD_LIBRARY_PATH=/usr/local/lib ./ncdirect-pydemo > /dev/null
# gone until we package libdeflate
#---
#kind: pipeline
#type: docker
#name: fedora-rawhide
#
#steps:
#- name: fedora-rawhide
# image: dankamongmen/rawhide:2021-11-14a
# commands:
# - export LANG=en_US.UTF-8
# - export TERM=xterm
# - mkdir build
# - cd build
# - cmake -DCMAKE_BUILD_TYPE=Release -DUSE_MULTIMEDIA=oiio -DUSE_QRCODEGEN=on ..
# - make -j2
# - ctest --output-on-failure
# - make install
# - ldconfig
# - cd ../cffi
# - LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include python3 setup.py sdist build install
# - cd ../python
# - LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include python3 setup.py sdist build install
# - env LD_LIBRARY_PATH=/usr/local/lib ./notcurses-pydemo > /dev/null
# - env LD_LIBRARY_PATH=/usr/local/lib ./ncdirect-pydemo > /dev/null
---
kind: pipeline
type: docker
name: fedora-rawhide
steps:
- name: fedora-rawhide
image: dankamongmen/rawhide:2021-11-14a
commands:
- export LANG=en_US.UTF-8
- export TERM=xterm
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DUSE_DEFLATE=no -DUSE_MULTIMEDIA=oiio -DUSE_QRCODEGEN=on ..
- make -j2
- ctest --output-on-failure
- make install
- ldconfig
- cd ../cffi
- LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include python3 setup.py sdist build install
- cd ../python
- LDFLAGS=-L/usr/local/lib CFLAGS=-I/usr/local/include python3 setup.py sdist build install
- env LD_LIBRARY_PATH=/usr/local/lib ./notcurses-pydemo > /dev/null
- env LD_LIBRARY_PATH=/usr/local/lib ./ncdirect-pydemo > /dev/null
#---
#kind: pipeline
#type: docker

@ -19,6 +19,7 @@ cmake_dependent_option(
USE_DOCTEST "Build notcurses-tester with doctest" ON
"BUILD_TESTING;USE_CPP" OFF
)
option(USE_DEFLATE "Use libdeflate for compression of Kitty graphics" 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)
@ -166,6 +167,7 @@ endif()
find_library(unistring unistring REQUIRED)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND libunistring)
set_package_properties(libunistring PROPERTIES TYPE REQUIRED)
if(${USE_DEFLATE})
unset(HAVE_DEFLATE_H CACHE)
check_include_file("libdeflate.h" HAVE_DEFLATE_H)
if(NOT "${HAVE_DEFLATE_H}")
@ -174,6 +176,7 @@ endif()
find_library(libdeflate deflate REQUIRED)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND libdeflate)
set_package_properties(libdeflate PROPERTIES TYPE REQUIRED)
endif()
if(${USE_GPM}) # no pkgconfig from gpm
unset(HAVE_GPM_H CACHE)
check_include_file("gpm.h" HAVE_GPM_H)

@ -20,7 +20,9 @@ Install build dependencies:
If you only intend to build core Notcurses (without multimedia support), you
can omit `libavformat-dev`, `libavutil-dev`, and `libswscale-dev` from this
list.
list. If you do not want to deflate Kitty graphics, you can omit
'libdeflate-dev'. If you don't want to generate QR codes, you can omit
'libqrcodegen-dev'.
If you want to build the Python wrappers, you'll also need:
@ -34,24 +36,31 @@ Install build dependencies:
If you only intend to build core Notcurses (without multimedia support), you
can omit `OpenImageIO-devel`. If you're building outside Fedora Core (e.g. with
RPM Fusion), you might want to use FFmpeg rather than OpenImageIO.
RPM Fusion), you might want to use FFmpeg rather than OpenImageIO. If you don't
want to generate QR codes, you can omit 'libqrcodegen-devel'.
### FreeBSD / DragonFly BSD
Install build dependencies:
`pkg install devel/ncurses multimedia/ffmpeg graphics/qr-code-generator devel/libunistring`
`pkg install archivers/libdeflate devel/ncurses multimedia/ffmpeg graphics/qr-code-generator devel/libunistring`
If you only intend to build core Notcurses (without multimedia support), you
can omit `multimedia/ffmpeg`. If you do not want to deflate Kitty graphics,
you can omit 'archivers/libdeflate'. If you don't want to generate QR codes,
you can omit 'graphics/qr-code-generator'.
### Microsoft Windows
Currently, building on Windows requires [MSYS2](https://www.msys2.org/) in its
Building on Windows requires [MSYS2](https://www.msys2.org/) in its
64-bit Universal C Runtime (UCRT) incarnation. This builds native Windows DLLs
and EXEs, though it does not use Visual Studio. Install build dependencies:
`pacman -S mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-doctest mingw-w64-ucrt-x86_64-ffmpeg mingw-w64-ucrt-x86_64-libunistring mingw-w64-ucrt-x86_64-ncurses mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-ninja`
`pacman -S mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-doctest mingw-w64-ucrt-x86_64-ffmpeg mingw-w64-ucrt-x86_64-libdeflate mingw-w64-ucrt-x86_64-libunistring mingw-w64-ucrt-x86_64-ncurses mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-ninja`
If you only intend to build core Notcurses (without multimedia support), you
can omit `mingw-w64-ucrt-x86_64-ffmpeg`.
can omit `mingw-w64-ucrt-x86_64-ffmpeg`. If you do not want to deflate Kitty
graphics, you can omit 'mingw-w64-ucrt-x86_64-libdeflate'.
## Building
@ -80,8 +89,8 @@ test failures, *please* file a bug including the output of
(`make test` also runs `notcurses-tester`, but hides important output).
To watch the bitchin' demo, run `make demo`. More details can
be found on the `notcurses-demo(1)` man page.
To watch the bitchin' demo, run `make demo` (or `./notcurses-demo -p ../data`).
More details can be found on the `notcurses-demo(1)` man page.
Install with `make install` following a successful build. This installs the C
core library, the C headers, the C++ library, and the C++ headers (note that

@ -1,6 +1,8 @@
#include <libdeflate.h>
#include "internal.h"
#include "base64.h"
#ifdef USE_DEFLATE
#include <libdeflate.h>
#endif
// Kitty has its own bitmap graphics protocol, rather superior to DEC Sixel.
// A header is written with various directives, followed by a number of
@ -627,6 +629,10 @@ encode_and_chunkify(fbuf* f, const unsigned char* buf, size_t blen, unsigned com
static int
deflate_buf(void* buf, fbuf* f, int dimy, int dimx){
const size_t blen = dimx * dimy * 4;
void* cbuf = NULL;
size_t clen = 0;
#ifdef USE_DEFLATE
// 2 has been shown to work pretty well for things that are actually going
// to compress; results per unit time fall off quickly after 2.
struct libdeflate_compressor* cmp = libdeflate_alloc_compressor(6);
@ -634,24 +640,22 @@ deflate_buf(void* buf, fbuf* f, int dimy, int dimx){
logerror("couldn't get libdeflate context\n");
return -1;
}
size_t blen = dimx * dimy * 4;
// if this allocation fails, just skip compression, no need to bail
void* cbuf = malloc(blen);
size_t clen;
cbuf = malloc(blen);
if(cbuf){
clen = libdeflate_zlib_compress(cmp, buf, blen, cbuf, blen);
}else{
clen = 0;
}
libdeflate_free_compressor(cmp);
#endif
int ret;
if(0 == clen){ // wasn't enough room; compressed data is larger than original
loginfo("deflated in vain; using original %" PRIuPTR "B\n", blen);
ret = encode_and_chunkify(f, buf, blen, 0);
}else{
loginfo("deflated %" PRIuPTR "B to %" PRIuPTR "B\n", blen, clen);
ret = encode_and_chunkify(f, cbuf, clen, 1);
}
free(cbuf);
libdeflate_free_compressor(cmp);
return ret;
}

@ -1,5 +1,6 @@
// Populated by CMake; not installed
#cmakedefine DFSG_BUILD
#cmakedefine USE_DEFLATE
#cmakedefine USE_GPM
#cmakedefine USE_QRCODEGEN
// exclusive with USE_OIIO

Loading…
Cancel
Save