Commit 13fabb75 authored by Brenden Blanco's avatar Brenden Blanco

Move frontends into individual directories

Other commits to follow with cleanup of the code itself.
Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent 8e54e878
......@@ -2,18 +2,21 @@
# Licensed under the Apache License, Version 2.0 (the "License")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
# to be removed
include_directories(${CMAKE_CURRENT_BINARY_DIR}/frontends/b)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frontends/b)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frontends/clang)
include_directories(${LLVM_INCLUDE_DIRS})
# todo: if check for kernel version
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/compat)
add_definitions(${LLVM_DEFINITIONS})
configure_file(libbpfprog.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libbpfprog.pc @ONLY)
BISON_TARGET(Parser parser.yy ${CMAKE_CURRENT_BINARY_DIR}/parser.yy.cc COMPILE_FLAGS "-o parser.yy.cc -v --debug")
FLEX_TARGET(Lexer lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/lexer.ll.cc COMPILE_FLAGS "--c++ --o lexer.ll.cc")
ADD_FLEX_BISON_DEPENDENCY(Lexer Parser)
# prune unused llvm static library stuff when linking into the new .so
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs=ALL")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
# if gcc 4.9 or higher is used, static libstdc++ is a good option
if (CMAKE_COMPILER_IS_GNUCC)
......@@ -26,10 +29,7 @@ endif()
# tell the shared library where it is being installed so it can find shared header files
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBCC_INSTALL_PREFIX='\"${CMAKE_INSTALL_PREFIX}\"'")
add_library(bpfprog SHARED bpf_common.cc bpf_module.cc codegen_llvm.cc
node.cc parser.cc printer.cc type_check.cc libbpf.c b_frontend_action.cc
kbuild_helper.cc
${BISON_Parser_OUTPUTS} ${FLEX_Lexer_OUTPUTS})
add_library(bpfprog SHARED bpf_common.cc bpf_module.cc libbpf.c)
# BPF is still experimental otherwise it should be available
#llvm_map_components_to_libnames(llvm_libs bpf mcjit irreader passes)
......@@ -40,7 +40,7 @@ set(clang_libs ${libclangFrontend} ${libclangSerialization} ${libclangDriver} ${
${libclangAST} ${libclangLex} ${libclangBasic})
# Link against LLVM libraries
target_link_libraries(bpfprog ${clang_libs} ${llvm_libs} LLVMBPFCodeGen)
target_link_libraries(bpfprog b_frontend clang_frontend ${clang_libs} ${llvm_libs} LLVMBPFCodeGen)
install(TARGETS bpfprog LIBRARY DESTINATION lib${LIBSUFFIX})
install(DIRECTORY export/ DESTINATION share/bcc/include/bcc
......@@ -49,3 +49,5 @@ install(FILES bpf_common.h ../libbpf.h DESTINATION include/bcc)
install(DIRECTORY compat/linux/ DESTINATION include/bcc/compat/linux
FILES_MATCHING PATTERN "*.h")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbpfprog.pc DESTINATION lib${LIBSUFFIX}/pkgconfig)
add_subdirectory(frontends)
......@@ -57,10 +57,10 @@
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
#include "exception.h"
#include "parser.h"
#include "type_check.h"
#include "codegen_llvm.h"
#include "b_frontend_action.h"
#include "frontends/b/parser.h"
#include "frontends/b/type_check.h"
#include "frontends/b/codegen_llvm.h"
#include "frontends/clang/b_frontend_action.h"
#include "bpf_module.h"
#include "kbuild_helper.h"
#include "libbpf.h"
......
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
add_subdirectory(b)
add_subdirectory(clang)
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
BISON_TARGET(Parser parser.yy ${CMAKE_CURRENT_BINARY_DIR}/parser.yy.cc COMPILE_FLAGS "-o parser.yy.cc -v --debug")
FLEX_TARGET(Lexer lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/lexer.ll.cc COMPILE_FLAGS "--c++ --o lexer.ll.cc")
ADD_FLEX_BISON_DEPENDENCY(Lexer Parser)
add_library(b_frontend codegen_llvm.cc node.cc parser.cc printer.cc
type_check.cc ${BISON_Parser_OUTPUTS} ${FLEX_Lexer_OUTPUTS})
......@@ -34,9 +34,9 @@
#include <llvm/IR/Module.h>
#include "exception.h"
#include "cc/codegen_llvm.h"
#include "cc/lexer.h"
#include "cc/type_helper.h"
#include "codegen_llvm.h"
#include "lexer.h"
#include "type_helper.h"
#include "linux/bpf.h"
#include "libbpf.h"
......
......@@ -21,8 +21,8 @@
#include <string>
#include <set>
#include "cc/node.h"
#include "cc/scope.h"
#include "node.h"
#include "scope.h"
namespace llvm {
class AllocaInst;
......
......@@ -27,7 +27,7 @@
#include <iostream> // NOLINT
#include <list>
#include "cc/parser.yy.hh"
#include "parser.yy.hh"
namespace ebpf {
namespace cc {
......
......@@ -15,14 +15,14 @@
*/
%{
#include "cc/lexer.h"
#include "lexer.h"
%}
%option yylineno nodefault yyclass="Lexer" noyywrap c++ prefix="ebpfcc"
%option never-interactive
%{
#include <string>
#include "cc/parser.yy.hh"
#include "parser.yy.hh"
std::string tmp_str_cc;
%}
......
......@@ -18,7 +18,7 @@
#include <vector>
#include <string>
#include "cc/node.h"
#include "node.h"
namespace ebpf {
namespace cc {
......
......@@ -22,7 +22,7 @@
#include <memory>
#include <algorithm>
#include <stdint.h>
#include "cc/scope.h"
#include "scope.h"
#define REVISION_MASK 0xfff
#define MAJOR_VER_POS 22
......
......@@ -17,8 +17,8 @@
#include <algorithm>
#include <assert.h>
#include "exception.h"
#include "cc/parser.h"
#include "cc/type_helper.h"
#include "parser.h"
#include "type_helper.h"
namespace ebpf {
namespace cc {
......
......@@ -17,9 +17,9 @@
#pragma once
#include <fstream> // NOLINT
#include "cc/node.h"
#include "cc/lexer.h"
#include "cc/scope.h"
#include "node.h"
#include "lexer.h"
#include "scope.h"
namespace ebpf {
namespace cc {
......
......@@ -27,7 +27,7 @@
#include <memory>
#include <vector>
#include <string>
#include "cc/node.h"
#include "node.h"
// forward declaration
namespace ebpf { namespace cc {
class Lexer;
......@@ -42,8 +42,8 @@
}
%{
#include "cc/node.h"
#include "cc/parser.h"
#include "node.h"
#include "parser.h"
using std::unique_ptr;
using std::vector;
using std::string;
......@@ -620,7 +620,7 @@ void ebpf::cc::BisonParser::error(const ebpf::cc::BisonParser::location_type &lo
std::cerr << "Error: " << loc << " " << msg << std::endl;
}
#include "cc/lexer.h"
#include "lexer.h"
static int yylex(ebpf::cc::BisonParser::semantic_type *yylval,
ebpf::cc::BisonParser::location_type *yylloc,
ebpf::cc::Lexer &lexer) {
......
......@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "cc/printer.h"
#include "cc/lexer.h"
#include "printer.h"
#include "lexer.h"
#include "exception.h"
namespace ebpf {
......
......@@ -18,7 +18,7 @@
#include <stdio.h>
#include "cc/node.h"
#include "node.h"
namespace ebpf {
namespace cc {
......
......@@ -17,8 +17,8 @@
#include <set>
#include <algorithm>
#include "exception.h"
#include "cc/type_check.h"
#include "cc/lexer.h"
#include "type_check.h"
#include "lexer.h"
namespace ebpf {
namespace cc {
......
......@@ -18,8 +18,8 @@
#include <vector>
#include <string>
#include "cc/node.h"
#include "cc/scope.h"
#include "node.h"
#include "scope.h"
namespace ebpf {
namespace cc {
......
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
add_library(clang_frontend b_frontend_action.cc kbuild_helper.cc)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment