From d98f0e1ae386e1a3722d45593b4ac3c08b8ad797 Mon Sep 17 00:00:00 2001 From: Pesc0 Date: Tue, 11 Jul 2023 15:50:47 +0200 Subject: [PATCH] Update .vscode, untrack and move to /contrib --- .vscode/c_cpp_properties.json | 12 --- .vscode/cmake-kits.json | 18 ---- .vscode/env.sh | 3 - .vscode/launch.json | 48 --------- .vscode/settings.json | 17 --- .vscode/tasks.json | 58 ---------- contrib/.vscode/c_cpp_properties.json | 27 +++++ {.vscode => contrib/.vscode}/extensions.json | 0 contrib/.vscode/launch.json | 102 ++++++++++++++++++ .../scripts/VSCodeAutostartDebug.FCMacro | 18 ++++ contrib/.vscode/scripts/WaitForDebugpy.py | 29 +++++ contrib/.vscode/settings.json | 39 +++++++ contrib/.vscode/tasks.json | 71 ++++++++++++ 13 files changed, 286 insertions(+), 156 deletions(-) delete mode 100644 .vscode/c_cpp_properties.json delete mode 100644 .vscode/cmake-kits.json delete mode 100755 .vscode/env.sh delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json delete mode 100644 .vscode/tasks.json create mode 100644 contrib/.vscode/c_cpp_properties.json rename {.vscode => contrib/.vscode}/extensions.json (100%) create mode 100644 contrib/.vscode/launch.json create mode 100644 contrib/.vscode/scripts/VSCodeAutostartDebug.FCMacro create mode 100644 contrib/.vscode/scripts/WaitForDebugpy.py create mode 100644 contrib/.vscode/settings.json create mode 100644 contrib/.vscode/tasks.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index f0d3f36d36..0000000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "configurations": [ - { - "name": "FreeCAD", - "includePath": ["${workspaceFolder}/**"], - "cStandard": "c17", - "cppStandard": "c++17", - "configurationProvider": "ms-vscode.cmake-tools" - } - ], - "version": 4 -} diff --git a/.vscode/cmake-kits.json b/.vscode/cmake-kits.json deleted file mode 100644 index bb35948554..0000000000 --- a/.vscode/cmake-kits.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "name": "FreeCAD Linux", - "compilers": { - "C": "${workspaceFolder}/.conda/freecad/bin/cc", - "CXX": "${workspaceFolder}/.conda/freecad/bin/c++" - }, - "environmentSetupScript": "${workspaceFolder}/.vscode/env.sh" - }, - { - "name": "FreeCAD macOS", - "compilers": { - "C": "${workspaceFolder}/.conda/freecad/bin/clang", - "CXX": "${workspaceFolder}/.conda/freecad/bin/clang++" - }, - "environmentSetupScript": "${workspaceFolder}/.vscode/env.sh" - } -] diff --git a/.vscode/env.sh b/.vscode/env.sh deleted file mode 100755 index 44b8d46883..0000000000 --- a/.vscode/env.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -source activate freecad diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 28c13c94b9..0000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "C/C++: Linux: build and debug FreeCAD", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/bin/FreeCAD", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "preLaunchTask": "CMake: build" - }, - { - "name": "C/C++: macOS: build and debug FreeCAD", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/bin/FreeCAD", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "lldb", - "preLaunchTask": "CMake: build" - }, - { - "name": "Python: Remote Attach", - "type": "python", - "request": "attach", - "preLaunchTask": "conda: activate environment", - "redirectOutput": true, - "connect": { - "host": "localhost", - "port": 5678 - }, - "pathMappings": [ - { - "localRoot": "${workspaceFolder}", - "remoteRoot": "${workspaceFolder}" - } - ], - "justMyCode": false - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 7c89ae6885..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "files.associations": { - "__config": "cpp", - "iosfwd": "cpp", - "vector": "cpp", - "tuple": "cpp" - }, - "editor.formatOnType": true, - "cmake.preferredGenerators": ["Ninja", "NMake Makefiles"], - "cmake.cmakePath": "${workspaceFolder}/.conda/freecad/bin/cmake", - "cmake.configureSettings": { - "BUILD_WITH_CONDA:BOOL": "ON", - "BUILD_FEM_NETGEN:BOOL": "ON", - "FREECAD_USE_PYBIND11:BOOL": "ON", - "FREECAD_USE_EXTERNAL_SMESH:BOOL": "ON" - } -} diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 52cc100ec9..0000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "tasks": [ - { - "type": "shell", - "label": "conda: activate environment", - "command": "activate freecad", - "problemMatcher": [], - "detail": "Activate conda environment", - "group": "build" - }, - { - "type": "cmake", - "label": "CMake: configure", - "command": "configure", - "problemMatcher": [], - "detail": "CMake template configure task", - "group": "build" - }, - { - "type": "cmake", - "label": "CMake: build", - "command": "build", - "targets": ["all"], - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": [], - "detail": "CMake template build task" - }, - { - "type": "cmake", - "label": "CMake: test", - "command": "test", - "problemMatcher": [], - "detail": "CMake template test task", - "group": "build" - }, - { - "type": "cmake", - "label": "CMake: clean", - "command": "clean", - "problemMatcher": [], - "detail": "CMake template clean task", - "group": "build" - }, - { - "type": "cmake", - "label": "CMake: clean rebuild", - "command": "cleanRebuild", - "targets": ["all"], - "problemMatcher": [], - "detail": "CMake template clean rebuild task", - "group": "build" - } - ], - "version": "2.0.0" -} diff --git a/contrib/.vscode/c_cpp_properties.json b/contrib/.vscode/c_cpp_properties.json new file mode 100644 index 0000000000..1aafc2e244 --- /dev/null +++ b/contrib/.vscode/c_cpp_properties.json @@ -0,0 +1,27 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "configurationProvider": "ms-vscode.cmake-tools" + }, + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**" + ], + "configurationProvider": "ms-vscode.cmake-tools" + }, + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/usr/include/**" + ], + "configurationProvider": "ms-vscode.cmake-tools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/extensions.json b/contrib/.vscode/extensions.json similarity index 100% rename from .vscode/extensions.json rename to contrib/.vscode/extensions.json diff --git a/contrib/.vscode/launch.json b/contrib/.vscode/launch.json new file mode 100644 index 0000000000..3ed74e00fb --- /dev/null +++ b/contrib/.vscode/launch.json @@ -0,0 +1,102 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug C++ Tests", + "type": "cppdbg", + "request": "launch", + "cwd": "${workspaceFolder}", + "program": "${command:cmake.buildDirectory}/tests/Tests_run", + "args": [], + "environment": [ + { + "name": "PATH", + "value": "${command:cmake.buildDirectory}/tests:${env:PATH}" + } + ], + "linux": { + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb" + }, + "osx": { + "MIMode": "lldb" + }, + "windows": { + "MIMode": "gdb", + "miDebuggerPath": "gdb.exe" + }, + "stopAtEntry": false, + "externalConsole": false, + "preLaunchTask": "CMake: build", + "sourceFileMap": { + "${workspaceFolder}": "${workspaceFolder}" + } + }, + { + "name": "C/C++ debugger", + "type": "cppdbg", + "request": "launch", + "cwd": "${workspaceFolder}", + "program": "${command:cmake.buildDirectory}/bin/FreeCAD", + "args": ["${workspaceFolder}/.vscode/scripts/VSCodeAutostartDebug.FCMacro"], + "environment": [ + { + "name": "PATH", + "value": "${command:cmake.buildDirectory}/bin:${env:PATH}" + }, + { + "name": "PYDEVD_DISABLE_FILE_VALIDATION", + "value": "1" + } + ], + "linux": { + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb" + }, + "osx": { + "MIMode": "lldb" + }, + "windows": { + "MIMode": "gdb", + "miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe" + }, + "stopAtEntry": false, + "externalConsole": false, + "presentation": { + "hidden": true, + } + }, + { + "name": "Python debugger", + "type": "python", + "request": "attach", + "preLaunchTask": "WaitForDebugpy", + "redirectOutput": true, + "connect": { + "host": "localhost", + "port": 5678 + }, + "pathMappings": [ + { + "localRoot": "${workspaceFolder}/src", + "remoteRoot": "${command:cmake.buildDirectory}" + } + ], + "justMyCode": false, + "presentation": { + "hidden": true, + } + } + ], + "compounds": [ + { + "name": "Debug FreeCAD", + "configurations": ["C/C++ debugger", "Python debugger"], + "preLaunchTask": "CMake: build", + "stopAll": true, + "presentation": { + "order": 1 + } + } + ] +} \ No newline at end of file diff --git a/contrib/.vscode/scripts/VSCodeAutostartDebug.FCMacro b/contrib/.vscode/scripts/VSCodeAutostartDebug.FCMacro new file mode 100644 index 0000000000..9734d7a5b2 --- /dev/null +++ b/contrib/.vscode/scripts/VSCodeAutostartDebug.FCMacro @@ -0,0 +1,18 @@ +import debugpy +from multiprocessing.connection import Listener +from freecad.utils import get_python_exe + +# get_python_exe is needed because debugpy needs a python interpreter to work. +# It does not have to be FC embedded interpreter. +# By default it attempts to use Freecad's PID mistaking it for python. +# https://github.com/microsoft/debugpy/issues/262 +debugpy.configure(python=get_python_exe()) +debugpy.listen(('localhost', 5678)) + +# Turns out you cannot probe debugpy to see if it is up: +# https://github.com/microsoft/debugpy/issues/974 +# Open another port that the script WaitForDebugpy can probe to see if +# debugpy is running +listener = Listener(('localhost', 6000), backlog=10) + +debugpy.wait_for_client() diff --git a/contrib/.vscode/scripts/WaitForDebugpy.py b/contrib/.vscode/scripts/WaitForDebugpy.py new file mode 100644 index 0000000000..8874490040 --- /dev/null +++ b/contrib/.vscode/scripts/WaitForDebugpy.py @@ -0,0 +1,29 @@ +import socket +from contextlib import closing +import time + +TIMEOUT_TIME_S = 30 +RETRY_DELAY_S = 0.1 + +MAX_ATTEMPTS = TIMEOUT_TIME_S / RETRY_DELAY_S + +def check_socket(host, port): + with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: + sock.settimeout(RETRY_DELAY_S) + return sock.connect_ex((host, port)) == 0 + +def main(): + # DO NOT CHECK 5678 or debugpy will break + # Check other port manually opened instead + attempt_counter = 0 + while (not check_socket('localhost', 6000)) and attempt_counter < MAX_ATTEMPTS: + time.sleep(RETRY_DELAY_S) + attempt_counter += 1 + + if attempt_counter >= MAX_ATTEMPTS: + exit(1) + else: + exit(0) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/contrib/.vscode/settings.json b/contrib/.vscode/settings.json new file mode 100644 index 0000000000..39cd9cbf14 --- /dev/null +++ b/contrib/.vscode/settings.json @@ -0,0 +1,39 @@ +{ + // This disables vscode from adding lines to files.associations, + // some files might not be recognized though. + // This is a vscode issue. + "C_Cpp.autoAddFileAssociations": false, + "files.associations": { + "*.c": "c", + "*.h": "cpp", + "*.cpp": "cpp", + "*.hpp": "cpp", + "*.cxx": "cpp", + "*.hxx": "cpp", + "*.py": "python", + "*.FCMacro": "python" + }, + + "editor.formatOnType": true, + "files.autoSave": "afterDelay", + "debug.onTaskErrors": "abort", //to not launch the python debugger when waitforport.py fails + + // Does not quick launch the debugger, forces to select debugger config every time + // Use the debug panel on the left instead + "debug.showInStatusBar": "never", + + "cmake.options.advanced": { + "configurePreset": { + "statusBarVisibility": "visible" + }, + "build": { + "statusBarVisibility": "visible" + }, + "launch": { + "statusBarVisibility": "hidden" + }, + "debug": { + "statusBarVisibility": "hidden" + } + } +} \ No newline at end of file diff --git a/contrib/.vscode/tasks.json b/contrib/.vscode/tasks.json new file mode 100644 index 0000000000..e8e1f77214 --- /dev/null +++ b/contrib/.vscode/tasks.json @@ -0,0 +1,71 @@ +{ + "tasks": [ + { + "type": "shell", + "label": "FreeCAD: setup conda environment", + "linux": { + "command": "conda/setup-environment.sh", + }, + "osx": { + "command": "conda/setup-environment.sh", + }, + "windows": { + "command": "conda/setup-environment.cmd", + }, + "group": "none", + "problemMatcher": [], + }, + { + "label": "WaitForDebugpy", + "type": "shell", + "command": "python ${workspaceFolder}/.vscode/scripts/WaitForDebugpy.py", + "group": "none", + "problemMatcher": [], + "presentation": { + "reveal": "never", //silently fail and don't launch the debugger + "panel": "dedicated", + "close": true, + "revealProblems": "never" + }, + "hide": true + }, + { + "type": "cmake", + "label": "CMake: build", + "command": "build", + "preset": "${command:cmake.activeBuildPresetName}", + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Build all targets", + "dependsOn": [], + "problemMatcher": ["$gcc"] + }, + { + "label": "Tests: run c++ tests", + "detail": "Run googletest", + "type": "shell", + "command": "${command:cmake.buildDirectory}/tests/Tests_run", + "group": { + "kind": "test", + "isDefault": true + }, + "dependsOn": ["CMake: build"], + "problemMatcher": [] + }, + { + "label": "Tests: run python tests", + "detail": "Run FreeCAD integrated tests", + "type": "shell", + "command": "${command:cmake.buildDirectory}/bin/FreeCAD", + "args": ["-t", "0"], + "group": { + "kind": "test" + }, + "dependsOn": ["CMake: build"], + "problemMatcher": [] + } + ], + "version": "2.0.0" +} \ No newline at end of file