From cc7740ae770c52ac1f385aa25cfc143fe79c6b6e Mon Sep 17 00:00:00 2001 From: tcmal Date: Wed, 9 Jun 2021 16:09:29 +0100 Subject: [PATCH] lldb: python into lib & wrap binary --- .../compilers/llvm/10/lldb/default.nix | 7 +++++-- .../compilers/llvm/10/lldb/gnu-install-dirs.patch | 15 ++++++++++++++- .../compilers/llvm/11/lldb/default.nix | 7 +++++-- .../compilers/llvm/11/lldb/gnu-install-dirs.patch | 15 ++++++++++++++- .../compilers/llvm/12/lldb/default.nix | 7 +++++-- .../compilers/llvm/12/lldb/gnu-install-dirs.patch | 15 ++++++++++++++- .../development/compilers/llvm/8/lldb/default.nix | 7 +++++-- .../compilers/llvm/8/lldb/gnu-install-dirs.patch | 13 +++++++++++++ .../development/compilers/llvm/9/lldb/default.nix | 7 +++++-- .../compilers/llvm/9/lldb/gnu-install-dirs.patch | 13 +++++++++++++ 10 files changed, 93 insertions(+), 13 deletions(-) diff --git a/pkgs/development/compilers/llvm/10/lldb/default.nix b/pkgs/development/compilers/llvm/10/lldb/default.nix index 7ce7e1f81503a..a762151a586c0 100644 --- a/pkgs/development/compilers/llvm/10/lldb/default.nix +++ b/pkgs/development/compilers/llvm/10/lldb/default.nix @@ -13,6 +13,7 @@ , version , darwin , lit +, makeWrapper , enableManpages ? false }: @@ -30,7 +31,7 @@ stdenv.mkDerivation (rec { outputs = [ "out" "lib" "dev" ]; nativeBuildInputs = [ - cmake python3 which swig lit + cmake python3 which swig lit makeWrapper ] ++ lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; @@ -69,12 +70,14 @@ stdenv.mkDerivation (rec { doCheck = false; installCheckPhase = '' - if [ ! -e "$out/lib/python3.8/site-packages/lldb/_lldb.so" ] ; then + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then return 1; fi ''; postInstall = '' + wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ + # Editor support # vscode: install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json diff --git a/pkgs/development/compilers/llvm/10/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/10/lldb/gnu-install-dirs.patch index d781779bbe002..0a7539db5e6b7 100644 --- a/pkgs/development/compilers/llvm/10/lldb/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/10/lldb/gnu-install-dirs.patch @@ -75,4 +75,17 @@ index 752113b..010f187 100644 +set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) if(WIN32 OR CYGWIN) # DLL platform -- put DLLs into bin. - set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) \ No newline at end of file + set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bf74802..1c98cae 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -222,7 +222,7 @@ if (LLDB_ENABLE_PYTHON) + if(LLDB_BUILD_FRAMEWORK) + set(LLDB_PYTHON_INSTALL_PATH ${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python) + else() +- set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH}) ++ set(LLDB_PYTHON_INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/../${LLDB_PYTHON_RELATIVE_PATH}) + endif() + if (NOT CMAKE_CFG_INTDIR STREQUAL ".") + string(REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}" LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_INSTALL_PATH}) diff --git a/pkgs/development/compilers/llvm/11/lldb/default.nix b/pkgs/development/compilers/llvm/11/lldb/default.nix index ed118537a5dda..46d6c6628e105 100644 --- a/pkgs/development/compilers/llvm/11/lldb/default.nix +++ b/pkgs/development/compilers/llvm/11/lldb/default.nix @@ -13,6 +13,7 @@ , version , darwin , lit +, makeWrapper , enableManpages ? false }: @@ -30,7 +31,7 @@ stdenv.mkDerivation (rec { outputs = [ "out" "lib" "dev" ]; nativeBuildInputs = [ - cmake python3 which swig lit + cmake python3 which swig lit makeWrapper ] ++ lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; @@ -69,12 +70,14 @@ stdenv.mkDerivation (rec { doCheck = false; installCheckPhase = '' - if [ ! -e "$out/lib/python3.8/site-packages/lldb/_lldb.so" ] ; then + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then return 1; fi ''; postInstall = '' + wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ + # Editor support # vscode: install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json diff --git a/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch index ac071617dd4a2..fd49be395a3a5 100644 --- a/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/11/lldb/gnu-install-dirs.patch @@ -75,4 +75,17 @@ index 752113b..010f187 100644 +set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) if(WIN32 OR CYGWIN) # DLL platform -- put DLLs into bin. - set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) \ No newline at end of file + set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bf74802..1c98cae 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -222,7 +222,7 @@ if (LLDB_ENABLE_PYTHON) + if(LLDB_BUILD_FRAMEWORK) + set(LLDB_PYTHON_INSTALL_PATH ${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python) + else() +- set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH}) ++ set(LLDB_PYTHON_INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/../${LLDB_PYTHON_RELATIVE_PATH}) + endif() + if (NOT CMAKE_CFG_INTDIR STREQUAL ".") + string(REPLACE ${CMAKE_CFG_INTDIR} "\$\{CMAKE_INSTALL_CONFIG_NAME\}" LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_INSTALL_PATH}) diff --git a/pkgs/development/compilers/llvm/12/lldb/default.nix b/pkgs/development/compilers/llvm/12/lldb/default.nix index 24cbcabddad35..0712396cccfa1 100644 --- a/pkgs/development/compilers/llvm/12/lldb/default.nix +++ b/pkgs/development/compilers/llvm/12/lldb/default.nix @@ -19,6 +19,7 @@ , Carbon , Cocoa , lit +, makeWrapper , enableManpages ? false }: @@ -41,7 +42,7 @@ stdenv.mkDerivation (rec { outputs = [ "out" "lib" "dev" ]; nativeBuildInputs = [ - cmake python3 which swig lit + cmake python3 which swig lit makeWrapper ] ++ lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; @@ -85,12 +86,14 @@ stdenv.mkDerivation (rec { doCheck = false; installCheckPhase = '' - if [ ! -e "$out/lib/python3.8/site-packages/lldb/_lldb.so" ] ; then + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then return 1; fi ''; postInstall = '' + wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ + # Editor support # vscode: install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json diff --git a/pkgs/development/compilers/llvm/12/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/12/lldb/gnu-install-dirs.patch index 0435784a24742..afc945ce26147 100644 --- a/pkgs/development/compilers/llvm/12/lldb/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/12/lldb/gnu-install-dirs.patch @@ -75,4 +75,17 @@ index 752113b..010f187 100644 +set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) if(WIN32 OR CYGWIN) # DLL platform -- put DLLs into bin. - set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) \ No newline at end of file + set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b5633e2..86e4738 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -79,7 +79,7 @@ if (LLDB_ENABLE_PYTHON) + if(LLDB_BUILD_FRAMEWORK) + set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb") + else() +- set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb") ++ set(lldb_python_target_dir "${CMAKE_INSTALL_LIBDIR}/../${LLDB_PYTHON_RELATIVE_PATH}/lldb") + endif() + get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR) + finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}") diff --git a/pkgs/development/compilers/llvm/8/lldb/default.nix b/pkgs/development/compilers/llvm/8/lldb/default.nix index 27ed52189b167..b6025f722ebb4 100644 --- a/pkgs/development/compilers/llvm/8/lldb/default.nix +++ b/pkgs/development/compilers/llvm/8/lldb/default.nix @@ -12,6 +12,7 @@ , python3 , version , darwin +, makeWrapper }: stdenv.mkDerivation rec { @@ -37,7 +38,7 @@ stdenv.mkDerivation rec { outputs = [ "out" "lib" "dev" ]; nativeBuildInputs = [ - cmake python3 which swig + cmake python3 which swig makeWrapper ]; buildInputs = [ @@ -62,12 +63,14 @@ stdenv.mkDerivation rec { doCheck = false; installCheckPhase = '' - if [ ! -e "$out/lib/python3.8/site-packages/lldb/_lldb.so" ] ; then + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then return 1; fi ''; postInstall = '' + wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ + mkdir -p $out/share/man/man1 cp ../docs/lldb.1 $out/share/man/man1/ diff --git a/pkgs/development/compilers/llvm/8/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/8/lldb/gnu-install-dirs.patch index eb1ca727df4a5..ffc946816b0d6 100644 --- a/pkgs/development/compilers/llvm/8/lldb/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/8/lldb/gnu-install-dirs.patch @@ -92,3 +92,16 @@ index cdf22c4..d56fc6a 100644 ${use_python_wrapper_from_src_dir} ${use_six_py_from_system} VERBATIM +diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake +index a9059dd..d76a47d 100644 +--- a/cmake/modules/LLDBStandalone.cmake ++++ b/cmake/modules/LLDBStandalone.cmake +@@ -124,7 +124,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + link_directories("${LLVM_LIBRARY_DIR}") + + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) ++ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}/lib${LLVM_LIBDIR_SUFFIX}) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) + + set(LLDB_BUILT_STANDALONE 1) diff --git a/pkgs/development/compilers/llvm/9/lldb/default.nix b/pkgs/development/compilers/llvm/9/lldb/default.nix index ee42e391b5835..63edc60828ebd 100644 --- a/pkgs/development/compilers/llvm/9/lldb/default.nix +++ b/pkgs/development/compilers/llvm/9/lldb/default.nix @@ -12,6 +12,7 @@ , python3 , version , darwin +, makeWrapper , lit }: @@ -29,7 +30,7 @@ stdenv.mkDerivation rec { outputs = [ "out" "lib" "dev" ]; nativeBuildInputs = [ - cmake python3 which swig lit + cmake python3 which swig lit makeWrapper ]; buildInputs = [ @@ -59,12 +60,14 @@ stdenv.mkDerivation rec { doCheck = false; installCheckPhase = '' - if [ ! -e "$out/lib/python3.8/site-packages/lldb/_lldb.so" ] ; then + if [ ! -e "$lib/${python3.sitePackages}/lldb/_lldb.so" ] ; then return 1; fi ''; postInstall = '' + wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/ + # man page mkdir -p $out/share/man/man1 install ../docs/lldb.1 -t $out/share/man/man1/ diff --git a/pkgs/development/compilers/llvm/9/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/9/lldb/gnu-install-dirs.patch index a482aac577988..7876220e4d338 100644 --- a/pkgs/development/compilers/llvm/9/lldb/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/9/lldb/gnu-install-dirs.patch @@ -76,3 +76,16 @@ index cdf22c4..d56fc6a 100644 ${use_python_wrapper_from_src_dir} ${use_six_py_from_system} VERBATIM +diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake +index b726797..1f057ac 100644 +--- a/cmake/modules/LLDBStandalone.cmake ++++ b/cmake/modules/LLDBStandalone.cmake +@@ -95,7 +95,7 @@ include_directories( + "${CLANG_INCLUDE_DIRS}") + + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) ++set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}/lib${LLVM_LIBDIR_SUFFIX}) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) + + set(LLDB_BUILT_STANDALONE 1)