naming_output_files.txt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. Naming Output Files
  2. --------------------
  3. This document describes how to cause output files from a build
  4. to be named so that they are related (so one can group them)
  5. but distinguished (so that they don't overwrite each other).
  6. Examples would be logfiles, annotation files, history files etc.
  7. Multiple Builds
  8. ----------------
  9. In a situation where several builds are done, one after the other by
  10. some automation system, the makefiles and log files are named so that
  11. they don't clash - this way it is possible for the logs and makefiles
  12. to be analysed, inspected for errors etc long after the entire sequence
  13. is finished.
  14. Some make engines generate extra output files - not just logs.
  15. e.g annotation files that indicate what happened during a build - from
  16. clashes to timings for each build command.
  17. In these use cases one also needs to be able to produce uniquely named
  18. files so that successive builds can avoid writing over the information
  19. from the previous build.
  20. e.g.
  21. sbs -m ncp_01012010.mk -f ncp_01012010.log -c all_variants
  22. sbs -m dfs_01012010.mk -f dfs_01012010.log -c generic
  23. sbs -m winscw_01012010.mk -f winscw_01012010.log -c winscw
  24. Note that the date is being included in the name so that not only is the
  25. "stage" of each build unique but the overall sequence of builds is also
  26. unique (at least to the resolution of a day).
  27. #MAKEFILE#
  28. -----------
  29. Since Raptor builds in stages (a measure designed to take the pressure
  30. off the build engine by reducing the number of many-to-many dependencies
  31. it has to handle) there are actually 5 makefiles and 5 invocations of
  32. make for every invocation of raptor:
  33. ncp_01012010.mk.export
  34. ncp_01012010.mk.bitmap
  35. ncp_01012010.mk.resource_deps
  36. ncp_01012010.mk.resource
  37. ncp_01012010.mk.default
  38. dfs_01012010.mk.export
  39. dfs_01012010.mk.bitmap
  40. dfs_01012010.mk.resource_deps
  41. dfs_01012010.mk.resource
  42. dfs_01012010.mk.default
  43. winscw_01012010.mk.export
  44. winscw_01012010.mk.bitmap
  45. winscw_01012010.mk.resource_deps
  46. winscw_01012010.mk.resource
  47. winscw_01012010.mk.default
  48. Ask can be seen, Raptor takes the argument to "-m" as a "base" for the
  49. filename of the makefiles it generates.
  50. If we had a hypothetical build engine, called "wmake" for example,
  51. and it offered an annotation feature then we could tell it to create
  52. the annotation files with a unique name by copying the makefile
  53. name we supplied to "-m" e.g.
  54. sbs -e wmake -m ncp_01012010.mk -c all_variants --mo=--annofile=ncp_01012010.anno
  55. This would work badly, however, because Raptor actually runs make 5 times
  56. - once for each stage and each of these stages has a different makefile
  57. with different recipes. Raptor knows how to create unique makefiles
  58. automatically but it doesn't understand the "--annofile" option which is
  59. being passed through to wmake so it has no way of also making that unique.
  60. The annotation file would get overwritten 4 times and we would be left
  61. with only the data from the "default" stage - no annotation data for
  62. "resource" or "bitmap".
  63. So Raptor provides a feature which replaces the string "#MAKEFILE#"
  64. with the full makefile name, including the stage:
  65. sbs -e wmake -m ncp_01012010.mk -c all_variants --mo=--annofile=#MAKEFILE#.anno
  66. This ensures that there are 5 unique annotation files - one for each
  67. stage of the build:
  68. ncp_01012010.mk.export.anno
  69. ncp_01012010.mk.bitmap.anno
  70. ... etc
  71. Date Independent Files - #STAGE#
  72. ---------------------------------
  73. #MAKEFILE# is designed so that the user can make a sequence of builds
  74. include the date and time in all filenames. That makes it possible to
  75. keep logs from successive build attempts in the same directory structure.
  76. In essence a sequence of builds may fail and be restarted and this allows
  77. *all* the logging information to be kept for post-mortem analysis.
  78. #STAGE# is different. It only substitutes the stage name and this is for
  79. files that need to be the same from one attempt to another but where there
  80. must still be one per stage. History files are like this - they are a way for
  81. a build system to remember sequencing problems from the last build and
  82. thereby generate more efficient sequencing in the new one.
  83. e.g.
  84. sbs -e wmake -m ncp_makefile_01012010 -c all_variants --mo=--historyfile=ncp_#STAGE#.history
  85. . . . would generate . . .
  86. ncp_export.history
  87. ncp_default.history
  88. ncp_resource.history
  89. ncp_resource_deps.history
  90. ncp_bitmap.history
  91. Note that the date is included in the makefile name so we get new
  92. makefiles every time but the history files get reused. This is what we
  93. want because history files are a store of knowledge that helps the build
  94. system to learn from one "ncp_resource" (for example) to the next.