You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/Cakelisp.org
+77
Original file line number
Diff line number
Diff line change
@@ -319,3 +319,80 @@ See [[file:../src/GeneratorHelpers.hpp][GeneratorHelpers.hpp]]. All of these fun
319
319
Additionally, the ~Expect~ functions are quick ways to validate your inputs. They will write an error if the expectation isn't met.
320
320
321
321
[[file:../src/Generators.cpp][Generators.cpp]] serves as a good reference to how generators are written. However, they are rather verbose because they don't use any macros and have extensive validation. Generators written in Cakelisp can be much more compact thanks to macros.
322
+
* Build system
323
+
Cakelisp's build system is powerful enough at this point to serve as a general-purpose C/C++ build system, even if you aren't using Cakelisp for any runtime code.
324
+
325
+
For example, Cakelisp itself consists of C++ code. [[file:../Bootstrap.cake][Bootstrap.cake]] builds Cakelisp, and serves as a good demonstration of the build system. I'll explain it here.
326
+
327
+
#+BEGIN_SRC lisp
328
+
(skip-build)
329
+
#+END_SRC
330
+
This indicates the current module should not be built, nor be linked into the final executable. ~Bootstrap.cake~ doesn't contain any runtime code, so we omit it. Modules which contain only compile-time functions like macros should also ~skip-build~.
This changes the location where the final executable is output. Note that if you don't have a ~(main)~ function defined, you can change this output to e.g. ~lib/libCakelisp.so~ to output a dynamic library (on Linux).
336
+
337
+
#+BEGIN_SRC lisp
338
+
(add-c-search-directory module "src")
339
+
#+END_SRC
340
+
It is good practice to refer to files without any directories in the path. This helps future developers if they need to relocate files. In this case, we add ~src~ to the ~module~ search paths, which means only this module and its dependencies will have that search path.
341
+
342
+
If ~global~ is specified instead, all modules and build dependencies would include the search path. Generally, you should try to use ~module~ only, because it lessens the chances of unnecessary rebuilds due to command signature changes, and is one less directory for the compiler to search.
;; Use separate build configuration in case other things build files from src/
387
+
(add-build-config-label "Bootstrap")
388
+
#+END_SRC
389
+
390
+
** Cache validity
391
+
The C/C++ compilation time dominates the total time from ~.cake~ to executable. In order to minimize this, Cakelisp maintains a cache of previously built "artifacts" and reuses them when possible.
392
+
393
+
It is critical that the cache does not become stale. To the developer, a stale cache results in confusion, because the developer might have made a change but does not see the change reflected in the output. Cakelisp's build system errs on the side of caution at the cost of build time performance to ensure this doesn't occur.
394
+
395
+
The following things are checked before a cached artifact is used (not all are relevant to all types of artifacts):
0 commit comments