From f59f35c7ba0f63c6330c08d55a46a0392b8351f6 Mon Sep 17 00:00:00 2001 From: Tadej Novak <tadej.novak@cern.ch> Date: Mon, 15 Nov 2021 22:50:44 +0100 Subject: [PATCH] Add IDE / VS Code helpers --- .devcontainer/devcontainer.json | 7 +-- .vscode/IDEHelperScripts/Setup.cmake | 45 +++++++++++++++++++ .vscode/IDEHelperScripts/flake8_wrapper.sh.in | 3 ++ .../IDEHelperScripts/gdb_runner_plain.sh.in | 6 +++ .../gdb_runner_singularity.sh.in | 7 +++ .vscode/IDEHelperScripts/gdb_wrapper.sh.in | 20 +++++++++ .vscode/c_cpp_properties.json | 2 +- .vscode/settings.json | 14 +++++- Projects/WorkDir/CMakeLists.txt | 15 +++---- 9 files changed, 104 insertions(+), 15 deletions(-) create mode 100644 .vscode/IDEHelperScripts/Setup.cmake create mode 100755 .vscode/IDEHelperScripts/flake8_wrapper.sh.in create mode 100755 .vscode/IDEHelperScripts/gdb_runner_plain.sh.in create mode 100755 .vscode/IDEHelperScripts/gdb_runner_singularity.sh.in create mode 100755 .vscode/IDEHelperScripts/gdb_wrapper.sh.in diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5939cbd1b46e..3834d038d1b1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,13 +13,14 @@ "settings": { "terminal.integrated.shell.linux": "/bin/bash", "git.path": "/opt/rh/sclo-git25/root/usr/bin/git", - "python.envFile": "/workspaces/build/env.txt", + "python.envFile": "${workspaceFolder}/../build/env.txt", "python.linting.enabled": true, "python.linting.pylintEnabled": false, "python.linting.flake8Enabled": true, "python.linting.flake8Args": [ - "--select=ATL,F,E7,E9,W6", - "--enable-extension=ATL902" + "--select=ATL,F,E101,E7,E9,W6", + "--ignore=ATL238,ATL9,E701,E702,E704,E741", + "--enable-extensions=ATL902" ] }, diff --git a/.vscode/IDEHelperScripts/Setup.cmake b/.vscode/IDEHelperScripts/Setup.cmake new file mode 100644 index 000000000000..6e2c817f7d54 --- /dev/null +++ b/.vscode/IDEHelperScripts/Setup.cmake @@ -0,0 +1,45 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + +message( STATUS "Preparing IDE helpers" ) + +# singularity settings +set( ATLAS_SINGULARITY_IMAGE "" CACHE PATH + "Use singularity wrapper" ) +set( ATLAS_SINGULARITY_ARGS "" CACHE STRING + "Singularity weapper args" ) + +# Common prefix +set( ATLAS_IDE_PREFIX "${CMAKE_BINARY_DIR}/ide_" ) + +# Dump python environment variables +set( ATLAS_DUMP_ENV_FILE "${CMAKE_BINARY_DIR}/env.txt" CACHE FILEPATH + "File containing dump of environment variables" ) + +if( ATLAS_DUMP_ENV_FILE ) + execute_process( + COMMAND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/atlas_build_run.sh" printenv + COMMAND grep -w ^PYTHONPATH + OUTPUT_FILE "${ATLAS_DUMP_ENV_FILE}" ) +endif() + +# compiler +execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CXX_COMPILER}" "${ATLAS_IDE_PREFIX}compiler" + OUTPUT_FILE "${ATLAS_IDE_PREFIX}compiler" ) + +# python +find_package( Python COMPONENTS Interpreter ) +execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink "${Python_EXECUTABLE}" "${ATLAS_IDE_PREFIX}python" + OUTPUT_FILE "${ATLAS_IDE_PREFIX}python" ) + +# flake8 wrapper +configure_file( "${CMAKE_CURRENT_LIST_DIR}/flake8_wrapper.sh.in" "${ATLAS_IDE_PREFIX}flake8" @ONLY ) + +# gdb wrappers +configure_file( "${CMAKE_CURRENT_LIST_DIR}/gdb_wrapper.sh.in" "${ATLAS_IDE_PREFIX}gdb_wrapper" @ONLY ) +if( ATLAS_SINGULARITY_IMAGE ) + configure_file( "${CMAKE_CURRENT_LIST_DIR}/gdb_runner_singularity.sh.in" "${ATLAS_IDE_PREFIX}gdb_runner" @ONLY ) +else() + configure_file( "${CMAKE_CURRENT_LIST_DIR}/gdb_runner_plain.sh.in" "${ATLAS_IDE_PREFIX}gdb_runner" @ONLY ) +endif() diff --git a/.vscode/IDEHelperScripts/flake8_wrapper.sh.in b/.vscode/IDEHelperScripts/flake8_wrapper.sh.in new file mode 100755 index 000000000000..642fe148f21d --- /dev/null +++ b/.vscode/IDEHelperScripts/flake8_wrapper.sh.in @@ -0,0 +1,3 @@ +#!/bin/bash + +"@CMAKE_BINARY_DIR@@CMAKE_FILES_DIRECTORY@/atlas_build_run.sh" "@Python_EXECUTABLE@" -m flake8 "$@" diff --git a/.vscode/IDEHelperScripts/gdb_runner_plain.sh.in b/.vscode/IDEHelperScripts/gdb_runner_plain.sh.in new file mode 100755 index 000000000000..df3900960593 --- /dev/null +++ b/.vscode/IDEHelperScripts/gdb_runner_plain.sh.in @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "Running GDB wrapper at '@ATLAS_IDE_PREFIX@gdb_wrapper'" +echo + +"@ATLAS_IDE_PREFIX@gdb_wrapper" "$@" diff --git a/.vscode/IDEHelperScripts/gdb_runner_singularity.sh.in b/.vscode/IDEHelperScripts/gdb_runner_singularity.sh.in new file mode 100755 index 000000000000..235ad9c24f66 --- /dev/null +++ b/.vscode/IDEHelperScripts/gdb_runner_singularity.sh.in @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "Using singularity 'singularity exec @ATLAS_SINGULARITY_ARGS@ \"@ATLAS_SINGULARITY_IMAGE@\"'" +echo "Running GDB wrapper at '@ATLAS_IDE_PREFIX@gdb_wrapper'" +echo + +singularity exec @ATLAS_SINGULARITY_ARGS@ "@ATLAS_SINGULARITY_IMAGE@" "/bin/bash" "@ATLAS_IDE_PREFIX@gdb_wrapper" "$@" diff --git a/.vscode/IDEHelperScripts/gdb_wrapper.sh.in b/.vscode/IDEHelperScripts/gdb_wrapper.sh.in new file mode 100755 index 000000000000..e1f46624eb36 --- /dev/null +++ b/.vscode/IDEHelperScripts/gdb_wrapper.sh.in @@ -0,0 +1,20 @@ +#!/bin/bash + +args=("$@") + +set -- + +export ATLAS_LOCAL_ROOT_BASE="/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase" +source "${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh" + +echo +binary_dir="@CMAKE_BINARY_DIR@" +pushd "${binary_dir}" || exit +asetup --restore +source "@ATLAS_PLATFORM@/setup.sh" +popd || exit +echo + +echo "Running gdb with args '${args[*]}'" + +gdb "${args[@]}" diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 44c6152e182f..886bba865da2 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -6,7 +6,7 @@ "${workspaceFolder}/**" ], "defines": [], - "compilerPath": "${env:CXX}", + "compilerPath": "${workspaceFolder}/../build/ide_compiler", "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "gcc-x64", diff --git a/.vscode/settings.json b/.vscode/settings.json index 260ecde21786..27b9095cf60a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,20 @@ { "remote.SSH.defaultExtensions": [ "ms-vscode.cpptools", + "ms-python.python", "twxs.cmake" ], "remote.SSH.lockfilesInTmp": true, - "gitlab.instanceUrl": "https://gitlab.cern.ch" + "gitlab.instanceUrl": "https://gitlab.cern.ch", + "python.pythonPath": "${workspaceFolder}/../build/ide_python", + "python.envFile": "${workspaceFolder}/../build/env.txt", + "python.linting.enabled": true, + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.flake8Path": "${workspaceFolder}/../build/ide_flake8", + "python.linting.flake8Args": [ + "--select=ATL,F,E101,E7,E9,W6", + "--ignore=ATL238,ATL9,E701,E702,E704,E741", + "--enable-extensions=ATL902" + ] } diff --git a/Projects/WorkDir/CMakeLists.txt b/Projects/WorkDir/CMakeLists.txt index 0e97de9b6e02..5fe5dbf05ae6 100644 --- a/Projects/WorkDir/CMakeLists.txt +++ b/Projects/WorkDir/CMakeLists.txt @@ -110,16 +110,11 @@ lcg_generate_env( SH_FILE ${CMAKE_BINARY_DIR}/${ATLAS_PLATFORM}/env_setup.sh ) install( FILES ${CMAKE_BINARY_DIR}/${ATLAS_PLATFORM}/env_setup.sh DESTINATION . ) -# Dump some environment variables for IDE use: -set( CMAKE_DUMP_ENV_FILE ${CMAKE_BINARY_DIR}/env.txt CACHE FILEPATH - "File containing dump of environment variables" ) - -if( CMAKE_DUMP_ENV_FILE ) - execute_process( - COMMAND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/atlas_build_run.sh printenv - COMMAND grep -w ^PYTHONPATH - OUTPUT_FILE "${CMAKE_DUMP_ENV_FILE}" ) -endif() +# Setup IDE integration: +set( ATLAS_IDEHELPERSCRIPTS_SETUP + "${CMAKE_SOURCE_DIR}/../../.vscode/IDEHelperScripts/Setup.cmake" + CACHE FILEPATH "Setup file for the IDE / VS Code helpers" ) +include( "${ATLAS_IDEHELPERSCRIPTS_SETUP}" OPTIONAL ) # Set up CPack: atlas_cpack_setup() -- GitLab