Compile library

Hello there

How to compile library BuildLibrary with main builder, but without link LIB to project
I want to export to this LIB - veneers of std functions
and currently there is duplication of function and veneer
the compiler doesn’t “cry” but it is worrying

Good question, I don’t think PlatformIO has any function that builds a .a file but doesn’t include it in the build.

I found a solution

def REMOVE_LIBRARY(source, target, env):
    for N in env["LIBS"]:
        if "libopenapi.a" in str(N) :
            env["LIBS"].remove(N)

env.AddPreAction("$BUILD_DIR/${PROGNAME}.elf", REMOVE_LIBRARY)

but how to hide action info from terminal - print function name, source and target

...
Building in release mode
REMOVE_LIBRARY([".pio\build\MT\FIRMWARE.elf"]....
...
1 Like

Can you write

env["LIBS"] = [x for x in env["LIBS] if str(x) != "libopenapi.a"]

instead? This avoids calling .remove() which might trigger the print. (But maybe this also breaks the build.)

Ahh, actually this is should just be the output in the verbose build mode because any function that is used with env.AddPreAction() is printed that way. Does this output still appear with a regular build, not an advanced → verbose build?

YEP

Untitled-1

env["LIBS"] = [x for x in env["LIBS"] if str(x) != "libopenapi.a"]
EDIT: this line not remove lib from linker command - need full path to lib

is the same
function name…etc is printed before execution

Okay but then write

env["LIBS"] = [x for x in env["LIBS"] if str(x) not in "libopenapi.a"]

env["LIBS"] = [ x for x in env["LIBS"] if "libopenapi.a" not in str(x) ]
is OK
but terminal info exist