aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Arduino.mk32
-rw-r--r--HISTORY.md1
-rw-r--r--arduino-mk-vars.md52
3 files changed, 85 insertions, 0 deletions
diff --git a/Arduino.mk b/Arduino.mk
index 5b0af0f..8dfd9c5 100644
--- a/Arduino.mk
+++ b/Arduino.mk
@@ -1308,6 +1308,22 @@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(COMMON_DEPS)
$(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@
########################################################################
+# Ctags
+
+# Assume ctags is on path unless has been specified
+ifndef CTAGS_EXEC
+ CTAGS_EXEC = ctags
+endif
+
+# Default to 'tags' unless user has specified a tags file
+ifndef TAGS_FILE
+ TAGS_FILE = tags
+endif
+
+# ctags command: append file with user options before
+CTAGS_CMD = $(CTAGS_EXEC) $(CTAGS_OPTS) -auf
+
+########################################################################
# Avrdude
# If avrdude is installed separately, it can find its own config file
@@ -1562,6 +1578,21 @@ generate_assembly: $(OBJDIR)/$(TARGET).s
generated_assembly: generate_assembly
@$(ECHO) "\"generated_assembly\" target is deprecated. Use \"generate_assembly\" target instead\n\n"
+.PHONY: tags
+tags:
+ rm -f $(shell pwd)/$(TAGS_FILE)
+ @$(ECHO) "Generating tags for source files: "
+ $(CTAGS_CMD) $(TAGS_FILE) $(shell find "`pwd`" -name "*.cpp" -o -name "*.h" -o -name "*.c")
+ @$(ECHO) "Generating tags for IDO an PDE files as C++: "
+ $(CTAGS_CMD) $(TAGS_FILE) --langmap=c++:.ino --langmap=c++:.pde $(shell find "`pwd`" -name "*.ino" -o -name "*.pde")
+ @$(ECHO) "Generating tags for project libraries: "
+ $(CTAGS_CMD) $(TAGS_FILE) $(foreach lib, $(ARDUINO_LIBS),$(USER_LIB_PATH)/$(lib)/*)
+ @$(ECHO) "Generating tags for Arduino core: "
+ $(CTAGS_CMD) $(TAGS_FILE) $(ARDUINO_CORE_PATH)/*
+ @$(ECHO) "Sorting..\n"
+ @sort $(TAGS_FILE) -o $(TAGS_FILE)
+ @$(ECHO) "Tag file generation complete, output: $(TAGS_FILE)"
+
help_vars:
@$(CAT) $(ARDMK_DIR)/arduino-mk-vars.md
@@ -1593,6 +1624,7 @@ help:
generated assembly of the main sketch.\n\
make burn_bootloader - burn bootloader and fuses\n\
make set_fuses - set fuses without burning bootloader\n\
+ make tags - generate tags file including project libs and Arduino core\n\
make help_vars - print all variables that can be overridden\n\
make help - show this help\n\
"
diff --git a/HISTORY.md b/HISTORY.md
index c35d3f8..34bb516 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -13,6 +13,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
- New: Add support for good old cu as monitor command (issue #492) (https://github.com/mwm)
- Tweak: Removed tilde from documentation (issue #497). (https://github.com/sej7278)
- New: Add a documentation how to setup Makefile for 3rd party boards (issue #499). (https://github.com/MilanV)
+- New: Add generation of tags file using ctags, which automatically includes project libs and Arduino core. (https://github.com/tuna-f1sh)
### 1.5.2 (2017-01-11)
diff --git a/arduino-mk-vars.md b/arduino-mk-vars.md
index 0df7a11..bef58bd 100644
--- a/arduino-mk-vars.md
+++ b/arduino-mk-vars.md
@@ -11,6 +11,7 @@ The following are the different variables that can be overwritten in the user ma
* [Avrdude setting variables](#avrdude-setting-variables)
* [Bootloader variables](#bootloader-variables)
* [ChipKIT variables](#chipkit-variables)
+* [Ctags variables](#ctags-variables)
## Global variables
@@ -1402,6 +1403,57 @@ MPIDE_DIR = $(HOME)/mpide
----
+## Ctags variables
+
+### TAGS_FILE
+
+**Description:**
+
+Output file name for tags. Defaults to 'tags'.
+
+**Example:**
+
+```Makefile
+TAGS_FILE = .tags
+```
+
+**Requirement:** *Optional*
+
+----
+
+### CTAGS_OPTS
+
+**Description:**
+
+Additional options to pass to `ctags` command.
+
+**Example:**
+
+```Makefile
+# Run ctags in verbose mode
+CTAGS_OPTS = -V
+```
+
+**Requirement:** *Optional*
+
+----
+
+### CTAGS_CMD
+
+**Description:**
+
+Location of `ctags` binary. Defaults to user path.
+
+**Example:**
+
+```Makefile
+CTAGS_CMD = /usr/local/bin/
+```
+
+**Requirement:** *Optional*
+
+----
+
### MPIDE_PREFERENCES_PATH
**Description:**