This is an example of a Rojo-powered project that uses Modules as a dependency. Like Modules itself, this project also uses GNU make (Makefile) to build the project. Although it's not required, using make
makes it easy.
Here's how Modules is included in this project as a dependency:
- The Modules repository is added as git submodule.
- The
Modules.rbxmx
file is built first: the Makefile is run by invokingmake
. It recursively invokes Modules' Makefile. - This project is built second: the file default.project.json is built using
rojo
from within the Makefile. It includes builtModules.rbxmx
into ReplicatedStorage after Modules is built.
You should first make your dependency into a git repository so it can be added as a submodule later. Assuming you put your code into a src
directory, this simple Makefile like this should be useful:
OUT_FILE = MyLibrary.rbxmx
ROJO_PROJECT = default.project.json
$(OUT_FILE) : $(shell find src -type f)
rojo build $(ROJO_PROJECT) --output $(OUT_FILE)
Note: the $(shell find src -type f)
here specifies that the OUT_FILE
depends on all files within the src/
directory.
Once you have your dependency repository set up nicely, you can add it to this example project by following these steps.
-
Add the git repository for your dependency as a git submodule (file path works too, but you probably should have it online):
$ git submodule add https://github.com/You/MyLibrary lib/MyLibrary
-
Add the rbxmx file to the
DEPS
variable in the Makefile (hint: use\
to use multiple lines).make
will be recursively invoked in the directory containing your dependency (below,lib/MyLibrary
).DEPS = lib/Modules/Modules.rbxmx \ lib/MyLibrary/MyLibrary.rbxmx
-
Include the dependency in this example's Rojo project via an instance description by pointing
$path
to the resulting rbxmx file (remember, this path is relative to the project file).{ "name": "MyProject", "tree": { "$className": "DataModel", "ReplicatedStorage": { "$className": "ReplicatedStorage", "Modules": { "$path": "lib/Modules/Modules.rbxmx" }, "MyProject": { "$path": "src/ReplicatedStorage" }, "MyLibrary": { "$path": "lib/MyLibrary/MyLibrary.rbxmx" } }, "ServerScriptService": { "$className": "ServerScriptService", "MyProject": { "$path": "src/ServerScriptService" } } } }