Commit ef3b5d9d authored by 4ast's avatar 4ast

Merge pull request #166 from iovisor/bblanco_dev

Add proper debian build support, rename libbcc.so
parents 85208ec1 9e5c352e
...@@ -49,17 +49,3 @@ add_subdirectory(scripts) ...@@ -49,17 +49,3 @@ add_subdirectory(scripts)
add_subdirectory(examples) add_subdirectory(examples)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(tests) add_subdirectory(tests)
set(CPACK_PACKAGE_NAME "libbcc")
set(CPACK_PACKAGE_VERSION "${REVISION}")
set(CPACK_PACKAGE_CONTACT "Brenden Blanco <bblanco@plumgrid.com")
if(EXISTS "/etc/redhat-release")
set(CPACK_GENERATOR "RPM")
else()
set(CPACK_GENERATOR "DEB")
endif()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libstdc++6, python, make, gcc")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Shared Library for BPF Compiler Collection (BCC)")
include(CPack)
...@@ -9,11 +9,12 @@ RUN printf "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty main\ndeb-src ...@@ -9,11 +9,12 @@ RUN printf "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty main\ndeb-src
RUN wget -q -O - http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add - RUN wget -q -O - http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add -
RUN apt-get -y update RUN apt-get -y update
RUN apt-get -y install bison build-essential cmake flex git libedit-dev python zlib1g-dev RUN apt-get -y install bison build-essential cmake debhelper devscripts flex git libedit-dev python zlib1g-dev
RUN apt-get -y install libllvm3.7 llvm-3.7-dev libclang-3.7-dev RUN apt-get -y install libllvm3.8 llvm-3.8-dev libclang-3.8-dev
RUN mkdir -p /root/bcc/build RUN mkdir -p /root/bcc/build
COPY ./ /root/bcc/ COPY ./ /root/bcc/
WORKDIR /root/bcc/build WORKDIR /root
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/usr RUN tar zcf bcc_0.1.1.orig.tar.gz bcc/
RUN make -j$(grep -c ^process /proc/cpuinfo) package WORKDIR /root/bcc
RUN DEB_BUILD_OPTIONS="nocheck parallel=4" debuild -us -uc
...@@ -5,9 +5,9 @@ A: Install pyroute2: ...@@ -5,9 +5,9 @@ A: Install pyroute2:
cd pyroute2; sudo make install cd pyroute2; sudo make install
Q: hello_world.py fails with: Q: hello_world.py fails with:
OSError: libbpfprog.so: cannot open shared object file: No such file or directory OSError: libbcc.so: cannot open shared object file: No such file or directory
A: make sure to 'make install' and add the directory A: make sure to 'make install' and add the directory
where libbpfprog.so was installed into your LD_LIBRARY_PATH where libbcc.so was installed into your LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Q: hello_world.py fails with: Q: hello_world.py fails with:
......
bcc (0.1.5-1) unstable; urgency=low
* Initial release
-- Brenden Blanco <bblanco@plumgrid.com> Mon, 06 Jul 2015 18:04:28 +0000
Source: bcc
Maintainer: Brenden Blanco <bblanco@plumgrid.com>
Section: misc
Priority: optional
Standards-Version: 3.9.5
Build-Depends: debhelper (>= 9), cmake, libllvm3.8, llvm-3.8-dev, libclang-3.8-dev
Homepage: https://github.com/iovisor/bcc
Package: libbcc
Architecture: amd64
Depends: libc6, libstdc++6, make, gcc
Description: Shared Library for BPF Compiler Collection (BCC)
Shared Library for BPF Compiler Collection to control BPF programs
from userspace.
Package: libbcc-examples
Architecture: any
Depends: libbcc
Description: Shared Library for BPF Compiler Collection (BCC)
Package: python-bpf
Architecture: all
Depends: libbcc, python
Description: Python wrappers for BPF Compiler Collection (BCC)
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: bcc
Source: https://github.com/iovisor/bcc
Files: *
Copyright: 2015 PLUMgrid, Inc.
License: Apache-2.0
FAQ.txt
LICENSE.txt
README.md
usr/share/bcc/examples/*
usr/include/bcc/*
usr/lib/libbcc* /usr/lib/x86_64-linux-gnu/
usr/share/bcc/include/*
usr/lib/python*
usr/bin/bpf-run
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
DEBIAN_VERSION := $(shell dpkg-parsechangelog | sed -rne "s,^Version: (.*),\1,p")
DEBIAN_REVISION := $(shell dpkg-parsechangelog | sed -rne "s,^Version: ([0-9.]+)(~|-)(.*),\3,p")
UPSTREAM_VERSION := $(shell dpkg-parsechangelog | sed -rne "s,^Version: ([0-9.]+)(~|-)(.*),\1,p")
%:
dh $@ --buildsystem=cmake --parallel
override_dh_auto_configure:
dh_auto_configure -- -DREVISION=$(UPSTREAM_VERSION)
...@@ -50,8 +50,8 @@ Reconnect and run the final step, building and testing bcc. ...@@ -50,8 +50,8 @@ Reconnect and run the final step, building and testing bcc.
[root@bpf-demo ~]# bcc-setup [root@bpf-demo ~]# bcc-setup
Cloning into 'bcc'... Cloning into 'bcc'...
... ...
Linking CXX shared library libbpfprog.so Linking CXX shared library libcc.so
[100%] Built target bpfprog [100%] Built target bcc
... ...
Running tests... Running tests...
Test project /root/bcc/build Test project /root/bcc/build
......
...@@ -11,7 +11,7 @@ include_directories(${LLVM_INCLUDE_DIRS}) ...@@ -11,7 +11,7 @@ include_directories(${LLVM_INCLUDE_DIRS})
# todo: if check for kernel version # todo: if check for kernel version
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/compat) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/compat)
add_definitions(${LLVM_DEFINITIONS}) add_definitions(${LLVM_DEFINITIONS})
configure_file(libbpfprog.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libbpfprog.pc @ONLY) configure_file(libbcc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libbcc.pc @ONLY)
# prune unused llvm static library stuff when linking into the new .so # prune unused llvm static library stuff when linking into the new .so
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs=ALL") set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs=ALL")
...@@ -29,7 +29,8 @@ endif() ...@@ -29,7 +29,8 @@ endif()
# tell the shared library where it is being installed so it can find shared header files # 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}\"'") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBCC_INSTALL_PREFIX='\"${CMAKE_INSTALL_PREFIX}\"'")
add_library(bpfprog SHARED bpf_common.cc bpf_module.cc libbpf.c) add_library(bcc SHARED bpf_common.cc bpf_module.cc libbpf.c)
set_target_properties(bcc PROPERTIES VERSION ${REVISION} SOVERSION 0)
# BPF is still experimental otherwise it should be available # BPF is still experimental otherwise it should be available
#llvm_map_components_to_libnames(llvm_libs bpf mcjit irreader passes) #llvm_map_components_to_libnames(llvm_libs bpf mcjit irreader passes)
...@@ -41,14 +42,19 @@ set(clang_libs ${libclangFrontend} ${libclangSerialization} ${libclangDriver} ${ ...@@ -41,14 +42,19 @@ set(clang_libs ${libclangFrontend} ${libclangSerialization} ${libclangDriver} ${
${libclangAST} ${libclangLex} ${libclangBasic}) ${libclangAST} ${libclangLex} ${libclangBasic})
# Link against LLVM libraries # Link against LLVM libraries
target_link_libraries(bpfprog b_frontend clang_frontend ${clang_libs} ${llvm_libs} LLVMBPFCodeGen) target_link_libraries(bcc b_frontend clang_frontend ${clang_libs} ${llvm_libs} LLVMBPFCodeGen)
install(TARGETS bpfprog LIBRARY DESTINATION lib${LIBSUFFIX}) install(TARGETS bcc LIBRARY COMPONENT libbcc
install(DIRECTORY export/ DESTINATION share/bcc/include/bcc DESTINATION lib${LIBSUFFIX})
install(DIRECTORY export/ COMPONENT libbcc
DESTINATION share/bcc/include/bcc
FILES_MATCHING PATTERN "*.h") FILES_MATCHING PATTERN "*.h")
install(FILES bpf_common.h ../libbpf.h DESTINATION include/bcc) install(FILES bpf_common.h ../libbpf.h COMPONENT libbcc
install(DIRECTORY compat/linux/ DESTINATION include/bcc/compat/linux DESTINATION include/bcc)
install(DIRECTORY compat/linux/ COMPONENT libbcc
DESTINATION include/bcc/compat/linux
FILES_MATCHING PATTERN "*.h") FILES_MATCHING PATTERN "*.h")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbpfprog.pc DESTINATION lib${LIBSUFFIX}/pkgconfig) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbcc.pc COMPONENT libbcc
DESTINATION lib${LIBSUFFIX}/pkgconfig)
add_subdirectory(frontends) add_subdirectory(frontends)
...@@ -6,9 +6,9 @@ datarootdir=${prefix}/share ...@@ -6,9 +6,9 @@ datarootdir=${prefix}/share
compatdir=${includedir}/bcc/compat compatdir=${includedir}/bcc/compat
Name: libbpfprog Name: libbcc
Version: @REVISION@ Version: @REVISION@
Description: BPF Program library Description: BCC Program library
Requires: Requires:
Libs: -L${libdir} -lbpfprog Libs: -L${libdir} -lbcc
Cflags: -I${includedir} -I${compatdir} Cflags: -I${includedir} -I${compatdir}
...@@ -22,4 +22,5 @@ if(EXISTS "/etc/debian_version") ...@@ -22,4 +22,5 @@ if(EXISTS "/etc/debian_version")
set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb") set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb")
endif() endif()
install(CODE "execute_process(COMMAND python setup.py install -f ${PYTHON_FLAGS} install(CODE "execute_process(COMMAND python setup.py install -f ${PYTHON_FLAGS}
--prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"
COMPONENT python)
...@@ -23,7 +23,7 @@ from subprocess import Popen, PIPE ...@@ -23,7 +23,7 @@ from subprocess import Popen, PIPE
import sys import sys
basestring = (unicode if sys.version_info[0] < 3 else str) basestring = (unicode if sys.version_info[0] < 3 else str)
lib = ct.CDLL("libbpfprog.so") lib = ct.CDLL("libbcc.so")
# keep in sync with bpf_common.h # keep in sync with bpf_common.h
lib.bpf_module_create_b.restype = ct.c_void_p lib.bpf_module_create_b.restype = ct.c_void_p
......
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