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

Allow compiling without python #109

Open
wants to merge 5 commits 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
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ bison.tab.hpp
*.o
parser.output
dump_json_ast
Ast.h
Ast.cpp
AstVisitor.h
/Ast.h
/Ast.cpp
/AstVisitor.h
*.dSYM
CMakeCache.txt
CMakeFiles
Expand Down
49 changes: 29 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ INCLUDE(version)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

FIND_PACKAGE(PythonInterp 2 REQUIRED)
FIND_PACKAGE(PythonInterp 2)
IF (NOT PYTHON_VERSION_MAJOR EQUAL 2)
MESSAGE(FATAL_ERROR "Python 2 is required.")
MESSAGE(WARNING "Python 2 is required.")
ELSE()
FIND_PROGRAM(CTYPESGEN_FOUND ctypesgen.py)
ENDIF()

FIND_PROGRAM(CTYPESGEN_FOUND ctypesgen.py)

FIND_PACKAGE(BISON 3)
FIND_PACKAGE(FLEX)
Expand All @@ -35,7 +36,7 @@ ELSE()
${CMAKE_CURRENT_SOURCE_DIR}/parsergen/location.hh
${CMAKE_CURRENT_SOURCE_DIR}/parsergen/position.hh
${CMAKE_CURRENT_SOURCE_DIR}/parsergen/stack.hh
${CMAKE_CURRENT_BINARY_DIR})
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
ENDIF()

IF(FLEX_FOUND)
Expand All @@ -48,7 +49,7 @@ ELSE()
FILE(COPY
${CMAKE_CURRENT_SOURCE_DIR}/parsergen/lexer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/parsergen/lexer.h
${CMAKE_CURRENT_BINARY_DIR})
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
ENDIF()

FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/c)
Expand Down Expand Up @@ -89,21 +90,29 @@ FUNCTION(GENERATE_AST_FILE FILE_TYPE FILE_RELATIVE_PATH)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ast/ast.ast ${CMAKE_CURRENT_SOURCE_DIR}/ast/ast.py ${CMAKE_CURRENT_SOURCE_DIR}/ast/${FILE_TYPE}.py)
ENDFUNCTION(GENERATE_AST_FILE)

GENERATE_AST_FILE(cxx Ast.h)

GENERATE_AST_FILE(cxx_visitor AstVisitor.h)

GENERATE_AST_FILE(cxx_impl Ast.cpp)

GENERATE_AST_FILE(c c/GraphQLAst.h)

GENERATE_AST_FILE(c_impl c/GraphQLAst.cpp)

GENERATE_AST_FILE(c_visitor_impl c/GraphQLAstForEachConcreteType.h)

GENERATE_AST_FILE(cxx_json_visitor_header JsonVisitor.h.inc)

GENERATE_AST_FILE(cxx_json_visitor_impl JsonVisitor.cpp.inc)
IF(PythonInterp_FOUND)
GENERATE_AST_FILE(cxx Ast.h)
GENERATE_AST_FILE(cxx_visitor AstVisitor.h)
GENERATE_AST_FILE(cxx_impl Ast.cpp)
GENERATE_AST_FILE(c c/GraphQLAst.h)
GENERATE_AST_FILE(c_impl c/GraphQLAst.cpp)
GENERATE_AST_FILE(c_visitor_impl c/GraphQLAstForEachConcreteType.h)
GENERATE_AST_FILE(cxx_json_visitor_header JsonVisitor.h.inc)
GENERATE_AST_FILE(cxx_json_visitor_impl JsonVisitor.cpp.inc)
ELSE()
FILE(COPY
${CMAKE_CURRENT_SOURCE_DIR}/pregenerated_ast/Ast.h
${CMAKE_CURRENT_SOURCE_DIR}/pregenerated_ast/Ast.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pregenerated_ast/AstVisitor.h
${CMAKE_CURRENT_SOURCE_DIR}/pregenerated_ast/JsonVisitor.h.inc
${CMAKE_CURRENT_SOURCE_DIR}/pregenerated_ast/JsonVisitor.cpp.inc
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR})
FILE(COPY
${CMAKE_CURRENT_SOURCE_DIR}/pregenerated_ast/c/GraphQLAst.h
${CMAKE_CURRENT_SOURCE_DIR}/pregenerated_ast/c/GraphQLAst.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pregenerated_ast/c/GraphQLAstForEachConcreteType.h
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/c)
ENDIF()

ADD_SUBDIRECTORY(python)

Expand Down
4 changes: 2 additions & 2 deletions libgraphqlparser.pc.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/graphqlparser
includedir=${prefix}/include/

Name: @CMAKE_PROJECT_NAME@
Description: facebook graphql parsing library
Version: @LIBGRAPHQLPARSER_VERSION@
Libs: -L${libdir} -lgraphqlparser
Libs.private:
Cflags: -I${includedir}
Cflags: -I${includedir}
Loading