Skip to content

Commit 360db6f

Browse files
authored
Merge pull request #502 from tuna-f1sh/master
Support for generation of project tags file
2 parents 983db51 + 73426bc commit 360db6f

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

Arduino.mk

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,22 @@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(COMMON_DEPS)
13091309
@$(MKDIR) $(dir $@)
13101310
$(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@
13111311

1312+
########################################################################
1313+
# Ctags
1314+
1315+
# Assume ctags is on path unless has been specified
1316+
ifndef CTAGS_EXEC
1317+
CTAGS_EXEC = ctags
1318+
endif
1319+
1320+
# Default to 'tags' unless user has specified a tags file
1321+
ifndef TAGS_FILE
1322+
TAGS_FILE = tags
1323+
endif
1324+
1325+
# ctags command: append, flags unsort (as will be sorted after) and specify filename
1326+
CTAGS_CMD = $(CTAGS_EXEC) $(CTAGS_OPTS) -auf
1327+
13121328
########################################################################
13131329
# Avrdude
13141330

@@ -1564,6 +1580,23 @@ generate_assembly: $(OBJDIR)/$(TARGET).s
15641580
generated_assembly: generate_assembly
15651581
@$(ECHO) "\"generated_assembly\" target is deprecated. Use \"generate_assembly\" target instead\n\n"
15661582

1583+
.PHONY: tags
1584+
tags:
1585+
ifneq ($(words $(wildcard $(TAGS_FILE))), 0)
1586+
rm -f $(TAGS_FILE)
1587+
endif
1588+
@$(ECHO) "Generating tags for local sources (INO an PDE files as C++): "
1589+
$(CTAGS_CMD) $(TAGS_FILE) --langmap=c++:.ino --langmap=c++:.pde $(LOCAL_SRCS)
1590+
ifneq ($(words $(ARDUINO_LIBS)), 0)
1591+
@$(ECHO) "Generating tags for project libraries: "
1592+
$(CTAGS_CMD) $(TAGS_FILE) $(foreach lib, $(ARDUINO_LIBS),$(USER_LIB_PATH)/$(lib)/*)
1593+
endif
1594+
@$(ECHO) "Generating tags for Arduino core: "
1595+
$(CTAGS_CMD) $(TAGS_FILE) $(ARDUINO_CORE_PATH)/*
1596+
@$(ECHO) "Sorting..\n"
1597+
@sort $(TAGS_FILE) -o $(TAGS_FILE)
1598+
@$(ECHO) "Tag file generation complete, output: $(TAGS_FILE)\n"
1599+
15671600
help_vars:
15681601
@$(CAT) $(ARDMK_DIR)/arduino-mk-vars.md
15691602

@@ -1595,6 +1628,7 @@ help:
15951628
generated assembly of the main sketch.\n\
15961629
make burn_bootloader - burn bootloader and fuses\n\
15971630
make set_fuses - set fuses without burning bootloader\n\
1631+
make tags - generate tags file including project libs and Arduino core\n\
15981632
make help_vars - print all variables that can be overridden\n\
15991633
make help - show this help\n\
16001634
"

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
1010
- Tweak: Set ARDMK_VERSION to 1.6 (https://github.com/sej7278)
1111
- Tweak: Move non-standard-related items from CxxFLAGS_STD to CxxFLAGS (issue #523) (https://github.com/sej7278)
1212
- New: Added -fdiagnostics-color to *STD flags (https://github.com/sej7278)
13+
- New: Add generation of tags file using ctags, which automatically includes project libs and Arduino core. (https://github.com/tuna-f1sh)
1314

1415
### 1.6.0 (2017-07-11)
1516
- Fix: Allowed for SparkFun's weird usb pid/vid submenu shenanigans (issue #499). (https://github.com/sej7278)

arduino-mk-vars.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The following are the different variables that can be overwritten in the user ma
1111
* [Avrdude setting variables](#avrdude-setting-variables)
1212
* [Bootloader variables](#bootloader-variables)
1313
* [ChipKIT variables](#chipkit-variables)
14+
* [Ctags variables](#ctags-variables)
1415

1516
## Global variables
1617

@@ -1404,6 +1405,57 @@ MPIDE_DIR = $(HOME)/mpide
14041405

14051406
----
14061407

1408+
## Ctags variables
1409+
1410+
### TAGS_FILE
1411+
1412+
**Description:**
1413+
1414+
Output file name for tags. Defaults to 'tags'.
1415+
1416+
**Example:**
1417+
1418+
```Makefile
1419+
TAGS_FILE = .tags
1420+
```
1421+
1422+
**Requirement:** *Optional*
1423+
1424+
----
1425+
1426+
### CTAGS_OPTS
1427+
1428+
**Description:**
1429+
1430+
Additional options to pass to `ctags` command.
1431+
1432+
**Example:**
1433+
1434+
```Makefile
1435+
# Run ctags in verbose mode
1436+
CTAGS_OPTS = -V
1437+
```
1438+
1439+
**Requirement:** *Optional*
1440+
1441+
----
1442+
1443+
### CTAGS_CMD
1444+
1445+
**Description:**
1446+
1447+
Location of `ctags` binary. Defaults to user path.
1448+
1449+
**Example:**
1450+
1451+
```Makefile
1452+
CTAGS_CMD = /usr/local/bin/
1453+
```
1454+
1455+
**Requirement:** *Optional*
1456+
1457+
----
1458+
14071459
### MPIDE_PREFERENCES_PATH
14081460

14091461
**Description:**

0 commit comments

Comments
 (0)