File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,3 +18,4 @@ cmake_install.cmake
1818GraphQLParser.py
1919install_manifest.txt
2020build /
21+ libgraphqlparser.pc
Original file line number Diff line number Diff line change 11CMAKE_MINIMUM_REQUIRED (VERSION 2.8 )
22PROJECT (libgraphqlparser C CXX )
33
4+ SET (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake" "${CMAKE_MODULE_PATH} " )
5+
6+ INCLUDE (version )
7+
48SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11" )
59
610FIND_PACKAGE (PythonInterp 2 REQUIRED )
@@ -97,6 +101,17 @@ INSTALL(FILES
97101INSTALL (TARGETS graphqlparser
98102 LIBRARY DESTINATION lib)
99103
104+ if (UNIX )
105+ # generate pkgconfig file
106+ include (FindPkgConfig QUIET )
107+ if (PKG_CONFIG_FOUND)
108+ # generate .pc and install
109+ configure_file ("libgraphqlparser.pc.in" "libgraphqlparser.pc" @ONLY )
110+ install (FILES "${CMAKE_CURRENT_BINARY_DIR} /libgraphqlparser.pc"
111+ DESTINATION "${CMAKE_INSTALL_PREFIX} /lib/pkgconfig" )
112+ endif ()
113+ endif ()
114+
100115IF (test )
101116 ADD_SUBDIRECTORY (test )
102117
Original file line number Diff line number Diff line change 1+ find_package (Git QUIET )
2+
3+ # default version string
4+ set (LIBGRAPHQLPARSER_VERSION "0.0-dev" )
5+
6+ if (GIT_EXECUTABLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /.git)
7+ execute_process (COMMAND ${GIT_EXECUTABLE} describe --tags
8+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
9+ OUTPUT_VARIABLE LIBGRAPHQLPARSER_VERSION
10+ ERROR_QUIET
11+ OUTPUT_STRIP_TRAILING_WHITESPACE
12+ )
13+ string (SUBSTRING ${LIBGRAPHQLPARSER_VERSION} 1 -1 LIBGRAPHQLPARSER_VERSION)
14+ endif ()
Original file line number Diff line number Diff line change 1- This directory contains an example usage of the GraphQL parser and AST
2- library from Go. See [ cgo's
3- documentation] ( https://github.com/golang/go/wiki/cgo ) , particularly
4- the "Function pointer callbacks" section, for explanation of the
5- mechanisms in use.
6-
7- To build, first build the main GraphQLParser library in the parent
8- directory, and then set this directory to be your ` GOPATH ` and run `go
9- build`.
1+ # About
2+ This directory contains an example using the libgraphqlparser C library from [ Go] ( https://golang.org/project/ ) .
3+
4+ For an overview of binding to C libraries in Go, please see the [ cgo documentation] ( https://github.com/golang/go/wiki/cgo ) .
5+ Specifically, please read the overview of [ Function pointer callbacks] ( https://github.com/golang/go/wiki/cgo#function-pointer-callbacks ) in Go and C.
6+
7+ ## Building and Running
8+
9+ To build with Go, please ensure that you have ` pkg-config ` installed for your
10+ system.
11+
12+ Assuming pkg-config has been installed, it should be possible to then build
13+ using Go in the normal fashion:
14+ ``` sh
15+ $ cd libgraphqlparser/go
16+ $ go build
17+ $ ./go
18+ field : myfield
19+ Example error: 1.18-19: syntax error, unexpected on, expecting ( or @ or {
20+ ` ` `
Original file line number Diff line number Diff line change 99package main
1010
1111/*
12- #cgo CFLAGS: -I ../c -I ..
13- #cgo LDFLAGS: -L .. -lgraphqlparser
14- #include "GraphQLAst.h"
15- #include "GraphQLAstNode.h"
16- #include "GraphQLAstVisitor.h"
17- #include "GraphQLParser.h"
12+ #cgo pkg-config: libgraphqlparser
13+
14+ #include "c/ GraphQLAst.h"
15+ #include "c/ GraphQLAstNode.h"
16+ #include "c/ GraphQLAstVisitor.h"
17+ #include "c/ GraphQLParser.h"
1818#include <stdlib.h>
1919
2020int printField_cgo(struct GraphQLAstField *field, void *unused);
Original file line number Diff line number Diff line change 1+ prefix=@CMAKE_INSTALL_PREFIX@
2+ exec_prefix=${prefix}
3+ libdir=${exec_prefix}/lib
4+ includedir=${prefix}/include/graphqlparser
5+
6+ Name: @CMAKE_PROJECT_NAME@
7+ Description: facebook graphql parsing library
8+ Version: @LIBGRAPHQLPARSER_VERSION@
9+ Libs: -L${libdir} -lgraphqlparser
10+ Libs.private:
11+ Cflags: -I${includedir}
You can’t perform that action at this time.
0 commit comments