Using ProcessUnFlags in middlewares script?

Hello all,

I’m importing an edge-impulse middleware into a project. The Tensorflow contents produce some build errors (due to uninitialized variables). My solution is to use the middleware script, as below.

My question is does the env.ProcessUnFlags(“-Werror=maybe-uninitialized”) only effect the node captured or the entire project? Is there a better way to do this?

Thanks

Import("env") 
import sys

# --- Add custom macros for the ALL files which path contains "edge-impulse-sdk"
def edge_impulse_sdk_configuration(env, node):

    if "edge-impulse-sdk" not in node.get_path():
        return node

    # Remove -Werror=maybe-uninitialized
    print("WARNING: Adding custom build flags for edge-impulse-sdk")
    env.ProcessUnFlags("-Werror=maybe-uninitialized")
    return node

env.AddBuildMiddleware(edge_impulse_sdk_configuration)

That looks like it effects the whole project / environment.

You can try something like

def edge_impulse_sdk_configuration(env, node):
    if "edge-impulse-sdk" not in node.get_path():
        return node
    return env.Object(
        node,
        CCFLAGS=[flag for flag in env["CCFLAGS"] if flag != "-Werror=maybe-uninitialized"]
    )
1 Like

Many thanks, I’ll give that a go.