Skip to content

Commit

Permalink
Add sym addr generation for doxygen (#504)
Browse files Browse the repository at this point in the history
* Add doxygen gen for syms
  • Loading branch information
MegaMech committed Dec 24, 2023
1 parent b7b494f commit bd32f31
Show file tree
Hide file tree
Showing 4 changed files with 21,351 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,8 @@ WARN_LOGFILE =
# Note: If this tag is empty the current directory is searched.

INPUT = src/ \
include/
include/ \
tools/doxygen_syms.txt

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ $(ROM): $(ELF)
$(call print,Building ROM:,$<,$@)
$(V)$(OBJCOPY) $(OBJCOPYFLAGS) $< $(@:.z64=.bin) -O binary
$(V)$(N64CKSUM) $(@:.z64=.bin) $@
$(PYTHON) tools/doxygen_symbol_gen.py

$(BUILD_DIR)/$(TARGET).hex: $(TARGET).z64
xxd $< > $@
Expand Down
47 changes: 47 additions & 0 deletions tools/doxygen_symbol_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
def process_map_file(map_file_path):
result = (
"/**\n"
" * @page memory_addresses Memory Addresses\n"
" * This page displays the memory addresses of variables in the project.\n"
" *\n"
" * @section sec_addresses Memory Addresses\n"
" * The following table shows the memory addresses of important variables:\n"
" * | Variable Name | Memory Address |\n"
)

with open(map_file_path, 'r') as file:
for line in file:
# Check if the line starts with a memory address (e.g., 0x)
if line.strip().startswith("0x"):
# Split the line into tokens
tokens = line.split()

# Ensure there are enough tokens to extract address and function name
if len(tokens) >= 2:
address = f"0x{tokens[0][2:].upper()}"
function_name = tokens[-1]

# Format the information into the Doxygen style
result += f" * | {function_name} | {address} |\n"

result += (
" *\n"
" * @note This information is generated during the compilation process.\n"
" */\n"
)

return result


if __name__ == "__main__":
map_file_path = "../build/us/mk64.us.map"
doxygen_formatted_content = process_map_file(map_file_path)

# Specify the output file path
output_file_path = "doxygen_syms.txt"

# Write the result to the output file
with open(output_file_path, 'w') as output_file:
output_file.write(doxygen_formatted_content)

print(f"Output written to: {output_file_path}")
Loading

0 comments on commit bd32f31

Please sign in to comment.