compiletools 5.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. compiletools/README.ct-cache-clean.rst +45 -0
  2. compiletools/README.ct-cache.rst +61 -0
  3. compiletools/README.ct-cake.rst +293 -0
  4. compiletools/README.ct-commandline.rst +21 -0
  5. compiletools/README.ct-config.rst +129 -0
  6. compiletools/README.ct-cppdeps.rst +63 -0
  7. compiletools/README.ct-doc.rst +96 -0
  8. compiletools/README.ct-filelist.rst +81 -0
  9. compiletools/README.ct-findtargets.rst +53 -0
  10. compiletools/README.ct-gitroot.rst +41 -0
  11. compiletools/README.ct-headertree.rst +64 -0
  12. compiletools/README.ct-jobs.rst +38 -0
  13. compiletools/README.ct-list-variants.rst +55 -0
  14. compiletools/README.ct-magicflags.rst +101 -0
  15. compiletools/__init__.py +5 -0
  16. compiletools/apptools.py +706 -0
  17. compiletools/cache_clean.py +30 -0
  18. compiletools/cake.py +335 -0
  19. compiletools/compiler_macros.py +74 -0
  20. compiletools/config.py +32 -0
  21. compiletools/configutils.py +331 -0
  22. compiletools/cppdeps.py +39 -0
  23. compiletools/create_cmakelists.py +118 -0
  24. compiletools/ct.conf.d/blank.conf +1 -0
  25. compiletools/ct.conf.d/clang.debug.conf +8 -0
  26. compiletools/ct.conf.d/clang.release.conf +8 -0
  27. compiletools/ct.conf.d/ct.conf +7 -0
  28. compiletools/ct.conf.d/gcc.debug.conf +8 -0
  29. compiletools/ct.conf.d/gcc.release.conf +8 -0
  30. compiletools/dirnamer.py +104 -0
  31. compiletools/diskcache.py +251 -0
  32. compiletools/doc.py +10 -0
  33. compiletools/file_analyzer.py +423 -0
  34. compiletools/filelist.py +193 -0
  35. compiletools/findtargets.py +200 -0
  36. compiletools/git_utils.py +105 -0
  37. compiletools/headerdeps.py +332 -0
  38. compiletools/headertree.py +259 -0
  39. compiletools/hunter.py +134 -0
  40. compiletools/jobs.py +80 -0
  41. compiletools/listvariants.py +163 -0
  42. compiletools/magicflags.py +529 -0
  43. compiletools/makefile.py +701 -0
  44. compiletools/memoize.py +19 -0
  45. compiletools/namer.py +168 -0
  46. compiletools/preprocessor.py +52 -0
  47. compiletools/samples/conditional_includes/linux_header.h +2 -0
  48. compiletools/samples/conditional_includes/main.cpp +9 -0
  49. compiletools/samples/conditional_includes/windows_header.h +2 -0
  50. compiletools/samples/cppflags_macros/aarch64_feature.hpp +4 -0
  51. compiletools/samples/cppflags_macros/advanced_feature.hpp +11 -0
  52. compiletools/samples/cppflags_macros/advanced_preprocessor_header.hpp +39 -0
  53. compiletools/samples/cppflags_macros/advanced_preprocessor_test.cpp +5 -0
  54. compiletools/samples/cppflags_macros/alt_form_feature.hpp +4 -0
  55. compiletools/samples/cppflags_macros/arm_feature.hpp +4 -0
  56. compiletools/samples/cppflags_macros/armcc_feature.hpp +4 -0
  57. compiletools/samples/cppflags_macros/avx2_optimization.hpp +0 -0
  58. compiletools/samples/cppflags_macros/basic_feature.hpp +5 -0
  59. compiletools/samples/cppflags_macros/cache_profiler.hpp +0 -0
  60. compiletools/samples/cppflags_macros/certificate_validation.hpp +0 -0
  61. compiletools/samples/cppflags_macros/cflags_feature.hpp +4 -0
  62. compiletools/samples/cppflags_macros/clang_feature.hpp +4 -0
  63. compiletools/samples/cppflags_macros/combined_features.hpp +4 -0
  64. compiletools/samples/cppflags_macros/compiler_builtin_header.hpp +52 -0
  65. compiletools/samples/cppflags_macros/compiler_builtin_test.cpp +5 -0
  66. compiletools/samples/cppflags_macros/conditional_header.hpp +14 -0
  67. compiletools/samples/cppflags_macros/cppflags_feature.hpp +4 -0
  68. compiletools/samples/cppflags_macros/cpu_profiler.hpp +0 -0
  69. compiletools/samples/cppflags_macros/custom_allocator.hpp +0 -0
  70. compiletools/samples/cppflags_macros/cxxflags_feature.hpp +4 -0
  71. compiletools/samples/cppflags_macros/default_feature.hpp +4 -0
  72. compiletools/samples/cppflags_macros/detailed_profiler.hpp +0 -0
  73. compiletools/samples/cppflags_macros/elif_header.hpp +14 -0
  74. compiletools/samples/cppflags_macros/elif_test.cpp +5 -0
  75. compiletools/samples/cppflags_macros/emscripten_feature.hpp +4 -0
  76. compiletools/samples/cppflags_macros/expert_feature.hpp +8 -0
  77. compiletools/samples/cppflags_macros/expert_mode_base.hpp +0 -0
  78. compiletools/samples/cppflags_macros/fma_optimization.hpp +0 -0
  79. compiletools/samples/cppflags_macros/gcc_feature.hpp +4 -0
  80. compiletools/samples/cppflags_macros/high_optimization.hpp +0 -0
  81. compiletools/samples/cppflags_macros/intel_feature.hpp +4 -0
  82. compiletools/samples/cppflags_macros/leak_detector.hpp +0 -0
  83. compiletools/samples/cppflags_macros/linux_advanced.hpp +8 -0
  84. compiletools/samples/cppflags_macros/linux_epoll_threading.hpp +8 -0
  85. compiletools/samples/cppflags_macros/linux_feature.hpp +4 -0
  86. compiletools/samples/cppflags_macros/main.cpp +5 -0
  87. compiletools/samples/cppflags_macros/memory_profiler.hpp +0 -0
  88. compiletools/samples/cppflags_macros/memory_tracker.hpp +0 -0
  89. compiletools/samples/cppflags_macros/msvc_feature.hpp +4 -0
  90. compiletools/samples/cppflags_macros/multi_flag_header.hpp +16 -0
  91. compiletools/samples/cppflags_macros/multi_flag_test.cpp +5 -0
  92. compiletools/samples/cppflags_macros/nested_macros_header.hpp +200 -0
  93. compiletools/samples/cppflags_macros/nested_macros_test.cpp +5 -0
  94. compiletools/samples/cppflags_macros/networking_base.hpp +0 -0
  95. compiletools/samples/cppflags_macros/numa_threading.hpp +8 -0
  96. compiletools/samples/cppflags_macros/partial_features.hpp +4 -0
  97. compiletools/samples/cppflags_macros/profiling_base.hpp +0 -0
  98. compiletools/samples/cppflags_macros/riscv_feature.hpp +4 -0
  99. compiletools/samples/cppflags_macros/simd_optimization.hpp +0 -0
  100. compiletools/samples/cppflags_macros/ssl_networking.hpp +0 -0
  101. compiletools/samples/cppflags_macros/stack_tracer.hpp +0 -0
  102. compiletools/samples/cppflags_macros/strict_cert_validation.hpp +0 -0
  103. compiletools/samples/cppflags_macros/tcc_feature.hpp +4 -0
  104. compiletools/samples/cppflags_macros/temp_defined.hpp +4 -0
  105. compiletools/samples/cppflags_macros/temp_still_defined.hpp +4 -0
  106. compiletools/samples/cppflags_macros/version1_feature.hpp +4 -0
  107. compiletools/samples/cppflags_macros/version2_feature.hpp +4 -0
  108. compiletools/samples/cppflags_macros/version3_feature.hpp +4 -0
  109. compiletools/samples/cppflags_macros/version_205_plus.hpp +4 -0
  110. compiletools/samples/cppflags_macros/version_ge_2_feature.hpp +4 -0
  111. compiletools/samples/cppflags_macros/windows_advanced.hpp +0 -0
  112. compiletools/samples/cppflags_macros/windows_iocp.hpp +0 -0
  113. compiletools/samples/cppflags_macros/windows_iocp_threading.hpp +0 -0
  114. compiletools/samples/cppflags_macros/x86_64_feature.hpp +4 -0
  115. compiletools/samples/cross_platform/cross_platform.cpp +15 -0
  116. compiletools/samples/cross_platform/cross_platform.hpp +8 -0
  117. compiletools/samples/cross_platform/cross_platform_lin.cpp +7 -0
  118. compiletools/samples/cross_platform/cross_platform_win.cpp +7 -0
  119. compiletools/samples/cross_platform/test_source.cpp +8 -0
  120. compiletools/samples/cycle/cycle_a.hpp +5 -0
  121. compiletools/samples/cycle/cycle_b.hpp +2 -0
  122. compiletools/samples/cycle/cycle_c.hpp +2 -0
  123. compiletools/samples/dottypaths/d1/d1.cpp +6 -0
  124. compiletools/samples/dottypaths/d1/d1.hpp +4 -0
  125. compiletools/samples/dottypaths/d2/d2.cpp +7 -0
  126. compiletools/samples/dottypaths/d2/d2.hpp +3 -0
  127. compiletools/samples/dottypaths/dottypaths.cpp +13 -0
  128. compiletools/samples/factory/a_widget.cpp +9 -0
  129. compiletools/samples/factory/a_widget.hpp +7 -0
  130. compiletools/samples/factory/red_herring_c_style_2.hpp +5 -0
  131. compiletools/samples/factory/test_factory.cpp +24 -0
  132. compiletools/samples/factory/widget.hpp +8 -0
  133. compiletools/samples/factory/widget_factory.cpp +16 -0
  134. compiletools/samples/factory/widget_factory.hpp +38 -0
  135. compiletools/samples/factory/z_widget.cpp +9 -0
  136. compiletools/samples/factory/z_widget.hpp +7 -0
  137. compiletools/samples/feature_headers/database.h +8 -0
  138. compiletools/samples/feature_headers/feature_config.h +15 -0
  139. compiletools/samples/feature_headers/graphics.h +8 -0
  140. compiletools/samples/feature_headers/logging.h +8 -0
  141. compiletools/samples/feature_headers/main.cpp +9 -0
  142. compiletools/samples/feature_headers/networking.h +8 -0
  143. compiletools/samples/ldflags/conditional_ldflags_test.cpp +16 -0
  144. compiletools/samples/ldflags/version_dependent_ldflags.cpp +23 -0
  145. compiletools/samples/ldflags/version_macro.hpp +12 -0
  146. compiletools/samples/library/build.sh +12 -0
  147. compiletools/samples/library/main.cpp +23 -0
  148. compiletools/samples/library/mylib/get_double.cpp +2 -0
  149. compiletools/samples/library/mylib/get_double.hpp +2 -0
  150. compiletools/samples/library/mylib/get_int.cpp +2 -0
  151. compiletools/samples/library/mylib/get_int.hpp +2 -0
  152. compiletools/samples/library/mylib/get_numbers.cpp +5 -0
  153. compiletools/samples/library/mylib/get_numbers.hpp +3 -0
  154. compiletools/samples/lotsofmagic/lotsofmagic.cpp +31 -0
  155. compiletools/samples/macro_deps/feature_header.hpp +9 -0
  156. compiletools/samples/macro_deps/feature_x_impl.cpp +5 -0
  157. compiletools/samples/macro_deps/feature_y_impl.cpp +5 -0
  158. compiletools/samples/macro_deps/main.cpp +6 -0
  159. compiletools/samples/macro_state_dependency/README.md +41 -0
  160. compiletools/samples/macro_state_dependency/debug.h +5 -0
  161. compiletools/samples/macro_state_dependency/feature.h +10 -0
  162. compiletools/samples/macro_state_dependency/release.h +5 -0
  163. compiletools/samples/macro_state_dependency/sample.cpp +5 -0
  164. compiletools/samples/macro_state_dependency/test_macro_state_dependency.py +165 -0
  165. compiletools/samples/magicinclude/main.cpp +18 -0
  166. compiletools/samples/magicinclude/subdir/important.hpp +10 -0
  167. compiletools/samples/magicinclude/subdir2/important2.hpp +10 -0
  168. compiletools/samples/magicinclude/subdir3/important3.hpp +10 -0
  169. compiletools/samples/magicpkgconfig/main.cpp +30 -0
  170. compiletools/samples/magicsourceinheader/include_dir/some_header.hpp +2 -0
  171. compiletools/samples/magicsourceinheader/include_dir/sub_dir/another_header.hpp +7 -0
  172. compiletools/samples/magicsourceinheader/include_dir/sub_dir/the_code_lin.cpp +4 -0
  173. compiletools/samples/magicsourceinheader/include_dir/sub_dir/the_code_win.cpp +4 -0
  174. compiletools/samples/magicsourceinheader/main.cpp +6 -0
  175. compiletools/samples/movingheaders/main.cpp +5 -0
  176. compiletools/samples/movingheaders/someheader.hpp +3 -0
  177. compiletools/samples/nestedconfig/gcc.debug.conf +8 -0
  178. compiletools/samples/nestedconfig/nc.cpp +13 -0
  179. compiletools/samples/nestedconfig/subdir/gcc.debug.conf +8 -0
  180. compiletools/samples/nestedconfig/subdir/nc.cpp +16 -0
  181. compiletools/samples/numbers/get_double.cpp +2 -0
  182. compiletools/samples/numbers/get_double.hpp +2 -0
  183. compiletools/samples/numbers/get_int.cpp +2 -0
  184. compiletools/samples/numbers/get_int.hpp +2 -0
  185. compiletools/samples/numbers/get_numbers.cpp +5 -0
  186. compiletools/samples/numbers/get_numbers.hpp +3 -0
  187. compiletools/samples/numbers/test_direct_include.cpp +11 -0
  188. compiletools/samples/numbers/test_library.cpp +20 -0
  189. compiletools/samples/pkgconfig/main.cpp +29 -0
  190. compiletools/samples/serialise_tests/README.txt +11 -0
  191. compiletools/samples/serialise_tests/createfile.cpp +18 -0
  192. compiletools/samples/serialise_tests/createfile.hpp +3 -0
  193. compiletools/samples/serialise_tests/filename.hpp +3 -0
  194. compiletools/samples/serialise_tests/obtainlock.cpp +33 -0
  195. compiletools/samples/serialise_tests/obtainlock.hpp +3 -0
  196. compiletools/samples/serialise_tests/test_flock_1.cpp +8 -0
  197. compiletools/samples/serialise_tests/test_flock_2.cpp +8 -0
  198. compiletools/samples/simple/helloworld_c.c +15 -0
  199. compiletools/samples/simple/helloworld_cpp.cpp +11 -0
  200. compiletools/samples/simple/test_cflags.c +11 -0
  201. compiletools/simple_preprocessor.py +465 -0
  202. compiletools/test_apptools.py +132 -0
  203. compiletools/test_base.py +146 -0
  204. compiletools/test_cake.py +275 -0
  205. compiletools/test_cap.py +65 -0
  206. compiletools/test_compiler_macros.py +161 -0
  207. compiletools/test_configutils.py +117 -0
  208. compiletools/test_cppdeps.py +45 -0
  209. compiletools/test_environment_assumptions.py +241 -0
  210. compiletools/test_file_analyzer.py +468 -0
  211. compiletools/test_file_analyzer_integration.py +345 -0
  212. compiletools/test_findtargets.py +95 -0
  213. compiletools/test_headerdeps.py +353 -0
  214. compiletools/test_hunter.py +130 -0
  215. compiletools/test_library.py +65 -0
  216. compiletools/test_listvariants.py +41 -0
  217. compiletools/test_macro_state_dependency.py +70 -0
  218. compiletools/test_magicflags.py +168 -0
  219. compiletools/test_magicinclude.py +75 -0
  220. compiletools/test_magicpkgconfig.py +160 -0
  221. compiletools/test_makefile.py +105 -0
  222. compiletools/test_movingheaders.py +54 -0
  223. compiletools/test_namer.py +33 -0
  224. compiletools/test_serialisetests.py +39 -0
  225. compiletools/test_simple_preprocessor.py +347 -0
  226. compiletools/test_timing.py +261 -0
  227. compiletools/test_utils.py +95 -0
  228. compiletools/testhelper.py +516 -0
  229. compiletools/timing.py +190 -0
  230. compiletools/tree.py +99 -0
  231. compiletools/uth_reload.py +18 -0
  232. compiletools/utils.py +158 -0
  233. compiletools/version.py +5 -0
  234. compiletools/wrappedos.py +59 -0
  235. compiletools-5.0.0.dist-info/METADATA +130 -0
  236. compiletools-5.0.0.dist-info/RECORD +238 -0
  237. compiletools-5.0.0.dist-info/WHEEL +4 -0
  238. compiletools-5.0.0.dist-info/entry_points.txt +17 -0
@@ -0,0 +1,45 @@
1
+ ================
2
+ ct-cache-clean
3
+ ================
4
+
5
+ ------------------------------------------------------------------------
6
+ Remove the current dependency cache
7
+ ------------------------------------------------------------------------
8
+
9
+ :Author: drgeoffathome@gmail.com
10
+ :Date: 2018-02-23
11
+ :Copyright: Copyright (C) 2011-2018 Zomojo Pty Ltd
12
+ :Version: 5.0.0
13
+ :Manual section: 1
14
+ :Manual group: developers
15
+
16
+ SYNOPSIS
17
+ ========
18
+ ct-cache-clean [-h] [-v]
19
+
20
+
21
+ DESCRIPTION
22
+ ===========
23
+ In most cases this is just a fancy ``rm -rf <cachedir>``. It is possible for
24
+ different config files to specify different caches (yes this would be
25
+ pathological, but it is possible) so be careful to make sure
26
+ that you are removing the cache you think you are removing. ``ct-cache``
27
+ will answer that question for you.
28
+
29
+ Mostly you will never need this tool. It's primarily for people how need to
30
+ do internal performance testing of parts of the compiletools infrastructure.
31
+
32
+ EXAMPLES
33
+ ========
34
+
35
+ ct-cache-clean
36
+
37
+ ct-cache-clean -v
38
+
39
+ ct-cache-clean -vv
40
+
41
+ export CTCACHE=/dev/shm/ct; ct-cache-clean
42
+
43
+ SEE ALSO
44
+ ========
45
+ ``compiletools`` (1), ``ct-config`` (1), ``ct-cache`` (1)
@@ -0,0 +1,61 @@
1
+ ================
2
+ ct-cache
3
+ ================
4
+
5
+ ------------------------------------------------------------------------
6
+ Where is the dependency information used by the ct-* applications stored
7
+ ------------------------------------------------------------------------
8
+
9
+ :Author: drgeoffathome@gmail.com
10
+ :Date: 2018-02-21
11
+ :Copyright: Copyright (C) 2011-2018 Zomojo Pty Ltd
12
+ :Version: 5.0.0
13
+ :Manual section: 1
14
+ :Manual group: developers
15
+
16
+ SYNOPSIS
17
+ ========
18
+ ct-cache [-h] [--CTCACHE CTCACHE] [-v]
19
+
20
+
21
+ DESCRIPTION
22
+ ===========
23
+ The various ct-* applications need to determine the dependency graph of each
24
+ source file. It is possible to get a minor speed improvement by caching this
25
+ dependency tree. By default caching of dependencies is turned off and
26
+ ct-cache will return "None".
27
+
28
+ ct-cache uses the command line arguments and environment variables to
29
+ determine which dependency cache will be used to store the dependency graph
30
+ of a given file.
31
+
32
+ If you need to set the location of the cache, set the variable ``CTCACHE``
33
+ in one of the config files. For example, the default /etc/xdg/ct/ct.conf uses
34
+ ``CTCACHE=None``.
35
+ Another common usecase is
36
+ ``CTCACHE=/dev/shm/ct``.
37
+
38
+ Increasing the verbosity levels gives more information about how the ct-*
39
+ applications do their search to determine what the cache location should be.
40
+ See the ``ct-config`` manpage for more information about configuration file
41
+ locations.
42
+
43
+ The default cache is set to None due to python recursion limits that will cause
44
+ failure on large projects. Having said that, the author uses
45
+ ``CTCACHE=/dev/shm/ct`` on all their projects. Naturally the cache can be
46
+ specified to be on disk too. The cache can be cleared using ``ct-cache-clean``.
47
+
48
+ EXAMPLES
49
+ ========
50
+
51
+ ct-cache
52
+
53
+ ct-cache -v
54
+
55
+ ct-cache -vv
56
+
57
+ export CTCACHE=/dev/shm/ct; ct-cache
58
+
59
+ SEE ALSO
60
+ ========
61
+ ``compiletools`` (1), ``ct-config`` (1), ``ct-cache-clean`` (1)
@@ -0,0 +1,293 @@
1
+ ============
2
+ ct-cake
3
+ ============
4
+
5
+ ---------------------------------------------
6
+ Swiss army knife for building a C/C++ project
7
+ ---------------------------------------------
8
+
9
+ :Author: drgeoffathome@gmail.com
10
+ :Date: 2018-02-06
11
+ :Copyright: Copyright (C) 2011-2016 Zomojo Pty Ltd
12
+ :Version: 5.0.0
13
+ :Manual section: 1
14
+ :Manual group: developers
15
+
16
+ SYNOPSIS
17
+ ========
18
+ ct-cake [compilation args] [--variant=<VARIANT>] filename.cpp
19
+
20
+ DESCRIPTION
21
+ ===========
22
+ ct-cake is the Swiss army knife of build tools that combines many of the
23
+ compiletools into one uber-tool. For many C/C++ projects you can compile
24
+ simply using
25
+
26
+ ``ct-cake --auto``
27
+
28
+ ct-cake will try to determine the correct source files to generate executables
29
+ from and also determine the tests to build and run. It works by spidering over
30
+ the source code to determine what implementation files to build, what libraries
31
+ to link against and what compiler flags to set. Only build what you
32
+ need, and throw out your Makefiles.
33
+
34
+ The --auto flag tells ct-cake to search for files that will be the "main" file.
35
+ From that set of files, ct-cake then uses the header includes to
36
+ determine what implementation (cpp) files are also required to be built and
37
+ linked into the final executable/s.
38
+
39
+ Cake works off the same principles as Ruby on Rails. It will make your life
40
+ easy if you don't arbitrarily name things. The main rules are:
41
+
42
+ * ct-cake only builds C and C++. Everything can be done just fine with
43
+ other tools, so there's no point reinventing them. Anyway, it's easy to
44
+ embed cake into other toolchains, see the last section.
45
+ * All binaries end up in the bin directory, with the same base name as
46
+ their source filename. You can override this at the command-line, but it's
47
+ against the spirit of the tool.
48
+ * The implementation file for point.hpp should be called point.cpp. This
49
+ is so ct-cake can compile it and recursively hunt down its dependencies.
50
+ * If a header or implementation file will not work without being linked
51
+ with a certain flag, add a //#LDFLAGS=myflag directly to the source code.
52
+ * Likewise, if a special compiler option is needed, use //#CXXFLAGS=myflag.
53
+ * Minimise the use of "-I" include flags. They make it hard not only for
54
+ cake to generate dependencies, but also autocomplete tools like Eclipse
55
+ and ctags. You can avoid -I flags by structuring your code in the same way
56
+ you refer to paths in your source code.
57
+ * Currently only varieties of Linux are actively supported because that's
58
+ what the compiletools developers have easy access to. That said, it stands
59
+ a good chance of working on \*BSD and macOS. We are interested in receiving
60
+ patches for other platforms including Windows.
61
+
62
+ ct-cake works off a "pull" philosophy of building, unlike the "push" model
63
+ of most build processes. Often, there is the monolithic build script that
64
+ rebuilds everything. Users iterate over changing a file, relinking everything
65
+ and then rerunning their binary. A hierarchy of libraries is built up and
66
+ then linked in to the final executables. All of this takes a lot of time,
67
+ particularly for C++.
68
+
69
+ With ct-cake, you only pull in what is strictly necessary to what you need to
70
+ run right now. Say, you are testing a particular tool in a large project, with
71
+ a large base of 2000 library files for string handling, sockets, etc. There
72
+ is simply no Makefile (This is actually a lie, there is a Makefile under the
73
+ hood). You might want to create a build.sh for regression
74
+ testing, but it's not essential.
75
+
76
+ The basic workflow is to simply type:
77
+
78
+ ``ct-cake --auto``
79
+
80
+ If there are multiple executables that --auto finds and you only want to build
81
+ one specific one:
82
+
83
+ ``ct-cake path/to/src/app.cpp``
84
+
85
+ Only the library cpp files that are needed, directly, or indirectly to create
86
+ ./bin/app are actually compiled. If you don't #include anything that refers
87
+ to a library file, you don't pay for it. Also, only the link options that
88
+ are strictly needed to generate the app are included. Its possible to do in
89
+ make files, but such fine-level granularity is rarely set up in practice,
90
+ because its too error-prone to do manually, or with recursive make goodness.
91
+
92
+
93
+ How it Works
94
+ ============
95
+
96
+ ct-cake generates the header dependencies for the "main.cpp"
97
+ file you specify at the command line by either examining the "#include" lines in
98
+ the source code (or by executing "gcc -MM -MF" if you use the --preprocess flag).
99
+ For each header file found in the source file, it looks for
100
+ an underlying implementation (c,cpp,cc,cxx,etc) file with the same name, and
101
+ adds that implementation file to the build. ct-cake also reads the first 8KB
102
+ of each file for special comments
103
+ that indicate needed link and compile flags. Then it recurses through the
104
+ dependencies of the cpp file, and uses this spidering to generate complete
105
+ dependency information for the application. A Makefile is generated and finally
106
+ it calls make.
107
+
108
+ Magic Comments / Magic Flags
109
+ ============================
110
+
111
+ ct-cake works very differently to other build systems, which specify a hierarchy
112
+ of link flags and compile options, because ct-cake ties the compiler flags
113
+ directly to the source code. If you have compress.hpp that requires "-lzip"
114
+ on the link line, add the following comment in the first 8KB of the header file:
115
+
116
+ ``//#LDFLAGS=-lzip``
117
+
118
+ Whenever the header is included (either directly or indirectly), the -lzip
119
+ will be automatically added to the link step. If you stop using the header,
120
+ for a particular executable, cake will figure that out and not link against it.
121
+
122
+ If you want to compile a cpp file with a particular optimization enabled,
123
+ add, say:
124
+
125
+ ``//#CXXFLAGS=-fstrict-aliasing``
126
+
127
+ Because the code and build flags are defined so close to each other, its
128
+ much easier to tweak the compilation locally.
129
+
130
+ Performance
131
+ ===========
132
+
133
+ Because ct-cake internally generates a makefile to build the C++ file, cake is
134
+ about as fast as a handrolled Makefile that uses the same lazily generated
135
+ dependencies. One particular example project took 0.04 seconds to build if
136
+ nothing is out of date, versus 2 seconds for, say, Boost.Build.
137
+
138
+ ct-cake also eliminates the redundant generation of static archive files that
139
+ a more hierarchical build process would generate as intermediaries, saving
140
+ the cost of running 'ar'.
141
+
142
+ Note that ct-cake doesn't build all cpp files that you have checked out, only
143
+ those
144
+ strictly needed to build your particular binary, so you only pay for what
145
+ you use. This difference alone should see a large improvement on most
146
+ projects, especially for incremental rebuilds.
147
+
148
+ Selective build and test
149
+ ========================
150
+
151
+ You can instruct ct-cake to only build binaries dependant on a list of
152
+ source files using the ``--build-only-changed`` flag. This is helpful for
153
+ limiting building and testing in a Continuous Integration pipeline to only
154
+ source that has changed from master.
155
+
156
+ ``changed_source=git diff --name-only master | sed "s,^,$(git rev-parse --show-toplevel)/,"
157
+ ct-cake --auto --build-only-changed \"$changed_source\"``
158
+
159
+ Configuration
160
+ =============
161
+
162
+ The compiletools programs require *almost* no configuration. However, it is
163
+ still
164
+ useful to have some shortcut build templates such as 'release',
165
+ 'profile' etc.
166
+
167
+ Config files for the ct-* applications are programmatically located using
168
+ python-appdirs, which on linux is a wrapper around the XDG specification. Thus
169
+ default locations are /etc/xdb/ct/ and $HOME/.config/ct/. Configuration parsing
170
+ is done using python-configargparse which automatically handles environment
171
+ variables, command line arguments, system configs
172
+ and user configs.
173
+
174
+ Specifically, the config files are searched for in the following locations (from
175
+ lowest to highest priority):
176
+
177
+ * same path as exe,
178
+ * system config (XDG compliant, so usually /etc/xdg/ct)
179
+ * python virtual environment system configs
180
+ (${python-site-packages}/etc/xdg/ct)
181
+ * user config (XDG compliant, so usually ~/.config/ct)
182
+
183
+ The ct-* applications are aware of two levels of configs. There is a base level
184
+ ct.conf that contains the basic variables that apply no matter what variant
185
+ (i.e, debug/release/etc) is being built.
186
+
187
+ The second layer of config files are the variant configs that contain the
188
+ details for the debug/release/etc. The variant names are simply a config file
189
+ name but without the .conf. There are also variant aliases to make for less
190
+ typing. So --variant=debug looks up the variant alias (specified in ct.conf) and
191
+ notices that "debug" really means "gcc.debug". So the config file that gets
192
+ opened is "gcc.debug.conf". If any config value is specified in more than one
193
+ way then the following hierarchy is used
194
+
195
+ * command line > environment variables > config file values > defaults
196
+
197
+ If you need to append values rather than replace values, this can be
198
+ done (currently only for environment variables) by specifying
199
+ --variable-handling-method append
200
+ or equivalently add an environment variable
201
+ VARIABLE_HANDLING_METHOD=append
202
+
203
+ The example /etc/xdg/ct/gcc.release.conf file looks as follows:
204
+
205
+ .. code-block:: ini
206
+
207
+ ID=GNU
208
+ CC=gcc
209
+ CXX=g++
210
+ LD=g++
211
+ CFLAGS=-fPIC -g -Wall -O3 -DNDEBUG -finline-functions -Wno-inline
212
+ CXXFLAGS=-std=c++11 -fPIC -g -Wall -O3 -DNDEBUG -finline-functions -Wno-inline
213
+ LDFLAGS=-fPIC -Wall -Werror -Xlinker --build-id
214
+ TESTPREFIX=timeout 300 valgrind --quiet --error-exitcode=1
215
+
216
+ CXXFLAGS lists the flags appended to each compilation job. The value in
217
+ /etc/xdg/ct/\*.conf
218
+ is overridden by the environment variable, which is in return overridden by
219
+ the command-line argument --CXXFLAGS=. Likewise, LDFLAGS sets the default
220
+ options used for linking.
221
+
222
+ TESTPREFIX specifies a command prefix to place in front of unit test runs. This
223
+ should ideally be a tool like valgrind, gdb or purify that can be configured
224
+ to execute the app and return a non-zero exit code on any failure.
225
+
226
+
227
+ Build variants
228
+ ==============
229
+ A variant is a configuration file that specifies various configurable settings
230
+ like the compiler and compiler flags. Common variants are "debug" and "release".
231
+ Build variants are used by specifying the variant name at the command-line as
232
+ follows:
233
+
234
+ ``$ ct-cake --variant=release a.cpp``
235
+
236
+ Unit Tests
237
+ ==========
238
+
239
+ ct-cake integrates with unit tests in a fairly simple (and perhaps simplistic)
240
+ way.
241
+
242
+ ct-cake allows you to specify multiple build targets on each line,
243
+ so the following is valid and useful:
244
+
245
+ ``$ ct-cake utilities/*.cpp # builds all apps and places them under bin/``
246
+
247
+ Unit tests are executables that are generated, that create an additional
248
+ build step. They must run and return an exit code of 0 as part of the build
249
+ process. To specify that executables are unit tests, use the --tests flag.
250
+
251
+ ``$ ct-cake utilities/*.cpp --tests tests/*.cpp``
252
+
253
+ If the *TESTPREFIX* variable is set, you can automatically check
254
+ all unit tests with a code purifying tool. For example:
255
+
256
+ ``export TESTPREFIX="valgrind --quiet --error-exitcode=1"``
257
+
258
+ will cause all unit tests to only pass if they run through valgrind with no
259
+ memory errors.
260
+
261
+ Putting it all together - a typical build setup
262
+ ===============================================
263
+
264
+ For most simple projects, a build.sh script that looks like the
265
+ following is quite useful. You can simply add more cpp to the apps directory to
266
+ generate more tools from the project,
267
+ or add test scripts to the regression directory to improve
268
+ test coverage.
269
+
270
+ Code generation steps can be added at the beginning of
271
+ the build.sh, before cake runs.
272
+
273
+ .. code-block:: bash
274
+
275
+ #!/bin/sh
276
+ set -e
277
+ python fancypythoncodegenerator.py
278
+ ct-cake --auto "$@"
279
+
280
+
281
+ The special *"$@"* marker is the recommended way
282
+ of forwarding arguments to an application. You can then
283
+ run the build script like this:
284
+
285
+ ``$ ./build.sh --variant=release``
286
+
287
+ or:
288
+
289
+ ``$ ./build.sh --variant=release --append-CXXFLAGS=-DSPECIALMODE``
290
+
291
+ SEE ALSO
292
+ ========
293
+ ``compiletools`` (1), ``ct-list-variants`` (1), ``ct-config`` (1)
@@ -0,0 +1,21 @@
1
+ ==============
2
+ ct-commandline
3
+ ==============
4
+
5
+ ---------------------------------------------------------------------------------------
6
+ This document describes the command line arguments that are common across ct-* programs
7
+ ---------------------------------------------------------------------------------------
8
+
9
+ :Author: drgeoffathome@gmail.com
10
+ :Date: 2017-07-06
11
+ :Copyright: Copyright (C) 2011-2016 Zomojo Pty Ltd
12
+ :Version: 5.0.0
13
+ :Manual section: 1
14
+ :Manual group: developers
15
+
16
+ SYNOPSIS
17
+ ========
18
+ ct-* [args]
19
+
20
+ DESCRIPTION
21
+ ===========
@@ -0,0 +1,129 @@
1
+ ============
2
+ ct-config
3
+ ============
4
+
5
+ --------------------------------------------
6
+ Helper tool for examining ct-* configuration
7
+ --------------------------------------------
8
+
9
+ :Author: drgeoffathome@gmail.com
10
+ :Date: 2016-08-16
11
+ :Copyright: Copyright (C) 2011-2016 Zomojo Pty Ltd
12
+ :Version: 5.0.0
13
+ :Manual section: 1
14
+ :Manual group: developers
15
+
16
+ SYNOPSIS
17
+ ========
18
+ ct-config [compilation args] [--variant=<VARIANT>] [-w output.conf]
19
+
20
+ DESCRIPTION
21
+ ===========
22
+ ct-config is a helper tool for examining how config files, command line
23
+ arguments and environment variables are combined to make the internal
24
+ variables that the ct-* applications use to do their job.
25
+
26
+ Config files for the ct-* applications are programmatically located using
27
+ python-appdirs, which on linux is a wrapper around the XDG specification.
28
+ Thus default locations are /etc/xdg/ct/ and $HOME/.config/ct/.
29
+ Configuration parsing is done using python-configargparse which automatically
30
+ handles environment variables, command line arguments, system configs
31
+ and user configs.
32
+
33
+ Specifically, the config files are searched for in the following
34
+ locations (from lowest to highest priority):
35
+ * same path as exe,
36
+ * system config (XDG compliant, so usually /etc/xdg/ct)
37
+ * python virtual environment system configs (${python-site-packages}/etc/xdg/ct)
38
+ * user config (XDG compliant, so usually ~/.config/ct)
39
+ * gitroot
40
+ * current working directory
41
+
42
+ The ct-* applications are aware of two levels of configs.
43
+ There is a base level ct.conf that contains the basic variables that apply no
44
+ matter what variant (i.e, debug/release/etc) is being built. The default
45
+ ct.conf defines the following variables:
46
+
47
+ .. code-block:: ini
48
+
49
+ CTCACHE = None
50
+ variant = debug
51
+ variantaliases = {'debug':'gcc.debug', 'release':'gcc.release'}
52
+ exemarkers = [main(,main (,wxIMPLEMENT_APP,g_main_loop_new]
53
+ testmarkers = unit_test.hpp
54
+
55
+ The second layer of config files are the variant configs that contain the
56
+ details for the debug/release/etc. The variant names are simply a config file
57
+ name but without the .conf. There are also variant aliases to make for less
58
+ typing. So --variant=debug looks up the variant alias (specified in ct.conf)
59
+ and notices that "debug" really means "gcc.debug". So the config file that
60
+ gets opened is "gcc.debug.conf". The default gcc.debug.conf defines the
61
+ following variables:
62
+
63
+ .. code-block:: ini
64
+
65
+ ID=GNU
66
+ CC=gcc
67
+ CXX=g++
68
+ LD=g++
69
+ CFLAGS=-fPIC -g -Wall
70
+ CXXFLAGS=-std=c++11 -fPIC -g -Wall
71
+ LDFLAGS=-fPIC -Wall -Werror -Xlinker --build-id
72
+
73
+ If any config value is specified in more than one way then the following
74
+ hierarchy is used to overwrite the final value
75
+
76
+ * command line > environment variables > config file values > defaults
77
+
78
+ If you need to append values rather than replace values, this can be
79
+ done (currently only for environment variables) by specifying
80
+ --variable-handling-method append
81
+ or equivalently add an environment variable
82
+ VARIABLE_HANDLING_METHOD=append
83
+
84
+ ct-config can be used to create a new config and write the config to file
85
+ simply by using the ``-w`` flag.
86
+
87
+ OPTIONS
88
+ =======
89
+
90
+ --verbose, -v Output verbosity. Add more v's to make it more verbose (default: 0)
91
+ --version Show program's version number and exit
92
+ --help, -h Show help and exit
93
+ --variant VARIANT Specifies which variant of the config should be used. Use the config name without the .conf (default: gcc.debug)
94
+ --write-out-config-file OUTPUT_PATH, -w OUTPUT_PATH takes the current command line args and writes them out to a config file at the given path, then exits (default: None)
95
+
96
+ ``compilation args``
97
+ Any of the standard compilation arguments you want to go into the config.
98
+
99
+ EXAMPLE
100
+ =======
101
+
102
+ Say that you are cross compiling to a beaglebone. First off you might discover that the following line worked but was rather tedious to type
103
+
104
+ * ct-cake main.cpp --CXX=arm-linux-gnueabihf-g++ --CPP=arm-linux-gnueabihf-g++ --CC=arm-linux-gnueabihf-g++ --LD=arm-linux-gnueabihf-g++
105
+
106
+ What you would really prefer to type is
107
+
108
+ * ct-cake main.cpp --variant=bb.debug
109
+ * ct-cake main.cpp --variant=bb.release
110
+
111
+ Which leads you to the question, how do you write the new variant? A variant is just a config file (with extension .conf) so you could simply copy an existing variant config and edit with a text editor. Alternatively, there is an app for that. The -w option on the ct-config command will write a new config file.
112
+
113
+ * ct-config --CXX=arm-linux-gnueabihf-g++ --CPP=arm-linux-gnueabihf-g++ --CC=arm-linux-gnueabihf-g++ --LD=arm-linux-gnueabihf-g++ -w ~/.config/ct/bb.debug.conf
114
+
115
+ Once that has written you should now use your favourite editor to edit ~/.config/ct/bb.debug.conf. You will probably need to edit the various FLAGS variables. Most of the other variables can be removed as they will default to the values shown in the file anyway.
116
+
117
+ Now if almost all you ever do is cross compile to the beaglebone then you might prefer that the "debug" meant "bb.debug" and similarly for release. That is, you really might prefer to type
118
+
119
+ * ct-cake main.cpp --variant=release # meaning bb.release
120
+ * ct-cake main.cpp # meaning bb.debug
121
+
122
+ To achieve that you have to edit the ct.conf file in ~/.config/ct/ct.conf (or /etc/xdg/ct/ct.conf if you are doing a systemwide setup) to include the following lines
123
+
124
+ variant = debug
125
+ variantaliases = {'debug':'bb.debug', 'release':'bb.release'}
126
+
127
+ SEE ALSO
128
+ ========
129
+ ``compiletools`` (1), ``ct-list-variants`` (1)
@@ -0,0 +1,63 @@
1
+ ================
2
+ ct-cppdeps
3
+ ================
4
+
5
+ ------------------------------------------------------------
6
+ What
7
+ ------------------------------------------------------------
8
+
9
+ :Author: drgeoffathome@gmail.com
10
+ :Date: 2022-06-05
11
+ :Copyright: Copyright (C) Geoffery Ericksson
12
+ :Version: 4.1.85
13
+ :Manual section: 1
14
+ :Manual group: developers
15
+
16
+ SYNOPSIS
17
+ ========
18
+ ct-cppdeps [-h] [-c CONFIG_FILE] [--variant VARIANT] [-v] [-q]
19
+ [--version] [-?] [--man]
20
+ [--CTCACHE CTCACHE] [--ID ID]
21
+ [--CPP CPP] [--CC CC] [--CXX CXX]
22
+ [--CPPFLAGS CPPFLAGS] [--CXXFLAGS CXXFLAGS]
23
+ [--CFLAGS CFLAGS]
24
+ [--git-root | --no-git-root]
25
+ [--include INCLUDE] [--pkg-config PKG_CONFIG]
26
+ [--shorten | --no-shorten]
27
+ [--headerdeps {direct,cpp}]
28
+ filename [filename ...]
29
+
30
+ DESCRIPTION
31
+ ===========
32
+ ct-cppdeps generates the header dependencies for the file you specify at the
33
+ command line. There are two possible methodologys:
34
+
35
+ * "--headerdeps=direct" uses a regex to find the "#include" lines in the source
36
+ code. This methodology is fast. However, while the regex correctly ignores
37
+ commented out includes, it incorrectly identifies files that are surrounded
38
+ by #ifdef 0 guards.
39
+
40
+ * "--headerdeps=cpp" executes "$CPP -MM -MF" which is slower but guarantees correctness.
41
+
42
+
43
+ For each header file found in the source file, it looks for
44
+ an underlying implementation (c,cpp,cc,cxx,etc) file with the same name, and
45
+ adds that implementation file to the build.
46
+ ct-cppdeps also reads the first 8KB of each file for special comments
47
+ that indicate needed link and compile flags. Then it recurses through the
48
+ dependencies of the cpp file, and uses this spidering to generate complete
49
+ dependency information for the application.
50
+
51
+ EXAMPLES
52
+ ========
53
+
54
+ ct-cppdeps somefile1.cpp somefile2.cpp
55
+
56
+ ct-cppdeps --variant=release somefile.cpp
57
+
58
+
59
+ SEE ALSO
60
+ ========
61
+ ``compiletools`` (1), ``ct-findtargets`` (1), ``ct-headertree`` (1), ``ct-config`` (1), ``ct-cake`` (1)
62
+
63
+