Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F22590412
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/Makefile b/src/Makefile
index fdb1501..bafd1d5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,113 +1,131 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# ___ __ \_____ ___ /____ /____(_)_ /___ |/ /_ __ \ #
# __ /_/ / __ `/_ __ \_ __ \_ /_ __/_ /|_/ /_ / / / #
# _ _, _// /_/ /_ /_/ / /_/ / / / /_ _ / / / / /_/ / #
# /_/ |_| \__,_/ /_.___//_.___//_/ \__/ /_/ /_/ \___\_\ #
# _____________________ #
# RabbitMQ C AMQP client library TCL wrapper ___ __/_ ____/__ / #
# TCL module to connect to AMQP brokers. __ / _ / __ / #
# _ / / /___ _ /___ #
# (c) 2015, Nasqueron, some rights reserved. /_/ \____/ /_____/ #
# Released under BSD-2-Clause license. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Useful targets:
# ---------------
# Compile released version ........... make
# Compile customized build ........... make clean lint all
# Compile, run tests & tclsh ......... make rebuild
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Codebase and build configuration #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Library versioning
# These variables should be coherent with src/version.h
MAJOR_VERSION=0
VERSION=0.1.0
# 3rd party versions
TCLVERSION=8.6
# Headers to include
TCL_INCLUDE=/usr/include/tcl${TCLVERSION}
RABBITMQ_INCLUDE=/usr/include
INCLUDES=-I$(TCL_INCLUDE) -I$(RABBITMQ_INCLUDE)
# Libraries to use
LIBS=-ltcl${TCLVERSION} -lrabbitmq
# Other options
CCOPTS=-DDEBUG
# Paths
BUILD=../build
# Commands to use
ARC=arc
CAT=cat
CC=clang ${CCOPTS} ${INCLUDES}
DATE=date
LINKER=clang ${LIBS}
MKDIR=mkdir -p
RLWRAP=rlwrap
RM=rm -f
SYMLINK=ln -s
TCLSH=tclsh${TCLVERSION}
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Targets, build process utility steps #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-# Main targets
+# Main build targets
-all: print-banner ${BUILD}/rabbitmq.so
+all: print-banner lib pkg
-clean:
+clean: cleanlib cleanpkg
+
+# Build steps targets
+
+lib: ${BUILD}/rabbitmq.so
+
+pkg: ${BUILD}/pkgIndex.tcl
+
+cleanlib:
$(RM) core ${BUILD}/*.o ${BUILD}/*.so ${BUILD}/*.so.${VERSION}
+cleanpkg:
+ $(RM) ${BUILD}/makePkgIndex ${BUILD}/pkgIndex.tcl
+
# Dev targets
lint:
${ARC} lint --apply-patches
test:
cd ../tests && make retest
demo:
${RLWRAP} ${TCLSH}
rebuild: clean lint all test demo
# Helpers
print-banner:
@${CAT} ../doc/banner
@${DATE}
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Compile and link process #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
${BUILD}/rabbitmq.so: ${BUILD}/rabbitmq.o
${LINKER} -shared -Wl,-soname,rabbitmq.so.${MAJOR_VERSION} -o ${BUILD}/rabbitmq.so.${VERSION} ${BUILD}/*.o
cd ${BUILD} && ${SYMLINK} rabbitmq.so.${VERSION} rabbitmq.so
${BUILD}/rabbitmq.o:
${MKDIR} ${BUILD}
${CC} -c -fPIC utils/netutils.c -o ${BUILD}/netutils.o
${CC} -c -fPIC rabbitmq-tcl.c -o ${BUILD}/rabbitmq.o
+
+${BUILD}/makePkgIndex:
+ ${MKDIR} ${BUILD}
+ ${CC} makePkgIndex.c -o ${BUILD}/makePkgIndex
+
+${BUILD}/pkgIndex.tcl: ${BUILD}/makePkgIndex
+ ${BUILD}/makePkgIndex pkgIndex.tcl.in > ${BUILD}/pkgIndex.tcl
diff --git a/src/makePkgIndex.c b/src/makePkgIndex.c
new file mode 100644
index 0000000..8d0b58b
--- /dev/null
+++ b/src/makePkgIndex.c
@@ -0,0 +1,93 @@
+/* -------------------------------------------------------------
+ RabbitMQ TCL - Create pkgIndex.tcl file
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ ___ __ \_____ ___ /____ /____(_)_ /___ |/ /_ __ \
+ __ /_/ / __ `/_ __ \_ __ \_ /_ __/_ /|_/ /_ / / /
+ _ _, _// /_/ /_ /_/ / /_/ / / / /_ _ / / / / /_/ /
+ /_/ |_| \__,_/ /_.___//_.___//_/ \__/ /_/ /_/ \___\_\
+ _____________________
+ RabbitMQ C AMQP client library TCL wrapper ___ __/_ ____/__ /
+ TCL module to connect to AMQP brokers. __ / _ / __ /
+ _ / / /___ _ /___
+ (c) 2015, Nasqueron, some rights reserved. /_/ \____/ /_____/
+ Released under BSD-2-Clause license.
+
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ Software: RabbitMQ TCL
+ Author: Sébastien Santoro aka Dereckson
+ Filename: rabbitmq-tcl.h
+ Created: 2015-12-08
+ Licence: BSD-2-Clause
+ ------------------------------------------------------------- */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "version.h"
+#include "utils/strutils.h"
+
+/* -------------------------------------------------------------
+ Templates functions
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+/**
+ * Substitutes templates variables
+ *
+ * @param text The text with variables to substitute
+ * @return The substituted text
+ */
+char *subst_template_variables(char *text) {
+ char *substText;
+
+ substText = str_replace("%%PACKAGE_NAME%%", PACKAGE_NAME, text);
+ substText = str_replace("%%PACKAGE_VERSION%%", PACKAGE_VERSION, substText);
+
+ return substText;
+}
+
+/**
+ * Prints a template, after variable substitution
+ *
+ * @param filename The patho to the template
+ */
+void print_template(const char *filename) {
+ FILE *fp;
+ char *line = NULL;
+ size_t len = 0;
+ ssize_t read;
+
+ // Reads line by line, substitutes and prints
+ // TODO: replace by more standard than getline
+ fp = fopen(filename, "r");
+ while ((read = getline(&line, &len, fp)) != -1) {
+ printf("%s", subst_template_variables(line));
+ }
+ fclose(fp);
+}
+
+/* -------------------------------------------------------------
+ Program entry point
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+int main(int argc, char **argv) {
+ char *filename;
+
+ // Usage: <executable> <template file>
+ if (argc != 2) {
+ printf("Wrong argument count.\n");
+ return 1;
+ }
+
+ // Template to read
+ filename = argv[1];
+ if (access(filename, F_OK) == -1) {
+ return 2;
+ }
+
+ // Output
+ print_template(filename);
+
+ return 0;
+}
diff --git a/src/pkgIndex.tcl.in b/src/pkgIndex.tcl.in
new file mode 100644
index 0000000..f5ea72d
--- /dev/null
+++ b/src/pkgIndex.tcl.in
@@ -0,0 +1,4 @@
+# Package index for %%PACKAGE_NAME%%
+
+package ifneeded %%PACKAGE_NAME%% %%PACKAGE_VERSION%% \
+ [list load [file join [list $dir] %%PACKAGE_NAME%%[info sharedlibextension]]]
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Jan 31, 17:51 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3403934
Default Alt Text
(7 KB)
Attached To
Mode
rRABBITMQTCL RabbitMQ TCL extension
Attached
Detach File
Event Timeline
Log In to Comment