makefile 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #
  2. # LUFA Library
  3. # Copyright (C) Dean Camera, 2018.
  4. #
  5. # dean [at] fourwalledcubicle [dot] com
  6. # www.lufa-lib.org
  7. #
  8. # ---------------------------------------
  9. # Makefile for the LUFA Atmel Studio Integration.
  10. # ---------------------------------------
  11. LUFA_ROOT := ..
  12. LUFA_VERSION_NUM := $(shell grep -e "\#define *LUFA_VERSION_STRING " $(LUFA_ROOT)/Version.h | cut -d'"' -f2)
  13. LUFA_VERSION_TYPE := $(shell grep -e "\#define *LUFA_VERSION_RELEASE_TYPE " $(LUFA_ROOT)/Version.h)
  14. ifneq ($(findstring LUFA_VERSION_RELEASE_TYPE_DEVELOPMENT, $(LUFA_VERSION_TYPE)),LUFA_VERSION_RELEASE_TYPE_DEVELOPMENT)
  15. EXT_VERSION_NUM := $(shell date +"%y.%m.%d").$(LUFA_VERSION_NUM)
  16. EXT_VSIX_NAME := LUFA-RELEASE-$(LUFA_VERSION_NUM).vsix
  17. else
  18. EXT_VERSION_NUM := 0.$(shell date +"%y%m%d.%H%M%S")
  19. EXT_VSIX_NAME := LUFA-TESTING-$(shell date +"%y.%m.%d-%H.%M.%S").vsix
  20. $(warning Development mode set - assuming a test version should be created.)
  21. endif
  22. DOXYGEN_TAG_FILE_XML := $(LUFA_ROOT)/Documentation/lufa_doc_tags.xml
  23. DOXYGEN_COMBINED_XML := $(LUFA_ROOT)/Documentation/xml/lufa_doc.xml
  24. TEMP_MANIFEST_XML := manifest.xml
  25. EXTENSION_OUTPUT_XML := $(LUFA_ROOT)/../extension.xml
  26. MODULE_OUTPUT_XML := $(LUFA_ROOT)/asf.xml
  27. MSHELP_OUTPUT_XML := $(LUFA_ROOT)/../lufa_help_$(subst .,_,$(EXT_VERSION_NUM)).mshc
  28. XML_FILES := $(filter-out $(TEMP_MANIFEST_FILE), $(shell ls *.xml))
  29. VSIX_ASSETS := $(LUFA_ROOT)/DoxygenPages/Images/LUFA_thumb.png \
  30. $(LUFA_ROOT)/DoxygenPages/Images/LUFA.png \
  31. $(LUFA_ROOT)/License.txt \
  32. VSIX/"[Content_Types].xml" \
  33. VSIX/LUFA.dll \
  34. VSIX/LUFA.pkgdef
  35. VSIX_GEN_PARAMS := --stringparam extension-version "$(EXT_VERSION_NUM)" \
  36. --stringparam lufa-version "$(LUFA_VERSION_NUM)" \
  37. --stringparam help-package-filename "$(notdir $(MSHELP_OUTPUT_XML))"
  38. MSHELP_GEN_PARAMS := --stringparam generate.toc "book toc" \
  39. --stringparam chunk.quietly "1" \
  40. --stringparam chunk.section.depth "3" \
  41. --stringparam chunk.first.sections "1" \
  42. --stringparam chapter.autolabel "0" \
  43. --stringparam root.filename "LUFA" \
  44. --stringparam html.stylesheet "lufa_studio_help_styling.css"
  45. all: clear_project_dirs generate_xml check_filenames generate_vsix
  46. clear_project_dirs:
  47. @make -s -C $(LUFA_ROOT)/.. clean
  48. clean:
  49. @rm -f $(TEMP_MANIFEST_XML) $(MODULE_OUTPUT_XML) $(EXTENSION_OUTPUT_XML) $(DOXYGEN_TAG_FILE_XML) $(DOXYGEN_COMBINED_XML) $(MSHELP_OUTPUT_XML)
  50. @rm -rf mshelp
  51. @cd $(LUFA_ROOT)/.. && rm -f contents.zip exampleProjects.xml content.xml.cache extension.vsixmanifest asf-manifest.xml extension.xml helpcontentsetup.msha $(notdir $(VSIX_ASSETS)) *.vsix *.mshc
  52. $(DOXYGEN_TAG_FILE_XML):
  53. @make -C ../ doxygen DOXYGEN_OVERRIDE_PARAMS="GENERATE_TAGFILE=Documentation/lufa_doc_tags.xml GENERATE_HTML=no GENERATE_XML=yes"
  54. $(DOXYGEN_COMBINED_XML): $(DOXYGEN_TAG_FILE_XML)
  55. @xsltproc $(dir $@)/combine.xslt $(dir $@)/index.xml > $(DOXYGEN_COMBINED_XML)
  56. $(TEMP_MANIFEST_XML): $(DOXYGEN_TAG_FILE_XML) $(DOXYGEN_COMBINED_XML)
  57. @echo Generating temporary module manifest XML...
  58. @printf "<lufa-manifest version=\"%s\" tagfile=\"%s\" docfile=\"%s\">\n" $(LUFA_VERSION_NUM) $(DOXYGEN_TAG_FILE_XML) $(DOXYGEN_COMBINED_XML) > $@
  59. @for i in $(XML_FILES); do \
  60. printf "\t<xml-source filename=\"%s\"/>\n" $$i >> $@; \
  61. done;
  62. @echo '</lufa-manifest>' >> $@
  63. $(MODULE_OUTPUT_XML): $(TEMP_MANIFEST_XML)
  64. @echo Generating library core XDK module manifest file...
  65. @xsltproc XDK/lufa_module_transform.xslt $< | xsltproc XDK/lufa_indent_transform.xslt - > $(MODULE_OUTPUT_XML)
  66. $(EXTENSION_OUTPUT_XML): $(TEMP_MANIFEST_XML)
  67. @echo Generating library XDK extension manifest file...
  68. @xsltproc XDK/lufa_extension_transform.xslt $< | xsltproc XDK/lufa_indent_transform.xslt - > $(EXTENSION_OUTPUT_XML)
  69. $(MSHELP_OUTPUT_XML): $(DOXYGEN_COMBINED_XML)
  70. @echo Converting Doxygen XML to DocBook...
  71. @-mkdir mshelp 2> /dev/null
  72. @xsltproc HV1/lufa_docbook_transform.xslt $(DOXYGEN_COMBINED_XML) > mshelp/lufa_docbook.xml
  73. @echo Converting DocBook XML to Microsoft Help 1.0...
  74. @cd mshelp && xsltproc $(MSHELP_GEN_PARAMS) ../HV1/lufa_hv1_transform.xslt lufa_docbook.xml
  75. @echo Copying help assets...
  76. @cp HV1/lufa_studio_help_styling.css mshelp
  77. @-mkdir mshelp/images 2> /dev/null
  78. @cp `find $(LUFA_ROOT)/DoxygenPages/Images -type f` mshelp/images
  79. @echo Archiving help content...
  80. @cd mshelp && zip ../$(MSHELP_OUTPUT_XML) -q -0 -r *.html *.css images
  81. @echo Generating HV1 manifest...
  82. @xsltproc $(VSIX_GEN_PARAMS) HV1/lufa_helpcontentsetup_transform.xslt HV1/helpcontentsetup.msha > $(LUFA_ROOT)/../helpcontentsetup.msha
  83. generate_help: $(MSHELP_OUTPUT_XML)
  84. generate_xml: $(EXTENSION_OUTPUT_XML) $(MODULE_OUTPUT_XML)
  85. generate_vsix: $(EXTENSION_OUTPUT_XML) $(MODULE_OUTPUT_XML) $(MSHELP_OUTPUT_XML)
  86. @echo Generating XDK cache files...
  87. @rm -f $(LUFA_ROOT)/../content.xml.cache
  88. @rm -f $(LUFA_ROOT)/../ExampleProjects.xml
  89. @python VSIX/generate_caches.py $(LUFA_ROOT)/../
  90. @echo Archiving XDK content...
  91. @rm -f contents.zip
  92. @cd $(LUFA_ROOT)/../ && zip contents.zip -q -0 -r --exclude=*Documentation* --exclude=*StudioIntegration* LUFA Bootloaders Demos Projects README.txt
  93. @echo Creating VSIX dependencies...
  94. @cp $(VSIX_ASSETS) $(LUFA_ROOT)/..
  95. @xsltproc $(VSIX_GEN_PARAMS) VSIX/lufa_vsmanifest_transform.xslt VSIX/extension.vsixmanifest > $(LUFA_ROOT)/../extension.vsixmanifest
  96. @xsltproc $(VSIX_GEN_PARAMS) VSIX/lufa_asfmanifest_transform.xslt VSIX/asf-manifest.xml > $(LUFA_ROOT)/../asf-manifest.xml
  97. @echo Generating Atmel Studio VSIX file...
  98. cd $(LUFA_ROOT)/../ && zip $(EXT_VSIX_NAME) -q -9 contents.zip exampleProjects.xml content.xml.cache extension.vsixmanifest asf-manifest.xml extension.xml helpcontentsetup.msha $(notdir $(MSHELP_OUTPUT_XML)) $(notdir $(VSIX_ASSETS))
  99. @echo "Atmel Studio VSIX extension file generated."
  100. check_filenames: $(MODULE_OUTPUT_XML)
  101. @echo Verifying referenced filenames of XDK modules...
  102. @for f in `find $(LUFA_ROOT)/../ -name "asf.xml"`; do \
  103. echo "Checking $$f..."; \
  104. asf_file_dir=`dirname $$f`; \
  105. xsltproc XDK/lufa_filelist_transform.xslt $$f | sed -e "/^$$/d" | while read -r i; do \
  106. if ( ( ! test -f "$$asf_file_dir/$$i" ) && ( ! test -d "$$asf_file_dir/$$i" ) ); then \
  107. echo "Source file \"$$i\" referenced in $$f does not exist!"; \
  108. exit 1; \
  109. fi; \
  110. done || exit 1; \
  111. done;
  112. check_database:
  113. python ProjectGenerator/project_generator.py -b $(LUFA_ROOT)/../ --main-ext-uuid=0e160d5c-e331-48d9-850b-e0387912171b CHECK
  114. .PHONY: all clean generate_help generate_xml generate_vsix check_filenames check_database