-
My goal is: [describe your goal]
To be able to conditionally select in the yml file which files to include from the fs directory -
My actions are: [describe your actions - code, commands, etc]
-
The result I see is: [show the result - log, etc]
If I have fileA. fileB and fileC in the fs directory I would like to be able to select which of these to compile into the esps32 directory. -
My expectation & question is: [describe your expectation and your question]
Select in yml file to conditionally add a subset of possible files from the fs directory into the product file system
You can use build_vars
to select the files to included in the filesystem:
filesystem:
- fs/common0
build_vars:
FILES: 0
conds:
- when: build_vars.FILES == "0"
apply:
filesystem:
- fs/f00
- fs/f01
- when: build_vars.FILES == "1"
apply:
filesystem:
- fs/f10
- fs/f11
Build with the option e.g. --build-var FILES=1
mos ls
ca.pem
common0
conf0.json
f10
f11
where should the files be located in my APP structure? I tried putting them in src and the root, but they didn’t show up after the build (mos ls)
That’s what you were asking for.
What I see happening is that every file I put in the fs directory ends up in the product fs directory. It doesn’t matter what I set the conditions too. Therefor I assumed the conditional files needed to go somewhere else for the build process.
Did you add --build-var FILES=1
to the build command?
No, I added it to the other build_vars in the mos.yml file
Did you keep the top level filesystem
section?
filesystem:
- fs
Remove it, otherwise it will add all the files in the fs
directory regardless the selection made by the build_vars
.
No luck with any of your suggestions. It seems I either get everything in the fs directory or nothing.
Updated to 2.14 - no difference.
Is there a “don’t include” option to remove from fs directory on build?
I’m not sure what you are doing wrong.
Here is an example which uses the idea I presented earlier.
definitely something strange going on. I downloaded your example from git. Built it and flashed it. ran “mos ls” and got back:
Build was done thru the mos build command in the GUI (2.14.0)
Yes, I tested too on Windows and it does not work.
I usually build on Debian where it works.
I found a workaround that works on Windows:
filesystem:
- fs\dummy
- fs/common0
Wow good find and thanks for posting the example in GIT.
Big help for the next person that needs this.