Skip to content

Commit

Permalink
Merge pull request #13 from goccy/feature/update-github-actions
Browse files Browse the repository at this point in the history
Support build for windows
  • Loading branch information
goccy authored Feb 10, 2020
2 parents 60b33c0 + 9f71741 commit 836f224
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 33 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Go
on: [push]
jobs:

build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:

- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
Expand Down
8 changes: 4 additions & 4 deletions graphviz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func TestGraphviz_Image(t *testing.T) {
if err := g.Render(graph, graphviz.PNG, &buf); err != nil {
t.Fatalf("%+v", err)
}
if len(buf.Bytes()) != 4610 {
t.Fatal("failed to encode png")
if len(buf.Bytes()) != 4638 {
t.Fatalf("failed to encode png: bytes length is %d", len(buf.Bytes()))
}
})
t.Run("RenderImage", func(t *testing.T) {
Expand All @@ -61,8 +61,8 @@ func TestGraphviz_Image(t *testing.T) {
if err := g.Render(graph, graphviz.JPG, &buf); err != nil {
t.Fatalf("%+v", err)
}
if len(buf.Bytes()) != 3322 {
t.Fatal("failed to encode png")
if len(buf.Bytes()) != 3281 {
t.Fatalf("failed to encode jpg: bytes length is %d", len(buf.Bytes()))
}
})
t.Run("RenderImage", func(t *testing.T) {
Expand Down
7 changes: 3 additions & 4 deletions internal/ccall/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#include "gvplugin.h"
#include "gvplugin_render.h"
#include <stdio.h>
#include "_cgo_export.h"

extern gvplugin_library_t gvplugin_dot_layout_LTX_library;
extern gvplugin_library_t gvplugin_neato_layout_LTX_library;
extern gvplugin_library_t gvplugin_core_LTX_library;
extern gvplugin_library_t gvplugin_go_library;

lt_symlist_t lt_preloaded_symbols[] = {
{ "gvplugin_dot_layout_LTX_library", (void*)(&gvplugin_dot_layout_LTX_library) },
lt_symlist_t lt_preloaded_symbols[PRLOADED_SYMBOL_N] = {
{ "gvplugin_dot_layout_LTX_library", (void *)(&gvplugin_dot_layout_LTX_library) },
{ "gvplugin_neato_layout_LTX_library", (void*)(&gvplugin_neato_layout_LTX_library) },
{ "gvplugin_core_LTX_library", (void*)(&gvplugin_core_LTX_library) },
{ "gvplugin_go_LTX_library", (void*)(&gvplugin_go_library) },
Expand All @@ -29,8 +30,6 @@ gvplugin_library_t gvplugin_go_library = { "go", go_apis };

typedef enum { FORMAT_PNG, FORMAT_JPG } go_format_type;

#include "_cgo_export.h"

void *call_searchf(Dtsearch_f searchf, Dt_t *a0, void *a1, int a2) {
return searchf(a0, a1, a2);
}
Expand Down
3 changes: 2 additions & 1 deletion internal/ccall/ccall.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ package ccall
#cgo CFLAGS: -Itwopigen
#cgo CFLAGS: -I../
#cgo CFLAGS: -I../libltdl
#cgo CFLAGS: -Wno-unused-result -Wno-format
#cgo CFLAGS: -Wno-unused-result -Wno-format -Wno-pointer-to-int-cast -Wno-attributes
#cgo LDFLAGS: -lm
#include "config.h"
#include "gvc.h"
#include "color.h"
#include "gvcjob.h"
Expand Down
7 changes: 4 additions & 3 deletions internal/ccall/cdt.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ package ccall
#cgo CFLAGS: -Itwopigen
#cgo CFLAGS: -I../
#cgo CFLAGS: -I../libltdl
#cgo CFLAGS: -Wno-unused-result -Wno-format
#cgo CFLAGS: -Wno-unused-result -Wno-format -Wno-pointer-to-int-cast -Wno-attributes
#include "config.h"
#include "cdt.h"
extern void *call_searchf(Dtsearch_f searchf, Dt_t *a0, void *a1, int a2);
Expand Down Expand Up @@ -330,7 +331,7 @@ func (g *Dtdisc) Memory() Dtmemory {
return g.memoryf
}
return func(a0 *Dict, a1 unsafe.Pointer, a2 uint, a3 *Dtdisc) unsafe.Pointer {
return C.call_memoryf(g.c.memoryf, a0.c, a1, C.ulong(a2), a3.c)
return C.call_memoryf(g.c.memoryf, a0.c, a1, C.size_t(a2), a3.c)
}
}

Expand Down Expand Up @@ -407,7 +408,7 @@ func (g *Dict) Memory() Dtmemory {
return g.memory
}
return func(a0 *Dict, a1 unsafe.Pointer, a2 uint, a3 *Dtdisc) unsafe.Pointer {
return C.call_memoryf(g.c.memoryf, a0.c, a1, C.ulong(a2), a3.c)
return C.call_memoryf(g.c.memoryf, a0.c, a1, C.size_t(a2), a3.c)
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/ccall/cdt/cdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ struct _dtstat_s

/* public data */
#if defined(_BLD_cdt) && defined(__EXPORT__)
#define extern __EXPORT__
#define extern
#endif
#if !defined(_BLD_cdt) && defined(__IMPORT__)
#define extern __IMPORT__
#define extern
#endif

extern Dtmethod_t* Dtset;
Expand Down Expand Up @@ -191,7 +191,7 @@ extern Dtmethod_t _Dtstack;

/* public functions */
#if defined(_BLD_cdt) && defined(__EXPORT__)
#define extern __EXPORT__
#define extern
#endif

extern Dt_t* dtopen(Dtdisc_t*, Dtmethod_t*);
Expand Down
5 changes: 3 additions & 2 deletions internal/ccall/cgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ package ccall
#cgo CFLAGS: -Itwopigen
#cgo CFLAGS: -I../
#cgo CFLAGS: -I../libltdl
#cgo CFLAGS: -Wno-unused-result -Wno-format
#cgo CFLAGS: -Wno-unused-result -Wno-format -Wno-pointer-to-int-cast -Wno-attributes
#include "config.h"
#include "cgraph.h"
#include <stdlib.h>
Expand Down Expand Up @@ -1150,7 +1151,7 @@ func Agcountuniqedges(g *Agraph, n *Agnode, in int, out int) int {
}

func Agalloc(g *Agraph, size uint) unsafe.Pointer {
return C.agalloc(g.c, C.ulong(size))
return C.agalloc(g.c, C.size_t(size))
}

func Agfree(g *Agraph, ptr unsafe.Pointer) {
Expand Down
3 changes: 2 additions & 1 deletion internal/ccall/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ package ccall
#cgo CFLAGS: -Itwopigen
#cgo CFLAGS: -I../
#cgo CFLAGS: -I../libltdl
#cgo CFLAGS: -Wno-unused-result -Wno-format
#cgo CFLAGS: -Wno-unused-result -Wno-format -Wno-pointer-to-int-cast -Wno-attributes
#include "config.h"
#include "gvc.h"
#include "gvcjob.h"
#include "textspan.h"
Expand Down
4 changes: 3 additions & 1 deletion internal/ccall/common/geom.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include "geom.h"
#include "geomprocs.h"
#ifdef _WIN32
#define inline
#ifndef inline
#define inline
#endif
#endif

box mkbox(point p, point q)
Expand Down
4 changes: 2 additions & 2 deletions internal/ccall/common/geomprocs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ extern "C" {

#ifdef _WIN32
#ifdef GVDLL
#define extern __declspec(dllexport)
#define extern
#else
#define extern __declspec(dllimport)
#define extern
#endif
#endif

Expand Down
1 change: 1 addition & 0 deletions internal/ccall/common/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef GV_MEMORY_H
#define GV_MEMORY_H

#include "config.h"
#include <stdlib.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
Expand Down
7 changes: 4 additions & 3 deletions internal/ccall/gvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ package ccall
#cgo CFLAGS: -Itwopigen
#cgo CFLAGS: -I../
#cgo CFLAGS: -I../libltdl
#cgo CFLAGS: -Wno-unused-result -Wno-format
#cgo CFLAGS: -Wno-unused-result -Wno-format -Wno-pointer-to-int-cast -Wno-attributes
#include "config.h"
#include "gvc.h"
#include "gvcjob.h"
#include "cgraph.h"
Expand Down Expand Up @@ -485,9 +486,9 @@ func (g *GVJ) OutputData() []byte {

func (g *GVJ) SetOutputData(v []byte) {
length := len(v)
g.c.output_data = (*C.char)(C.realloc(unsafe.Pointer(g.c.output_data), C.ulong(length)))
g.c.output_data = (*C.char)(C.realloc(unsafe.Pointer(g.c.output_data), C.size_t(length)))
header := (*reflect.SliceHeader)(unsafe.Pointer(&v))
C.memcpy(unsafe.Pointer(g.c.output_data), unsafe.Pointer(header.Data), C.ulong(length))
C.memcpy(unsafe.Pointer(g.c.output_data), unsafe.Pointer(header.Data), C.size_t(length))
g.c.output_data_position = C.uint(length)
}

Expand Down
9 changes: 4 additions & 5 deletions internal/ccall/gvc/gvcext.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,22 @@ extern "C" {
/*visual studio*/
#ifdef WIN32
#ifndef GVC_EXPORTS
__declspec(dllimport) lt_symlist_t lt_preloaded_symbols[];
__declspec(dllimport) lt_symlist_t lt_preloaded_symbols[PRLOADED_SYMBOL_N];
#else
//__declspec(dllexport) lt_symlist_t lt_preloaded_symbols[];
#if !defined(LTDL_H)
lt_symlist_t lt_preloaded_symbols[];
lt_symlist_t lt_preloaded_symbols[PRLOADED_SYMBOL_N];
#endif
#endif
#endif
/*end visual studio*/


#ifndef WIN32
#if defined(GVDLL)
__declspec(dllexport) lt_symlist_t lt_preloaded_symbols[];
__declspec(dllexport) lt_symlist_t lt_preloaded_symbols[PRLOADED_SYMBOL_N];
#else
#if !defined(LTDL_H)
extern lt_symlist_t lt_preloaded_symbols[];
extern lt_symlist_t lt_preloaded_symbols[PRLOADED_SYMBOL_N];
#endif
#endif
#endif
Expand Down
2 changes: 2 additions & 0 deletions internal/ccall/gvc/gvconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include "gvconfig.h"

#include <string.h>
#ifndef WIN32
#include <regex.h>
#endif

#ifdef ENABLE_LTDL
#include <sys/types.h>
Expand Down
8 changes: 8 additions & 0 deletions internal/ccall/gvc/gvusershape.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
#define DMKEY "Software\\Microsoft" //key to look for library dir
#endif

#ifndef WIN32
#include <regex.h>
#endif

#include "types.h"
#include "logic.h"
#include "memory.h"
Expand Down Expand Up @@ -167,10 +170,14 @@ static unsigned int svg_units_convert(double n, char *u)
}

static char* svg_attr_value_re = "([a-z][a-zA-Z]*)=\"([^\"]*)\"";

#ifndef WIN32
static regex_t re, *pre = NULL;
#endif

static void svg_size (usershape_t *us)
{
#ifndef WIN32
unsigned int w = 0, h = 0;
double n, x0, y0, x1, y1;
char u[10];
Expand Down Expand Up @@ -235,6 +242,7 @@ static void svg_size (usershape_t *us)
us->dpi = 0;
us->w = w;
us->h = h;
#endif
}

static void png_size (usershape_t *us)
Expand Down
1 change: 1 addition & 0 deletions internal/ccall/pathplan/pathutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define _PATHUTIL_INCLUDE
#define _BLD_pathplan 1

#include "config.h"
#include "pathplan.h"

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions internal/ccall/pathplan/vis.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include "config.h"
#include "vispath.h"
#include "pathutil.h"

Expand Down
2 changes: 2 additions & 0 deletions internal/ccall/plugin.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "config.h"

#include "../plugin/core/gvplugin_core.c"
#include "../plugin/core/gvrender_core_dot.c"
#include "../plugin/core/gvrender_core_json.c"
Expand Down
15 changes: 14 additions & 1 deletion internal/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define DIGCOLA 1

/* Define if you want on-demand plugin loading */
#define ENABLE_LTDL 1
//#define ENABLE_LTDL 1

/* Define for DLLs on Windows. */
/* #undef GVDLL */
Expand Down Expand Up @@ -98,8 +98,10 @@
/* Define to 1 if you have the <dl.h> header file. */
/* #undef HAVE_DL_H */

#ifndef WIN32
/* Define to 1 if you have the `drand48' function. */
#define HAVE_DRAND48 1
#endif

/* Define if you have the _dyld_func_lookup function. */
/* #undef HAVE_DYLD */
Expand Down Expand Up @@ -302,8 +304,10 @@
/* Define to 1 if you have the <search.h> header file. */
#define HAVE_SEARCH_H 1

#ifndef WIN32
/* Define to 1 if you have the `setenv' function. */
#define HAVE_SETENV 1
#endif

/* Define to 1 if you have the `setmode' function. */
#define HAVE_SETMODE 1
Expand All @@ -315,7 +319,9 @@
/* #undef HAVE_SINCOS */

/* Define to 1 if you have the `srand48' function. */
#ifndef WIN32
#define HAVE_SRAND48 1
#endif

/* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1
Expand Down Expand Up @@ -367,7 +373,9 @@
#define HAVE_SYS_IOCTL_H 1

/* Define to 1 if you have the <sys/mman.h> header file. */
#ifndef WIN32
#define HAVE_SYS_MMAN_H 1
#endif

/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
Expand Down Expand Up @@ -523,6 +531,11 @@
/* Define to a type to use for `error_t' if it is not otherwise available. */
#define error_t int

#define GVC_EXPORTS 1
#define PATHPLAN_EXPORTS 1

#define PRLOADED_SYMBOL_N 5

/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef gid_t */

Expand Down

0 comments on commit 836f224

Please sign in to comment.