| 
 | 1 | +from os.path import realpath  | 
 | 2 | + | 
 | 3 | +Import("env") # type: ignore  | 
 | 4 | +menv=env # type: ignore  | 
 | 5 | + | 
 | 6 | +src_filter = [  | 
 | 7 | +  '+<*.cpp>',  | 
 | 8 | +  '+<helpers/*.cpp>',  | 
 | 9 | +  '+<helpers/sensors>',  | 
 | 10 | +  '+<helpers/radiolib/*.cpp>',  | 
 | 11 | +  '+<helpers/ui/MomentaryButton.cpp>',  | 
 | 12 | +  '+<helpers/ui/buzzer.cpp>',  | 
 | 13 | +]  | 
 | 14 | + | 
 | 15 | +# add build and include dirs according to CPPDEFINES  | 
 | 16 | +for item in menv.get("CPPDEFINES", []):  | 
 | 17 | +   | 
 | 18 | +    # PLATFORM HANDLING  | 
 | 19 | +    if item == "STM32_PLATFORM":  | 
 | 20 | +        src_filter.append("+<helpers/stm32/*>")  | 
 | 21 | +    elif item == "ESP32":  | 
 | 22 | +        src_filter.append("+<helpers/esp32/*>")  | 
 | 23 | +    elif item == "NRF52_PLATFORM":  | 
 | 24 | +        src_filter.append("+<helpers/nrf52/*>")  | 
 | 25 | +    elif item == "RP2040_PLATFORM":  | 
 | 26 | +        src_filter.append("+<helpers/rp2040/*>")  | 
 | 27 | +      | 
 | 28 | +    # DISPLAY HANDLING  | 
 | 29 | +    elif isinstance(item, tuple) and item[0] == "DISPLAY_CLASS":  | 
 | 30 | +        display_class = item[1]  | 
 | 31 | +        src_filter.append(f"+<helpers/ui/{display_class}.cpp>")  | 
 | 32 | +        if (display_class == "ST7789Display") :  | 
 | 33 | +            src_filter.append(f"+<helpers/ui/OLEDDisplay.cpp>")  | 
 | 34 | +            src_filter.append(f"+<helpers/ui/OLEDDisplayFonts.cpp>")  | 
 | 35 | + | 
 | 36 | +    # VARIANTS HANDLING  | 
 | 37 | +    elif isinstance(item, tuple) and item[0] == "MC_VARIANT":  | 
 | 38 | +        variant_name = item[1]  | 
 | 39 | +        src_filter.append(f"+<../variants/{variant_name}>")  | 
 | 40 | +      | 
 | 41 | +    # INCLUDE EXAMPLE CODE IN BUILD (to provide your own support files without touching the tree)  | 
 | 42 | +    elif isinstance(item, tuple) and item[0] == "BUILD_EXAMPLE":  | 
 | 43 | +        example_name = item[1]  | 
 | 44 | +        src_filter.append(f"+<../examples/{example_name}/*.cpp>")  | 
 | 45 | + | 
 | 46 | +    # EXCLUDE A SOURCE FILE FROM AN EXAMPLE (must be placed after example name or boom)  | 
 | 47 | +    elif isinstance(item, tuple) and item[0] == "EXCLUDE_FROM_EXAMPLE":  | 
 | 48 | +        exclude_name = item[1]  | 
 | 49 | +        if example_name is None:  | 
 | 50 | +            print("***** PLEASE DEFINE EXAMPLE FIRST *****")  | 
 | 51 | +            break  | 
 | 52 | +        src_filter.append(f"-<../examples/{example_name}/{exclude_name}>")  | 
 | 53 | + | 
 | 54 | +    # DEAL WITH UI VARIANT FOR AN EXAMPLE  | 
 | 55 | +    elif isinstance(item, tuple) and item[0] == "MC_UI_FLAVOR":  | 
 | 56 | +        ui_flavor = item[1]  | 
 | 57 | +        if example_name is None:  | 
 | 58 | +            print("***** PLEASE DEFINE EXAMPLE FIRST *****")  | 
 | 59 | +            break  | 
 | 60 | +        src_filter.append(f"+<../examples/{example_name}/{ui_flavor}/*.cpp>")  | 
 | 61 | +          | 
 | 62 | +menv.Replace(SRC_FILTER=src_filter)  | 
 | 63 | + | 
 | 64 | +#print (menv.Dump())  | 
0 commit comments