Binary Modules
Binary modules allow you to change or extend the behavior of Pragma without having to change the core source code. Binary modules are written in C++ and loaded during runtime using Lua (with some special exceptions). Some example modules are:
- pr_chromium: Adds an integrated Chromium-based Web Browser to Pragma
- pr_openvr: Adds virtual reality support to Pragma
- pr_bullet: Adds support for the Bullet physics engine to Pragma
- pr_physx: Adds support for the PhysX physics engine to Pragma
- pr_curl: Adds support for the curl library to Pragma
- pr_sqlite: Adds SQLite support to Pragma
Installing Modules
Binary modules are installed to "Pragma/modules/". Simple modules that consist of a single library file can usually be found in the root-directory, while more complex modules (like chromium) reside in their own sub-directory.
The module can then be loaded with a simple Lua-script:
local moduleName = "chromium/pr_chromium"
local result = engine.load_library(moduleName)
if(result ~= true) then
console.print_warning("Failed to load \"" .. moduleName .. "\" module: " .. r)
return
end
The module name is the path to the binary file, without the "modules/" prefix and without the file extension. On Linux the module file also has the "lib" prefix, which has to be omitted as well. For instance, if the module filename is "modules/curl/libpr_curl.so", then the module name should be "curl/pr_curl".
Building Modules
If you want to build a module manually, follow the instructions for building Pragma, and add the following argument when running the build script:
--module <name>:<gitUrl>
For instance, if you want to add the pr_chromium
module:
--module pr_chromium:https://github.com/Silverlan/pr_chromium
The build script will clone, build and install the module automatically. If you want to make any changes to the module afterwards, you can run the following command to rebuild and reinstall it without having to re-run the build script every time:
cmake --build --target pr_chromium pragma-install
Custom Modules
Go to the Pragma module template repository on GitHub and create a new repository from it:
You can choose whatever name you want for the repository, but for consistency it is recommended that it should have the same name as the module, which means:
- It should start with the "pr_" prefix
- It should be all lowercase
- It should only contain letters and underscores
Some examples are: "pr_chromium", "pr_bullet", "pr_audio_fmod", etc.
Click "Create repository from template" to generate the repository. The generated repository now contains a bunch of template files, which still need to be initialized. To do so, open the file "template_pragma_module.json" on GitHub and edit the values:
- "name": A pretty name, which will appear in the generated readme.
- "module_name": The internal name of the module (i.e. the name of the CMake target and the binaries). This name should always start with the prefix
pr_
and always be lowercase. - "install_directory": The directory where the module should be installed to, relative to the Pragma installation. This should be somewhere in
modules/
.
Now commit your changes. This will trigger a workflow which will initialize the repository with the values, which should take about two minutes. Simply refresh the page a few times, once you can see the following icons at the top of the readme, that means the initialization was completed: