Browse Source

Remove skip-build and comptime-only from docs

Deprecate skip-build.
macOS
Macoy Madson 2 years ago
parent
commit
459d8a53bf
  1. 18
      doc/Cakelisp.org
  2. 8
      doc/Tutorial_Basics.org
  3. 2
      runtime/ComptimeHelpers.cake
  4. 2
      runtime/TextAdventure.cake
  5. 3
      src/Generators.cpp
  6. 4
      src/Metadata.cpp
  7. 2
      tools/cakelisp.el

18
doc/Cakelisp.org

@ -27,15 +27,14 @@ The ~local~ keyword or suffix is typically relative to module scope. It tells Ca
** Importing modules
The ~import~ function adds the specified file to the environment:
#+BEGIN_SRC lisp
(import "MyFile.cake" "AnotherFile.cake")
(import "MyFile.cake" "AnotherFile.cake")
;; Include MyForwardDeclares.cake's generated header in the current module's generated header
;; You might need to do this if you have non-module-local types/signatures which rely on other types
(import &with-decls "MyForwardDeclares.cake")
;; Include MyForwardDeclares.cake's generated header in the current module's generated header
;; You might need to do this if you have non-module-local types/signatures which rely on other types
(import &with-decls "MyForwardDeclares.cake")
;; Do not include in any generated code. This is essential for comptime-only modules, which won't
;; even generate headers
(import &comptime-only "ComptimeHelpers.cake")
;; Do not build the module, only include its header (its declarations)
(import &decls-only "OnlyHeader.cake")
#+END_SRC
By default, ~&with-defs~ is specified, meaning the generated header will be included in the generated source file only.
@ -399,11 +398,6 @@ Basic projects don't need any build customization at all. Cakelisp uses its modu
** Example: Bootstrap
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.
#+BEGIN_SRC lisp
(skip-build)
#+END_SRC
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~.
#+BEGIN_SRC lisp
(set-cakelisp-option executable-output "bin/cakelisp")
#+END_SRC

8
doc/Tutorial_Basics.org

@ -264,10 +264,10 @@ We need to add the command to a compile-time list so that code can be generated
For this, we need some external help, because we don't know how to save data for later during compile-time. Add this to the top of your ~Hello.cake~:
#+BEGIN_SRC lisp
(import &comptime-only "ComptimeHelpers.cake")
(import "ComptimeHelpers.cake")
#+END_SRC
This ~ComptimeHelpers.cake~ file provides a handy macro, ~get-or-create-comptime-var~. We ~import~ it to tell Cakelisp that we need that file to be loaded into the environment. We include ~&comptime-only~ because we know we won't use any code in it at runtime.
This ~ComptimeHelpers.cake~ file provides a handy macro, ~get-or-create-comptime-var~. We ~import~ it to tell Cakelisp that we need that file to be loaded into the environment.
However, if we try to build now, we get an error:
@ -283,7 +283,7 @@ Cakelisp doesn't know where ~ComptimeHelpers.cake~ is. We need to add its direct
#+BEGIN_SRC lisp
(add-cakelisp-search-directory "runtime")
(import &comptime-only "ComptimeHelpers.cake")
(import "ComptimeHelpers.cake")
#+END_SRC
This allows you to move things around as you like without having to update all the imports. You would otherwise need relative or absolute paths to find files. You only need to add the directory once. The entire Environment and any additional imports will use the same search paths.
@ -547,7 +547,7 @@ And to make sure it works, we will reference ~command-table~ in ~main~. We will
Update our ~import~ to include ~CHelpers.cake~, which has a handy macro for iterating over static arrays:
#+BEGIN_SRC lisp
(import &comptime-only "ComptimeHelpers.cake" "CHelpers.cake")
(import "ComptimeHelpers.cake" "CHelpers.cake")
#+END_SRC
In ~main~, add the code to list commands. Put it at the very start of the function so it always occurs:

2
runtime/ComptimeHelpers.cake

@ -1,4 +1,4 @@
(import &comptime-only "CppHelpers.cake")
(import "CppHelpers.cake")
;; Binds the variable's address to the named var
;; Note that this causes the caller's function to return false if the binding failed

2
runtime/TextAdventure.cake

@ -2,8 +2,6 @@
;; This is meant to be a dead simple "game" which you can modify while it is running.
;; This is to test hot-reloading
;; (import &comptime-only "ComptimeHelpers.cake")
(c-import "<stdio.h>"
"cctype" ;; For isdigit
"<stdlib.h>" ;; atoi

3
src/Generators.cpp

@ -635,6 +635,7 @@ enum ImportState
WithDeclarations,
CompTimeOnly,
DeclarationsOnly,
// TODO: Remove?
DefinitionsOnly
};
@ -3197,7 +3198,9 @@ void importFundamentalGenerators(EvaluatorEnvironment& environment)
environment.generators["set-module-option"] = SetModuleOption;
// All things build
s_deprecatedHelpStrings["skip-build"] = "you should not need to specify skip-build any more";
environment.generators["skip-build"] = SkipBuildGenerator;
environment.generators["add-cpp-build-dependency"] = AddDependencyGenerator;
environment.generators["add-c-build-dependency"] = AddDependencyGenerator;
environment.generators["add-compile-time-hook"] = AddCompileTimeHookGenerator;

4
src/Metadata.cpp

@ -57,8 +57,8 @@ GeneratorMetadata g_generatorMetadata[] = {
//
{"skip-build", GeneratorCategory_Build, LanguageRequirement_Evaluated,
EvaluationTime_EvaluatedImmediately, 0, 0,
"Mark the current module to be excluded from the runtime build process. This is necessary "
"when the module does not provide any runtime code. For example, a module with only "
"[DEPRECATED] Mark the current module to be excluded from the runtime build process. This is "
"necessary when the module does not provide any runtime code. For example, a module with only "
"compile-time function definitions would need to skip building."},
{
"add-c-search-directory-global",

2
tools/cakelisp.el

@ -44,7 +44,7 @@
;; "(def[a-zA-Z0-9-]*" all define keywords
;; Configuration, build stuff, etc.
(font-lock-add-keywords nil '(("(\\(add-build-config-label\\|add-build-options\\|add-build-options-global\\|add-c-build-dependency\\|add-c-search-directory-global\\|add-c-search-directory-module\\|add-cakelisp-search-directory\\|add-compile-time-hook\\|add-compile-time-hook-module\\|add-compiler-link-options\\|add-cpp-build-dependency\\|add-library-dependency\\|add-library-runtime-search-directory\\|add-library-search-directory\\|add-linker-options\\|set-cakelisp-option\\|set-module-option\\|skip-build\\|c-import\\|c-preprocessor-define\\|c-preprocessor-define-global\\|comptime-cond\\|comptime-define-symbol\\|comptime-error\\|import\\|rename-builtin\\|splice-point\\|tokenize-push\\)[ )\n]"
(font-lock-add-keywords nil '(("(\\(add-build-config-label\\|add-build-options\\|add-build-options-global\\|add-c-build-dependency\\|add-c-search-directory-global\\|add-c-search-directory-module\\|add-cakelisp-search-directory\\|add-compile-time-hook\\|add-compile-time-hook-module\\|add-compiler-link-options\\|add-cpp-build-dependency\\|add-library-dependency\\|add-library-runtime-search-directory\\|add-library-search-directory\\|add-linker-options\\|set-cakelisp-option\\|set-module-option\\|c-import\\|c-preprocessor-define\\|c-preprocessor-define-global\\|comptime-cond\\|comptime-define-symbol\\|comptime-error\\|import\\|rename-builtin\\|splice-point\\|tokenize-push\\)[ )\n]"
1 font-lock-builtin-face)))
(font-lock-add-keywords nil '(("\\b\\(true\\|false\\|null\\)\\b"

Loading…
Cancel
Save