You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/vscode.md
+28-32Lines changed: 28 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,19 @@
1
1
# Configuring Visual Studio Code
2
2
3
-
Visual Studio is a free code editor, which runs on the macOS, Linux, and Windows operating systems.
4
-
5
-
It has nice tooling for Python and C++ development, visual debugger, git integration, and many more
6
-
useful features. It is a great editor to use for TensorFlow IO development, but it takes some effort
7
-
to configure it properly. VSCode configuration is very flexible, it allows compiling project using
8
-
bazel, and running code under Python and C++ debuggers. This manual is for Linux, other OSes
9
-
might have specifics, but approach should be similar.
10
-
3
+
Visual Studio Code (VSCode) is a free code editor, which runs on the macOS, Linux, and Windows operating systems. It has elegent tooling support which supports Python & C++ development, visual debugging, integration with git and many more interesting features. Owing to the ease of use and extension management, it is a great editor for TensorFlow IO development. However, some effort is necessary
4
+
to configure it properly. Since VSCode configuration is very flexible, it allows developers to
5
+
compile project using bazel and run the code under Python and C++ debuggers. The base tool setup might differ based on the operation systems, but the configuration approach should be similar.
11
6
12
7
## Extensions
13
-
To install an extension click the extensions view icon (Extensions) on the Sidebar, or use the shortcut Ctrl+Shift+X.
14
-
Then searh for keyword below.
8
+
9
+
To install an extension click the extensions view icon (Extensions) on the Sidebar, or use the shortcut Ctrl+Shift+X. Then searh for keyword below.
15
10
16
11
-[C/C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) - Official C++ extension from Microsoft
17
12
-[Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) - Official Python extension from Microsoft
18
13
-[Python Extension Pack](https://marketplace.visualstudio.com/items?itemName=donjayamanne.python-extension-pack) - another useful extension for Python development
19
14
20
15
## Compiling projects
16
+
21
17
TensorFlow IO is compiled using bazel build command:
22
18
23
19
```sh
@@ -28,9 +24,9 @@ See project [README](https://github.com/tensorflow/io#ubuntu-18042004) file for
28
24
--compilation_mode dbg flag here indicates that produced binary should have debug symbols.
29
25
Once you can compile project from command line, you can also configure VSCode to be able to invoke same command.
30
26
31
-
Open View->Command Pallete (Ctrl+Shift+P) and start typing: "Tasks: Configure Build Task".
27
+
Open View->Command Pallete (**Ctrl+Shift+P**) and start typing: "Tasks: Configure Build Task".
32
28
If you are doing this for the first time, editor is going to suggest creating tasks.json file.
33
-
Once you have it, paste following json:
29
+
Once you have it, paste the following json:
34
30
35
31
```jsonc
36
32
{
@@ -50,29 +46,28 @@ Once you have it, paste following json:
50
46
}
51
47
```
52
48
53
-
Now, you can press "Ctrl+Shift+B", and VSCode is going to use the command above to build the project.
54
-
It uses its own terminal window, where all links are clickable. So when compilation error occurs, you can
55
-
just click the link, and editor will open corresponding file and navigate to the line.
49
+
Now, you can press **Ctrl+Shift+B**, and VSCode is going to use the command above to build the project.
50
+
It uses its own terminal window, where all links are clickable. So when a compilation error occurs, you open the corresponding file and navigate to the line by just clicking on the link in the terminal window.
56
51
57
52
## Debugging projects
58
-
Debugging Python code is trivial, follow official documentation to figure out how to configure VSCode to enable that: https://code.visualstudio.com/docs/python/debugging
59
-
Debugging C++ code requires GDB to be installed on your system.
60
-
If you have a bq_sample_read.py python script that is using tensorflow-io library that is normally
61
-
executed like:
53
+
54
+
Debugging Python code is trivial, follow official documentation to figure out how to configure VSCode to enable that: https://code.visualstudio.com/docs/python/debugging.
55
+
56
+
However, debugging C++ code requires [GDB](https://www.gnu.org/software/gdb/) to be installed on your system. If you have a `bq_sample_read.py` python script that uses `tensorflow-io` library and is normally executed in the follow manner:
57
+
62
58
```sh
63
59
python3 bq_sample_read.py --gcp_project_id=...
64
60
```
65
61
66
-
In order to execute it under GDB, run following:
62
+
You can execute it under GDB using the following:
63
+
67
64
```sh
68
65
gdb -ex r --args python3 bq_sample_read.py --gcp_project_id=...
69
66
```
70
67
71
-
If application crashes in C++ code, you can run ```backtrace``` in GDB console to get stacktrace.
68
+
If the application crashes in the C++ code phase, you can run ```backtrace``` in GDB console to get the stacktrace of the error.
72
69
73
-
VSCode also has GDB debugger support, it allows adding breakpoints, see values of variables and step through the code.
74
-
To add debug configuration press the Debug View icon (Debug) on the Sidebar, or use the shortcut Ctrl+Shift+D. Here press the little down arrow next to the play button and select "Add Configuration...".
75
-
It will create launch.json file, add following config here:
70
+
VSCode also has GDB debugger support. It allows adding breakpoints, observe values of variables and step through the code in a step by step manner. To add debug configuration press the Debug View icon (Debug) on the Sidebar, or use the shortcut **Ctrl+Shift+D**. Here, press the little down arrow next to the play button and select "Add Configuration...". It will now create a `launch.json` file, to which, please add the following config:
76
71
77
72
```jsonc
78
73
{
@@ -107,28 +102,29 @@ It will create launch.json file, add following config here:
107
102
}
108
103
```
109
104
110
-
If everything is configured correctly, you should be able to do Run -> Start Debugging (F5) or Run -> Run Without Debugging (Ctrl + F5). This will run your code under debugger:
105
+
If everything is configured correctly, you should be able to do _Run -> Start Debugging_ (**F5**) or _Run -> Run Without Debugging_ (**Ctrl + F5**). This will run your code under debugger:
111
106
112
107

113
108
114
-
One other thing worth doing to simplify debugging experience is configuting GDB to skip standard C++ libraries, so you don't step into code you don't care about. In order to do this, create ```~/.gdbinit``` file with following content:
109
+
In order to further simplify the debugging experience, you can configure GDB to skip standard C++ libraries. This allows you to ignore the code that you don't care about. To do this, create a ```~/.gdbinit``` file with the following content:
110
+
115
111
```
116
112
skip -gfi /usr/include/c++/*/*/*
117
113
skip -gfi /usr/include/c++/*/*
118
114
skip -gfi /usr/include/c++/*
119
115
```
120
116
121
117
## Formatting files
122
-
You can always reformat C++ or Python file by Right Click -> Format Document (Ctrl + Shift + I), but VSCode uses different style conention. Luckily it is easy to change.
118
+
119
+
You can always reformat C++ or Python file by _Right Click -> Format Document_ (**Ctrl + Shift + I**), but VSCode uses a different style convention. Luckily, it is easy to change.
123
120
124
121
For Python formatting, see https://donjayamanne.github.io/pythonVSCodeDocs/docs/formatting/
125
122
126
-
To configure C++ formatter, do following:
123
+
For C++ formatting, do the following:
127
124
128
-
- Go Preferences -> Settings
129
-
- Search C_Cpp.clang_format_fallbackStyle
130
-
- Modify the file:setting.json directly
131
-
- Add following
125
+
- Go to _Preferences -> Settings_
126
+
- Search for "C_Cpp.clang_format_fallbackStyle"
127
+
- Modify the `file:setting.json` file directly by adding the following content
0 commit comments