Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
schtanislau
Visitor

source folder structure

Hello!

Excuse me, I have a question regarding 'source' folder structure. I understand, that we can have any kind of structure in the 'source' folder, but it can slower the compilation time.

Assuming, that I have this kind of structure:

source/
source/common
source/common/test1.brs
source/utilities
source/utilities/test2.brs
source/classes
source/classes/test3.brs
source/appMain.brs

I understand, that the app.mk file in the RokuSDK needs to be adjusted so it will compile files not only in the 'source' folder, but even in the nested folders.

DISTREL = ../../dist
COMMONREL = ../common
SOURCEREL = ..

ZIPREL = $(DISTREL)/apps
PKGREL = $(DISTREL)/packages

APPSOURCEDIR = source
IMPORTFILES = $(foreach f,$(IMPORTS),$(COMMONREL)/$f.brs)
IMPORTCLEANUP = $(foreach f,$(IMPORTS),$(APPSOURCEDIR)/$f.brs)


I'm not sure how to adjust this code for '/utilities' and '/classes' folders.

Can anyone help me on this? Thank you 🙂
0 Kudos
5 REPLIES 5
Veeta
Visitor

Re: source folder structure

I don't quite understand "can slower the compilation time" comment. But the app.mk by default will use "zip -r" and gather up all sources in the subdirectories as well.
0 Kudos
schtanislau
Visitor

Re: source folder structure

It will zip all folders and sub directories, but will it be possible i.e. to access functions from /source/utilities/test.brs from /source/appMain.brs ? I think not.

Regarding slowing the compilation time - last post in this thread 🙂
0 Kudos
schtanislau
Visitor

Re: source folder structure

Just tested my helloworld app. Actually, I can call function from source/folder/functions.brs in source/appMain.brs.

Question is closed :oops:
0 Kudos
EnTerr
Roku Guru

Re: source folder structure

"schtanislau" wrote:
It will zip all folders and sub directories, but will it be possible i.e. to access functions from /source/utilities/test.brs from /source/appMain.brs ? I think not.

Regarding slowing the compilation time - last post in this thread 🙂

That same thread is telling you that B/S interpreter will "slurp" all BRS files under /source, regardless of the directory (sub)structure. Everything will be #included, everything will be flattened, there are no packages and namespaces, it's equivalent to concatenating everything to one file.

And may i share personal opinion: there is no point of breaking your source to subdirectories, there is no point of splitting it to separate files either - unless you are sharing codebase between different projects. No need to split to multiple files till your source is at least 2000 lines long. No need to organize in subdirectory structure till you have at least couple of dozen files. Writing in a high-level language, that means at least 20k lines - which is a massive, massive, massive undertaking not likely to be your case. I just published a puzzle game and it is under 2k lines total. All code in one file - lock, stock, and barrel. So, umm...
0 Kudos
Komag
Roku Guru

Re: source folder structure

I have all my brs files in one folder, and I prefer to keep them under 1000 lines, far under usually. I like separate files divided into various sections/categories, so I can have them open in multiple tabs and "see" everything I'm doing without scrolling up and down much. But yeah, it all just gets lumped together in the end.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.