Mos.yml conditional files in fs directory

  1. My goal is: [describe your goal]
    To be able to conditionally select in the yml file which files to include from the fs directory

  2. My actions are: [describe your actions - code, commands, etc]

  3. 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.

  4. 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:

  - fs/common0

  FILES: 0

  - when: build_vars.FILES == "0"
        - fs/f00
        - fs/f01
  - when: build_vars.FILES == "1"
        - fs/f10
        - fs/f11

Build with the option e.g. --build-var FILES=1

mos ls
1 Like

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?

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

Thru command line:

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:

  - fs\dummy
  - fs/common0
1 Like

Wow good find and thanks for posting the example in GIT.
Big help for the next person that needs this.