initial commit

This commit is contained in:
Aliberk Sandıkçı 2022-10-27 08:31:55 +03:00
parent 0e2237b566
commit 90983f85e5
61 changed files with 9064 additions and 0 deletions

View file

@ -4,6 +4,13 @@
cd || exit
mkdir tmp_install
cd tmp_install || exit
if [ "$1" == 1 ]; then
curl https://sertifika.meb.gov.tr/MEB_SERTIFIKASI.cer --output MEB_SERTIFIKASI.cer
openssl x509 -inform DER -in MEB_SERTIFIKASI.cer -out MEB_SERTIFIKASI.crt
sudo cp MEB_SERTIFIKASI.crt /usr/local/share/ca-certificates/
sudo chmod 644 /usr/local/share/ca-certificates/MEB_SERTIFIKASI.crt
sudo update-ca-certificates
fi
wget https://github.com/asandikci/iflbot-setup/archive/refs/heads/main.tar.gz
tar -xzvf main.tar.gz
cd iflbot-setup-main || exit
@ -13,3 +20,7 @@ chmod +x prerequisites.sh
chmod +x applications.sh
bash .prerequisites.sh
bash .applications.sh
cp franneck94.c-cpp-runner-4.1.2 /home/"$USER"/.vscode/extensions/
cd || exit
rm -r tmp_install
rmdir tmp_install

View file

@ -0,0 +1,32 @@
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View file

@ -0,0 +1,469 @@
# C/C++ Runner Change Log
## Version 4.1.2: Oct 11, 2022
- **Bugfix**: MSVC C++ standard bugfix
## Version 4.1.1: Oct 04, 2022
- **Bugfix**: MSVC c standard bugfix
- **Bugfix**: Added problems output again
- **Info**: MSVC Default C Standard is now C11
## Version 4.1.0: Oct 03, 2022
- **Info**: Better default value for MSVC, by scanning for installed VS
## Version 4.0.7: Sep 12, 2022
- **Info**: Added check for windows system drive
## Version 4.0.6: Sep 11, 2022
- **Bugfix**: Bug fixes for compiler detection
## Version 4.0.5: Sep 08, 2022
- **Bugfix**: Fixed build error with default include paths
## Version 4.0.4: Aug 21, 2022
- **Bugfix**: On windows gcc, external console for debugging is true
- **Bugfix**: Fixed issue with MIDebuggerPath on Mac with non ARM chip
## Version 4.0.3: May 24, 2022
- **Info**: Updated README
- **Regression**: Removed include paths sync with Microsoft's extension, the user should rather set the include paths settings value of this extension
## Version 4.0.2: May 23, 2022
- **Regression**: Fixed properties <=> settings sync bugs
## Version 4.0.1: May 22, 2022
- **Regression**: Fixed failing msvc compilation with multiple source files
- **Regression**: Fixed properties <=> settings sync bug
## Version 4.0.0: May 17, 2022
- **Info**: Major update about the settings handling. Now, the global (default) settings are used to generate the local .vscode settings files, instead of searching for any compiler installation on your computer. If you do not set an absolute compiler path in the settings, it is expected to have the compiler in the PATH variables (like calling `gcc` in the terminal).
- **Info**: Added boolean flag setting **useMsvc** to indicate if the user wants to use MSVC instead of GCC/Clang in the current workspace.
- **Info**: Clang on windows (backed by MSVC) will also use the MSVC debuggee type
- **Info**: Updated settings.json <=> c_cpp_properties.json sync:
- **Only** Only syncing: C/C++ compiler path, C/C++ standard and include paths
## Version 3.4.0: May 4, 2022
- **Info**: Shortened the msvc commands to have a better overview of the executed command
- **Info**: Added currently known problems list to the README
## Version 3.3.0: April 14, 2022
- **Info**: For debugging the internal console is now used on all operating systems
- **Info**: Removed not working logging
## Version 3.2.4: March 24, 2022
- **Regression**: Fixed MSVC compiling issue
## Version 3.2.3: March 22, 2022
- **Bugfix**: Fixed cmd argument bugs
- **Bugfix**: Fixed double folder entries in folder selection
## Version 3.2.2: March 6, 2022
- **Internal**: Removed task provider
- **Regression**: Fixed CMD arguments bug with whitespaces
## Version 3.2.1: March 5, 2022
- **Regression**: Fixed problem with whitespaces in workspace dir
## Version 3.2.0: March 5, 2022
- **Info**: Now using relative paths for building the binary, hence the console output is shortened and more readable
- **Bugfix**: Hotfix since the extension was not working anymore with VSCode 1.65.0
## Version 3.1.1: January 31, 2022
- **Info**: Updated MSVC instructions
## Version 3.1.0: January 19, 20212
- **Info**: Removed Makefile deactivation
- **Info**: Updated README
## Version 3.0.0: December 31, 2021
- **Feature**: MSVC Compiler Support
- Add Compiler Commands
- Add Setting for MSVC Batch Path
- E.g.: "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat"
- MSVC Host/Target architecture is equal to current architecture
- Added debug config for MSVC
- Default warning level for MSVC is **/W4**, this will be set if MSVC "mode" is active
- Default C version is c17 for MSVC
- **Info**: Removed warnings from compiler args in c_cpp_properties.json
- **Feature**: Updated logic for exclude pattern for folder selection
- **Feature**: Added Include pattern for folder selection
## Version 2.1.1: December 21, 2021
- **Bugfix**: Now passing linker args after the object files
## Version 2.1.0: December 07, 2021
- **Info**: Load global *C_Cpp.default.includePath* setting for the extensions *includePaths*
- **Bugfix**: Opening a project for the first time with the C/C++ Runner extension and an already existing c_cpp_properties.json file, the compiler args are now correctly read-in.
## Version 2.0.5: November 29, 2021
- **Info**: Updated README
- **Info**: Now using the internal console for debugging on Mac M1
- **Bugfix**: Command-line arguments are now stored in a single line in launch.json's args array, thus whitespaces in the arguments are handled correctly
## Version 2.0.4: November 23, 2021
- **Info**: On windows, the paths in the launch.json file are now stored with "/" instead of "\\"
- **Info**: On windows, the commands are now always launched in an extra CMD instance
## Version 2.0.3: November 22, 2021
- **Regression Bugfix**: Fixed issue with cmd arguments
## Version 2.0.2: November 22, 2021
- **Bugfix**: Fixed issue for ARM64 Mac user
## Version 2.0.1: November 17, 2021
- **Regression Bugfix**: Fixed issue for handling whitespaces in paths
## Version 2.0.0: November 16, 2021
- **Info**: Makefile is not used anymore and hence it is no dependency, instead all commands are directly executed with VSCode's task API
- **Info**: Added C++23 Standard to **C_Cpp_Runner.cppStandard** setting
- **Improvement**: Added shortcut for active folder selection **ctrl+alt+f**
- **Improvement**: Added shortcut for build mode selection **ctrl+alt+g**
- **Info**: Added **vadimcn.vscode-lldb** as an extension dependency since this will be used for debugging on Mac with M1 chip
- **Info**: Updated debug target on MacOS with an ARM chip
## Version 1.5.5: November 12, 2021
- **Info**: For Windows users, the paths to the compiler tools are now stored with single slashed "/" instead of double backslashes "\\\\" due to issues with the properties handler of Microsoft's C/C++ extension
## Version 1.5.4: November 10, 2021
- **Bugfix**: Bugfix for settings detection based on c_cpp_properties.json file when there is no local settings.json file present
## Version 1.5.3: November 09, 2021
- **Bugfix**: For a single file task the Compiler, Linker, and Include args are now correctly handled
## Version 1.5.2: October 28, 2021
- **Bugfix**: For a single file task the command line arguments are now passed into the executable call
- **Bugfix**: For single-file tasks, the active folder is now updated
## Version 1.5.1: October 28, 2021
- **Bugfix**: Fixed bug where single file tasks can't be executed when no active folder was selected
## Version 1.5.0: October 27, 2021
- **Improvement**: If the workspace is opened with an existing c_cpp_properties file but no settings.json file, the settings from the properties file are now used for initialization
- **Info**: For Windows users with one of the following conditions, the experimental setting (compiling without Makefile) is now the standard due to several issues in the past:
- MinGW (e.g. MSYS2) users
- Space in the username
- Any space in the filenames of the active folder
- **Info**: Toggle extension keybind command is changed from **ctrl+alt+r** to **ctrl+alt+t**
- **Info**: Commandline arguments keybind command is changed from **ctrl+shift+a** to **ctrl+alt+a**
- **Improvement**: Added following commands for single C/C++ files:
- Build single file (**ctrl+alt+b**) - **b** for build
- Run single file (**ctrl+alt+r**) - **r** for run
- Debug single file (**ctrl+alt+d**) - **d** for debug
## Version 1.4.2: October 25, 2021
- **Info**: Set mac launch config to console andf stopAtEntry.
## Version 1.4.1: September 20, 2021
- **Bugfix**: Fixed big for deactivation event with Makefile projects.
## Version 1.4.0: September 18, 2021
- **Improvement**: Updated activation/deactivation logic with the previously called keybinding *toggle status bar* which is now called *toggleExtensionState*. By this command, you can de-/activate the extension for the current workspace. If the extension is deactivated, the setting/properties/launch files won't be re-created on delete.
- **Improvement**: In a workspace with multiple sub-directories, and hence the active folder is not selected on start-up, the settings and properties files are created once the active folder is selected. This speeds up the start-up time for vscode with this extension activated and makes no difference in the usage of this extension.
- **Improvement**: Added command to reset local settings and properties file
- **Bugfix**: Fixed issue for Windows PowerShell users with the experimental setting. Now the CMD is also used to execute the tasks even if the PowerShell is the default terminal.
## Version 1.3.0: August 28, 2021
- **Improvement**: Update gcc/clang search logic, to only search in */usr/* and */usr/bin/* on Linux, and only in paths containing Cygwin, mingw, or msys on windows
- **Improvement**: If the build path contains whitespaces or non-extended ASCII chars the extension's experimental code runner is used instead of Makefile
- **Bugfix**: Fixed using incorrect compiler path in the experimental setting
## Version 1.2.0: August 25, 2021
- **Feature**: Added pretty print for gdb in debug (launch) configuration
## Version 1.1.5: August 16, 2021
- **Bugfix**: Fixed problem with empty arguments for executing the binary on windows with mingw compiler
## Version 1.1.4: August 15, 2021
- **Bugfix**: Fixed problem with Linker Args
- **Info**: Updated README
## Version 1.1.3: July 27, 2021
- **Bugfix**: Fixed problem with Makefile in .vscode folder (regarding my Udemy Courses setup)
## Version 1.1.2: July 26, 2021
- **Bugfix**: Updated run task for windows such that the executable name has .exe file extension since this is needed for MinGW
- **Bugfix**: Fixed bug that debugging the release build was not possible
## Version 1.1.1: July 26, 2021
- **Improvement**: Creating and deleting the build folder is now executed by the extension code and not anymore by the Makefile
## Version 1.1.0: July 24, 2021
- **Feature**: Added experimental setting to run compiler commands without Makefile
## Version 1.0.2: July 9, 2021
- **Bugfix**: Fixed bug for compiler search on Linux and Mac
## Version 1.0.1: July 4, 2021
- **Info**: Added information message if a path has whitespaces. Makefile can not work with paths/filenames with whitespaces properly.
## Version 1.0.0: July 3, 2021
- **Improvement**: Following settings are now array of strings instead of strings:
- `C_Cpp_runner.warnings`
- `C_Cpp_runner.includePaths`
- `C_Cpp_runner.compilerArgs`
- `C_Cpp_runner.linkerArgs`
So for example previously we used:
```json
{
"C_Cpp_Runner.warnings": "-Wall -Wextra -Wpedantic"
}
```
This would now be:
```json
{
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic"
]
}
```
- All settings are now stored in the local `.vscode/settings.json` file
## Version 0.17.1: June 16, 2021
- **Bugfix**: Bugfix for passing multiple include paths
## Version 0.17.0: June 13, 2021
- **Improvement**: Added option for glob patterns to exclude from the selected folder search
- **Bugfix**: Bugfix for configuration triplet
## Version 0.16.2: June 12, 2021
- **Bugfix**: Bugfix for configuration triplet
## Version 0.16.1: June 12, 2021
- **Bugfix**: Several bug fixes for Linux/mac
## Version 0.16.0: June 12, 2021
- **Improvement**: Updating c_cpp_properties.json and launch.json do trigger an update for settings.json. Hence, the user can edit any of these files and all other files are updated accordingly.
- **Improvement**: Updated compiler search on windows, to speed up the process.
- **Info**: Added some unit tests. Will be extended in the future.
- **Bugfix**: Several bug fixes
## Version 0.15.0: June 7, 2021
- **Info**: If settings/properties were configured e.g. windows and the project is opened in for example Linux, the commands (compiler, etc.) are searched again and stored in the settings.json/c_cpp_properties.json file
- **Bugfix**: Fixed extension crash
## Version 0.14.2: June 3, 2021
- **Info**: When using cygwin64 the intellisense triplet is changed to "Linux" due to the following [issue](https://github.com/microsoft/vscode-cpptools/issues/7637).
## Version 0.14.1: June 1, 2021
- **Bugfix**: Fixed crash when no compiler was found
- **Info**: Do not list folders in the selection that contain '__' (2 underscores)
- **Info**: Do not list folders that are named 'build' (equality check)
- **Info**: Added x64 as default architecture
## Version 0.14.0: May 26, 2021
- **Feature**: Added option to pass arguments to the binary for running and debugging. Users can set the arguments by the new keybinding `ctrl+shift+a`.
- **Bugfix**: Fixed bug for shortened folder path in the status bar.
- **Important Info**: Removed `ctrl+rshift+r` keybinding for the tasks dropdown menu. If the user does not want to use the status bar items, the commands can be executed from the command palette.
- **Info**: Removed extension activation "onDebugResolve:c/cpp" since the debugging is not triggered by the user anyway.
- **Info**: Removed extension activation "workspaceContains:.vscode/c_cpp_properties.json" since this may result in extension activations where the user does not intend to use c/cpp code.
## Version 0.13.0: May 19, 2021
- **Improvement**: Selected folder path is shortened in the status bar.
- **Improvement**: Remove x86/x64 architecture from build mode. The user should rather select an appropriate x86 or x64 compiler in the settings.
- **Improvement**: The default c and cpp standard is now the compiler's default.
- **Improvement**: Improved lookup performance for installed software.
## Version 0.12.1: May 10, 2021
- **Bugfix**: Fixed naming "C_cpp_Properties.json" to "c_cpp_properties.json".
## Version 0.12.0: May 09, 2021
- **Info**: Extension does not show up if a Makefile is present in the root directory of the workspace or inside the .vscode folder of the workspace.
## Version 0.11.0: May 04, 2021
- **Improvement**: The settings are now read/saved correctly in a use case with multiple workspaces.
A multi-workspace setting is now fully compatible with the extension.
- **Bugfix**: External console is now set to false for Mac due to debugging issues.
- **Bugfix**: In a multi-root workspace use case the cmake detection is now working properly.
## Version 0.10.0: April 26, 2021
- **Info**: Updated display logic of status bar items. For more info see the [here](https://github.com/franneck94/vscode-c-cpp-runner/blob/HEAD/README.md)
- **Info**: Added logging entries
- **Info**: Updated project structure
## Version 0.9.1: April 23, 2021
- **Bugfix**: Major bugfix of tasks were not working
## Version 0.9.0: April 23, 2021
- **Bugfix**: Makefile issue with Windows/MinGW
- **Info**: Added try/catch clauses to all IO related functions
- **Info**: Added logger to log certain info/errors. Also added the setting loggingActive to activate the logger
## Version 0.8.2: April 19, 2021
- **Bugfix**: Set debug console to external for lldb (MacOS) - see: [github issue](https://github.com/microsoft/vscode-cpptools/issues/5079)
- **Bugfix**: Makefile arguments that can hold multiple values are now passed with "" instead of ''
- **Bugfix**: In a multi-root workspace use case, the file watchers were not updated to a new selected workspace (on workspace change)
- **Info**: In a multi-root workspace use case, the extension's settings are stored in the '.code-workspace' file
## Version 0.8.1: April 14, 2021
- **Bugfix**: Commands are now callable if the extension is not activated
- **Bugfix**: Now the correct debug config is used
- **Bugfix**: Removed bug that the debug task was always executed when the selected folder has "debug" in its name
- **Improvement**: Now filtering only the target files on delete events
- **Info**: Toggle status bar command changes to `Ctrl+Alt+R`
- **Info**: Added toggle command description to README
## Version 0.8.0: April 14, 2021
- **Feature**: Added command `Shift+Alt+R` to toggle (hide/show) the status bar items
- **Improvement**: Renamed launch (debug) config to 'C/C++ Runner: Debug Session'
- **Bugfix**: Fixed bug of passing the warnings flags to the Makefile
- **Info**: Folders with a '.' in their name are not displayed in the folder quick pick menu
## Version 0.7.0: April 12, 2021
- **Feature**: Added context menu option to select the folder
- **Feature**: Deactivate extension, if "cmake.sourceDirectory" is set
- **Improvement**: Added events for a selected folder on a name change and delete
- **Bugfix**: Fixed behavior of settings/launch/c_cpp_properties.json files if these were already present without the extension entries
- **Bugfix**: Fixed makefile issue when 'Warnings' is an empty string
- **Info**: Updated C Standard default to c99
- **Info**: Update README regarding context menu
## Version 0.6.2: April 11, 2021
- **Bugfix**: Fixed file watcher for single root folder use-case
- **Improvement**: Now sorting the folder list by localeCompare ordering
- **Improvement**: Compilers are searched in the PATH just once on extension start and not re-searched after deleting the local settings.json file
## Version 0.6.1: April 10, 2021
- **Bugfix**: Fixed file watcher for single root folder use-case
## Version 0.6.0: April 9, 2021
- **Feature**: Removed extension activation when CMakeLists.txt is present in the root folder of the workspace
- **Feature**: Select the root folder automatically, if this is the only folder in the workspace
- **Bugfix**: Corrected packing with webpack
- **Bugfix**: settings.json is now re-created on delete event
- **Info**: Added Microsoft's C/C++ extension as "extensionDependencies" entry
- **Info**: Updated README for an easier introduction
## Version 0.5.3: April 5, 2021
- **Feature**: Added search for "mingw32-make" for MinGW users
- **Feature**: Updated makefile for Windows users without Cygwin/MSYS installed
- **Info**: Removed Microsoft's C/C++ extension as an "extensionPack" entry, since deactivating/uninstalling this extension would also do so for the Microsoft ones
- **Bugfix**: The extension couldn't start after installing
## Version 0.5.2: April 5, 2021
- **Info**: Added Microsoft's C/C++ extension as "extensionPack" entry
## Version 0.5.1: April 5, 2021
- **Bugfix**: Fixed critical bug of getting the extension's root dir
## Version 0.5.0: April 4, 2021
- **Feature**: Added new buttons to the status bar for: Build, Run, and Debug
- **Feature**: Added a task for debugging to the tasks list (ctrl+shift+r)
- **Bugfix**: If the root directory has code and there is no sub-dir, no dir can be selected
- **Bugfix**: Corrected path to the binary in the launch.json file
- **Feature**: New activation command for extension: .vscode/c_cpp_properties.json is present in workspace
## Version 0.4.0: April 3, 2021
- **Feature**: Added quick pick to select a folder for compiling/running etc.
- After picking a folder a c_cpp_properties.json and launch.json config file is created
- **Feature**: Added status bar item for build and architecture mode (e.g. Debug - x64)
- Architecture mode selection works as follows:
- For 64bit compiler: -m64 compiler argument
- For 32bit compiler: -m32 compiler argument
- **Bugfix**: When deleting the .vscode folder, no \*.json files are created
- **Feature**: Updated task provider behavior:
- Only provide tasks if the user has selected a working directory
- Only run and clean tasks are provided if there is a build folder in the selected working directory
- **Feature**: Output binary with unified name (non-dependent on the C/C++ file name), always called outDebug (.exe for windows)
## Version 0.3.0: April 1, 2021
- **Feature**: Generating a launch.json configuration for the debug build
## Version 0.2.0: March 31, 2021
- **Feature**: If not provided, creating a c_cpp_properties.json file for the C/C++ Microsoft extension
- **Feature**: Added options for the include path, additional compiler, and linker args
- **Feature**: Updated Build/Run/Clean tasks
- **Info**: Now bundling with webpack for improved performance
## Version 0.1.0: March 29, 2021
- **Feature**: Added platform-dependent compiler usage
## Version 0.0.1: March 23, 2021
- **Info**: First alpha Version

View file

@ -0,0 +1,21 @@
Copyright (c) 2021-2022 Jan Schaffranek. All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,5 @@
clean:
rm -rf test/**/.vscode 2> /dev/null
rm -rf test/**/build 2> /dev/null
.phony: clean

View file

@ -0,0 +1,139 @@
# VSCode C/C++ Runner
🚀 Compile, run and debug **single** or **multiple** C/C++ files with ease. 🚀
You do not need to know about any compiler commands. 😎
## Example
![ExampleGif](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/ExecuteTasks.gif?raw=true)
## Software Requirements
- 🔧 For C code: Any GCC, Clang or MSVC compiler
- 🔧 For C++ code: Any G++, Clang++ or MSVC compiler
Make sure that your GCC/Clang compiler is either in your PATH or you have to set the **C/ C++ Compiler Path** setting of this extension.
For the MSVC compiler usage see [here](#Using-the-MSVC-Compiler).
## Extension Activation Conditions
- Whenever there is a C/C++ file in the **base** directory of your workspace
- Whenever you open a C/C++ file in your workspace
## How to use: Compile **all** files in a folder
1⃣ Select the folder that contains the C/C++ files.
You can select the folder by the quick pick menu from the status bar.
![TaskStatusBar](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/FolderStatusBar.png)
Besides that, you can also select a folder by right-clicking in the context menu.
2⃣ Select either debug or release mode for building the binary (debug is the default case).
![TaskStatusBar](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/ModeStatusBar.png)
3⃣ Now you can build/run/debug the binary.
![TaskStatusBar](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/TaskStatusBar.png)
- ⚙️ Build: This task will compile all C/C++ files in the selected folder and will link them into a binary.
- ▶️ Run*: This task will execute the built binary.
- 🗑️ Clean*: This helper task will delete all compiled object files (*.o).
- 🐞 Debug*: This task will start a debugging session for the binary.
*This task is a no-op if the build task was not executed previously.
## How to use: Compile a **single** file
1⃣ Open the C/C++ file you want to compile (build).
2⃣ Select either debug or release mode for building the binary (debug is the default case).
3⃣ To build the binary press **ctrl+alt+b**.
4⃣ To run the binary press **ctrl+alt+r**.
5⃣ To debug the binary press **ctrl+alt+d**.
## Extension Features
### Passing Commandline Arguments
You can pass in command-line arguments for running or debugging the binary.
Make sure to select the active folder beforehand, then press `ctrl+alt+a` to open the message box to type in the arguments:
![Arguments](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/arguments.png)
These arguments will be stored in the launch.json config for debugging the binary.
![ArgumentsDebug](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/argumentsDebug.png)
If you now run or debug your program these values will be fed into **argc**/**argv**.
The stored arguments will be reset after selecting a new active folder.
Note: For strings with whitespaces please use \" (not single \').
### Include & Exclude Folders for Selection
You can add glob patterns to include and exclude folders from the search to shorten the list.
Note: The include pattern is used before the exclude pattern.
For example with the following exclude glob pattern:
![ExcludePattern](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/excludePattern.png)
The folder selection would change from left to right.
![ExcludePaths1](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/excludePaths1.png)
![ExcludePaths2](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/excludePaths2.png)
For more information about glob pattern see [here](https://en.wikipedia.org/wiki/Glob_(programming)#Syntax).
### Configuration
The current configuration settings will be stored locally in *".vscode/settings.json"*.
![FoundCompiler](https://github.com/franneck94/vscode-c-cpp-runner/raw/HEAD/media/Settings.png)
Based on the settings, the local *.vscode/c_cpp_properties.json* file is created and will be used by [Microsoft's *C/C++*](https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference) extension for intellisense.
There, the compiler path, the C/C++ standard, and the included paths are **synced** with this extension settings.
### Extension Settings
- ⚙️ C Compiler path (defaults to gcc)
- ⚙️ C Standard (defaults to the compiler's default)
- ⚙️ C++ Compiler path (defaults to g++)
- ⚙️ C++ Standard (defaults to the compiler's default)
- ⚙️ Debugger path (defaults to gdb)
- ⚙️ MSVC batch path (defaults to \"\")
- ⚙️ Use MSVC (defaults to false)
- ⚙️ To enable warnings (defaults to True)
- ⚙️ What warnings should be checked by the compiler (defaults to [\"-Wall\", \"-Wextra\", \"-Wpedantic\"])
- ⚙️ To treat warnings as errors (defaults to False)
- ⚙️ Additional compiler arguments (defaults to [] e.g. **-flto**)
- ⚙️ Additional linker arguments (defaults to [] e.g. **-lpthread**).
- Note: It **is** expected to prefix the arguments with the appropriate flags (e.g. -l or -L)
- ⚙️ Additional include paths (defaults to [] e.g. **path/to/headers/**)
- Note: It is **not** (!) expected to prefix the arguments with the **-I** flag
- ⚙️ Include glob pattern for the folder selection (defaults to ["\*", "\*\*/\*"])
- ⚙️ Exclude glob pattern for the folder selection (defaults to ["\*\*/build", "\*\*/.\*", "\*\*/.vscode",])
## Important Notes
### Constraints on Files and Folders
- 📝 Allowed file extensions for headers: \*.h, \*.hpp, \*.hh, \*.hxx
- 📝 Allowed file extensions for sources: \*.c, \*.cpp, \*.cc, \*.cxx
- ⚠️ Include paths with whitespaces can make the compilation fail
### CMake Projects in the Workspace Directory
This extension does not start whenever there is a CMakeLists.txt in the workspace root directory.
This prevents an overloaded status bar with a lot of icons due to Microsoft's CMake extension.
However, the user can trigger the start-up of this extension by pressing `ctrl+alt+t`.
## Using the MSVC Compiler
To use the MSVC compiler (toolchain), set the **msvcBatchPath** setting to a valid path.
An example path would be **"*PathToVs2022*/Community/VC/Auxiliary/Build/vcvarsall.bat"**.
Then set the **useMsvc** to true, to not use GCC/Clang tools in the current workspace.
If you want to stop using the MSVC compiler, just set **useMsvc** to false.
Note: Only the 64bit (no cross-compiling) version of MSVC is allowed
## Release Notes
Refer to the [CHANGELOG](https://github.com/franneck94/vscode-c-cpp-runner/blob/HEAD/CHANGELOG.md).
## License
Copyright (C) 2021-2022 Jan Schaffranek.
Licensed under the [MIT License](https://github.com/franneck94/vscode-c-cpp-runner/blob/HEAD/LICENSE).

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeBuildTask = void 0;
const path = require("path");
const vscode = require("vscode");
const fileUtils_1 = require("../utils/fileUtils");
const types_1 = require("../utils/types");
async function executeBuildTask(task, settingsProvider, activeFolder, buildMode) {
const language = fileUtils_1.getLanguage(activeFolder);
const files = fileUtils_1.filesInDir(activeFolder);
const buildDir = path.join(activeFolder, 'build');
const modeDir = path.join(buildDir, `${buildMode}`);
if (!fileUtils_1.pathExists(modeDir)) {
fileUtils_1.mkdirRecursive(modeDir);
}
let executableName;
if (settingsProvider.operatingSystem === types_1.OperatingSystems.windows) {
executableName = `out${buildMode}.exe`;
}
else {
executableName = `out${buildMode}`;
}
const executablePath = path.join(modeDir, executableName);
let compiler;
let standard;
if (language === types_1.Languages.cpp) {
compiler = settingsProvider.cppCompilerPath;
standard = settingsProvider.cppStandard;
}
else {
compiler = settingsProvider.cCompilerPath;
standard = settingsProvider.cStandard;
}
const useWarnings = settingsProvider.enableWarnings;
const warningsAsErrors = settingsProvider.warningsAsError;
let warnings = '';
if (useWarnings) {
warnings = settingsProvider.warnings.join(' ');
}
if (useWarnings && warningsAsErrors) {
warnings += ' -Werror';
}
const includePaths = settingsProvider.includePaths;
const includes = includePaths.join(' -I ');
const compilerArgs = settingsProvider.compilerArgs;
const linkerArgs = settingsProvider.linkerArgs;
let fullCompilerArgs = '';
if (warnings) {
fullCompilerArgs += `${warnings}`;
}
if (standard) {
fullCompilerArgs += ` --std=${standard}`;
}
if (buildMode === types_1.Builds.debug) {
fullCompilerArgs += ' -g3 -O0';
}
else {
fullCompilerArgs += ' -O3 -DNDEBUG';
}
if (compilerArgs) {
fullCompilerArgs += compilerArgs;
}
if (linkerArgs) {
fullCompilerArgs += linkerArgs;
}
if (includes) {
fullCompilerArgs += includes;
}
let commandLine = '';
const objectFiles = [];
for (const file of files) {
const fileExtension = path.parse(file).ext;
if (language === types_1.Languages.c && !fileUtils_1.isCSourceFile(fileExtension)) {
continue;
}
else if (language === types_1.Languages.cpp && !fileUtils_1.isCppSourceFile(fileExtension)) {
continue;
}
const fileBaseName = path.parse(file).name;
const filePath = path.join(activeFolder, file);
const objectFilePath = path.join(modeDir, fileBaseName + '.o');
objectFiles.push(objectFilePath);
const fullFileArgs = `-c ${filePath} -o ${objectFilePath}`;
if (commandLine.length === 0) {
commandLine += `${compiler} ${fullCompilerArgs} ${fullFileArgs}`;
}
else {
commandLine += ` && ${compiler} ${fullCompilerArgs} ${fullFileArgs}`;
}
}
const objectFilesStr = objectFiles.join(' ');
const fullObjectFileArgs = `${objectFilesStr} -o ${executablePath}`;
if (task && task.execution) {
commandLine += ` && ${compiler} ${fullCompilerArgs} ${fullObjectFileArgs}`;
task.execution.commandLine = commandLine;
await vscode.tasks.executeTask(task);
}
}
exports.executeBuildTask = executeBuildTask;
//# sourceMappingURL=builder.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../../src/executor/builder.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,iCAAiC;AAGjC,kDAO4B;AAC5B,0CAA2E;AAEpE,KAAK,UAAU,gBAAgB,CACpC,IAAU,EACV,gBAAkC,EAClC,YAAoB,EACpB,SAAiB;IAEjB,MAAM,QAAQ,GAAG,uBAAW,CAAC,YAAY,CAAC,CAAC;IAE3C,MAAM,KAAK,GAAG,sBAAU,CAAC,YAAY,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;IAEpD,IAAI,CAAC,sBAAU,CAAC,OAAO,CAAC,EAAE;QACxB,0BAAc,CAAC,OAAO,CAAC,CAAC;KACzB;IAED,IAAI,cAAsB,CAAC;IAC3B,IAAI,gBAAgB,CAAC,eAAe,KAAK,wBAAgB,CAAC,OAAO,EAAE;QACjE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AI,gBAAgB,IAAI,YAAY,EAAE,CAAC;SACtE;KACF;IAGD,MAAM,cAAc,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,kBAAkB,GAAG,GAAG,cAAc,OAAO,cAAc,EAAE,CAAC;IACpE,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE;QAC1B,WAAW,IAAI,OAAO,QAAQ,IAAI,gBAAgB,IAAI,kBAAkB,EAAE,CAAC;QAC3E,IAAI,CAAC,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC;QACzC,MAAM,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KACtC;AACH,CAAC;AA1GD,4CA0GC"}

View file

@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.runDebugger = void 0;
const path = require("path");
const vscode = require("vscode");
const fileUtils_1 = require("../utils/fileUtils");
const vscodeUtils_1 = require("../utils/vscodeUtils");
const CONFIG_NAME = 'C/C++ Runner: Debug Session';
async function runDebugger(activeFolder, workspaceFolder, buildMode) {
if (!activeFolder)
return;
if (!workspaceFolder)
return;
const uriWorkspaceFolder = vscode.Uri.file(workspaceFolder);
const folder = vscode.workspace.getWorkspaceFolder(uriWorkspaceFolder);
const launchPath = path.join(workspaceFolder, '.vscode', 'launch.json');
const configJson = fileUtils_1.readJsonFile(launchPath);
if (!configJson)
return;
const configIdx = vscodeUtils_1.getLaunchConfigIndex(configJson, CONFIG_NAME);
if (configIdx === undefined)
return;
const buildDir = path.join(activeFolder, 'build');
const modeDir = path.join(buildDir, `${buildMode}`);
if (!fileUtils_1.pathExists(modeDir))
return;
await vscode.debug.startDebugging(folder, configJson.configurations[configIdx]);
}
exports.runDebugger = runDebugger;
//# sourceMappingURL=debugger.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../../../src/executor/debugger.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,iCAAiC;AAEjC,kDAA8D;AAE9D,sDAA4D;AAE5D,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAE3C,KAAK,UAAU,WAAW,CAC/B,YAAgC,EAChC,eAAmC,EACnC,SAAiB;IAEjB,IAAI,CAAC,YAAY;QAAE,OAAO;IAC1B,IAAI,CAAC,eAAe;QAAE,OAAO;IAE7B,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IACvE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IAExE,MAAM,UAAU,GAAkC,wBAAY,CAAC,UAAU,CAAC,CAAC;IAE3E,IAAI,CAAC,UAAU;QAAE,OAAO;IAExB,MAAM,SAAS,GAAG,kCAAoB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAEhE,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO;IAEpC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;IACpD,IAAI,CAAC,sBAAU,CAAC,OAAO,CAAC;QAAE,OAAO;IAEjC,MAAM,MAAM,CAAC,KAAK,CAAC,cAAc,CAC/B,MAAM,EACN,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CACrC,CAAC;AACJ,CAAC;AA5BD,kCA4BC"}

View file

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeRunTask = void 0;
const path = require("path");
const vscode = require("vscode");
const fileUtils_1 = require("../utils/fileUtils");
const types_1 = require("../utils/types");
async function executeRunTask(task, activeFolder, buildMode, argumentsString, operatingSystem) {
const buildDir = path.join(activeFolder, 'build');
const modeDir = path.join(buildDir, `${buildMode}`);
if (!fileUtils_1.pathExists(modeDir))
return;
let executableName;
if (operatingSystem === types_1.OperatingSystems.windows) {
executableName = `out${buildMode}.exe`;
}
else {
executableName = `./out${buildMode}`;
}
if (argumentsString) {
executableName += argumentsString;
}
const executablePath = path.join(modeDir, executableName);
if (!fileUtils_1.pathExists(executablePath))
return;
if (task && task.execution) {
const commandLine = `${executablePath}`;
task.execution.commandLine = commandLine;
await vscode.tasks.executeTask(task);
}
}
exports.executeRunTask = executeRunTask;
//# sourceMappingURL=runner.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/executor/runner.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,iCAAiC;AAEjC,kDAAgD;AAChD,0CAAgE;AAEzD,KAAK,UAAU,cAAc,CAClC,IAAU,EACV,YAAoB,EACpB,SAAiB,EACjB,eAAmC,EACnC,eAAiC;IAEjC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;IACpD,IAAI,CAAC,sBAAU,CAAC,OAAO,CAAC;QAAE,OAAO;IAEjC,IAAI,cAAsB,CAAC;IAC3B,IAAI,eAAe,KAAK,wBAAgB,CAAC,OAAO,EAAE;QAChD,cAAc,GAAG,MAAM,SAAS,MAAM,CAAC;KACxC;SAAM;QACL,cAAc,GAAG,QAAQ,SAAS,EAAE,CAAC;KACtC;IAED,IAAI,eAAe,EAAE;QACnB,cAAc,IAAI,eAAe,CAAC;KACnC;IAED,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE1D,IAAI,CAAC,sBAAU,CAAC,cAAc,CAAC;QAAE,OAAO;IAExC,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE;QAC1B,MAAM,WAAW,GAAG,GAAG,cAAc,EAAE,CAAC;QACxC,IAAI,CAAC,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC;QACzC,MAAM,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KACtC;AACH,CAAC;AA/BD,wCA+BC"}

View file

@ -0,0 +1,581 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deactivate = exports.activate = exports.experimentalExecutionEnabled = exports.loggingActive = exports.extensionPath = exports.extensionState = exports.extensionContext = void 0;
const path = require("path");
const vscode = require("vscode");
const builder_1 = require("./executor/builder");
const debugger_1 = require("./executor/debugger");
const runner_1 = require("./executor/runner");
const folderHandler_1 = require("./handler/folderHandler");
const modeHandler_1 = require("./handler/modeHandler");
const statusBarItems_1 = require("./items/statusBarItems");
const launchProvider_1 = require("./provider/launchProvider");
const propertiesProvider_1 = require("./provider/propertiesProvider");
const settingsProvider_1 = require("./provider/settingsProvider");
const taskProvider_1 = require("./provider/taskProvider");
const fileUtils_1 = require("./utils/fileUtils");
const logger = require("./utils/logger");
const types_1 = require("./utils/types");
const vscodeUtils_1 = require("./utils/vscodeUtils");
let folderContextMenuDisposable;
let taskProviderDisposable;
let commandHandlerDisposable;
let commandToggleStateDisposable;
let commandFolderDisposable;
let commandModeDisposable;
let commandBuildDisposable;
let commandRunDisposable;
let commandDebugDisposable;
let commandCleanDisposable;
let commandArgumentDisposable;
let commandResetDisposable;
let eventConfigurationDisposable;
let eventRenameFilesDisposable;
let eventDeleteFilesDisposable;
let settingsProvider;
let launchProvider;
let propertiesProvider;
let taskProvider;
let folderStatusBar;
let modeStatusBar;
let buildStatusBar;
let runStatusBar;
let debugStatusBar;
let cleanStatusBar;
let argumentsString;
let workspaceFolder;
let activeFolder;
let buildMode = types_1.Builds.debug;
let showStatusBarItems = true;
let createExtensionFiles = true;
const EXTENSION_NAME = 'C_Cpp_Runner';
exports.loggingActive = false;
exports.experimentalExecutionEnabled = false;
function activate(context) {
if (!vscode.workspace.workspaceFolders ||
vscode.workspace.workspaceFolders.length === 0) {
return;
}
if (!vscode.workspace.workspaceFolders[0] ||
!vscode.workspace.workspaceFolders[0].uri) {
return;
}
if (vscode.workspace.workspaceFolders.length === 1) {
workspaceFolder = vscode.workspace.workspaceFolders[0].uri.fsPath;
}
vscodeUtils_1.setContextValue(`${EXTENSION_NAME}:activatedExtension`, true);
vscodeUtils_1.updateActivationState(true);
const courseMakefileFound = vscodeUtils_1.isCourseProject();
if (courseMakefileFound) {
const infoMessage = `Course Makefile found. Exiting extension.`;
logger.log(exports.loggingActive, infoMessage);
deactivate();
return;
}
const cmakeFileFound = vscodeUtils_1.isCmakeProject();
if (cmakeFileFound) {
showStatusBarItems = false;
createExtensionFiles = false;
const infoMessage = `CMake Project found. UI disabled.`;
logger.log(exports.loggingActive, infoMessage);
}
exports.extensionContext = context;
exports.extensionPath = context.extensionPath;
exports.extensionState = context.workspaceState;
vscodeUtils_1.updateLoggingState();
exports.loggingActive = vscodeUtils_1.getLoggingState();
exports.experimentalExecutionEnabled = vscodeUtils_1.getExperimentalExecutionState();
initFolderStatusBar();
initModeStatusBar();
initBuildStatusBar();
initRunStatusBar();
initDebugStatusBar();
initCleanStatusBar();
initWorkspaceProvider();
initWorkspaceDisposables();
initEventListener();
}
exports.activate = activate;
function deactivate() {
vscodeUtils_1.setContextValue(`${EXTENSION_NAME}:activatedExtension`, false);
vscodeUtils_1.updateActivationState(false);
vscodeUtils_1.disposeItem(folderStatusBar);
vscodeUtils_1.disposeItem(modeStatusBar);
vscodeUtils_1.disposeItem(buildStatusBar);
vscodeUtils_1.disposeItem(runStatusBar);
vscodeUtils_1.disposeItem(debugStatusBar);
vscodeUtils_1.disposeItem(cleanStatusBar);
vscodeUtils_1.disposeItem(taskProviderDisposable);
vscodeUtils_1.disposeItem(folderContextMenuDisposable);
vscodeUtils_1.disposeItem(commandHandlerDisposable);
vscodeUtils_1.disposeItem(commandToggleStateDisposable);
vscodeUtils_1.disposeItem(commandFolderDisposable);
vscodeUtils_1.disposeItem(commandModeDisposable);
vscodeUtils_1.disposeItem(commandBuildDisposable);
vscodeUtils_1.disposeItem(commandRunDisposable);
vscodeUtils_1.disposeItem(commandDebugDisposable);
vscodeUtils_1.disposeItem(commandCleanDisposable);
vscodeUtils_1.disposeItem(commandArgumentDisposable);
vscodeUtils_1.disposeItem(commandResetDisposable);
vscodeUtils_1.disposeItem(eventConfigurationDisposable);
vscodeUtils_1.disposeItem(eventDeleteFilesDisposable);
vscodeUtils_1.disposeItem(eventRenameFilesDisposable);
}
exports.deactivate = deactivate;
function initWorkspaceProvider() {
if (!workspaceFolder || !createExtensionFiles || !activeFolder)
return;
if (!settingsProvider) {
settingsProvider = new settingsProvider_1.SettingsProvider(workspaceFolder, activeFolder);
}
if (!propertiesProvider) {
propertiesProvider = new propertiesProvider_1.PropertiesProvider(settingsProvider, workspaceFolder, activeFolder);
}
if (!launchProvider) {
launchProvider = new launchProvider_1.LaunchProvider(settingsProvider, workspaceFolder, activeFolder);
}
if (!taskProvider) {
taskProvider = new taskProvider_1.TaskProvider(settingsProvider, workspaceFolder, activeFolder, buildMode, argumentsString);
}
}
function initWorkspaceDisposables() {
initTaskProviderDisposable();
initArgumentParser();
initContextMenuDisposable();
initReset();
initToggleDisposable();
}
function initTaskProviderDisposable() {
if (!taskProvider || taskProviderDisposable)
return;
taskProviderDisposable = vscode.tasks.registerTaskProvider(EXTENSION_NAME, taskProvider);
exports.extensionContext?.subscriptions.push(taskProviderDisposable);
}
function initToggleDisposable() {
if (commandToggleStateDisposable)
return;
commandToggleStateDisposable = vscode.commands.registerCommand(`${EXTENSION_NAME}.toggleExtensionState`, () => {
showStatusBarItems = !showStatusBarItems;
toggleStatusBarItems();
createExtensionFiles = !createExtensionFiles;
if (createExtensionFiles) {
initWorkspaceProvider();
initWorkspaceDisposables();
settingsProvider?.createFileData();
propertiesProvider?.createFileData();
}
const extensionIsDisabled = !showStatusBarItems && !createExtensionFiles;
if (extensionIsDisabled) {
vscodeUtils_1.setContextValue(`${EXTENSION_NAME}:activatedExtension`, !extensionIsDisabled);
vscodeUtils_1.updateActivationState(!extensionIsDisabled);
}
else {
vscodeUtils_1.setContextValue(`${EXTENSION_NAME}:activatedExtension`, !extensionIsDisabled);
vscodeUtils_1.updateActivationState(!extensionIsDisabled);
}
const infoMessage = `Called toggleExtensionState.`;
logger.log(exports.loggingActive, infoMessage);
});
exports.extensionContext?.subscriptions.push(commandToggleStateDisposable);
}
function initContextMenuDisposable() {
if (folderContextMenuDisposable)
return;
folderContextMenuDisposable = vscode.commands.registerCommand(`${EXTENSION_NAME}.folderContextMenu`, async (clickedUriItem, selectedUriItems) => {
if (selectedUriItems.length > 1)
return;
const workspaceItem = vscode.workspace.getWorkspaceFolder(clickedUriItem);
if (!workspaceItem)
return;
activeFolder = clickedUriItem.fsPath;
workspaceFolder = workspaceItem.uri.fsPath;
updateFolderData();
const infoMessage = `Called folderContextMenu.`;
logger.log(exports.loggingActive, infoMessage);
});
exports.extensionContext?.subscriptions.push(folderContextMenuDisposable);
}
function initEventListener() {
initConfigurationChangeDisposable();
initFileRenameDisposable();
initFileDeleteDisposable();
}
function initConfigurationChangeDisposable() {
if (eventConfigurationDisposable)
return;
eventConfigurationDisposable = vscode.workspace.onDidChangeConfiguration((e) => {
const isChanged = e.affectsConfiguration(EXTENSION_NAME);
const extensionIsActive = vscodeUtils_1.getActivationState();
if (isChanged && extensionIsActive) {
settingsProvider?.updateFileContent();
propertiesProvider?.updateFileContent();
launchProvider?.updateFileContent();
taskProvider?.getTasks();
}
});
exports.extensionContext?.subscriptions.push(eventConfigurationDisposable);
}
function initFileRenameDisposable() {
if (eventRenameFilesDisposable)
return;
eventRenameFilesDisposable = vscode.workspace.onDidRenameFiles((e) => {
const extensionIsActive = vscodeUtils_1.getActivationState();
if (!extensionIsActive)
return;
e.files.forEach((file) => {
const oldName = file.oldUri.fsPath;
const newName = file.newUri.fsPath;
const infoMessage = `Renaming: ${oldName} -> ${newName}.`;
logger.log(exports.loggingActive, infoMessage);
if (workspaceFolder && oldName === workspaceFolder) {
workspaceFolder = newName;
updateFolderData();
}
else if (activeFolder && oldName === activeFolder) {
activeFolder = newName;
updateFolderData();
}
});
});
exports.extensionContext?.subscriptions.push(eventRenameFilesDisposable);
}
function initFileDeleteDisposable() {
if (!eventDeleteFilesDisposable)
return;
eventDeleteFilesDisposable = vscode.workspace.onDidDeleteFiles((e) => {
const extensionIsActive = vscodeUtils_1.getActivationState();
if (!extensionIsActive)
return;
e.files.forEach((file) => {
const oldName = file.fsPath;
const infoMessage = `Deleting: ${oldName}.`;
logger.log(exports.loggingActive, infoMessage);
if (workspaceFolder && oldName === workspaceFolder) {
workspaceFolder = undefined;
updateFolderData();
statusBarItems_1.updateFolderStatus(folderStatusBar, taskProvider, showStatusBarItems);
}
else if (activeFolder && oldName === activeFolder) {
activeFolder = undefined;
updateFolderData();
statusBarItems_1.updateFolderStatus(folderStatusBar, taskProvider, showStatusBarItems);
}
});
});
exports.extensionContext?.subscriptions.push(eventDeleteFilesDisposable);
}
function toggleStatusBarItems() {
if (showStatusBarItems) {
folderStatusBar?.show();
modeStatusBar?.show();
buildStatusBar?.show();
runStatusBar?.show();
debugStatusBar?.show();
cleanStatusBar?.show();
}
else {
folderStatusBar?.hide();
modeStatusBar?.hide();
buildStatusBar?.hide();
runStatusBar?.hide();
debugStatusBar?.hide();
cleanStatusBar?.hide();
}
}
function updateFolderData() {
initWorkspaceProvider();
initWorkspaceDisposables();
argumentsString = '';
if (taskProvider) {
taskProvider.updateFolderData(workspaceFolder, activeFolder);
taskProvider.updateArguments(argumentsString);
taskProvider.updateModeData(buildMode);
}
if (workspaceFolder && activeFolder) {
if (settingsProvider) {
settingsProvider.updateFolderData(workspaceFolder);
settingsProvider.updateFileContent();
if (propertiesProvider) {
propertiesProvider.updateFolderData(workspaceFolder);
}
if (launchProvider) {
launchProvider.updateFolderData(workspaceFolder, activeFolder);
launchProvider.updateModeData(buildMode);
launchProvider.updateFileContent();
}
}
}
if (folderStatusBar) {
statusBarItems_1.updateFolderStatus(folderStatusBar, taskProvider, showStatusBarItems);
}
if (modeStatusBar) {
statusBarItems_1.updateModeStatus(modeStatusBar, showStatusBarItems, activeFolder, buildMode);
}
if (buildStatusBar) {
statusBarItems_1.updateBuildStatus(buildStatusBar, showStatusBarItems, activeFolder);
}
if (runStatusBar) {
statusBarItems_1.updateRunStatus(runStatusBar, showStatusBarItems, activeFolder);
}
if (cleanStatusBar) {
statusBarItems_1.updateCleanStatus(cleanStatusBar, showStatusBarItems, activeFolder);
}
if (debugStatusBar) {
statusBarItems_1.updateDebugStatus(debugStatusBar, showStatusBarItems, activeFolder);
}
}
function initFolderStatusBar() {
if (folderStatusBar)
return;
folderStatusBar = vscodeUtils_1.createStatusBarItem();
exports.extensionContext?.subscriptions.push(folderStatusBar);
const workspaceFolders = vscode.workspace.workspaceFolders;
if (workspaceFolders) {
if (workspaceFolders.length === 1) {
if (!workspaceFolders[0] || !workspaceFolders[0].uri.fsPath)
return;
const workspaceFolderFs = workspaceFolders[0].uri.fsPath;
const folders = fileUtils_1.foldersInDir(workspaceFolderFs);
if (folders.length === 0) {
workspaceFolder = workspaceFolderFs;
activeFolder = workspaceFolderFs;
updateFolderData();
}
else {
statusBarItems_1.updateFolderStatus(folderStatusBar, taskProvider, showStatusBarItems);
}
}
else {
statusBarItems_1.updateFolderStatus(folderStatusBar, taskProvider, showStatusBarItems);
}
}
if (commandFolderDisposable)
return;
const commandName = `${EXTENSION_NAME}.folder`;
commandFolderDisposable = vscode.commands.registerCommand(commandName, async () => {
const ret = await folderHandler_1.folderHandler(settingsProvider);
if (ret && ret.activeFolder && ret.workspaceFolder) {
activeFolder = ret.activeFolder;
workspaceFolder = ret.workspaceFolder;
updateFolderData();
}
else {
const infoMessage = `Folder callback aborted.`;
logger.log(exports.loggingActive, infoMessage);
}
});
folderStatusBar.command = commandName;
exports.extensionContext?.subscriptions.push(commandFolderDisposable);
}
function initModeStatusBar() {
if (modeStatusBar)
return;
modeStatusBar = vscodeUtils_1.createStatusBarItem();
exports.extensionContext?.subscriptions.push(modeStatusBar);
statusBarItems_1.updateModeStatus(modeStatusBar, showStatusBarItems, activeFolder, buildMode);
const commandName = `${EXTENSION_NAME}.mode`;
commandModeDisposable = vscode.commands.registerCommand(commandName, async () => {
const pickedMode = await modeHandler_1.modeHandler();
if (pickedMode) {
buildMode = pickedMode;
if (taskProvider) {
taskProvider.updateModeData(buildMode);
}
statusBarItems_1.updateModeStatus(modeStatusBar, showStatusBarItems, activeFolder, buildMode);
if (!taskProvider)
return;
taskProvider.updateModeData(buildMode);
if (!launchProvider)
return;
launchProvider.updateModeData(buildMode);
launchProvider.updateFileContent();
}
else {
const infoMessage = `Mode callback aborted.`;
logger.log(exports.loggingActive, infoMessage);
}
});
modeStatusBar.command = commandName;
exports.extensionContext?.subscriptions.push(commandModeDisposable);
}
function initArgumentParser() {
if (commandResetDisposable)
return;
const commandName = `${EXTENSION_NAME}.args`;
commandResetDisposable = vscode.commands.registerCommand(commandName, async () => {
argumentsString = await vscode.window.showInputBox();
if (taskProvider) {
taskProvider.updateArguments(argumentsString);
}
});
exports.extensionContext?.subscriptions.push(commandResetDisposable);
}
function initReset() {
if (commandArgumentDisposable)
return;
const commandName = `${EXTENSION_NAME}.resetLocalSettings`;
commandArgumentDisposable = vscode.commands.registerCommand(commandName, async () => {
if (!settingsProvider)
return;
settingsProvider.reset();
propertiesProvider?.updateFileContent();
taskProvider?.getTasks();
launchProvider?.updateFileContent();
});
exports.extensionContext?.subscriptions.push(commandArgumentDisposable);
}
function initBuildStatusBar() {
if (buildStatusBar)
return;
buildStatusBar = vscodeUtils_1.createStatusBarItem();
exports.extensionContext?.subscriptions.push(buildStatusBar);
statusBarItems_1.updateBuildStatus(buildStatusBar, showStatusBarItems, activeFolder);
const commandName = `${EXTENSION_NAME}.build`;
commandBuildDisposable = vscode.commands.registerCommand(commandName, async () => {
if (!taskProvider || !taskProvider.tasks) {
const infoMessage = `buildCallback failed`;
logger.log(exports.loggingActive, infoMessage);
return;
}
taskProvider.getTasks();
const projectFolder = taskProvider.getProjectFolder();
if (!projectFolder)
return;
const buildTaskIndex = 0;
const buildTask = taskProvider.tasks[buildTaskIndex];
if (!buildTask)
return;
if (!buildTask.execution ||
!(buildTask.execution instanceof vscode.ShellExecution) ||
!buildTask.execution.commandLine) {
return;
}
buildTask.execution.commandLine = buildTask.execution.commandLine.replace('FILE_DIR', projectFolder);
if (!activeFolder)
return;
const buildDir = path.join(activeFolder, 'build');
const modeDir = path.join(buildDir, `${buildMode}`);
if (!fileUtils_1.pathExists(modeDir))
fileUtils_1.mkdirRecursive(modeDir);
if (!settingsProvider)
return;
const hasNoneExtendedAsciiChars = [...buildDir].some((char) => char.charCodeAt(0) > 255);
if (exports.experimentalExecutionEnabled ||
buildDir.includes(' ') ||
hasNoneExtendedAsciiChars) {
await builder_1.executeBuildTask(buildTask, settingsProvider, activeFolder, buildMode);
}
else {
await vscode.tasks.executeTask(buildTask);
}
});
buildStatusBar.command = commandName;
exports.extensionContext?.subscriptions.push(commandBuildDisposable);
}
function initRunStatusBar() {
if (runStatusBar)
return;
runStatusBar = vscodeUtils_1.createStatusBarItem();
exports.extensionContext?.subscriptions.push(runStatusBar);
statusBarItems_1.updateRunStatus(runStatusBar, showStatusBarItems, activeFolder);
const commandName = `${EXTENSION_NAME}.run`;
commandRunDisposable = vscode.commands.registerCommand(commandName, async () => {
if (!taskProvider || !taskProvider.tasks) {
const infoMessage = `runCallback failed`;
logger.log(exports.loggingActive, infoMessage);
return;
}
taskProvider.getTasks();
const projectFolder = taskProvider.getProjectFolder();
if (!projectFolder)
return;
const runTaskIndex = 1;
const runTask = taskProvider.tasks[runTaskIndex];
if (!runTask)
return;
if (!runTask.execution ||
!(runTask.execution instanceof vscode.ShellExecution) ||
!runTask.execution.commandLine) {
return;
}
runTask.execution.commandLine = runTask.execution.commandLine.replace('FILE_DIR', projectFolder);
if (!activeFolder)
return;
const buildDir = path.join(activeFolder, 'build');
const modeDir = path.join(buildDir, `${buildMode}`);
if (!fileUtils_1.pathExists(modeDir))
return;
if (!settingsProvider) {
return;
}
const hasNoneExtendedAsciiChars = [...buildDir].some((char) => char.charCodeAt(0) > 255);
if (exports.experimentalExecutionEnabled ||
buildDir.includes(' ') ||
hasNoneExtendedAsciiChars) {
await runner_1.executeRunTask(runTask, activeFolder, buildMode, argumentsString, settingsProvider.operatingSystem);
}
else {
await vscode.tasks.executeTask(runTask);
}
});
runStatusBar.command = commandName;
exports.extensionContext?.subscriptions.push(commandRunDisposable);
}
function initDebugStatusBar() {
if (debugStatusBar)
return;
debugStatusBar = vscodeUtils_1.createStatusBarItem();
exports.extensionContext?.subscriptions.push(debugStatusBar);
statusBarItems_1.updateDebugStatus(debugStatusBar, showStatusBarItems, activeFolder);
const commandName = `${EXTENSION_NAME}.debug`;
commandDebugDisposable = vscode.commands.registerCommand(commandName, () => {
if (!activeFolder || !workspaceFolder) {
const infoMessage = `debugCallback failed`;
logger.log(exports.loggingActive, infoMessage);
return;
}
if (taskProvider)
debugger_1.runDebugger(activeFolder, workspaceFolder, buildMode);
});
debugStatusBar.command = commandName;
exports.extensionContext?.subscriptions.push(commandDebugDisposable);
}
function initCleanStatusBar() {
if (cleanStatusBar)
return;
cleanStatusBar = vscodeUtils_1.createStatusBarItem();
exports.extensionContext?.subscriptions.push(cleanStatusBar);
statusBarItems_1.updateCleanStatus(cleanStatusBar, showStatusBarItems, activeFolder);
const commandName = `${EXTENSION_NAME}.clean`;
commandCleanDisposable = vscode.commands.registerCommand(commandName, async () => {
if (!taskProvider ||
!taskProvider.tasks ||
!activeFolder ||
!workspaceFolder) {
const infoMessage = `cleanCallback failed`;
logger.log(exports.loggingActive, infoMessage);
return;
}
const cleanTaskIndex = 2;
const cleanTask = taskProvider.tasks[cleanTaskIndex];
if (!cleanTask)
return;
const buildDir = path.join(activeFolder, 'build');
const modeDir = path.join(buildDir, `${buildMode}`);
if (!cleanTask.execution ||
!(cleanTask.execution instanceof vscode.ShellExecution) ||
!cleanTask.execution.commandLine) {
return;
}
let relativeModeDir = modeDir.replace(workspaceFolder, '');
relativeModeDir = fileUtils_1.replaceBackslashes(relativeModeDir);
cleanTask.execution.commandLine = `echo Cleaning ${relativeModeDir}...`;
if (!fileUtils_1.pathExists(modeDir))
return;
fileUtils_1.rmdirRecursive(modeDir);
await vscode.tasks.executeTask(cleanTask);
});
cleanStatusBar.command = commandName;
exports.extensionContext?.subscriptions.push(commandCleanDisposable);
}
//# sourceMappingURL=extension.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.folderHandler = void 0;
const path = require("path");
const vscode = require("vscode");
const fileUtils_1 = require("../utils/fileUtils");
async function folderHandler(settingsProvider) {
const workspacesFolders = vscode.workspace.workspaceFolders;
if (!workspacesFolders)
return;
let foldersList = [];
workspacesFolders.forEach((folder) => {
const directories = [folder.name];
const recursiveDirectories = fileUtils_1.getDirectoriesRecursive(folder.uri.fsPath);
if (recursiveDirectories) {
directories.push(...recursiveDirectories);
}
directories.forEach((dir) => {
let text = dir.replace(folder.uri.fsPath, folder.name);
text = fileUtils_1.replaceBackslashes(text);
foldersList.push(text);
});
if (settingsProvider) {
foldersList = fileUtils_1.excludePatternFromList(settingsProvider.excludeSearch, foldersList);
}
foldersList = fileUtils_1.naturalSort(foldersList);
});
const activeFolderStr = await vscode.window.showQuickPick(foldersList, {
placeHolder: 'Select folder to init the C/C++ Runner extension.',
});
let activeFolder;
let workspaceFolder;
if (activeFolderStr) {
const folderSplit = activeFolderStr.split('/');
const workspaceName = folderSplit[0];
workspacesFolders.forEach((folder) => {
if (folder.name === workspaceName) {
workspaceFolder = folder.uri.fsPath;
}
});
if (workspaceFolder) {
activeFolder = path.join(workspaceFolder, ...folderSplit.slice(1));
}
}
return { activeFolder, workspaceFolder };
}
exports.folderHandler = folderHandler;
//# sourceMappingURL=folderHandler.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"folderHandler.js","sourceRoot":"","sources":["../../../src/handler/folderHandler.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,iCAAiC;AAGjC,kDAK4B;AAErB,KAAK,UAAU,aAAa,CACjC,gBAA8C;IAE9C,MAAM,iBAAiB,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC;IAE5D,IAAI,CAAC,iBAAiB;QAAE,OAAO;IAE/B,IAAI,WAAW,GAAa,EAAE,CAAC;IAC/B,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,oBAAoB,GAAG,mCAAuB,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxE,IAAI,oBAAoB,EAAE;YACxB,WAAW,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,CAAC;SAC3C;QAED,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC1B,IAAI,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YACvD,IAAI,GAAG,8BAAkB,CAAC,IAAI,CAAC,CAAC;YAChC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,IAAI,gBAAgB,EAAE;YACpB,WAAW,GAAG,kCAAsB,CAClC,gBAAgB,CAAC,aAAa,EAC9B,WAAW,CACZ,CAAC;SACH;QAED,WAAW,GAAG,uBAAW,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE;QACrE,WAAW,EAAE,mDAAmD;KACjE,CAAC,CAAC;IACH,IAAI,YAAgC,CAAC;IACrC,IAAI,eAAmC,CAAC;IAExC,IAAI,eAAe,EAAE;QACnB,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QACrC,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACnC,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE;gBACjC,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;aACrC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,eAAe,EAAE;YACnB,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACpE;KACF;IAED,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AAC3C,CAAC;AApDD,sCAoDC"}

View file

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.modeHandler = void 0;
const vscode = require("vscode");
const types_1 = require("../utils/types");
async function modeHandler() {
const combinations = [types_1.Builds.debug, types_1.Builds.release];
const pickedCombination = await vscode.window.showQuickPick(combinations, {
placeHolder: 'Select a build mode',
});
if (!pickedCombination)
return undefined;
const pickedMode = pickedCombination.includes(types_1.Builds.debug)
? types_1.Builds.debug
: types_1.Builds.release;
return pickedMode;
}
exports.modeHandler = modeHandler;
//# sourceMappingURL=modeHandler.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"modeHandler.js","sourceRoot":"","sources":["../../../src/handler/modeHandler.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,0CAAwC;AAEjC,KAAK,UAAU,WAAW;IAC/B,MAAM,YAAY,GAAG,CAAC,cAAM,CAAC,KAAK,EAAE,cAAM,CAAC,OAAO,CAAC,CAAC;IAEpD,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,EAAE;QACxE,WAAW,EAAE,qBAAqB;KACnC,CAAC,CAAC;IAEH,IAAI,CAAC,iBAAiB;QAAE,OAAO,SAAS,CAAC;IAEzC,MAAM,UAAU,GAAG,iBAAiB,CAAC,QAAQ,CAAC,cAAM,CAAC,KAAK,CAAC;QACzD,CAAC,CAAC,cAAM,CAAC,KAAK;QACd,CAAC,CAAC,cAAM,CAAC,OAAO,CAAC;IAEnB,OAAO,UAAU,CAAC;AACpB,CAAC;AAdD,kCAcC"}

View file

@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateCleanStatus = exports.updateDebugStatus = exports.updateRunStatus = exports.updateBuildStatus = exports.updateModeStatus = exports.updateFolderStatus = void 0;
const path = require("path");
const fileUtils_1 = require("../utils/fileUtils");
function updateFolderStatus(status, taskProvider, showStatusBarItems) {
if (!status)
return;
if (taskProvider &&
taskProvider.workspaceFolder &&
taskProvider.activeFolder) {
const workspaceFolder = taskProvider.workspaceFolder;
const workspaceName = path.basename(workspaceFolder);
let text = taskProvider.activeFolder.replace(workspaceFolder, workspaceName);
text = fileUtils_1.replaceBackslashes(text);
const dirs = text.split('/');
if (dirs.length > 2) {
const lastElement = dirs.length - 1;
text = `${dirs[0]}/.../${dirs[lastElement]}`;
}
status.color = '';
status.text = `$(folder-active) ${text}`;
}
else {
status.color = '#ffff00';
status.text = '$(alert) Select folder.';
}
if (showStatusBarItems) {
status.show();
}
else {
status.hide();
}
}
exports.updateFolderStatus = updateFolderStatus;
function updateModeStatus(status, showStatusBarItems, activeFolder, buildMode) {
if (!status)
return;
status.text = `$(tools) ${buildMode}`;
toggleShow(status, showStatusBarItems, activeFolder);
}
exports.updateModeStatus = updateModeStatus;
function updateBuildStatus(status, showStatusBarItems, activeFolder) {
if (!status)
return;
status.text = `$(gear)`;
toggleShow(status, showStatusBarItems, activeFolder);
}
exports.updateBuildStatus = updateBuildStatus;
function updateRunStatus(status, showStatusBarItems, activeFolder) {
if (!status)
return;
status.text = `$(play)`;
toggleShow(status, showStatusBarItems, activeFolder);
}
exports.updateRunStatus = updateRunStatus;
function updateDebugStatus(status, showStatusBarItems, activeFolder) {
if (!status)
return;
status.text = `$(bug)`;
toggleShow(status, showStatusBarItems, activeFolder);
}
exports.updateDebugStatus = updateDebugStatus;
function updateCleanStatus(status, showStatusBarItems, activeFolder) {
if (!status)
return;
status.text = `$(trash)`;
toggleShow(status, showStatusBarItems, activeFolder);
}
exports.updateCleanStatus = updateCleanStatus;
function toggleShow(status, showStatusBarItems, activeFolder) {
if (!status)
return;
if (showStatusBarItems && activeFolder) {
status.show();
}
else {
status.hide();
}
}
//# sourceMappingURL=statusBarItems.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"statusBarItems.js","sourceRoot":"","sources":["../../../src/items/statusBarItems.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAI7B,kDAAwD;AAGxD,SAAgB,kBAAkB,CAChC,MAAwC,EACxC,YAAsC,EACtC,kBAA2B;IAE3B,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,IACE,YAAY;QACZ,YAAY,CAAC,eAAe;QAC5B,YAAY,CAAC,YAAY,EACzB;QACA,MAAM,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;QACrD,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACrD,IAAI,IAAI,GAAG,YAAY,CAAC,YAAY,CAAC,OAAO,CAC1C,eAAe,EACf,aAAa,CACd,CAAC;QAEF,IAAI,GAAG,8BAAkB,CAAC,IAAI,CAAC,CAAC;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE7B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YACpC,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI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,CAAC;IACvB,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAC;AACvD,CAAC;AATD,8CASC;AAED,SAAgB,iBAAiB,CAC/B,MAAwC,EACxC,kBAA2B,EAC3B,YAAgC;IAEhC,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAC;AACvD,CAAC;AATD,8CASC;AAED,SAAS,UAAU,CACjB,MAAwC,EACxC,kBAA2B,EAC3B,YAAgC;IAEhC,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,IAAI,kBAAkB,IAAI,YAAY,EAAE;QACtC,MAAM,CAAC,IAAI,EAAE,CAAC;KACf;SAAM;QACL,MAAM,CAAC,IAAI,EAAE,CAAC;KACf;AACH,CAAC"}

View file

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CallbackProvider = void 0;
const path = require("path");
const vscode = require("vscode");
const vscodeUtils_1 = require("../utils/vscodeUtils");
class CallbackProvider {
constructor(_workspaceFolder, templateFileName, outputFileName) {
this._workspaceFolder = _workspaceFolder;
this.templateFileName = templateFileName;
this.outputFileName = outputFileName;
this._vscodeDirectory = path.join(this._workspaceFolder, '.vscode');
this._outputPath = path.join(this._vscodeDirectory, outputFileName);
this.createFileWatcher();
}
createFileWatcher() {
const filePattern = new vscode.RelativePattern(this._workspaceFolder, '.vscode/**');
this._fileWatcherOnDelete = vscode.workspace.createFileSystemWatcher(filePattern, true, true, false);
this._fileWatcherOnChange = vscode.workspace.createFileSystemWatcher(filePattern, true, false, true);
this._fileWatcherOnDelete.onDidDelete((e) => {
const pathName = e.fsPath;
if (pathName === this._vscodeDirectory || pathName === this._outputPath) {
const extensionIsActive = vscodeUtils_1.getActivationState();
if (extensionIsActive)
this.deleteCallback();
}
});
this._fileWatcherOnChange.onDidChange((e) => {
const pathName = e.fsPath;
if (pathName === this._outputPath) {
this.changeCallback();
}
});
return;
}
}
exports.CallbackProvider = CallbackProvider;
//# sourceMappingURL=callbackProvider.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"callbackProvider.js","sourceRoot":"","sources":["../../../src/provider/callbackProvider.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,iCAAiC;AAEjC,sDAA0D;AAE1D,MAAsB,gBAAgB;IAMpC,YACY,gBAAwB,EACxB,gBAAwB,EACxB,cAAsB;QAFtB,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,mBAAc,GAAd,cAAc,CAAQ;QAEhC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;QACpE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAEpE,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAES,iBAAiB;QACzB,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,eAAe,CAC5C,IAAI,CAAC,gBAAgB,EACrB,YAAY,CACb,CAAC;QAEF,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,SAAS,CAAC,uBAAuB,CAClE,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,KAAK,CACN,CAAC;QAEF,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,SAAS,CAAC,uBAAuB,CAClE,WAAW,EACX,IAAI,EACJ,KAAK,EACL,IAAI,CACL,CAAC;QAEF,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAa,EAAE,EAAE;YACtD,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;YAC1B,IAAI,QAAQ,KAAK,IAAI,CAAC,gBAAgB,IAAI,QAAQ,KAAK,IAAI,CAAC,WAAW,EAAE;gBACvE,MAAM,iBAAiB,GAAG,gCAAkB,EAAE,CAAC;gBAC/C,IAAI,iBAAiB;oBAAE,IAAI,CAAC,cAAc,EAAE,CAAC;aAC9C;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAa,EAAE,EAAE;YACtD,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;YAC1B,IAAI,QAAQ,KAAK,IAAI,CAAC,WAAW,EAAE;gBACjC,IAAI,CAAC,cAAc,EAAE,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO;IACT,CAAC;CAKF;AA1DD,4CA0DC"}

View file

@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileProvider = void 0;
const path = require("path");
const extension_1 = require("../extension");
const fileUtils_1 = require("../utils/fileUtils");
const vscodeUtils_1 = require("../utils/vscodeUtils");
const callbackProvider_1 = require("./callbackProvider");
class FileProvider extends callbackProvider_1.CallbackProvider {
constructor(workspaceFolder, templateFileName, outputFileName) {
super(workspaceFolder, templateFileName, outputFileName);
const templateDirectory = path.join(extension_1.extensionPath ? extension_1.extensionPath : '', 'templates');
this.templatePath = path.join(templateDirectory, templateFileName);
if (!fileUtils_1.pathExists(this._vscodeDirectory)) {
fileUtils_1.mkdirRecursive(this._vscodeDirectory);
}
}
createFileData() {
if (!fileUtils_1.pathExists(this._vscodeDirectory)) {
fileUtils_1.mkdirRecursive(this._vscodeDirectory);
}
this.writeFileData();
}
updateFileContent() {
this.writeFileData();
}
deleteCallback() {
const extensionIsActive = vscodeUtils_1.getActivationState();
if (extensionIsActive)
this.createFileData();
}
_updateFolderData(_workspaceFolder) {
this._workspaceFolder = _workspaceFolder;
this._vscodeDirectory = path.join(this._workspaceFolder, '.vscode');
this._outputPath = path.join(this._vscodeDirectory, this.outputFileName);
this.createFileWatcher();
}
}
exports.FileProvider = FileProvider;
//# sourceMappingURL=fileProvider.js.map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,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACzE,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;CACF;AAhDD,oCAgDC"}

View file

@ -0,0 +1,124 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LaunchProvider = void 0;
const path = require("path");
const fileUtils_1 = require("../utils/fileUtils");
const types_1 = require("../utils/types");
const vscodeUtils_1 = require("../utils/vscodeUtils");
const fileProvider_1 = require("./fileProvider");
const settingsProvider_1 = require("./settingsProvider");
const TEMPLATE_FILENAME = 'launch_template.json';
const OUTPUT_FILENAME = 'launch.json';
const CONFIG_NAME = 'C/C++ Runner: Debug Session';
class LaunchProvider extends fileProvider_1.FileProvider {
constructor(settings, workspaceFolder, activeFolder) {
super(workspaceFolder, TEMPLATE_FILENAME, OUTPUT_FILENAME);
this.settings = settings;
this.workspaceFolder = workspaceFolder;
this.activeFolder = activeFolder;
this.buildMode = types_1.Builds.debug;
if (!this.activeFolder) {
this.activeFolder = this.workspaceFolder;
}
const updateRequired = this.updateCheck();
if (updateRequired) {
this.createFileData();
}
}
updateCheck() {
let doUpdate = false;
if (!fileUtils_1.pathExists(this._outputPath)) {
doUpdate = true;
}
else {
const configJson = fileUtils_1.readJsonFile(this._outputPath);
if (configJson) {
let foundConfig = false;
configJson.configurations.forEach((config) => {
const triplet = config.name;
if (triplet.includes(this.settings.operatingSystem)) {
foundConfig = true;
}
});
if (!foundConfig) {
doUpdate = true;
}
}
}
return doUpdate;
}
writeFileData() {
if (!this.workspaceFolder && !this.activeFolder)
return;
if (!this.activeFolder) {
this.activeFolder = this.workspaceFolder;
}
const launchTemplate = fileUtils_1.readJsonFile(this.templatePath);
if (!launchTemplate)
return;
launchTemplate.configurations[0].name = CONFIG_NAME;
if (this.settings.debugger) {
launchTemplate.configurations[0].MIMode = this.settings.debugger;
launchTemplate.configurations[0].miDebuggerPath = this.settings.debuggerPath;
if (types_1.OperatingSystems.windows === this.settings.operatingSystem &&
this.settings.isCygwin) {
launchTemplate.configurations[0].externalConsole = true;
}
}
else {
launchTemplate.configurations[0].MIMode =
settingsProvider_1.SettingsProvider.DEFAULT_DEBUGGER_PATH;
launchTemplate.configurations[0].miDebuggerPath =
settingsProvider_1.SettingsProvider.DEFAULT_DEBUGGER_PATH;
}
launchTemplate.configurations[0].cwd = this.activeFolder;
const debugPath = path.join(this.activeFolder, `build/${this.buildMode}/out${this.buildMode}`);
launchTemplate.configurations[0].program = debugPath;
const launchLocal = fileUtils_1.readJsonFile(this._outputPath);
if (!launchLocal) {
fileUtils_1.writeJsonFile(this._outputPath, launchTemplate);
return;
}
let configIdx = vscodeUtils_1.getLaunchConfigIndex(launchLocal, CONFIG_NAME);
if (configIdx === undefined) {
configIdx = launchLocal.configurations.length;
}
if (launchLocal && launchLocal.configurations.length === configIdx) {
launchLocal.configurations.push(launchTemplate.configurations[0]);
}
else {
launchLocal.configurations[configIdx] = launchTemplate.configurations[0];
}
fileUtils_1.writeJsonFile(this._outputPath, launchLocal);
}
updateFolderData(workspaceFolder, activeFolder) {
this.activeFolder = activeFolder;
super._updateFolderData(workspaceFolder);
}
updateModeData(buildMode) {
this.buildMode = buildMode;
}
changeCallback() {
const launchLocal = fileUtils_1.readJsonFile(this._outputPath);
if (!launchLocal)
return;
const configIdx = vscodeUtils_1.getLaunchConfigIndex(launchLocal, CONFIG_NAME);
if (configIdx !== undefined) {
const currentConfig = launchLocal.configurations[configIdx];
if (currentConfig.miDebuggerPath !== this.settings.debuggerPath) {
this.settings.debuggerPath = currentConfig.miDebuggerPath;
if (currentConfig.miDebuggerPath.includes(types_1.Debuggers.gdb)) {
this.settings.setGDB(currentConfig.miDebuggerPath);
}
else if (currentConfig.miDebuggerPath.includes(types_1.Debuggers.lldb)) {
this.settings.setLLDB(currentConfig.miDebuggerPath);
}
}
}
else {
this.writeFileData();
}
}
}
exports.LaunchProvider = LaunchProvider;
//# sourceMappingURL=launchProvider.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"launchProvider.js","sourceRoot":"","sources":["../../../src/provider/launchProvider.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B,kDAA6E;AAC7E,0CAKwB;AACxB,sDAA4D;AAC5D,iDAA8C;AAC9C,yDAAsD;AAEtD,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AACjD,MAAM,eAAe,GAAG,aAAa,CAAC;AACtC,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAElD,MAAa,cAAe,SAAQ,2BAAY;IAG9C,YACY,QAA0B,EAC7B,eAAuB,EACvB,YAAoB;QAE3B,KAAK,CAAC,eAAe,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;QAJjD,aAAQ,GAAR,QAAQ,CAAkB;QAC7B,oBAAe,GAAf,eAAe,CAAQ;QACvB,iBAAY,GAAZ,YAAY,CAAQ;QALtB,cAAS,GAAW,cAAM,CAAC,KAAK,CAAC;QAStC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC;SAC1C;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAE1C,IAAI,cAAc,EAAE;YAClB,IAAI,CAAC,cAAc,EAAE,CAAC;SACvB;IACH,CAAC;IAES,WAAW;QACnB,IAAI,QAAQ,GAAG,KAAK,CAAC;QAErB,IAAI,CAAC,sBAAU,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;YACjC,QAAQ,GAAG,IAAI,CAAC;SACjB;aAAM;YACL,MAAM,UAAU,GAAsB,wBAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACrE,IAAI,UAAU,EAAE;gBACd,IAAI,WAAW,GAAG,KAAK,CAAC;gBAExB,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;oBAC3C,MAAM,OAAO,GAAW,MAAM,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AAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEM,cAAc;QACnB,MAAM,WAAW,GAAkC,wBAAY,CAC7D,IAAI,CAAC,WAAW,CACjB,CAAC;QAEF,IAAI,CAAC,WAAW;YAAE,OAAO;QAEzB,MAAM,SAAS,GAAG,kCAAoB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAEjE,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,MAAM,aAAa,GAAG,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,aAAa,CAAC,cAAc,KAAK,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE;gBAC/D,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,aAAa,CAAC,cAAc,CAAC;gBAE1D,IAAI,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,iBAAS,CAAC,GAAG,CAAC,EAAE;oBACxD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;iBACpD;qBAAM,IAAI,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,iBAAS,CAAC,IAAI,CAAC,EAAE;oBAChE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;iBACrD;aACF;SACF;aAAM;YACL,IAAI,CAAC,aAAa,EAAE,CAAC;SACtB;IACH,CAAC;CACF;AAhJD,wCAgJC"}

View file

@ -0,0 +1,153 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PropertiesProvider = void 0;
const fileUtils_1 = require("../utils/fileUtils");
const types_1 = require("../utils/types");
const fileProvider_1 = require("./fileProvider");
const TEMPLATE_FILENAME = 'properties_template.json';
const OUTPUT_FILENAME = 'c_cpp_properties.json';
const INCLUDE_PATTERN = '${workspaceFolder}/**';
class PropertiesProvider extends fileProvider_1.FileProvider {
constructor(settings, workspaceFolder, activeFolder) {
super(workspaceFolder, TEMPLATE_FILENAME, OUTPUT_FILENAME);
this.settings = settings;
this.workspaceFolder = workspaceFolder;
this.activeFolder = activeFolder;
const updateRequired = this.updateCheck();
if (updateRequired && activeFolder) {
this.createFileData();
}
}
updateCheck() {
let doUpdate = false;
if (!fileUtils_1.pathExists(this._outputPath)) {
doUpdate = true;
}
else {
const configLocal = fileUtils_1.readJsonFile(this._outputPath);
if (configLocal) {
const triplet = configLocal.configurations[0].name;
if (!triplet.includes(this.settings.operatingSystem)) {
doUpdate = true;
}
}
}
return doUpdate;
}
writeFileData() {
let configLocal;
if (!fileUtils_1.pathExists(this._outputPath)) {
configLocal = fileUtils_1.readJsonFile(this.templatePath);
}
else {
configLocal = fileUtils_1.readJsonFile(this._outputPath);
}
if (!configLocal)
return;
const triplet = `${this.settings.operatingSystem}-` +
`${this.settings.cCompiler}-` +
`${this.settings.architecure}`;
const currentConfig = configLocal.configurations[0];
currentConfig.compilerArgs = [];
if (this.settings.warnings) {
for (const warning of this.settings.warnings) {
const compilerArgsSet = new Set(currentConfig.compilerArgs);
if (!compilerArgsSet.has(warning)) {
currentConfig.compilerArgs.push(warning);
}
}
}
if (this.settings.compilerArgs) {
for (const arg of this.settings.compilerArgs) {
const compilerArgsSet = new Set(currentConfig.compilerArgs);
if (!compilerArgsSet.has(arg)) {
currentConfig.compilerArgs.push(arg);
}
}
}
if (this.settings.includePaths) {
currentConfig.includePath = [INCLUDE_PATTERN];
for (const path of this.settings.includePaths) {
const includePathSet = new Set(currentConfig.includePath);
if (path !== INCLUDE_PATTERN && !includePathSet.has(path)) {
currentConfig.includePath.push(path);
}
}
}
else {
currentConfig.includePath = [INCLUDE_PATTERN];
}
if (this.settings.cStandard) {
currentConfig.cStandard = this.settings.cStandard;
}
else {
currentConfig.cStandard = '${default}';
}
if (this.settings.cppStandard) {
currentConfig.cppStandard = this.settings.cppStandard;
}
else {
currentConfig.cppStandard = '${default}';
}
currentConfig.compilerPath = this.settings.cCompilerPath;
if (this.settings.isCygwin &&
this.settings.operatingSystem === types_1.OperatingSystems.windows) {
currentConfig.name = triplet.replace('windows', 'windows-cygwin');
currentConfig.intelliSenseMode = triplet.replace('windows', 'linux');
}
else {
currentConfig.name = triplet;
currentConfig.intelliSenseMode = triplet;
}
fileUtils_1.writeJsonFile(this._outputPath, configLocal);
}
updateFolderData(workspaceFolder) {
super._updateFolderData(workspaceFolder);
}
changeCallback() {
const configLocal = fileUtils_1.readJsonFile(this._outputPath);
if (!configLocal)
return;
const currentConfig = configLocal.configurations[0];
if (currentConfig.compilerPath !== this.settings.cCompilerPath &&
currentConfig.compilerPath !== this.settings.cppCompilerPath) {
let compilerName = currentConfig.compilerPath;
this.settings.cCompilerPath = currentConfig.compilerPath;
compilerName = fileUtils_1.getBasename(compilerName);
compilerName = fileUtils_1.removeExtension(compilerName, 'exe');
if (compilerName.includes(types_1.Compilers.clang)) {
this.settings.setClang(currentConfig.compilerPath);
}
else if (compilerName.includes(types_1.Compilers.clangpp)) {
this.settings.setClangpp(currentConfig.compilerPath);
}
else if (compilerName.includes(types_1.Compilers.gcc)) {
this.settings.setGcc(currentConfig.compilerPath);
}
else if (compilerName.includes(types_1.Compilers.gpp)) {
this.settings.setGpp(currentConfig.compilerPath);
}
}
if (currentConfig.cStandard !== '${default}' &&
currentConfig.cStandard !== this.settings.cStandard) {
this.settings.cStandard = currentConfig.cStandard;
this.settings.update('cStandard', currentConfig.cStandard);
}
if (currentConfig.cppStandard !== '${default}' &&
currentConfig.cppStandard !== this.settings.cppStandard) {
this.settings.cppStandard = currentConfig.cppStandard;
this.settings.update('cppStandard', currentConfig.cppStandard);
}
const argsSet = new Set(currentConfig.compilerArgs);
const args = [...argsSet];
const warningArgs = args.filter((arg) => arg.includes('-W'));
const compilerArgs = args.filter((arg) => !arg.includes('-W'));
const includeArgs = currentConfig.includePath.filter((path) => path !== INCLUDE_PATTERN);
this.settings.warnings = warningArgs;
this.settings.compilerArgs = compilerArgs;
this.settings.includePaths = includeArgs;
this.settings.setOtherSettings();
}
}
exports.PropertiesProvider = PropertiesProvider;
//# sourceMappingURL=propertiesProvider.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,481 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SettingsProvider = void 0;
const path = require("path");
const vscode = require("vscode");
const fileUtils_1 = require("../utils/fileUtils");
const systemUtils_1 = require("../utils/systemUtils");
const types_1 = require("../utils/types");
const vscodeUtils_1 = require("../utils/vscodeUtils");
const fileProvider_1 = require("./fileProvider");
const TEMPLATE_FILENAME = 'settings_template.json';
const OUTPUT_FILENAME = 'settings.json';
const EXTENSION_NAME = 'C_Cpp_Runner';
class SettingsProvider extends fileProvider_1.FileProvider {
constructor(workspaceFolder, activeFolder) {
super(workspaceFolder, TEMPLATE_FILENAME, OUTPUT_FILENAME);
this.workspaceFolder = workspaceFolder;
this.activeFolder = activeFolder;
this._configGlobal = vscode.workspace.getConfiguration(EXTENSION_NAME);
this.operatingSystem = systemUtils_1.getOperatingSystem();
this.isCygwin = false;
this._cCompilerFound = false;
this._cppCompilerFound = false;
this._makeFound = false;
this._debuggerFound = false;
this._commands = new types_1.Commands();
this.cCompilerPath = SettingsProvider.DEFAULT_C_COMPILER_PATH;
this.cppCompilerPath = SettingsProvider.DEFAULT_CPP_COMPILER_PATH;
this.debuggerPath = SettingsProvider.DEFAULT_DEBUGGER_PATH;
this.makePath = SettingsProvider.DEFAULT_MAKE_PATH;
this.cStandard = SettingsProvider.DEFAULT_C_STANDARD;
this.cppStandard = SettingsProvider.DEFAULT_CPP_STANDARD;
this.compilerArgs = SettingsProvider.DEFAULT_COMPILER_ARGS;
this.linkerArgs = SettingsProvider.DEFAULT_LINKER_ARGS;
this.includePaths = SettingsProvider.DEFAULT_INCLUDE_PATHS;
this.excludeSearch = SettingsProvider.DEFAULT_EXCLUDE_SEARCH;
this.enableWarnings = SettingsProvider.DEFAULT_ENABLE_WARNINGS;
this.warningsAsError = SettingsProvider.DEFAULT_WARNINGS_AS_ERRORS;
this.warnings = SettingsProvider.DEFAULT_WARNINGS;
const updateRequired = this.updateCheck();
if (updateRequired && activeFolder) {
this.createFileData();
}
else if (activeFolder) {
this.getSettings();
this.getCommandTypes();
this.getArchitecture();
}
}
updateCheck() {
let doUpdate = false;
if (!fileUtils_1.pathExists(this._outputPath)) {
doUpdate = true;
}
else if (!this.commandsStored()) {
doUpdate = true;
}
return doUpdate;
}
commandsStored() {
if (fileUtils_1.pathExists(this._outputPath)) {
const settingsJson = fileUtils_1.readJsonFile(this._outputPath);
if (!settingsJson)
return false;
if (fileUtils_1.commandCheck(`${EXTENSION_NAME}.cCompilerPath`, settingsJson) &&
fileUtils_1.commandCheck(`${EXTENSION_NAME}.cppCompilerPath`, settingsJson) &&
fileUtils_1.commandCheck(`${EXTENSION_NAME}.debuggerPath`, settingsJson) &&
fileUtils_1.commandCheck(`${EXTENSION_NAME}.makePath`, settingsJson)) {
return true;
}
if (this._cCompilerFound &&
this._cppCompilerFound &&
this._makeFound &&
this._debuggerFound) {
return true;
}
}
return false;
}
writeFileData() {
this.getSettings();
if (!this.commandsStored()) {
this.getCommands();
this.setCommands();
this.getCommandTypes();
this.getArchitecture();
}
}
deleteCallback() {
const extensionIsActive = vscodeUtils_1.getActivationState();
if (extensionIsActive)
this.writeFileData();
}
changeCallback() {
this.getSettings();
}
updateFolderData(workspaceFolder) {
super._updateFolderData(workspaceFolder);
}
getSettings() {
const settingsLocal = fileUtils_1.readJsonFile(this._outputPath);
this.cCompilerPath = this.getSettingsValue(settingsLocal, 'cCompilerPath', SettingsProvider.DEFAULT_C_COMPILER_PATH);
this.cppCompilerPath = this.getSettingsValue(settingsLocal, 'cppCompilerPath', SettingsProvider.DEFAULT_CPP_COMPILER_PATH);
this.debuggerPath = this.getSettingsValue(settingsLocal, 'debuggerPath', SettingsProvider.DEFAULT_DEBUGGER_PATH);
this.makePath = this.getSettingsValue(settingsLocal, 'makePath', SettingsProvider.DEFAULT_MAKE_PATH);
this.enableWarnings = this.getSettingsValue(settingsLocal, 'enableWarnings', SettingsProvider.DEFAULT_ENABLE_WARNINGS);
this.warnings = this.getSettingsValue(settingsLocal, 'warnings', SettingsProvider.DEFAULT_WARNINGS);
this.warningsAsError = this.getSettingsValue(settingsLocal, 'warningsAsError', SettingsProvider.DEFAULT_WARNINGS_AS_ERRORS);
this.cStandard = this.getSettingsValue(settingsLocal, 'cStandard', SettingsProvider.DEFAULT_C_STANDARD);
this.cppStandard = this.getSettingsValue(settingsLocal, 'cppStandard', SettingsProvider.DEFAULT_CPP_STANDARD);
this.compilerArgs = this.getSettingsValue(settingsLocal, 'compilerArgs', SettingsProvider.DEFAULT_COMPILER_ARGS);
this.linkerArgs = this.getSettingsValue(settingsLocal, 'linkerArgs', SettingsProvider.DEFAULT_LINKER_ARGS);
this.includePaths = this.getSettingsValue(settingsLocal, 'includePaths', SettingsProvider.DEFAULT_INCLUDE_PATHS);
this.excludeSearch = this.getSettingsValue(settingsLocal, 'excludeSearch', SettingsProvider.DEFAULT_EXCLUDE_SEARCH);
}
getCommands() {
this.searchPathVariables();
this.searchCommands();
}
async searchCommands() {
if (!this._commands.foundGcc) {
({
f: this._commands.foundGcc,
p: this._commands.pathGcc,
} = await systemUtils_1.commandExists(types_1.Compilers.gcc));
if (!this._commands.foundGcc) {
({
f: this._commands.foundClang,
p: this._commands.pathClang,
} = await systemUtils_1.commandExists(types_1.Compilers.clang));
}
}
if (!this._commands.foundGpp) {
({
f: this._commands.foundGpp,
p: this._commands.pathGpp,
} = await systemUtils_1.commandExists(types_1.Compilers.gpp));
if (!this._commands.foundGpp) {
({
f: this._commands.foundClangpp,
p: this._commands.pathClangpp,
} = await systemUtils_1.commandExists(types_1.Compilers.clangpp));
}
}
if (!this._commands.foundGDB) {
({
f: this._commands.foundGDB,
p: this._commands.pathGDB,
} = await systemUtils_1.commandExists(types_1.Debuggers.gdb));
if (!this._commands.foundGDB) {
({
f: this._commands.foundLLDB,
p: this._commands.pathLLDB,
} = await systemUtils_1.commandExists(types_1.Debuggers.lldb));
}
}
if (!this._commands.foundMake) {
({
f: this._commands.foundMake,
p: this._commands.pathMake,
} = await systemUtils_1.commandExists(types_1.Makefiles.make));
if (!this._commands.foundMake &&
this.operatingSystem === types_1.OperatingSystems.windows) {
({
f: this._commands.foundMake,
p: this._commands.pathMake,
} = await systemUtils_1.commandExists(types_1.Makefiles.make_mingw));
}
}
}
searchPathVariables() {
this._commands = new types_1.Commands();
const env = process.env;
if (env['PATH']) {
let paths = [];
if (this.operatingSystem === types_1.OperatingSystems.windows) {
paths = env['PATH'].split(';');
}
else {
paths = env['PATH'].split(':');
}
for (const envPath of paths) {
if ((this._commands.foundGcc &&
this._commands.foundGpp &&
this._commands.foundGDB) ||
(this._commands.foundClang &&
this._commands.foundClangpp &&
this._commands.foundLLDB)) {
break;
}
if (this.operatingSystem === types_1.OperatingSystems.windows) {
if (this.skipCheckWindows(envPath))
continue;
}
else if (this.operatingSystem === types_1.OperatingSystems.linux) {
if (this.skipCheckLinux(envPath))
continue;
}
else if (this.operatingSystem === types_1.OperatingSystems.mac) {
if (this.skipCheckMac(envPath))
continue;
}
if (this.operatingSystem === types_1.OperatingSystems.windows) {
this.searchPathVariablesWindows(envPath);
}
else if (this.operatingSystem === types_1.OperatingSystems.linux) {
this.searchPathVariablesLinux(envPath);
}
else if (this.operatingSystem === types_1.OperatingSystems.mac) {
this.searchPathVariablesMac(envPath);
}
}
}
}
skipCheckWindows(envPath) {
if (!envPath.toLowerCase().includes('bin') &&
!envPath.toLowerCase().includes('mingw') &&
!envPath.toLowerCase().includes('msys') &&
!envPath.toLowerCase().includes('cygwin')) {
return true;
}
return false;
}
skipCheckLinux(envPath) {
if (!envPath.toLowerCase().startsWith('/bin') &&
!envPath.toLowerCase().startsWith('/usr/bin')) {
return true;
}
return false;
}
skipCheckMac(envPath) {
if (!envPath.toLowerCase().includes('bin')) {
return true;
}
return false;
}
searchPathVariablesWindows(envPath) {
const lower_path = envPath.toLocaleLowerCase();
if (lower_path.includes(types_1.CompilerSystems.cygwin) ||
lower_path.includes(types_1.CompilerSystems.mingw) ||
lower_path.includes(types_1.CompilerSystems.msys2)) {
this._commands.pathGcc = path.join(envPath, types_1.Compilers.gcc + '.exe');
this._commands.pathGpp = path.join(envPath, types_1.Compilers.gpp + '.exe');
this._commands.pathGDB = path.join(envPath, types_1.Debuggers.gdb + '.exe');
this._commands.pathMake = path.join(envPath, types_1.Makefiles.make + '.exe');
if (fileUtils_1.pathExists(this._commands.pathGcc)) {
this._commands.foundGcc = true;
}
if (fileUtils_1.pathExists(this._commands.pathGpp)) {
this._commands.foundGpp = true;
}
if (fileUtils_1.pathExists(this._commands.pathGDB)) {
this._commands.foundGDB = true;
}
if (fileUtils_1.pathExists(this._commands.pathMake)) {
this._commands.foundMake = true;
}
else {
const altPathMake = path.join(envPath, types_1.Makefiles.make_mingw + '.exe');
if (fileUtils_1.pathExists(altPathMake)) {
this._commands.foundMake = true;
}
}
}
}
searchPathVariablesLinux(envPath) {
this._commands.pathGcc = path.join(envPath, types_1.Compilers.gcc);
this._commands.pathGpp = path.join(envPath, types_1.Compilers.gpp);
this._commands.pathGDB = path.join(envPath, types_1.Debuggers.gdb);
this._commands.pathMake = path.join(envPath, types_1.Makefiles.make);
if (fileUtils_1.pathExists(this._commands.pathGcc)) {
this._commands.foundGcc = true;
}
if (fileUtils_1.pathExists(this._commands.pathGpp)) {
this._commands.foundGpp = true;
}
if (fileUtils_1.pathExists(this._commands.pathGDB)) {
this._commands.foundGDB = true;
}
if (fileUtils_1.pathExists(this._commands.pathMake)) {
this._commands.foundMake = true;
}
}
searchPathVariablesMac(envPath) {
this._commands.pathClang = path.join(envPath, types_1.Compilers.clang);
this._commands.pathClangpp = path.join(envPath, types_1.Compilers.clangpp);
this._commands.pathLLDB = path.join(envPath, types_1.Debuggers.lldb);
this._commands.pathMake = path.join(envPath, types_1.Makefiles.make);
if (fileUtils_1.pathExists(this._commands.pathClang)) {
this._commands.foundClang = true;
}
if (fileUtils_1.pathExists(this._commands.pathClangpp)) {
this._commands.foundClangpp = true;
}
if (fileUtils_1.pathExists(this._commands.pathLLDB)) {
this._commands.foundLLDB = true;
}
if (fileUtils_1.pathExists(this._commands.pathMake)) {
this._commands.foundMake = true;
}
}
setCommands() {
if (this._commands.foundGcc && this._commands.pathGcc) {
this.setGcc(this._commands.pathGcc);
}
else if (this._commands.foundClang && this._commands.pathClang) {
this.setClang(this._commands.pathClang);
}
else {
this.cCompiler = undefined;
}
if (this._commands.foundGpp && this._commands.pathGpp) {
this.setGpp(this._commands.pathGpp);
}
else if (this._commands.foundClangpp && this._commands.pathClangpp) {
this.setClangpp(this._commands.pathClangpp);
}
else {
this.cppCompiler = undefined;
}
if (this._commands.foundGDB && this._commands.pathGDB) {
this.setGDB(this._commands.pathGDB);
}
else if (this._commands.foundLLDB && this._commands.pathLLDB) {
this.setLLDB(this._commands.pathLLDB);
}
else {
this.debugger = undefined;
}
if (this._commands.foundMake && this._commands.pathMake) {
this.setMake(this._commands.pathMake);
}
else {
this._makeFound = false;
}
this.setOtherSettings();
}
getCommandTypes() {
let cBasename = this.cCompilerPath;
let cppBasename = this.cppCompilerPath;
cBasename = fileUtils_1.getBasename(cBasename);
cBasename = fileUtils_1.removeExtension(cBasename, 'exe');
cppBasename = fileUtils_1.getBasename(cppBasename);
cppBasename = fileUtils_1.removeExtension(cppBasename, 'exe');
if (cBasename) {
if (cBasename.includes(types_1.Compilers.clang)) {
this.cCompiler = types_1.Compilers.clang;
this.debugger = types_1.Debuggers.lldb;
}
else {
this.cCompiler = types_1.Compilers.gcc;
this.debugger = types_1.Debuggers.gdb;
}
}
if (cppBasename) {
if (cppBasename.includes(types_1.Compilers.clangpp)) {
this.cppCompiler = types_1.Compilers.clangpp;
this.debugger = types_1.Debuggers.lldb;
}
else {
this.cppCompiler = types_1.Compilers.gpp;
this.debugger = types_1.Debuggers.gdb;
}
}
}
getArchitecture() {
if (this.cCompiler) {
const ret = systemUtils_1.getCompilerArchitecture(this.cCompiler);
this.architecure = ret.architecure;
this.isCygwin = ret.isCygwin;
}
else if (this.cppCompiler) {
const ret = systemUtils_1.getCompilerArchitecture(this.cppCompiler);
this.architecure = ret.architecure;
this.isCygwin = ret.isCygwin;
}
else {
this.architecure = types_1.Architectures.x64;
this.isCygwin = false;
}
}
reset() {
this.cCompilerPath = SettingsProvider.DEFAULT_C_COMPILER_PATH;
this.cppCompilerPath = SettingsProvider.DEFAULT_CPP_COMPILER_PATH;
this.debuggerPath = SettingsProvider.DEFAULT_DEBUGGER_PATH;
this.makePath = SettingsProvider.DEFAULT_MAKE_PATH;
this.enableWarnings = SettingsProvider.DEFAULT_ENABLE_WARNINGS;
this.warnings = SettingsProvider.DEFAULT_WARNINGS;
this.warningsAsError = SettingsProvider.DEFAULT_WARNINGS_AS_ERRORS;
this.cStandard = SettingsProvider.DEFAULT_C_STANDARD;
this.cppStandard = SettingsProvider.DEFAULT_CPP_STANDARD;
this.compilerArgs = SettingsProvider.DEFAULT_COMPILER_ARGS;
this.linkerArgs = SettingsProvider.DEFAULT_LINKER_ARGS;
this.includePaths = SettingsProvider.DEFAULT_INCLUDE_PATHS;
this.excludeSearch = SettingsProvider.DEFAULT_EXCLUDE_SEARCH;
this.setGcc(this.cCompilerPath);
this.setGpp(this.cppCompilerPath);
this.setGDB(this.debuggerPath);
this.setMake(this.makePath);
this.setOtherSettings();
}
getSettingsValue(settingsLocal, name, defaultValue) {
const settingName = `${EXTENSION_NAME}.${name}`;
if (settingsLocal && settingsLocal[settingName] !== undefined) {
return settingsLocal[settingName];
}
if (this._configGlobal.has(name)) {
return this._configGlobal.get(name, defaultValue);
}
return defaultValue;
}
update(key, value) {
let settingsJson = fileUtils_1.readJsonFile(this._outputPath);
if (!settingsJson) {
settingsJson = {};
}
const settingName = `${EXTENSION_NAME}.${key}`;
settingsJson[settingName] = value;
fileUtils_1.writeJsonFile(this._outputPath, settingsJson);
}
setGcc(pathGcc) {
this.update('cCompilerPath', pathGcc);
this.cCompiler = types_1.Compilers.gcc;
this._cCompilerFound = true;
}
setClang(pathClang) {
this.update('cCompilerPath', pathClang);
this.cCompiler = types_1.Compilers.clang;
this._cCompilerFound = true;
}
setGpp(pathGpp) {
this.update('cppCompilerPath', pathGpp);
this.cppCompiler = types_1.Compilers.gpp;
this._cppCompilerFound = true;
}
setClangpp(pathClangpp) {
this.update('cppCompilerPath', pathClangpp);
this.cppCompiler = types_1.Compilers.clangpp;
this._cppCompilerFound = true;
}
setLLDB(pathLLDB) {
this.update('debuggerPath', pathLLDB);
this.debugger = types_1.Debuggers.lldb;
this._debuggerFound = true;
}
setGDB(pathGDB) {
this.update('debuggerPath', pathGDB);
this.debugger = types_1.Debuggers.gdb;
this._debuggerFound = true;
}
setMake(pathMake) {
this.update('makePath', pathMake);
this._makeFound = true;
}
setOtherSettings() {
this.update('warnings', this.warnings);
this.update('compilerArgs', this.compilerArgs);
this.update('includePaths', this.includePaths);
this.update('linkerArgs', this.linkerArgs);
this.update('cStandard', this.cStandard);
this.update('cppStandard', this.cppStandard);
this.update('excludeSearch', this.excludeSearch);
this.update('enableWarnings', this.enableWarnings);
this.update('warningsAsError', this.warningsAsError);
}
}
exports.SettingsProvider = SettingsProvider;
SettingsProvider.DEFAULT_C_COMPILER_PATH = 'gcc';
SettingsProvider.DEFAULT_CPP_COMPILER_PATH = 'g++';
SettingsProvider.DEFAULT_DEBUGGER_PATH = 'gdb';
SettingsProvider.DEFAULT_MAKE_PATH = 'make';
SettingsProvider.DEFAULT_C_STANDARD = '';
SettingsProvider.DEFAULT_CPP_STANDARD = '';
SettingsProvider.DEFAULT_EXCLUDE_SEARCH = [];
SettingsProvider.DEFAULT_ENABLE_WARNINGS = true;
SettingsProvider.DEFAULT_WARNINGS_AS_ERRORS = false;
SettingsProvider.DEFAULT_WARNINGS = ['-Wall', '-Wextra', '-Wpedantic'];
SettingsProvider.DEFAULT_COMPILER_ARGS = [];
SettingsProvider.DEFAULT_LINKER_ARGS = [];
SettingsProvider.DEFAULT_INCLUDE_PATHS = [];
//# sourceMappingURL=settingsProvider.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,228 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskProvider = void 0;
const path = require("path");
const vscode = require("vscode");
const extension_1 = require("../extension");
const fileUtils_1 = require("../utils/fileUtils");
const types_1 = require("../utils/types");
const vscodeUtils_1 = require("../utils/vscodeUtils");
const settingsProvider_1 = require("./settingsProvider");
const EXTENSION_NAME = 'C_Cpp_Runner';
const CONFIG_NAME = 'C/C++ Runner: Debug Session';
class TaskProvider {
constructor(_settingsProvider, _workspaceFolder, _activeFolder, _buildMode, _argumentsString) {
this._settingsProvider = _settingsProvider;
this._workspaceFolder = _workspaceFolder;
this._activeFolder = _activeFolder;
this._buildMode = _buildMode;
this._argumentsString = _argumentsString;
const templateDirectory = path.join(extension_1.extensionPath ? extension_1.extensionPath : '', 'templates');
this._tasksFile = path.join(templateDirectory, 'tasks_template.json');
this._makefileFile = path.join(templateDirectory, 'Makefile');
this.getTasks();
}
async resolveTask(task) {
return task;
}
provideTasks() {
return this.getTasks();
}
getTasks() {
if (!this.activeFolder)
return [];
const language = fileUtils_1.getLanguage(this.activeFolder);
this.setTasksDefinition(language);
if (!this.tasks)
return [];
return this.tasks;
}
setTasksDefinition(language) {
const taskType = 'shell';
const configJson = fileUtils_1.readJsonFile(this._tasksFile);
if (!configJson) {
return [];
}
this.tasks = [];
for (const taskJson of configJson.tasks) {
if (taskJson.type !== taskType) {
continue;
}
if (taskJson.options) {
if (taskJson.options.hide) {
continue;
}
}
this.updateTaskBasedOnSettings(taskJson, language);
const shellCommand = `${taskJson.command} ${taskJson.args.join(' ')}`;
const definition = {
type: taskType,
task: taskJson.label,
};
const problemMatcher = '$gcc';
const scope = vscode.TaskScope.Workspace;
const execution = new vscode.ShellExecution(shellCommand);
const task = new types_1.Task(definition, scope, taskJson.label, EXTENSION_NAME, execution, problemMatcher);
this.tasks.push(task);
}
this.addDebugTask();
return this.tasks;
}
updateTaskBasedOnSettings(taskJson, language) {
if (!this.workspaceFolder || !this.activeFolder)
return;
const settings = this._settingsProvider;
const activeFolder = this.activeFolder;
const workspaceFolder = this.workspaceFolder;
const folder = activeFolder.replace(workspaceFolder, path.basename(workspaceFolder));
taskJson.label = taskJson.label.replace(taskJson.label.split(': ')[1], folder);
taskJson.label = fileUtils_1.replaceBackslashes(taskJson.label);
taskJson.command = settings.makePath;
taskJson.args[1] = `--file=${this._makefileFile}`;
const isRunTask = taskJson.label.includes(types_1.Tasks.run);
taskJson.args.push(`COMPILATION_MODE=${this.buildMode}`);
if (this._settingsProvider.operatingSystem === types_1.OperatingSystems.windows) {
taskJson.args.push(`EXECUTABLE_NAME=out${this.buildMode}.exe`);
}
else {
taskJson.args.push(`EXECUTABLE_NAME=out${this.buildMode}`);
}
taskJson.args.push(`LANGUAGE_MODE=${language}`);
if (!isRunTask) {
if (language === types_1.Languages.c) {
taskJson.args.push(`C_COMPILER=${settings.cCompilerPath}`);
if (settings.cStandard &&
settings.cStandard !== settingsProvider_1.SettingsProvider.DEFAULT_C_STANDARD) {
taskJson.args.push(`C_STANDARD=${settings.cStandard}`);
}
}
else {
taskJson.args.push(`CPP_COMPILER=${settings.cppCompilerPath}`);
if (settings.cppStandard &&
settings.cppStandard !== settingsProvider_1.SettingsProvider.DEFAULT_CPP_STANDARD) {
taskJson.args.push(`CPP_STANDARD=${settings.cppStandard}`);
}
}
taskJson.args.push(`ENABLE_WARNINGS=${+settings.enableWarnings}`);
taskJson.args.push(`WARNINGS_AS_ERRORS=${+settings.warningsAsError}`);
if (settings.warnings && settings.warnings.length > 0) {
const warningsStr = settings.warnings.join(' ');
taskJson.args.push(`WARNINGS="${warningsStr}"`);
}
if (settings.compilerArgs && settings.compilerArgs.length > 0) {
const compilerArgsStr = settings.compilerArgs.join(' ');
taskJson.args.push(`COMPILER_ARGS="${compilerArgsStr}"`);
}
if (settings.linkerArgs && settings.linkerArgs.length > 0) {
const linkerArgsStr = settings.linkerArgs.join(' ');
taskJson.args.push(`LINKER_ARGS="${linkerArgsStr}"`);
}
if (settings.includePaths && settings.includePaths.length > 0) {
const includePathsStr = settings.includePaths.join(' ');
taskJson.args.push(`INCLUDE_PATHS="${includePathsStr}"`);
}
}
if (isRunTask) {
if (this.argumentsString) {
taskJson.args.push(`ARGUMENTS=${this.argumentsString}`);
}
}
}
updateModeData(buildMode) {
this.buildMode = buildMode;
}
updateArguments(argumentsString) {
this.argumentsString = argumentsString;
if (this.workspaceFolder) {
const launchPath = path.join(this.workspaceFolder, '.vscode', 'launch.json');
const configJson = fileUtils_1.readJsonFile(launchPath);
if (!configJson)
return;
const configIdx = vscodeUtils_1.getLaunchConfigIndex(configJson, CONFIG_NAME);
if (configIdx === undefined)
return;
if (this.argumentsString) {
configJson.configurations[configIdx].args.push(this.argumentsString);
}
else {
configJson.configurations[configIdx].args = [];
}
fileUtils_1.writeJsonFile(launchPath, configJson);
}
}
updateFolderData(workspaceFolder, activeFolder) {
this.resetArguments();
this.workspaceFolder = workspaceFolder;
this.activeFolder = activeFolder;
}
resetArguments() {
if (this.workspaceFolder) {
const launchPath = path.join(this.workspaceFolder, '.vscode', 'launch.json');
const configJson = fileUtils_1.readJsonFile(launchPath);
if (configJson) {
const configIdx = vscodeUtils_1.getLaunchConfigIndex(configJson, CONFIG_NAME);
if (configIdx === undefined)
return;
configJson.configurations[configIdx].args = [];
fileUtils_1.writeJsonFile(launchPath, configJson);
}
}
this.argumentsString = undefined;
}
getProjectFolder() {
if (this.activeFolder) {
return this.activeFolder;
}
if (this.workspaceFolder) {
return this.workspaceFolder;
}
return undefined;
}
addDebugTask() {
if (!this.tasks)
return;
if (!this.workspaceFolder || !this.activeFolder)
return;
const folder = this.activeFolder.replace(this.workspaceFolder, path.basename(this.workspaceFolder));
let label = `Debug: ${this.activeFolder}`;
const splitted = label.split(': ');
if (!splitted[1])
return;
label = label.replace(splitted[1], folder);
label = fileUtils_1.replaceBackslashes(label);
const definition = {
type: 'shell',
task: label,
};
const problemMatcher = '$gcc';
const scope = vscode.TaskScope.Workspace;
const task = new types_1.Task(definition, scope, label, EXTENSION_NAME, undefined, problemMatcher);
this.tasks.push(task);
}
get buildMode() {
return this._buildMode;
}
set buildMode(value) {
this._buildMode = value;
}
get activeFolder() {
return this._activeFolder;
}
set activeFolder(value) {
this._activeFolder = value;
}
get workspaceFolder() {
return this._workspaceFolder;
}
set workspaceFolder(value) {
this._workspaceFolder = value;
}
get argumentsString() {
return this._argumentsString;
}
set argumentsString(value) {
this._argumentsString = value;
}
}
exports.TaskProvider = TaskProvider;
//# sourceMappingURL=taskProvider.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,209 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBasename = exports.removeExtension = exports.hasPathSeperators = exports.commandCheck = exports.naturalSort = exports.writeJsonFile = exports.readJsonFile = exports.foldersInDir = exports.excludePatternFromList = exports.filesInDir = exports.readDir = exports.getDirectoriesRecursive = exports.getLanguage = exports.isCSourceFile = exports.isCppSourceFile = exports.isHeaderFile = exports.addFileExtensionDot = exports.isSourceFile = exports.pathExists = exports.filterOnString = exports.rmdirRecursive = exports.mkdirRecursive = exports.replaceBackslashes = void 0;
const fs = require("fs");
const JSON5 = require("json5");
const minimatch = require("minimatch");
const path = require("path");
const extension_1 = require("../extension");
const logger = require("./logger");
const types_1 = require("./types");
function replaceBackslashes(text) {
return text.replace(/\\/g, '/');
}
exports.replaceBackslashes = replaceBackslashes;
function mkdirRecursive(dir) {
try {
fs.mkdirSync(dir, { recursive: true });
}
catch (err) {
const errorMessage = `mkdirRecursive: ${err}`;
logger.log(extension_1.loggingActive, errorMessage);
}
}
exports.mkdirRecursive = mkdirRecursive;
function rmdirRecursive(dir) {
try {
fs.rmdirSync(dir, { recursive: true });
}
catch (err) {
const errorMessage = `rmdirSync: ${err}`;
logger.log(extension_1.loggingActive, errorMessage);
}
}
exports.rmdirRecursive = rmdirRecursive;
function filterOnString(names, filterName) {
return names.filter((name) => !name.includes(filterName));
}
exports.filterOnString = filterOnString;
function pathExists(filepath) {
try {
fs.accessSync(filepath);
}
catch (err) {
return false;
}
return true;
}
exports.pathExists = pathExists;
function isSourceFile(fileExt) {
const fileExtLower = fileExt.toLowerCase();
if (isHeaderFile(fileExtLower)) {
return false;
}
if (!(isCSourceFile(fileExtLower) || isCppSourceFile(fileExtLower))) {
return false;
}
return true;
}
exports.isSourceFile = isSourceFile;
function addFileExtensionDot(fileExt) {
if (!fileExt.includes('.')) {
fileExt = `.${fileExt}`;
}
return fileExt;
}
exports.addFileExtensionDot = addFileExtensionDot;
function isHeaderFile(fileExtLower) {
fileExtLower = addFileExtensionDot(fileExtLower);
return ['.hpp', '.hh', '.hxx', '.h'].some((ext) => fileExtLower === ext);
}
exports.isHeaderFile = isHeaderFile;
function isCppSourceFile(fileExtLower) {
fileExtLower = addFileExtensionDot(fileExtLower);
return ['.cpp', '.cc', '.cxx'].some((ext) => fileExtLower === ext);
}
exports.isCppSourceFile = isCppSourceFile;
function isCSourceFile(fileExtLower) {
fileExtLower = addFileExtensionDot(fileExtLower);
return fileExtLower === '.c';
}
exports.isCSourceFile = isCSourceFile;
function getLanguage(dir) {
const files = filesInDir(dir);
const anyCppFile = files.some((file) => isCppSourceFile(path.extname(file)));
if (anyCppFile) {
return types_1.Languages.cpp;
}
else {
return types_1.Languages.c;
}
}
exports.getLanguage = getLanguage;
function getDirectoriesRecursive(dir) {
const directories = foldersInDir(dir);
if (directories.length === 0)
return;
directories.forEach((dir) => getDirectoriesRecursive(dir)?.forEach((newDir) => directories.push(newDir)));
return directories;
}
exports.getDirectoriesRecursive = getDirectoriesRecursive;
function readDir(dir) {
try {
return fs.readdirSync(dir, { withFileTypes: true });
}
catch (err) {
const errorMessage = `readDir: ${err}`;
logger.log(extension_1.loggingActive, errorMessage);
return undefined;
}
}
exports.readDir = readDir;
function filesInDir(dir) {
const fileDirents = readDir(dir);
if (!fileDirents)
return [];
const files = fileDirents
.filter((file) => file.isFile())
.map((file) => file.name);
return files;
}
exports.filesInDir = filesInDir;
function excludePatternFromList(excludeSearch, foldersList) {
for (const pattern of excludeSearch) {
foldersList = foldersList.filter((folder) => !minimatch(folder, pattern));
}
return foldersList;
}
exports.excludePatternFromList = excludePatternFromList;
function foldersInDir(dir) {
const fileDirents = readDir(dir);
if (!fileDirents)
return [];
let folders = fileDirents.filter((folder) => folder.isDirectory());
folders = folders.filter((folder) => !folder.name.includes('.'));
folders = folders.filter((folder) => !folder.name.includes('__'));
folders = folders.filter((folder) => !(folder.name === 'build'));
folders = folders.filter((folder) => !folder.name.includes('CMake'.toLowerCase()));
const folderNames = folders.map((folder) => path.join(dir.toString(), folder.name));
return folderNames;
}
exports.foldersInDir = foldersInDir;
function readJsonFile(filepath) {
let configJson;
try {
const fileContent = fs.readFileSync(filepath, 'utf-8');
configJson = JSON5.parse(fileContent);
}
catch (err) {
const errorMessage = `readJsonFile: ${err}`;
logger.log(extension_1.loggingActive, errorMessage);
return undefined;
}
return configJson;
}
exports.readJsonFile = readJsonFile;
function writeJsonFile(outputFilePath, jsonContent) {
if (jsonContent === undefined)
return;
const dirname = path.dirname(outputFilePath);
if (!pathExists(dirname)) {
mkdirRecursive(dirname);
}
const jsonString = JSON.stringify(jsonContent, null, 2);
try {
fs.writeFileSync(outputFilePath, jsonString);
}
catch (err) {
const errorMessage = `writeJsonFile: ${err}`;
logger.log(extension_1.loggingActive, errorMessage);
return;
}
}
exports.writeJsonFile = writeJsonFile;
function naturalSort(names) {
return names.sort((a, b) => a.localeCompare(b, undefined, {
numeric: true,
sensitivity: 'base',
}));
}
exports.naturalSort = naturalSort;
function commandCheck(key, jsonData) {
const commandPath = jsonData[key];
if (!commandPath)
return false;
if (!pathExists(commandPath))
return false;
return true;
}
exports.commandCheck = commandCheck;
function hasPathSeperators(pathStr) {
return pathStr.includes('/') || pathStr.includes('\\');
}
exports.hasPathSeperators = hasPathSeperators;
function removeExtension(pathStr, ext) {
const extStr = addFileExtensionDot(ext);
if (pathStr.includes(extStr)) {
return pathStr.replace(extStr, '');
}
return pathStr;
}
exports.removeExtension = removeExtension;
function getBasename(pathStr) {
if (hasPathSeperators(pathStr)) {
return path.basename(pathStr);
}
return pathStr;
}
exports.getBasename = getBasename;
//# sourceMappingURL=fileUtils.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.log = exports.getOutputChannelLogger = exports.showOutputChannel = exports.getOutputChannel = exports.Logger = void 0;
const os = require("os");
const vscode = require("vscode");
let outputChannel;
let outputChannelLogger;
class Logger {
constructor(writer) {
this.writer = writer;
}
append(message) {
this.writer(message);
}
appendLine(message) {
this.writer(message + os.EOL);
}
showInformationMessage(message, items) {
this.appendLine(message);
if (!items) {
return vscode.window.showInformationMessage(message);
}
return vscode.window.showInformationMessage(message, ...items);
}
showWarningMessage(message, items) {
this.appendLine(message);
if (!items) {
return vscode.window.showWarningMessage(message);
}
return vscode.window.showWarningMessage(message, ...items);
}
showErrorMessage(message, items) {
this.appendLine(message);
if (!items) {
return vscode.window.showErrorMessage(message);
}
return vscode.window.showErrorMessage(message, ...items);
}
}
exports.Logger = Logger;
function getOutputChannel() {
if (!outputChannel) {
outputChannel = vscode.window.createOutputChannel('C/C++ Runner');
}
return outputChannel;
}
exports.getOutputChannel = getOutputChannel;
function showOutputChannel() {
getOutputChannel().show(true);
}
exports.showOutputChannel = showOutputChannel;
function getOutputChannelLogger() {
if (!outputChannelLogger) {
outputChannelLogger = new Logger((message) => getOutputChannel().append(message));
}
return outputChannelLogger;
}
exports.getOutputChannelLogger = getOutputChannelLogger;
function log(loggingActive, message) {
if (loggingActive) {
getOutputChannel().appendLine(message);
showOutputChannel();
}
}
exports.log = log;
//# sourceMappingURL=logger.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,iCAAiC;AAEjC,IAAI,aAA+C,CAAC;AACpD,IAAI,mBAAuC,CAAC;AAE5C,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B,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;KACnE;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AALD,4CAKC;AAED,SAAgB,iBAAiB;IAC/B,gBAAgB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAFD,8CAEC;AAED,SAAgB,sBAAsB;IACpC,IAAI,CAAC,mBAAmB,EAAE;QACxB,mBAAmB,GAAG,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAC3C,gBAAgB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CACnC,CAAC;KACH;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAPD,wDAOC;AAED,SAAgB,GAAG,CAAC,aAAsB,EAAE,OAAe;IACzD,IAAI,aAAa,EAAE;QACjB,gBAAgB,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACvC,iBAAiB,EAAE,CAAC;KACrB;AACH,CAAC;AALD,kBAKC"}

View file

@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCompilerArchitecture = exports.getOperatingSystem = exports.commandExists = void 0;
const child_process_1 = require("child_process");
const lookpath_1 = require("lookpath");
const os_1 = require("os");
const types_1 = require("./types");
async function commandExists(command) {
let commandPath = await lookpath_1.lookpath(command);
if (!commandPath) {
return { f: false, p: commandPath };
}
if (commandPath.includes('.EXE')) {
commandPath = commandPath.replace('.EXE', '.exe');
}
return { f: true, p: commandPath };
}
exports.commandExists = commandExists;
function getOperatingSystem() {
const platformName = os_1.platform();
let operatingSystem;
if (platformName === 'win32') {
operatingSystem = types_1.OperatingSystems.windows;
}
else if (platformName === 'darwin') {
operatingSystem = types_1.OperatingSystems.mac;
}
else {
operatingSystem = types_1.OperatingSystems.linux;
}
return operatingSystem;
}
exports.getOperatingSystem = getOperatingSystem;
function getCompilerArchitecture(compiler) {
const command = `${compiler} -dumpmachine`;
let byteArray;
try {
byteArray = child_process_1.execSync(command);
}
catch (err) {
byteArray = Buffer.from('x64', 'utf-8');
}
const str = String.fromCharCode(...byteArray);
let architecure = types_1.Architectures.x86;
let isCygwin = false;
if (str.includes('64')) {
architecure = types_1.Architectures.x64;
}
if (str.includes('cygwin')) {
isCygwin = true;
}
return { architecure: architecure, isCygwin: isCygwin };
}
exports.getCompilerArchitecture = getCompilerArchitecture;
//# sourceMappingURL=systemUtils.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"systemUtils.js","sourceRoot":"","sources":["../../../src/utils/systemUtils.ts"],"names":[],"mappings":";;;AAAA,iDAAyC;AACzC,uCAAoC;AACpC,2BAA8B;AAE9B,mCAAqE;AAE9D,KAAK,UAAU,aAAa,CAAC,OAAe;IACjD,IAAI,WAAW,GAAG,MAAM,mBAAQ,CAAC,OAAO,CAAC,CAAC;IAE1C,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC;KACrC;IAED,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChC,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACnD;IAED,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC;AACrC,CAAC;AAZD,sCAYC;AAED,SAAgB,kBAAkB;IAChC,MAAM,YAAY,GAAG,aAAQ,EAAE,CAAC;IAChC,IAAI,eAAiC,CAAC;IAEtC,IAAI,YAAY,KAAK,OAAO,EAAE;QAC5B,eAAe,GAAG,wBAAgB,CAAC,OAAO,CAAC;KAC5C;SAAM,IAAI,YAAY,KAAK,QAAQ,EAAE;QACpC,eAAe,GAAG,wBAAgB,CAAC,GAAG,CAAC;KACxC;SAAM;QACL,eAAe,GAAG,wBAAgB,CAAC,KAAK,CAAC;KAC1C;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAbD,gDAaC;AAED,SAAgB,uBAAuB,CAAC,QAAmB;IACzD,MAAM,OAAO,GAAG,GAAG,QAAQ,eAAe,CAAC;IAC3C,IAAI,SAA6B,CAAC;IAElC,IAAI;QACF,SAAS,GAAG,wBAAQ,CAAC,OAAO,CAAC,CAAC;KAC/B;IAAC,OAAO,GAAG,EAAE;QACZ,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACzC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,CAAC;IAC9C,IAAI,WAAW,GAAG,qBAAa,CAAC,GAAG,CAAC;IACpC,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACtB,WAAW,GAAG,qBAAa,CAAC,GAAG,CAAC;KACjC;IAED,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAC1B,QAAQ,GAAG,IAAI,CAAC;KACjB;IAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAC1D,CAAC;AAvBD,0DAuBC"}

View file

@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tasks = exports.Builds = exports.Architectures = exports.OperatingSystems = exports.CompilerSystems = exports.Makefiles = exports.Debuggers = exports.Compilers = exports.Languages = exports.Commands = exports.Task = void 0;
const vscode = require("vscode");
class Task extends vscode.Task {
}
exports.Task = Task;
class Commands {
constructor() {
this.foundGcc = false;
this.foundGpp = false;
this.foundClang = false;
this.foundClangpp = false;
this.foundGDB = false;
this.foundLLDB = false;
this.foundMake = false;
}
}
exports.Commands = Commands;
var Languages;
(function (Languages) {
Languages["c"] = "C";
Languages["cpp"] = "Cpp";
})(Languages = exports.Languages || (exports.Languages = {}));
var Compilers;
(function (Compilers) {
Compilers["gcc"] = "gcc";
Compilers["gpp"] = "g++";
Compilers["clang"] = "clang";
Compilers["clangpp"] = "clang++";
})(Compilers = exports.Compilers || (exports.Compilers = {}));
var Debuggers;
(function (Debuggers) {
Debuggers["lldb"] = "lldb";
Debuggers["gdb"] = "gdb";
})(Debuggers = exports.Debuggers || (exports.Debuggers = {}));
var Makefiles;
(function (Makefiles) {
Makefiles["make"] = "make";
Makefiles["make_mingw"] = "mingw32-make";
})(Makefiles = exports.Makefiles || (exports.Makefiles = {}));
var CompilerSystems;
(function (CompilerSystems) {
CompilerSystems["cygwin"] = "cygwin";
CompilerSystems["mingw"] = "mingw";
CompilerSystems["msys2"] = "msys2";
CompilerSystems["clang"] = "clang";
})(CompilerSystems = exports.CompilerSystems || (exports.CompilerSystems = {}));
var OperatingSystems;
(function (OperatingSystems) {
OperatingSystems["windows"] = "windows";
OperatingSystems["linux"] = "linux";
OperatingSystems["mac"] = "macos";
})(OperatingSystems = exports.OperatingSystems || (exports.OperatingSystems = {}));
var Architectures;
(function (Architectures) {
Architectures["x86"] = "x86";
Architectures["x64"] = "x64";
})(Architectures = exports.Architectures || (exports.Architectures = {}));
var Builds;
(function (Builds) {
Builds["debug"] = "Debug";
Builds["release"] = "Release";
})(Builds = exports.Builds || (exports.Builds = {}));
var Tasks;
(function (Tasks) {
Tasks["build"] = "Build";
Tasks["run"] = "Run";
Tasks["clean"] = "Clean";
Tasks["debug"] = "Debug";
})(Tasks = exports.Tasks || (exports.Tasks = {}));
//# sourceMappingURL=types.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAsBjC,MAAa,IAAK,SAAQ,MAAM,CAAC,IAAI;CAEpC;AAFD,oBAEC;AAED,MAAa,QAAQ;IAArB;QACE,aAAQ,GAAY,KAAK,CAAC;QAE1B,aAAQ,GAAY,KAAK,CAAC;QAE1B,eAAU,GAAY,KAAK,CAAC;QAE5B,iBAAY,GAAY,KAAK,CAAC;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AM,GAAN,cAAM,KAAN,cAAM,QAGjB;AAED,IAAY,KAKX;AALD,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,oBAAW,CAAA;IACX,wBAAe,CAAA;IACf,wBAAe,CAAA;AACjB,CAAC,EALW,KAAK,GAAL,aAAK,KAAL,aAAK,QAKhB"}

View file

@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCourseProject = exports.isCmakeProject = exports.getActivationState = exports.getLoggingState = exports.getExperimentalExecutionState = exports.updateActivationState = exports.updateLoggingState = exports.getLaunchConfigIndex = exports.setContextValue = exports.createStatusBarItem = exports.disposeItem = void 0;
const path = require("path");
const vscode = require("vscode");
const extension_1 = require("../extension");
const fileUtils_1 = require("./fileUtils");
const STATUS_BAR_ALIGN = vscode.StatusBarAlignment.Left;
const STATUS_BAR_PRIORITY = 50;
function disposeItem(disposableItem) {
disposableItem?.dispose();
}
exports.disposeItem = disposeItem;
function createStatusBarItem() {
return vscode.window.createStatusBarItem(STATUS_BAR_ALIGN, STATUS_BAR_PRIORITY);
}
exports.createStatusBarItem = createStatusBarItem;
function setContextValue(key, value) {
return vscode.commands.executeCommand('setContext', key, value);
}
exports.setContextValue = setContextValue;
function getLaunchConfigIndex(configJson, configName) {
let configIdx = 0;
if (configJson) {
for (const config of configJson.configurations) {
if (config.name !== configName) {
configIdx++;
}
else {
return configIdx;
}
}
}
return undefined;
}
exports.getLaunchConfigIndex = getLaunchConfigIndex;
function updateLoggingState() {
extension_1.extensionState?.update('loggingActive', vscode.workspace
.getConfiguration('C_Cpp_Runner')
.get('loggingActive', false));
}
exports.updateLoggingState = updateLoggingState;
function updateActivationState(newState) {
extension_1.extensionState?.update('activatedExtension', newState);
}
exports.updateActivationState = updateActivationState;
function getExperimentalExecutionState() {
return vscode.workspace
.getConfiguration('C_Cpp_Runner')
.get('experimentalExecution', false);
}
exports.getExperimentalExecutionState = getExperimentalExecutionState;
function getLoggingState() {
if (extension_1.extensionState) {
const loggingActive = extension_1.extensionState.get('loggingActive');
return loggingActive;
}
return false;
}
exports.getLoggingState = getLoggingState;
function getActivationState() {
if (extension_1.extensionState) {
return extension_1.extensionState.get('activatedExtension');
}
return false;
}
exports.getActivationState = getActivationState;
function isCmakeProject() {
let cmakeFileFound = false;
const workspaceFodlers = vscode.workspace.workspaceFolders;
const cmakeExtensionName = 'cmake';
const cmakeSettingName = 'sourceDirectory';
if (workspaceFodlers) {
workspaceFodlers.forEach((folder) => {
if (!cmakeFileFound) {
const files = fileUtils_1.filesInDir(folder.uri.fsPath);
files.forEach((file) => {
if (file.toLowerCase() === 'CMakeLists.txt'.toLowerCase()) {
cmakeFileFound = true;
}
});
const settingsPath = path.join(folder.uri.fsPath, '.vscode', 'settings.json');
if (fileUtils_1.pathExists(settingsPath)) {
const configLocal = fileUtils_1.readJsonFile(settingsPath);
if (configLocal &&
configLocal[`${cmakeExtensionName}.${cmakeSettingName}`]) {
cmakeFileFound = true;
}
}
}
});
}
if (!cmakeFileFound) {
const config = vscode.workspace.getConfiguration(cmakeExtensionName);
const cmakeSetting = config.get(cmakeSettingName);
if (cmakeSetting && cmakeSetting !== '${workspaceFolder}') {
cmakeFileFound = true;
}
}
return cmakeFileFound;
}
exports.isCmakeProject = isCmakeProject;
function isCourseProject() {
const workspaceFodlers = vscode.workspace.workspaceFolders;
if (workspaceFodlers) {
workspaceFodlers.forEach((folder) => {
const vscodePath = path.join(folder.uri.fsPath, '.vscode');
const makefilePath = path.join(vscodePath, 'Makefile');
if (fileUtils_1.pathExists(makefilePath)) {
return true;
}
});
}
return false;
}
exports.isCourseProject = isCourseProject;
//# sourceMappingURL=vscodeUtils.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"vscodeUtils.js","sourceRoot":"","sources":["../../../src/utils/vscodeUtils.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,iCAAiC;AAEjC,4CAA8C;AAC9C,2CAAmE;AAGnE,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAk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B,IAAI,gBAAgB,EAAE,CAAC,EACxD;wBACA,cAAc,GAAG,IAAI,CAAC;qBACvB;iBACF;aACF;QACH,CAAC,CAAC,CAAC;KACJ;IAED,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;QACrE,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAElD,IAAI,YAAY,IAAI,YAAY,KAAK,oBAAoB,EAAE;YACzD,cAAc,GAAG,IAAI,CAAC;SACvB;KACF;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAjDD,wCAiDC;AAED,SAAgB,eAAe;IAC7B,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC;IAE3D,IAAI,gBAAgB,EAAE;QACpB,gBAAgB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAClC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YAC3D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAEvD,IAAI,sBAAU,CAAC,YAAY,CAAC,EAAE;gBAC5B,OAAO,IAAI,CAAC;aACb;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAfD,0CAeC"}

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Language="en-US" Id="c-cpp-runner" Version="4.1.2" Publisher="franneck94" />
<DisplayName>C/C++ Runner</DisplayName>
<Description xml:space="preserve">🚀 Compile, run and debug single or multiple C/C++ files with ease. 🚀</Description>
<Tags>keybindings,c,cpp,c++</Tags>
<Categories>Programming Languages,Debuggers,Snippets</Categories>
<GalleryFlags>Public</GalleryFlags>
<Properties>
<Property Id="Microsoft.VisualStudio.Code.Engine" Value="^1.71.0" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionDependencies" Value="ms-vscode.cpptools,vadimcn.vscode-lldb" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionPack" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="workspace" />
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="" />
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="https://github.com/franneck94/vscode-c-cpp-runner.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Getstarted" Value="https://github.com/franneck94/vscode-c-cpp-runner.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.GitHub" Value="https://github.com/franneck94/vscode-c-cpp-runner.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Support" Value="https://github.com/franneck94/vscode-c-cpp-runner/issues" />
<Property Id="Microsoft.VisualStudio.Services.Links.Learn" Value="https://github.com/franneck94/vscode-c-cpp-runner/README.md" />
<Property Id="Microsoft.VisualStudio.Services.Branding.Color" Value="#9c9c9c" />
<Property Id="Microsoft.VisualStudio.Services.Branding.Theme" Value="dark" />
<Property Id="Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown" Value="true" />
</Properties>
<License>extension/LICENSE.txt</License>
<Icon>extension/icon.png</Icon>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
</Installation>
<Dependencies/>
<Assets>
<Asset Type="Microsoft.VisualStudio.Code.Manifest" Path="extension/package.json" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Details" Path="extension/README.md" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Changelog" Path="extension/CHANGELOG.md" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE.txt" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Icons.Default" Path="extension/icon.png" Addressable="true" />
</Assets>
</PackageManifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -0,0 +1,378 @@
{
"name": "c-cpp-runner",
"displayName": "C/C++ Runner",
"description": "🚀 Compile, run and debug single or multiple C/C++ files with ease. 🚀",
"version": "4.1.2",
"publisher": "franneck94",
"license": "MIT",
"icon": "icon.png",
"galleryBanner": {
"color": "#9c9c9c",
"theme": "dark"
},
"engines": {
"vscode": "^1.71.0"
},
"categories": [
"Programming Languages",
"Debuggers",
"Snippets"
],
"tags": [
"c",
"c++",
"run",
"compile",
"build",
"debug"
],
"repository": {
"type": "git",
"url": "https://github.com/franneck94/vscode-c-cpp-runner.git"
},
"homepage": "https://github.com/franneck94/vscode-c-cpp-runner/README.md",
"bugs": {
"url": "https://github.com/franneck94/vscode-c-cpp-runner/issues"
},
"activationEvents": [
"onLanguage:c",
"onLanguage:cpp",
"workspaceContains:*.h",
"workspaceContains:*.c",
"workspaceContains:*.hh",
"workspaceContains:*.cc",
"workspaceContains:*.hxx",
"workspaceContains:*.cxx",
"workspaceContains:*.hpp",
"workspaceContains:*.cpp"
],
"main": "./dist/main",
"contributes": {
"taskDefinitions": [
{
"type": "C_Cpp_Runner"
}
],
"commands": [
{
"command": "C_Cpp_Runner.folder",
"title": "Select Folder",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.mode",
"title": "Select Mode",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.build",
"title": "Build Folder",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.run",
"title": "Run Folder",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.debug",
"title": "Debug Folder",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.clean",
"title": "Clean Folder",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.folderContextMenu",
"title": "Select folder from context menu",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.resetLocalSettings",
"title": "Reset local settings",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.toggleExtensionState",
"title": "Activate/Deactivate the extension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.args",
"title": "Commandline Arguments",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.buildSingleFile",
"title": "Build Single File",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.runSingleFile",
"title": "Run Single File",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
},
{
"command": "C_Cpp_Runner.debugSingleFile",
"title": "Debug Single File",
"when": "C_Cpp_Runner:activatedExtension",
"category": "C/C++ Runner"
}
],
"keybindings": [
{
"command": "C_Cpp_Runner.toggleExtensionState",
"key": "ctrl+alt+t",
"mac": "ctrl+alt+t"
},
{
"command": "C_Cpp_Runner.folder",
"key": "ctrl+alt+f",
"mac": "ctrl+alt+f",
"when": "C_Cpp_Runner:activatedExtension"
},
{
"command": "C_Cpp_Runner.mode",
"key": "ctrl+alt+g",
"mac": "ctrl+alt+g",
"when": "C_Cpp_Runner:activatedExtension"
},
{
"command": "C_Cpp_Runner.buildSingleFile",
"key": "ctrl+alt+b",
"mac": "ctrl+alt+b",
"when": "C_Cpp_Runner:activatedExtension"
},
{
"command": "C_Cpp_Runner.runSingleFile",
"key": "ctrl+alt+r",
"mac": "ctrl+alt+r",
"when": "C_Cpp_Runner:activatedExtension"
},
{
"command": "C_Cpp_Runner.debugSingleFile",
"key": "ctrl+alt+d",
"mac": "ctrl+alt+d",
"when": "C_Cpp_Runner:activatedExtension"
},
{
"command": "C_Cpp_Runner.args",
"key": "ctrl+alt+a",
"mac": "ctrl+alt+a",
"when": "C_Cpp_Runner:activatedExtension"
}
],
"menus": {
"explorer/context": [
{
"command": "C_Cpp_Runner.folderContextMenu",
"when": "explorerResourceIsFolder",
"group": "cCppRunnerGroup@1"
}
]
},
"configuration": {
"type": "object",
"title": "C/C++ Runner",
"properties": {
"C_Cpp_Runner.enableWarnings": {
"type": "boolean",
"default": true,
"description": "Whether to enable checking warnings or not.",
"scope": "resource"
},
"C_Cpp_Runner.warnings": {
"type": "array",
"items": {
"type": "string"
},
"default": [
"-Wall",
"-Wextra",
"-Wpedantic"
],
"description": "Warnings to check by the compiler.",
"scope": "resource"
},
"C_Cpp_Runner.warningsAsError": {
"type": "boolean",
"default": false,
"description": "Whether to treat warnings as compiler errors or not.",
"scope": "resource"
},
"C_Cpp_Runner.cCompilerPath": {
"type": "string",
"default": "gcc",
"description": "The path to the C Compiler (either gcc or clang).",
"scope": "resource"
},
"C_Cpp_Runner.cppCompilerPath": {
"type": "string",
"default": "g++",
"description": "The path to the C++ Compiler (either g++ or clang++).",
"scope": "resource"
},
"C_Cpp_Runner.debuggerPath": {
"type": "string",
"default": "gdb",
"description": "The path to the debugger (either gdb or lldb).",
"scope": "resource"
},
"C_Cpp_Runner.msvcBatchPath": {
"type": "string",
"default": "",
"description": "The path to the MSVC batch file (Needed to use the Visual Studio Compiler).",
"scope": "resource"
},
"C_Cpp_Runner.useMsvc": {
"type": "boolean",
"default": false,
"description": "Whether to use MSVC compiler or to use GCC/LLDB instead.",
"scope": "resource"
},
"C_Cpp_Runner.cStandard": {
"type": "string",
"enum": [
"",
"c89",
"c99",
"c11",
"c17",
"gnu89",
"gnu99",
"gnu11",
"gnu17"
],
"default": "",
"description": "C-Standard for the C Compiler. (If empty, compiler's default is used)",
"scope": "resource"
},
"C_Cpp_Runner.cppStandard": {
"type": "string",
"enum": [
"",
"c++98",
"c++03",
"c++11",
"c++14",
"c++17",
"c++20",
"c++23",
"gnu++98",
"gnu++03",
"gnu++11",
"gnu++14",
"gnu++17",
"gnu++20",
"gnu++23"
],
"default": "",
"description": "C++ Standard for the C++ Compiler. (If empty, compiler's default is used)",
"scope": "resource"
},
"C_Cpp_Runner.compilerArgs": {
"type": "array",
"default": [],
"items": {
"type": "string"
},
"description": "Additional compiler arguments.",
"scope": "resource"
},
"C_Cpp_Runner.linkerArgs": {
"type": "array",
"default": [],
"items": {
"type": "string"
},
"description": "Additional linker arguments.",
"scope": "resource"
},
"C_Cpp_Runner.includePaths": {
"type": "array",
"default": [],
"items": {
"type": "string"
},
"description": "Additional include paths.",
"scope": "resource"
},
"C_Cpp_Runner.includeSearch": {
"type": "array",
"default": [
"*",
"**/*"
],
"items": {
"type": "string"
},
"description": "Include glob patterns for folder selection. (Ran before exlcude pattern)",
"scope": "resource"
},
"C_Cpp_Runner.excludeSearch": {
"type": "array",
"default": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"items": {
"type": "string"
},
"description": "Exclude glob patterns for folder selection. (Ran after include pattern)",
"scope": "resource"
}
}
}
},
"scripts": {
"webpack": "webpack --mode development",
"webpack-watch": "webpack --mode development --watch",
"vscode:prepublish": "npm run webpack",
"compile": "npm run webpack",
"compile-watch": "npm run webpack-watch",
"watch": "tsc -watch -p ./"
},
"devDependencies": {
"@types/minimatch": "^3.0.5",
"@types/node": "^14.0.27",
"@types/vscode": "^1.53.0",
"@typescript-eslint/eslint-plugin": "^4.1.1",
"@typescript-eslint/eslint-plugin-tslint": "^4.20.0",
"@typescript-eslint/parser": "^4.1.1",
"eslint": "^7.9.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^32.3.0",
"prettier": "^2.2.1",
"typescript": "^4.0.2",
"webpack": "^5.28.0",
"webpack-cli": "^4.6.0"
},
"dependencies": {
"json5": "^2.2.0",
"lookpath": "^1.2.0",
"minimatch": "^3.0.4",
"ts-loader": "^8.1.0",
"vsce": "^1.87.1"
},
"extensionDependencies": [
"ms-vscode.cpptools",
"vadimcn.vscode-lldb"
]
}

View file

@ -0,0 +1,25 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"console": "externalTerminal",
"externalConsole": false,
"cwd": "${fileDirname}",
"program": "${fileDirname}/build/Debug/outDebug",
"MIMode": "",
"miDebuggerPath": "",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

View file

@ -0,0 +1,14 @@
{
"configurations": [
{
"name": "",
"includePath": ["${workspaceFolder}/**"],
"compilerPath": "",
"cStandard": "",
"cppStandard": "",
"intelliSenseMode": "",
"compilerArgs": [""]
}
],
"version": 4
}