Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
schtanislau
Level 7

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 Smiley Happy
0 Kudos
5 Replies
Veeta
Level 7

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
Level 7

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 Smiley Happy
0 Kudos
schtanislau
Level 7

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 Smiley Surprisedops:
0 Kudos
EnTerr
Level 8

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 Smiley Happy

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
Level 9

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