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

Hi there, thanks for sharing livizjs. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
178 changes: 165 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,167 @@
all:
cd cdt; make
cd common; make
cd gvc; make
cd pathplan; make
cd graph; make
cd dotgen; make
# Nathan Ramella ([email protected])

CC = clang
EMCC = emcc
DEFINES = -DHAVE_CONFIG_H
INCLUDE = -I. -Icdt -Icommon -Idotgen -Igraph -Igvc -Ipathplan
OPTIMIZATION_LEVEL = -O3

# Setting c99 might not be critically important, but c89 didn't play
# well for lack of inline.A

CFLAGS = -std=c99

ifeq "$(shell uname -s)" "Darwin"
EXTRA_CFLAGS = -arch i686
EXTRA_DEFINES = -DHAVE_STRINGS_H
endif

SUBDIRS = cdt common gvc pathplan graph dotgen dotgen/liviz-api

COMPILER_CMD=$(EMCC) $(DEFINES) $(EXTRA_DEFINES) $(INCLUDE) $(EXTRA_INCLUDE) $(CFLAGS) $(EXTRA_CFLAGS)

# Dynamically generate a timestamp to tag the
# build with.

BUILD_TIMESTAMP = $(shell date +%s)

CDT_SRC = $(addprefix cdt/, \
dtclose.c dtdisc.c dtextract.c dtview.c \
dthash.c dtlist.c dtflatten.c dtrestore.c \
dtopen.c dtsize.c dtstrhash.c dttreeset.c \
dttree.c dtwalk.c dtmethod.c)

COMMON_SRC = $(addprefix common/, \
ns.c xdot.c emit.c geom.c input.c utils.c \
arrows.c timing.c labels.c memory.c \
shapes.c splines.c globals.c htmllex.c \
postproc.c htmlparse.c htmltable.c \
routespl.c colxlate.c psusershape.c \
fontmetrics.c)

GVC_SRC = $(addprefix gvc/, \
gvc.c gvconfig.c gvcontext.c gvdevice.c \
gvlayout.c gvevent.c gvjobs.c gvplugin.c \
gvrender.c gvusershape.c gvloadimage.c \
gvtextlayout.c)

PATHPLAN_SRC = $(addprefix pathplan/, \
cvt.c inpoly.c route.c shortest.c \
solvers.c triang.c util.c \
visibility.c)

GRAPH_SRC = $(addprefix graph/, \
agxbuf.c attribs.c edge.c graph.c \
graphio.c lexer.c node.c parser.c \
refstr.c trie.c)

DOTGEN_SRC = $(addprefix dotgen/, \
acyclic.c aspect.c class1.c class2.c \
cluster.c compound.c conc.c decomp.c \
dotinit.c dotsplines.c fastgr.c \
flat.c mincross.c position.c rank.c \
sameport.c)

# This is a little trick to make the maintenance of exported
# functions a little easier. Add them to the EXPORTED_FUNCTION_LIST
# below and at build time through the magic of awk and some make
# voodoo, they'll be assembled into a Python parsable array that
# can be passed to emscripten.


EXPORTED_FUNCTION_LIST = \
_finalizeGVContext \
_prepareGVContext \
_getFirstNode \
_getNextNode \
_getCurentGraph \
_beginGVJob \
_testCountNodes \
_countEdges \
_extractGraph \
_runDotLayout \
_getNodeName \
_getGraphWidth \
_getGraphHeight \
_getEdgeColor \
_extractRanks \
_extractEdgesEarly \
_getEdgeLabel

EXPORTED_FUNCTIONS = $(addprefix -s EXPORTED_FUNCTIONS=[, \
$(addsuffix ], \
$(shell echo $(EXPORTED_FUNCTION_LIST) \
| awk '{for (i=1;i<NF;++i) printf("\\\"%s\\\",",$$i); printf("\\\"%s\\\"\n",$$NF) }') \
) \
)

LIBS = $(addprefix build/, \
libcdt-em.bc \
libcommon-em.bc \
libgvc-em.bc \
libpathplan-em.bc \
libgraph-em.bc \
dotgen-em.bc)

default: all

all: build build_config_summary em-dotgen.js
mv em-dotgen.js liviz/
@ls -l liviz/em-dotgen.js
@echo "-------------------------------------------------------"
@echo "Done!"

.PHONY:
build_config_summary:
@echo "-------------------------------------------------------"
@echo
@echo " DEFINES = $(DEFINES) $(EXTRA_DEFINES)" | pr -l1 -t -3
@echo " INCLUDE = $(INCLUDE) $(EXTRA_INCLUDE)" | pr -l1 -t -3
@echo " EMFLAGS = $(EMFLAGS)" | pr -l1 -t -3
@echo
@echo " OPT = $(OPTIMIZATION_LEVEL)"
@echo " DEBUG = $(DEBUG)"
@echo
@echo "-------------------------------------------------------"

build:
@mkdir -p build

em-dotgen.js: build/testrun-dot-2.bc
$(EMCC) $(OPTIMIZATION_LEVEL) $(EMFLAGS) $^ $(LIBS) build/liviz-apis.bc -o $@

build/testrun-dot-2.bc: build/liviz-apis.bc
$(COMPILER_CMD) -o $@ -c dotgen/testrun-dot-2.c

build/liviz-apis.bc: build $(LIBS)
$(COMPILER_CMD) -o $@ dotgen/liviz-apis/liviz-apis.c

build/libcdt-em.bc: $(CDT_SRC)
$(COMPILER_CMD) -o $@ $^

build/libcommon-em.bc: $(COMMON_SRC)
$(COMPILER_CMD) -o $@ $^

build/libgvc-em.bc: $(GVC_SRC)
$(COMPILER_CMD) -DBUILDDATE="\"$(BUILD_TIMESTAMP)\"" -o $@ $^

build/libpathplan-em.bc: $(PATHPLAN_SRC)
$(COMPILER_CMD) -o $@ $^

build/libgraph-em.bc: $(GRAPH_SRC)
$(COMPILER_CMD) -o $@ $^

build/dotgen-em.bc: $(DOTGEN_SRC)
$(COMPILER_CMD) -o $@ $^

.PHONY:
clean:
cd cdt; make clean
cd common; make clean
cd gvc; make clean
cd pathplan; make clean
cd graph; make clean
cd dotgen; make clean
rm -f ./build/* ./*.bc *.bc em-dotgen.js liviz/em-dotgen.js liviz-*.zip

.PHONY:
zip:
zip -r liviz-$(BUILD_TIMESTAMP).zip liviz

.PHONY:
install:
echo "This is where I put my install step.."
18 changes: 0 additions & 18 deletions cdt/Makefile

This file was deleted.

14 changes: 0 additions & 14 deletions common/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions common/arrows.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


#include "render.h"
#include <string.h>

#define EPSILON .0001

Expand Down
4 changes: 3 additions & 1 deletion common/geomprocs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
#ifndef GV_GEOMPROCS_H
#define GV_GEOMPROCS_H

//#define MIN(a,b) (((a)<(b))?(a):(b))
//#define MAX(a,b) (((a)>(b))?(a):(b))

#ifdef __cplusplus
extern "C" {
#endif


#include "geom.h"

#ifdef WIN32
Expand Down
1 change: 1 addition & 0 deletions common/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern "C" {
#include "gvcjob.h" /* must follow gvcext.h (in types.h) */
#include "gvcint.h" /* must follow gvcext.h (in types.h) */
#include "gvcproc.h" /* must follow gvcext.h (in types.h) */
#include "geom.h"

typedef struct epsf_s {
int macro_id;
Expand Down
15 changes: 1 addition & 14 deletions common/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,7 @@
* Contributors: See CVS logs. Details at http://www.graphviz.org/
*************************************************************************/

#include "render.h"
#include "agxbuf.h"
#include "htmltable.h"
#include "entities.h"
#include "logic.h"
#include "gvc.h"

#ifdef WIN32
#include "libltdl/lt_system.h"
#endif
#ifndef WIN32
#include <unistd.h>
#endif
#include <ctype.h>
#include "utils.h"

/*
* a queue of nodes
Expand Down
20 changes: 19 additions & 1 deletion common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,25 @@
*************************************************************************/

#ifndef _UTILS_H
#define _UTILS_H 1
#define _UTILS_H

#include "render.h"
#include "agxbuf.h"
#include "htmltable.h"
#include "entities.h"
#include "logic.h"
#include "gvc.h"


#ifdef WIN32
#include "libltdl/lt_system.h"
#endif
#ifndef WIN32
#include <unistd.h>
#include <string.h>
#endif
#include <ctype.h>


#ifdef __cplusplus
extern "C" {
Expand Down
8 changes: 3 additions & 5 deletions common/xdot.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*************************************************************************/

#include <xdot.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define NEW(t) (t*)calloc(1, sizeof(t))
#define N_NEW(n,t) (t*)calloc((n), sizeof(t))
Expand Down Expand Up @@ -533,8 +530,9 @@ typedef struct {
int dyna; /* true if buffer is malloc'ed */
} agxbuf;

#define agxbputc(X,C) ((((X)->ptr >= (X)->eptr) ? agxbmore(X,1) : 0), \
(int)(*(X)->ptr++ = ((unsigned char)C)))
//#define agxbputc(X,C) ((((X)->ptr >= (X)->eptr) ? agxbmore(X,1) : 0), (int)(*(X)->ptr++ = ((unsigned char)C)))
#define agxbputc(X,C) ((((X)->ptr >= (X)->eptr) ? agxbmore(X,1) : 0), (*(X)->ptr++ = ((unsigned char)C)))

#define agxbuse(X) (agxbputc(X,'\0'),(char*)((X)->ptr = (X)->buf))

static void agxbinit(agxbuf * xb, unsigned int hint, unsigned char *init)
Expand Down
4 changes: 4 additions & 0 deletions common/xdot.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#endif
#define INITIAL_XDOT_CAPACITY 512

#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef enum {
xd_left, xd_center, xd_right
} xdot_align;
Expand Down
4 changes: 4 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//#define MIN(a,b) (((a)<(b))?(a):(b))
//#define MAX(a,b) (((a)>(b))?(a):(b))

#define GVPLUGIN_CONFIG_FILE "config6"
#define GVPLUGIN_VERSION 6
#define PACKAGE "graphviz"
Expand All @@ -20,3 +23,4 @@
#define DEFAULT_DPI 96

#define HAVE_STRDUP 1
#define HAVE_STRINGS_H 1
45 changes: 0 additions & 45 deletions dotgen/Makefile

This file was deleted.

12 changes: 0 additions & 12 deletions dotgen/liviz-apis/Makefile

This file was deleted.

Loading