diff --git a/README.md b/README.md index ac89a1ae678f0ee52b723d619ed07ba3f7da85ca..dff65a71ec73da9c3dba9b1f9fa95308e593bb7d 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ bash build.sh python=true 安装后若需要卸载python库, 可以执行下述命令 ```shell -python3 -m pip unistall -y libkperf +python3 -m pip uninstall -y libkperf ``` #### 指令 diff --git a/build.sh b/build.sh index f6eb958ff3a06bf0d24201e61e0012867d2e9986..937a117770c41b5f124aa9fd370a83228df91bbf 100644 --- a/build.sh +++ b/build.sh @@ -32,6 +32,7 @@ creat_dir "${BUILD_DIR}" # Specifies the gcc used by all dependencies. export CC=gcc export CXX=g++ +PYTHON_EXE="" if [ -d "${THIRD_PARTY}/local" ];then echo ${THIRD_PARTY}/local "is exist" else @@ -47,12 +48,15 @@ for arg in "$@"; do python=*) PYTHON="${arg#*=}" ;; - installPath=*) + install_path=*) INSTALL_PATH="${arg#*=}" ;; build_type=*) BUILD_TYPE="${arg#*=}" ;; + python_exe=*) + PYTHON_EXE="${arg#*=}" + ;; esac done @@ -86,10 +90,10 @@ function build_elfin() { echo "install log path: $cmake_target_dir" } -build_libprof() +build_libkperf() { cd $BUILD_DIR - cmake -DINCLUDE_TEST=${INCLUDE_TEST} -DPYTHON=${PYTHON} -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} .. + cmake -DINCLUDE_TEST=${INCLUDE_TEST} -DPYTHON=${PYTHON} -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DPYTHON_KPERF=${PYTHON_EXE} .. make -j ${cpu_core_num} make install echo "build libkperf success" @@ -104,7 +108,7 @@ function build_test() main() { build_elfin - build_libprof + build_libkperf build_test } diff --git a/build/common.sh b/build/common.sh index fd88ba76348b3d21420fc0aa26928cede3d95437..9cc16b0f6d04d07d3df99e6c38b33cd1a953e980 100644 --- a/build/common.sh +++ b/build/common.sh @@ -41,38 +41,6 @@ function build_googletest(){ echo "install log path: $cmake_target_dir" } -function build_sqlite3(){ - local open_source_dir=$1 - local cmake_target_dir=$1/local/sqlite3 - if [ -d "${cmake_target_dir}" ];then - echo ${cmake_target_dir} "is exist" - return - else - echo ${cmake_target_dir} "is not exist" - fi - pushd "$open_source_dir/sqlite_src" - rm -rf sqlite-src-3370200 - unzip sqlite-src-3370200.zip - cd sqlite-src-3370200 - - patch -p1 < ../0001-sqlite-no-malloc-usable-size.patch - patch -p1 < ../0002-remove-fail-testcase-in-no-free-fd-situation.patch - patch -p1 < ../0003-CVE-2022-35737.patch - patch -p1 < ../0004-fix-memory-problem-in-the-rtree-test-suite.patch - patch -p1 < ../0005-fix-integer-overflow-on-gigabyte-string.patch - patch -p1 < ../0006-CVE-2022-46908.patch - patch -p1 < ../backport-CVE-2023-36191.patch - patch -p1 < ../backport-CVE-2023-7104.patch - - bash ./configure --prefix=${cmake_target_dir} --disable-threadsafe --disable-tcl --enable-fts5 --enable-json1 CFLAGS="-O2 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_RTREE=1 -fstack-protector-all -Wl,-z,relro,-z,now -s -fPIC -ftrapv" LDFLAGS="-pie -s -Wl,-z,relro,-z,now" - make -j ${cpu_core_num} - make install - - popd - rm -rf $open_source_dir/sqlite_src/sqlite-src-3370200 - echo "install sqlite3 path: $cmake_target_dir" -} - function execute_binary() { test_case_dir=("test_perf" "test_symbol") test_case_name=("test_perf" "test_symbol") diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6782045d439750b551e559a1c91c38bf93124a00..12a7af4ea713867166c3a2150ec08a6610d4f6cb 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -11,7 +11,12 @@ # Create: 2024-05-16 # Description: libkperf python module project(python_libkperf) -find_package(PythonInterp 3.7 REQUIRED) -find_package(PythonLibs 3.7 REQUIRED) +if(DEFINED PYTHON_KPERF AND NOT PYTHON_KPERF STREQUAL "") + set(PYTHON_EXECUTABLE ${PYTHON_KPERF}) +else() + find_package(PythonInterp 3.7 REQUIRED) + find_package(PythonLibs 3.7 REQUIRED) +endif() +message("PYTHON_EXECUTABLE is ${PYTHON_EXECUTABLE}") add_subdirectory(modules) \ No newline at end of file diff --git a/python/modules/_libkperf/Pmu.py b/python/modules/_libkperf/Pmu.py index 1055547e1c84edc287775e70a7682cc04bb53548..576ec65332bbba725126c2cc508b23a591b2198e 100644 --- a/python/modules/_libkperf/Pmu.py +++ b/python/modules/_libkperf/Pmu.py @@ -844,4 +844,5 @@ __all__ = [ 'PmuRead', 'PmuClose', 'PmuDumpData', + 'CtypesPmuAttr', ]