diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-12-13 09:37:21 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-12-16 11:28:44 -0700 |
| commit | 5abe94420528d3e107eceb0f3df073e8a1270191 (patch) | |
| tree | 332ab323c429250efcd086b15dac9beff6625a60 | |
| parent | bafcf13695f80dac6d9be87b65ad6156ddc3d621 (diff) | |
| download | vis-5abe94420528d3e107eceb0f3df073e8a1270191.tar.gz vis-5abe94420528d3e107eceb0f3df073e8a1270191.tar.xz | |
make vis a single file build
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 78 | ||||
| -rwxr-xr-x | configure | 64 | ||||
| -rw-r--r-- | main.c | 24 | ||||
| -rw-r--r-- | test/core/Makefile | 6 | ||||
| -rw-r--r-- | test/core/map-test.c | 2 | ||||
| -rw-r--r-- | test/core/text-test.c | 7 | ||||
| -rw-r--r-- | text.c | 18 | ||||
| -rw-r--r-- | util.h | 23 | ||||
| -rw-r--r-- | vis-lua.h | 4 | ||||
| -rw-r--r-- | vis.c | 19 |
11 files changed, 95 insertions, 152 deletions
@@ -1,7 +1,6 @@ /config.h /config.mk /dependency -/obj /vis /vis-menu /vis-single @@ -12,4 +11,3 @@ *.gcno *.gcov *.html -*.d @@ -1,36 +1,5 @@ -include config.mk -REGEX_SRC ?= text-regex.c - -SRC = array.c \ - buffer.c \ - event-basic.c \ - libutf.c \ - main.c \ - map.c \ - sam.c \ - text-common.c \ - text-io.c \ - text-iterator.c \ - text-motions.c \ - text-objects.c \ - text-util.c \ - text.c \ - ui-terminal.c \ - view.c \ - vis-lua.c \ - vis-marks.c \ - vis-modes.c \ - vis-motions.c \ - vis-operators.c \ - vis-prompt.c \ - vis-registers.c \ - vis-subprocess.c \ - vis-text-objects.c \ - vis.c \ - $(REGEX_SRC) -OBJ = $(SRC:%.c=obj/%.o) - ELF = vis vis-menu vis-digraph EXECUTABLES = $(ELF) vis-clipboard vis-complete vis-open @@ -40,29 +9,15 @@ DOCUMENTATION = LICENSE README.md VERSION = $(shell git describe --always --dirty 2>/dev/null || echo "v0.9-git") -CONFIG_HELP ?= 1 -CONFIG_CURSES ?= 1 -CONFIG_LUA ?= 1 -CONFIG_LPEG ?= 0 -CONFIG_TRE ?= 0 -CONFIG_ACL ?= 0 -CONFIG_SELINUX ?= 0 - -CFLAGS_STD ?= -std=c99 -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG -MMD +CFLAGS_STD ?= -std=c99 -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG CFLAGS_STD += -DVERSION=\"${VERSION}\" LDFLAGS_STD ?= -lc CFLAGS_VIS = $(CFLAGS_AUTO) $(CFLAGS_TERMKEY) $(CFLAGS_CURSES) $(CFLAGS_ACL) \ - $(CFLAGS_SELINUX) $(CFLAGS_TRE) $(CFLAGS_LUA) $(CFLAGS_LPEG) $(CFLAGS_STD) + $(CFLAGS_SELINUX) $(CFLAGS_TRE) $(CFLAGS_LUA) $(CFLAGS_LPEG) $(CFLAGS_STD) \ + -DVIS_EXPORT=static CFLAGS_VIS += -DVIS_PATH=\"${SHAREPREFIX}/vis\" -CFLAGS_VIS += -DCONFIG_HELP=${CONFIG_HELP} -CFLAGS_VIS += -DCONFIG_CURSES=${CONFIG_CURSES} -CFLAGS_VIS += -DCONFIG_LUA=${CONFIG_LUA} -CFLAGS_VIS += -DCONFIG_LPEG=${CONFIG_LPEG} -CFLAGS_VIS += -DCONFIG_TRE=${CONFIG_TRE} -CFLAGS_VIS += -DCONFIG_SELINUX=${CONFIG_SELINUX} -CFLAGS_VIS += -DCONFIG_ACL=${CONFIG_ACL} LDFLAGS_VIS = $(LDFLAGS_AUTO) $(LDFLAGS_TERMKEY) $(LDFLAGS_CURSES) $(LDFLAGS_ACL) \ $(LDFLAGS_SELINUX) $(LDFLAGS_TRE) $(LDFLAGS_LUA) $(LDFLAGS_LPEG) $(LDFLAGS_STD) @@ -79,19 +34,8 @@ config.h: config.mk: @touch $@ -obj/.tstamp: - mkdir obj - touch obj/.tstamp - -obj/main.o: config.h - -$(OBJ): config.mk obj/.tstamp - ${CC} ${CFLAGS} ${CFLAGS_VIS} ${CFLAGS_EXTRA} -o $@ -c $(@:obj/%.o=%.c) - --include obj/*.d - -vis: ${OBJ} - ${CC} -o $@ ${OBJ} ${LDFLAGS} ${LDFLAGS_VIS} ${LDFLAGS_EXTRA} +vis: config.h + ${CC} ${CFLAGS} ${CFLAGS_VIS} ${CFLAGS_EXTRA} main.c ${LDFLAGS} ${LDFLAGS_VIS} ${LDFLAGS_EXTRA} -o $@ vis-menu: vis-menu.c ${CC} ${CFLAGS} ${CFLAGS_AUTO} ${CFLAGS_STD} ${CFLAGS_EXTRA} $< ${LDFLAGS} ${LDFLAGS_STD} ${LDFLAGS_AUTO} ${LDFLAGS_EXTRA} -o $@ @@ -148,17 +92,13 @@ coverage: clean test: @$(MAKE) -C test -testclean: - @echo cleaning the test artifacts - [ ! -e test/Makefile ] || $(MAKE) -C test clean - clean: @echo cleaning @$(MAKE) -C doc clean - @rm -rf obj - @rm -f $(ELF) vis-single vis-single-payload.inc vis-*.tar.gz *.gcov *.gcda *.gcno *.d + @$(MAKE) -C test clean + @rm -f $(ELF) vis-single vis-single-payload.inc vis-*.tar.gz *.gcov *.gcda *.gcno -distclean: clean testclean +distclean: clean @echo cleaning build configuration @rm -f config.h config.mk @@ -229,4 +169,4 @@ uninstall: @echo removing support files from ${DESTDIR}${SHAREPREFIX}/vis @rm -rf ${DESTDIR}${SHAREPREFIX}/vis -.PHONY: all clean testclean dist distclean install install-strip uninstall debug profile coverage test test-update luadoc luadoc-all luacheck man docker-kill docker docker-clean +.PHONY: all clean vis dist distclean install install-strip uninstall debug profile coverage test test-update luadoc luadoc-all luacheck man docker-kill docker docker-clean @@ -220,7 +220,7 @@ tryflag CFLAGS_TRY -Werror=unused-command-line-argument tryldflag LDFLAGS_TRY -Werror=unknown-warning-option tryldflag LDFLAGS_TRY -Werror=unused-command-line-argument -CFLAGS_STD="-std=c99 -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG -MMD" +CFLAGS_STD="-std=c99 -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG" LDFLAGS_STD="-lc" OS=$(uname) @@ -252,6 +252,8 @@ tryldflag LDFLAGS -Wl,-z,now tryldflag LDFLAGS -Wl,-z,relro tryldflag LDFLAGS_AUTO -pie +[ "$help" = "no" ] && CFLAGS="${CFLAGS} -DCONFIG_HELP=0" + printf "creating config.mk... " cmdline=$(quote "$0") @@ -292,14 +294,6 @@ printf "checking for pkg-config... " cmdexists pkg-config && have_pkgconfig=yes printf "%s\n" "$have_pkgconfig" -if test "$help" = "yes" ; then - CONFIG_HELP=1 -else - CONFIG_HELP=0 -fi - -CONFIG_CURSES=0 - if test "$curses" != "no" ; then printf "checking for libcurses...\n" @@ -322,7 +316,7 @@ EOF LDFLAGS_CURSES=$(pkg-config --libs $libcurses 2>/dev/null) if test $? -eq 0 && $CC $CFLAGS $CFLAGS_CURSES "$tmpc" \ $LDFLAGS $LDFLAGS_CURSES -o "$tmpo" >/dev/null 2>&1 ; then - CONFIG_CURSES=1 + CFLAGS_CURSES="${CFLAGS_CURSES} -DCONFIG_CURSES=1" printf "yes\n" break fi @@ -333,17 +327,16 @@ EOF if $CC $CFLAGS $CFLAGS_CURSES "$tmpc" \ $LDFLAGS $LDFLAGS_CURSES -o "$tmpo" >/dev/null 2>&1 ; then - CONFIG_CURSES=1 + CFLAGS_CURSES="-DCONFIG_CURSES=1" printf "yes\n" break else - CFLAGS_CURSES="" LDFLAGS_CURSES="" printf "no\n" fi done - test "$curses" = "yes" -a $CONFIG_CURSES -ne 1 && fail "$0: cannot find libcurses" + test "$curses" = "yes" -a -z "${CFLAGS_CURSES}" && fail "$0: cannot find libcurses" fi # libtermkey is a mandatory dependency @@ -376,9 +369,6 @@ else fail "$0: cannot find libtermkey" fi -CONFIG_TRE=0 -REGEX_SRC=text-regex.c - if test "$tre" != "no" ; then printf "checking for libtre... " @@ -410,8 +400,7 @@ EOF if $CC $CFLAGS $CFLAGS_TRE "$tmpc" \ $LDFLAGS $LDFLAGS_TRE -o "$tmpo" >/dev/null 2>&1; then - CONFIG_TRE=1 - REGEX_SRC=text-regex-tre.c + CFLAGS_TRE="${CFLAGS_TRE} -DCONFIG_TRE=1" printf "%s\n" "yes" else printf "%s\n" "no" @@ -421,7 +410,6 @@ EOF fi fi -CONFIG_LUA=0 # enabling builtin lpeg requires lua support test "$lpeg" = "yes" -a "$lua" = "no" && fail "$0: need lua support for built-in lpeg" @@ -456,7 +444,7 @@ EOF LDFLAGS_LUA=$(pkg-config --libs $liblua 2>/dev/null) if test $? -eq 0 && $CC $CFLAGS $CFLAGS_LUA "$tmpc" \ $LDFLAGS $LDFLAGS_LUA -o "$tmpo" >/dev/null 2>&1 ; then - CONFIG_LUA=1 + CFLAGS_LUA="${CFLAGS_LUA} -DCONFIG_LUA=1" printf "yes\n" break fi @@ -467,26 +455,19 @@ EOF if $CC $CFLAGS $CFLAGS_LUA "$tmpc" \ $LDFLAGS $LDFLAGS_LUA -o "$tmpo" >/dev/null 2>&1 ; then - CONFIG_LUA=1 + CFLAGS_LUA="-DCONFIG_LUA=1" printf "yes\n" break else printf "no\n" - CFLAGS_LUA="" LDFLAGS_LUA="" fi done - test "$lua" = "yes" -a $CONFIG_LUA -ne 1 && fail "$0: cannot find liblua" - - if test $CONFIG_LUA -eq 1; then - CFLAGS_LUA="$CFLAGS_LUA -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_3 -DLUA_COMPAT_ALL" - fi + test "$lua" = "yes" -a -z "${CFLAGS_LUA}" && fail "$0: cannot find liblua" fi -CONFIG_LPEG=0 - -if test $CONFIG_LUA -eq 1 -a "$lpeg" != "no" ; then +if test -n "${CFLAGS_LUA}" -a "$lpeg" != "no" ; then printf "checking for Lua statically linked liblpeg...\n" @@ -517,7 +498,7 @@ EOF LDFLAGS_LPEG=$(pkg-config --libs $liblpeg 2>/dev/null) if test $? -eq 0 && $CC $CFLAGS $CFLAGS_LUA $CFLAGS_LPEG "$tmpc" \ $LDFLAGS $LDFLAGS_LUA $LDFLAGS_LPEG -o "$tmpo" >/dev/null 2>&1 ; then - CONFIG_LPEG=1 + CFLAGS_LPEG="${CFLAGS_LPEG} -DCONFIG_LPEG=1" printf "yes\n" break fi @@ -528,21 +509,18 @@ EOF if $CC $CFLAGS $CFLAGS_LUA $CFLAGS_LPEG "$tmpc" \ $LDFLAGS $LDFLAGS_LUA $LDFLAGS_LPEG -o "$tmpo" >/dev/null 2>&1 ; then - CONFIG_LPEG=1 + CFLAGS_LPEG="-DCONFIG_LPEG=1" printf "yes\n" break else printf "no\n" - CFLAGS_LPEG="" LDFLAGS_LPEG="" fi done - test "$lpeg" = "yes" -a $CONFIG_LPEG -ne 1 && fail "$0: cannot find liblpeg" + test "$lpeg" = "yes" -a -z "${CFLAGS_LPEG}" && fail "$0: cannot find liblpeg" fi -CONFIG_ACL=0 - if test "$OS" = "Linux" -a "$acl" != "no"; then printf "checking for libacl... " @@ -568,7 +546,7 @@ EOF if $CC $CFLAGS $CFLAGS_ACL "$tmpc" \ $LDFLAGS $LDFLAGS_ACL -o "$tmpo" >/dev/null 2>&1; then - CONFIG_ACL=1 + CFLAGS_ACL="${CFLAGS_ACL} -DCONFIG_ACL=1" printf "%s\n" "yes" else printf "%s\n" "no" @@ -578,8 +556,6 @@ EOF fi fi -CONFIG_SELINUX=0 - if test "$OS" = "Linux" -a "$selinux" != "no"; then printf "checking for libselinux... " @@ -603,7 +579,7 @@ EOF if $CC $CFLAGS $CFLAGS_SELINUX "$tmpc" \ $LDFLAGS $LDFLAGS_SELINUX -o "$tmpo" >/dev/null 2>&1; then - CONFIG_SELINUX=1 + CFLAGS_SELINUX="${CFLAGS_SELINUX} -DCONFIG_SELINUX=1" printf "%s\n" "yes" else printf "%s\n" "no" @@ -618,26 +594,18 @@ printf "completing config.mk... " exec 3>&1 1>>config.mk cat << EOF -CONFIG_HELP = $CONFIG_HELP CFLAGS_TERMKEY = $CFLAGS_TERMKEY LDFLAGS_TERMKEY = $LDFLAGS_TERMKEY -CONFIG_CURSES = $CONFIG_CURSES CFLAGS_CURSES = $CFLAGS_CURSES LDFLAGS_CURSES = $LDFLAGS_CURSES -REGEX_SRC = $REGEX_SRC -CONFIG_TRE = $CONFIG_TRE CFLAGS_TRE = $CFLAGS_TRE LDFLAGS_TRE = $LDFLAGS_TRE -CONFIG_LUA = $CONFIG_LUA CFLAGS_LUA = $CFLAGS_LUA LDFLAGS_LUA = $LDFLAGS_LUA -CONFIG_LPEG = $CONFIG_LPEG CFLAGS_LPEG = $CFLAGS_LPEG LDFLAGS_LPEG = $LDFLAGS_LPEG -CONFIG_ACL = $CONFIG_ACL CFLAGS_ACL = $CFLAGS_ACL LDFLAGS_ACL = $LDFLAGS_ACL -CONFIG_SELINUX = $CONFIG_SELINUX CFLAGS_SELINUX = $CFLAGS_SELINUX LDFLAGS_SELINUX = $LDFLAGS_SELINUX EOF @@ -1,26 +1,4 @@ -#include <signal.h> -#include <limits.h> -#include <string.h> -#include <stdio.h> -#include <wchar.h> -#include <ctype.h> -#include <errno.h> -#include <fcntl.h> -#include <inttypes.h> -#include <sys/stat.h> -#include <sys/types.h> - -#include "util.h" - -#include "ui.h" -#include "vis.h" -#include "vis-lua.h" -#include "text-util.h" -#include "text-motions.h" -#include "text-objects.h" -#include "libutf.h" -#include "array.h" -#include "buffer.h" +#include "vis.c" static Vis vis[1]; diff --git a/test/core/Makefile b/test/core/Makefile index 4430cde..fc108f0 100644 --- a/test/core/Makefile +++ b/test/core/Makefile @@ -2,7 +2,7 @@ ALL = buffer-test map-test array-test text-test SRC = $(wildcard ccan/*/*.c) -CFLAGS += -I. -I../.. -DBUFFER_SIZE=4 -DBLOCK_SIZE=4 +CFLAGS += -Wno-unused-function -I. -I../.. -DBUFFER_SIZE=4 -DBLOCK_SIZE=4 test: $(ALL) @./buffer-test @@ -16,7 +16,7 @@ config.h: text-test: config.h text-test.c ../../text.c ../../text-common.c ../../text-io.c ../../text-iterator.c ../../text-util.c ../../text-motions.c ../../text-objects.c ../../text-regex.c ../../array.c @echo Compiling $@ binary - @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_EXTRA} ${filter %.c, $^} ${SRC} ${LDFLAGS} -o $@ + @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_EXTRA} text-test.c ${SRC} ${LDFLAGS} -o $@ buffer-test: config.h buffer-test.c ../../buffer.c @echo Compiling $@ binary @@ -24,7 +24,7 @@ buffer-test: config.h buffer-test.c ../../buffer.c map-test: config.h map-test.c ../../map.c @echo Compiling $@ binary - @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_EXTRA} ${filter %.c, $^} ${SRC} ${LDFLAGS} -o $@ + @${CC} ${CFLAGS} ${CFLAGS_STD} ${CFLAGS_EXTRA} map-test.c ${SRC} ${LDFLAGS} -o $@ array-test: config.h array-test.c ../../array.c @echo Compiling $@ binary diff --git a/test/core/map-test.c b/test/core/map-test.c index 06364e4..a8231a3 100644 --- a/test/core/map-test.c +++ b/test/core/map-test.c @@ -3,7 +3,7 @@ #include <string.h> #include <stdio.h> #include "tap.h" -#include "map.h" +#include "map.c" static bool get(Map *map, const char *key, const void *data) { return map_get(map, key) == data && map_closest(map, key) == data; diff --git a/test/core/text-test.c b/test/core/text-test.c index f6004c1..c69038c 100644 --- a/test/core/text-test.c +++ b/test/core/text-test.c @@ -6,10 +6,13 @@ #include <string.h> #include <unistd.h> #include "tap.h" -#include "text.h" -#include "text-util.h" + #include "util.h" +#include "array.c" +#include "buffer.c" +#include "text.c" + #ifndef BUFSIZ #define BUFSIZ 1024 #endif @@ -13,13 +13,25 @@ #include <sys/stat.h> #include <sys/mman.h> -#include "text.h" -#include "text-util.h" -#include "text-motions.h" #include "util.h" + #include "array.h" + +#include "text.h" #include "text-internal.h" +#include "text-common.c" +#include "text-io.c" +#include "text-iterator.c" +#include "text-motions.c" +#include "text-objects.c" +#if CONFIG_TRE + #include "text-regex-tre.c" +#else + #include "text-regex.c" +#endif +#include "text-util.c" + /* A piece holds a reference (but doesn't itself store) a certain amount of data. * All active pieces chained together form the whole content of the document. * At the beginning there exists only one piece, spanning the whole document. @@ -2,7 +2,28 @@ #define UTIL_H #ifndef VIS_INTERNAL - #define VIS_INTERNAL + #define VIS_INTERNAL static +#endif +#ifndef CONFIG_HELP + #define CONFIG_HELP 1 +#endif +#ifndef CONFIG_CURSES + #define CONFIG_CURSES 0 +#endif +#ifndef CONFIG_LUA + #define CONFIG_LUA 0 +#endif +#ifndef CONFIG_LPEG + #define CONFIG_LPEG 0 +#endif +#ifndef CONFIG_TRE + #define CONFIG_TRE 0 +#endif +#ifndef CONFIG_SELINUX + #define CONFIG_SELINUX 0 +#endif +#ifndef CONFIG_ACL + #define CONFIG_ACL 0 #endif #include <stdbool.h> @@ -2,6 +2,10 @@ #define VIS_LUA_H #if CONFIG_LUA +#define LUA_COMPAT_5_1 +#define LUA_COMPAT_5_2 +#define LUA_COMPAT_5_3 +#define LUA_COMPAT_ALL #include <lua.h> #include <lualib.h> #include <lauxlib.h> @@ -32,6 +32,25 @@ #include "vis-subprocess.h" +#include "array.c" +#include "buffer.c" +#include "event-basic.c" +#include "libutf.c" +#include "map.c" +#include "sam.c" +#include "text.c" +#include "ui-terminal.c" +#include "view.c" +#include "vis-lua.c" +#include "vis-marks.c" +#include "vis-modes.c" +#include "vis-motions.c" +#include "vis-operators.c" +#include "vis-prompt.c" +#include "vis-registers.c" +#include "vis-subprocess.c" +#include "vis-text-objects.c" + static void macro_replay(Vis *vis, const Macro *macro); static void macro_replay_internal(Vis *vis, const Macro *macro); static void vis_keys_push(Vis *vis, const char *input, size_t pos, bool record); |
