Skip to content

Commit d742e5b

Browse files
committed
Added installation guide
1 parent 6e63b94 commit d742e5b

File tree

2 files changed

+64
-16
lines changed

2 files changed

+64
-16
lines changed

README.md

+50-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# arduino-cscope-ctags
22

3-
Generating tags of arduino sketch in one command for code tracing.
3+
Generating database of cscope/ctags from Arduino sketch in one command for code tracing.
44

55
## Introduction
66

7-
Arduino is a convenient environment for developing embedding application. Sometimes tracing the code of Arduino core can help us to realize how the lower-level function was implemented and futher assist debugging. However, it's a tough work that tracing code with vanilla Arduino IDE, especially with third party core variants like ESP32.
7+
Arduino is a convenient environment for developing embedding application. On the other hand, tracing the code of Arduino core can help us to realize how the lower-level function was implemented and futher assist us in debugging. However, it's a tough work that tracing code with vanilla Arduino IDE, especially with third party core variants like ESP32.
88
Thus, the purpose of this tool is to simplify the work to generate the symbol database of cscope and ctags from Arduino sketch. Once the database is generated, you can begin tracing the code use cscope/ctags with other text editor like vim, emacs, vscode or sublime text.
99

1010
## How to use
@@ -13,11 +13,26 @@ clear the cache /tmp/arduino-core-cache
1313

1414
## How to install
1515

16-
1. Install python3.6, arduino-cli, cscope and ctags via the package manage of your distrubution.
16+
### Dependencies
17+
18+
This tool depends on python, [arduino-cli](https://github.com/arduino/arduino-cli), [cscope](http://cscope.sourceforge.net/) and [ctags](https://github.com/universal-ctags/ctags).
19+
Specifically, this tool was developed and be tested on the following platform.
20+
21+
- ArchLinux 5.11.16-arch1-1
22+
- Python 3.6
23+
- Arduino-cli 0.18.3
24+
- Cscope 15.9
25+
- Universal Ctags 5.9.0
26+
27+
It shouldn't be any problem if you are using Linux based operating system and python 3.6~3.9. But working on other platform is not guaranteed. If you are encounting any problem to get this tool work, please kindly let me know. The contacting informations are listed below.
28+
29+
### Installing instruction
30+
31+
1. Install python3.6, arduino-cli, cscope and ctags via the package manager of your distrubution.
1732
2. Download the source code of this project.
1833

1934
```bash
20-
git clone https://github.io/ifTNT/arduino-cscope-ctags/arduino-cscope-ctags.git
35+
git clone https://github.com/ifTNT/arduino-cscope-ctags.git
2136
cd arduino-cscope-ctags/
2237
```
2338

@@ -27,19 +42,43 @@ cd arduino-cscope-ctags/
2742
sudo pip install -r requirements.txt
2843
```
2944

30-
4. Copy the executable to the system directory.
45+
4. Enable executing flag of the main program.
46+
47+
```bash
48+
chmod +x arduino-cscope-ctags
49+
```
50+
51+
5. Copy the executable to the system directory.
3152

3253
```bash
3354
sudo cp arduino-cscope-ctags /usr/local/bin/
3455
```
3556

36-
5. Enjoy hacking!
57+
6. Enjoy hacking!
3758

38-
### Dependencies
59+
## Command-line arguments
60+
61+
Usage:
62+
63+
```bash
64+
arduino-cscope-ctags [-h] [-o DB_OUTPUT] fqbn sketch_path
65+
```
3966

40-
python 3.6
41-
arduino-cli 0.18.3
42-
Universal Ctags 5.9.0
43-
cscope 15.9
67+
### Positional arguments
68+
69+
- fqbn : The Fully Qualified Board Name (FQBN) of your target board. It can be obtained by command `arduino-cli board listall`. e.g.: arduino:avr:uno
70+
- sketch_path : The path to your Arduino sketch. Must containing at least one '.ino' file.
71+
72+
### Optional arguments
73+
74+
- -h, --help : show this help message and exit
75+
- -o DB_OUTPUT, --db-output DB_OUTPUT
76+
- The base output folder related to your sketch directory. Default is the '.tags' folder in your sketch directory.
4477

4578
## How to contribute
79+
80+
Any contribution are welcomed.
81+
If you encounterd some problem, make a issue on GitHub and we will help you as soon as possible.
82+
If you have any idea to improve this tool, please let us know through the issue or pull request functionality on GitHub.
83+
Cause the tested platforms are limited. If this tool works fine on your platform, please create an issue on GitHub with the detailed version of your platform.
84+
You can also contact us via the e-mail _iftnt1999 [at] gmail.com_. We will apprciate if hearing any feedback from you.

arduino-cscope-ctags

+14-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import json
66
from pathlib import Path
77
import re
88
import itertools
9+
import argparse
910

1011
# The location to storage intermediate data
1112
build_temp_dir = Path("/tmp/arduino-cscope-ctags")
@@ -20,15 +21,15 @@ def get_header_list(path):
2021
files = list(Path(path).rglob(target_file_regex))
2122
return [get_abs_path(path) for path in files]
2223

23-
def main(board_fqbn, sketch_path):
24+
def main(board_fqbn, sketch_path, db_output_path):
2425
# Ensure sketch_path is a path object
2526
sketch_path = Path(sketch_path)
2627
# The path of compile commands file generated by arduino-cli
2728
compile_command_path= build_temp_dir/"compile_commands.json"
2829
# The intermediate file that storages the list of included files
2930
including_list_path = build_temp_dir/"includes.list"
3031
# The target path of tag databases
31-
database_path = sketch_path/".tags"
32+
database_path = sketch_path/db_output_path
3233
cscope_database_path = database_path/"cscope.out"
3334
ctags_database_path = database_path/"ctags"
3435

@@ -118,6 +119,14 @@ def main(board_fqbn, sketch_path):
118119
print("\nAll done successfully\n")
119120

120121
if __name__ == "__main__":
121-
board_fqbn = sys.argv[1]
122-
sketch_path = sys.argv[2]
123-
main(board_fqbn, sketch_path)
122+
# Parse the command-line argument
123+
parser = argparse.ArgumentParser()
124+
parser.add_argument("-o", "--db-output", help="The base output folder related to your sketch directory. Default is the '.tags' folder in your sketch directory.", default=".tags")
125+
parser.add_argument("fqbn", help="The Fully Qualified Board Name (FQBN) of your target board. It can be obtained by command `arduino-cli board listall`. e.g.: arduino:avr:uno")
126+
parser.add_argument("sketch_path", help="The path to your Arduino sketch. Must containing at least one '.ino' file.")
127+
args = parser.parse_args()
128+
129+
if not Path(args.sketch_path).is_dir():
130+
print(f"{args.sketch_path} is not a directory. Please check whether it had been existed.")
131+
else:
132+
main(args.fqbn, args.sketch_path, args.db_output)

0 commit comments

Comments
 (0)