Skip to content

General project setup

insomniac_lemon edited this page Aug 6, 2024 · 3 revisions

Non-addon projects

Forenote: This structure or details may change, though other structures may still be continue to work.

quick_template of demo repo as directory layout example:

  project root
+ ├── core #this is a workspace
+ │  ├── bootstrap.nim # init_library. Imports src files+register their classes. In this dir, compile w/nim c bootstrap
+ │  ├── config.nims # technical settings, --path allows defining source code dir
+ │  ├── main.gdextension # tells Godot library location of each extension. Custom class icons also defined here
+ │  ├── lib # folder added on compile, along with its contents
+ │  │   └── libcore.so # OS specific .ext. Name from workspace, currently .toDll also adds lib prefix
+ │  └── src # code files go here
  ├── scenes
  ├── .gitattributes
  ├── .gitignore  
  ├── icon.svg
  ├── icon.svg.import
  └── project.godot

See quick_template for file contents.

Notes:

  • workspace name is user choice
    • workspaces may be nested for multiple extensions
    • or at the same level for instance /addons/ may also be used alongside another workspace
  • .gdextension may be auto-generated in the future
    • .gdextension file can have any name...
      • but you will need to open+close+reopen the Godot editor for it to properly reload after rename
  • config.nims can also go at root (or in /addons/ etc) to act as default for all extensions below it
    • if doing so, a file like bootstrapconf.nims may be used to add extension-specific changes
  • you may register classes in your code after they are defined
    • this only really makes sense if you're creating a lot of classes in one file as...
    • the file still needs to be imported into init_library (bootstrap.nim), giving a warning, so...
    • you will want {.warning[UnusedImport]:off.} at the top of the init file for that
  • bootstrap.nim may also be renamed, but this means your compile command will differ
    • currently, desiredname.cfg in workspace folder with contents --define: ExtensionMain:desiredname
    • doing so will change your library name to libdesiredname.ext
    • via the same file you may also change the src folder to another directory for a custom structure
      • for instance --path: "$projectdir/../othername/src"...
        • allows you to have an additional folder at the same level as your extension where your src folder is

Clone this wiki locally