mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 12:39:01 -04:00
Split up kore cli tools into new binary.
Having the create, build, run tools baked into the kore binary made things harder then they had to be for multiple projects with each different build flavors. So move away this functionality into a new "kodev" (name may change) binary that is installed next to kore. The new build tools will automatically pick up the correct flavors the kore binary it points to is installed with. Or for single builds what flavors where enabled. The new tool also will honor looking into PREFIX for the kore binary when doing a `kodev run`. Additionally add a new command "info" that shows some basic info about your project and how it will be built. For example it will show you the flavors of the kore binary installed on the system or the flavors you configured for a single binary build. Obligitory, hacking on a plane comment.
This commit is contained in:
parent
a0c545884f
commit
fc6b3bf740
33
Makefile
33
Makefile
@ -4,7 +4,9 @@ CC?=gcc
|
||||
PREFIX?=/usr/local
|
||||
OBJDIR?=obj
|
||||
KORE=kore
|
||||
KODEV=kodev/kodev
|
||||
INSTALL_DIR=$(PREFIX)/bin
|
||||
SHARE_DIR=$(PREFIX)/share/kore
|
||||
INCLUDE_DIR=$(PREFIX)/include/kore
|
||||
|
||||
S_SRC= src/kore.c src/buf.c src/config.c src/connection.c \
|
||||
@ -13,6 +15,7 @@ S_SRC= src/kore.c src/buf.c src/config.c src/connection.c \
|
||||
src/keymgr.c
|
||||
|
||||
FEATURES=
|
||||
FEATURES_INC=
|
||||
|
||||
CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
|
||||
CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
|
||||
@ -20,9 +23,7 @@ CFLAGS+=-Wsign-compare -Iincludes -std=c99 -pedantic
|
||||
CFLAGS+=-DPREFIX='"$(PREFIX)"'
|
||||
LDFLAGS=-rdynamic -lssl -lcrypto
|
||||
|
||||
ifeq ("$(KORE_SINGLE_BINARY)", "")
|
||||
S_SRC+=src/cli.c
|
||||
else
|
||||
ifneq ("$(KORE_SINGLE_BINARY)", "")
|
||||
CFLAGS+=-DKORE_SINGLE_BINARY
|
||||
FEATURES+=-DKORE_SINGLE_BINARY
|
||||
endif
|
||||
@ -62,7 +63,8 @@ ifneq ("$(PGSQL)", "")
|
||||
LDFLAGS+=-L$(shell pg_config --libdir) -lpq
|
||||
CFLAGS+=-I$(shell pg_config --includedir) -DKORE_USE_PGSQL \
|
||||
-DPGSQL_INCLUDE_PATH="\"$(shell pg_config --includedir)\""
|
||||
FEATURES+=-I$(shell pg_config --includedir) -DKORE_USE_PGSQL
|
||||
FEATURES+=-DKORE_USE_PGSQL
|
||||
FEATURES_INC+=-I$(shell pg_config --includedir)
|
||||
endif
|
||||
|
||||
ifneq ("$(TASKS)", "")
|
||||
@ -83,7 +85,8 @@ ifneq ("$(PYTHON)", "")
|
||||
S_SRC+=src/python.c
|
||||
LDFLAGS+=$(shell python3-config --ldflags)
|
||||
CFLAGS+=$(shell python3-config --includes) -DKORE_USE_PYTHON
|
||||
FEATURES+=$(shell python3-config --includes) -DKORE_USE_PYTHON
|
||||
FEATURES+=-DKORE_USE_PYTHON
|
||||
FEATURES_INC+=$(shell python3-config --includes)
|
||||
endif
|
||||
|
||||
OSNAME=$(shell uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
|
||||
@ -105,33 +108,43 @@ endif
|
||||
|
||||
S_OBJS= $(S_SRC:src/%.c=$(OBJDIR)/%.o)
|
||||
|
||||
all: $(KORE) $(KODEV)
|
||||
|
||||
$(KODEV):
|
||||
$(MAKE) -C kodev
|
||||
|
||||
$(KORE): $(OBJDIR) $(S_OBJS)
|
||||
$(CC) $(S_OBJS) $(LDFLAGS) -o $(KORE)
|
||||
@echo $(FEATURES) > kore.features
|
||||
|
||||
objects: $(OBJDIR) $(S_OBJS)
|
||||
@echo $(LDFLAGS) > $(OBJDIR)/ldflags
|
||||
@echo $(FEATURES) > $(OBJDIR)/features
|
||||
|
||||
all: $(KORE)
|
||||
@echo "$(FEATURES) $(FEATURES_INC)" > $(OBJDIR)/features
|
||||
|
||||
$(OBJDIR):
|
||||
@mkdir -p $(OBJDIR)
|
||||
|
||||
install:
|
||||
install: $(KORE) $(KODEV)
|
||||
mkdir -p $(SHARE_DIR)
|
||||
mkdir -p $(INCLUDE_DIR)
|
||||
mkdir -p $(INSTALL_DIR)
|
||||
install -m 555 $(KORE) $(INSTALL_DIR)/$(KORE)
|
||||
install -m 644 kore.features $(SHARE_DIR)/features
|
||||
install -m 644 includes/*.h $(INCLUDE_DIR)
|
||||
$(MAKE) -C kodev install
|
||||
|
||||
uninstall:
|
||||
rm -f $(INSTALL_DIR)/$(KORE)
|
||||
rm -rf $(INCLUDE_DIR)
|
||||
rm -rf $(SHARE_DIR)
|
||||
$(MAKE) -C kodev uninstall
|
||||
|
||||
$(OBJDIR)/%.o: src/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
find . -type f -name \*.o -exec rm {} \;
|
||||
rm -rf $(KORE) $(OBJDIR)
|
||||
rm -rf $(KORE) $(OBJDIR) kore.features
|
||||
$(MAKE) -C kodev clean
|
||||
|
||||
.PHONY: all clean
|
||||
|
@ -19,10 +19,6 @@
|
||||
#ifndef __H_HTTP_H
|
||||
#define __H_HTTP_H
|
||||
|
||||
#if defined(KORE_USE_PYTHON)
|
||||
#include "python_api.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
@ -212,7 +208,7 @@ struct http_request {
|
||||
struct kore_module_handle *hdlr;
|
||||
|
||||
#if defined(KORE_USE_PYTHON)
|
||||
PyObject *py_coro;
|
||||
void *py_coro;
|
||||
#endif
|
||||
|
||||
LIST_HEAD(, kore_task) tasks;
|
||||
|
@ -477,9 +477,6 @@ extern struct kore_domain_h domains;
|
||||
extern struct kore_domain *primary_dom;
|
||||
extern struct kore_pool nb_pool;
|
||||
|
||||
void kore_cli_usage(int);
|
||||
int kore_cli_main(int, char **);
|
||||
|
||||
void kore_signal(int);
|
||||
void kore_worker_wait(int);
|
||||
void kore_worker_init(void);
|
||||
|
53
kodev/Makefile
Normal file
53
kodev/Makefile
Normal file
@ -0,0 +1,53 @@
|
||||
# kodev Makefile
|
||||
|
||||
CC?=gcc
|
||||
PREFIX?=/usr/local
|
||||
OBJDIR?=obj
|
||||
KODEV=kodev
|
||||
INSTALL_DIR=$(PREFIX)/bin
|
||||
|
||||
S_SRC= ../src/cli.c
|
||||
|
||||
CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
|
||||
CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
|
||||
CFLAGS+=-Wsign-compare -Iincludes -std=c99 -pedantic
|
||||
CFLAGS+=-DPREFIX='"$(PREFIX)"'
|
||||
LDFLAGS=-rdynamic -lcrypto
|
||||
|
||||
ifneq ("$(NOOPT)", "")
|
||||
CFLAGS+=-O0
|
||||
else
|
||||
CFLAGS+=-O2
|
||||
endif
|
||||
|
||||
OSNAME=$(shell uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
|
||||
ifeq ("$(OSNAME)", "darwin")
|
||||
CFLAGS+=-I/opt/local/include/ -I/usr/local/opt/openssl/include
|
||||
LDFLAGS+=-L/opt/local/lib -L/usr/local/opt/openssl/lib
|
||||
else ifeq ("$(OSNAME)", "linux")
|
||||
CFLAGS+=-D_GNU_SOURCE=1
|
||||
endif
|
||||
|
||||
S_OBJS= $(S_SRC:../src/%.c=$(OBJDIR)/%.o)
|
||||
|
||||
$(KODEV): $(OBJDIR) $(S_OBJS)
|
||||
$(CC) $(S_OBJS) $(LDFLAGS) -o $(KODEV)
|
||||
|
||||
$(OBJDIR):
|
||||
@mkdir -p $(OBJDIR)
|
||||
|
||||
install: $(KODEV)
|
||||
mkdir -p $(INSTALL_DIR)
|
||||
install -m 555 $(KODEV) $(INSTALL_DIR)/$(KODEV)
|
||||
|
||||
uninstall:
|
||||
rm -f $(INSTALL_DIR)/$(KODEV)
|
||||
|
||||
$(OBJDIR)/%.o: ../src/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
find . -type f -name \*.o -exec rm {} \;
|
||||
rm -rf $(KODEV) $(OBJDIR)
|
||||
|
||||
.PHONY: all clean
|
@ -29,6 +29,10 @@
|
||||
#include "kore.h"
|
||||
#include "http.h"
|
||||
|
||||
#if defined(KORE_USE_PYTHON)
|
||||
#include "python_api.h"
|
||||
#endif
|
||||
|
||||
#if defined(KORE_USE_PGSQL)
|
||||
#include "pgsql.h"
|
||||
#endif
|
||||
|
16
src/kore.c
16
src/kore.c
@ -63,7 +63,7 @@ static void
|
||||
usage(void)
|
||||
{
|
||||
#if !defined(KORE_SINGLE_BINARY)
|
||||
fprintf(stderr, "Usage: kore [options | command]\n");
|
||||
fprintf(stderr, "Usage: kore [options]\n");
|
||||
#else
|
||||
fprintf(stderr, "Usage: %s [options]\n", __progname);
|
||||
#endif
|
||||
@ -81,12 +81,8 @@ usage(void)
|
||||
fprintf(stderr, "\t-r\tdo not drop privileges\n");
|
||||
fprintf(stderr, "\t-v\tdisplay kore build information\n");
|
||||
|
||||
#if !defined(KORE_SINGLE_BINARY)
|
||||
kore_cli_usage(0);
|
||||
#else
|
||||
fprintf(stderr, "\nbuilt with https://kore.io\n");
|
||||
fprintf(stderr, "\nFind more information on https://kore.io\n");
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@ -171,14 +167,6 @@ main(int argc, char *argv[])
|
||||
|
||||
kore_mem_init();
|
||||
|
||||
#if !defined(KORE_SINGLE_BINARY)
|
||||
if (argc > 0) {
|
||||
if (flags)
|
||||
fatal("You cannot specify kore flags and a command");
|
||||
return (kore_cli_main(argc, argv));
|
||||
}
|
||||
#endif
|
||||
|
||||
kore_pid = getpid();
|
||||
nlisteners = 0;
|
||||
LIST_INIT(&listeners);
|
||||
|
Loading…
x
Reference in New Issue
Block a user