def METHOD_NAME(filename, source_folder, error):
    # Generate the libraries to build dynamically
    re_name = re.compile(r'name = "(.*)"')
    re_srcs_oneline = re.compile(r'srcs = \["(.*)"\],')
    re_deps_oneline = re.compile(r'deps = \["(.*)"\],')
    re_add_varname = re.compile(r'] \+ (.*),')
    proto_libraries = []
    basedir = os.path.dirname(filename)
    proto_library = None
    def parsing_sources(line):
        proto_path = os.path.relpath(os.path.join(basedir, line.strip(",").strip("\"")), source_folder).replace('\\', '/')
        proto_library.srcs.append(proto_path)
    def parsing_deps(line):
        line = line.strip(",").strip("\"")
        if line.startswith("@com_google_protobuf//:"):
            proto_library.deps.add("protobuf::libprotobuf")
        elif line.startswith("@com_google_googleapis//"):
            proto_library.deps.add("googleapis::googleapis")
        elif line.startswith(":"):
            proto_library.deps.add(grpc_target_name(line[1:]))
        else:
            error(f"Unrecognized dep: {line} -- {os.path.relpath(filename, source_folder)}")
    with open(filename, 'r') as f:
        action = None
        parsing_variable = None
        variables = {}
        for line in f.readlines():
            line = line.strip()
            if line == "proto_library(":
                assert proto_library == None
                proto_library = _ProtoLibrary()
            elif parsing_variable != None:
                if line == "]":
                    parsing_variable = None
                else:
                    parsing_variable(line)
            elif proto_library != None:
                if line.startswith("name ="):
                    proto_library.name = re_name.search(line).group(1)
                elif line.startswith("srcs = "):
                    m = re_srcs_oneline.search(line)
                    if m:
                        parsing_sources(m.group(1))
                    else:
                        action = parsing_sources
                elif line.startswith("deps = "):
                    m = re_deps_oneline.search(line)
                    if m:
                        parsing_deps(m.group(1))
                    else:
                        action = parsing_deps
                elif line.startswith("visibility = "):
                    pass
                elif line == ")":
                    proto_libraries.append(proto_library)
                    proto_library = None
                    action = None
                elif line == "],":
                    action = None 
                elif line.startswith("] + "):
                    varname = re_add_varname.search(line).group(1)
                    for it in variables[varname]:
                        action(it) 
                elif action:
                    action(line)
    return proto_libraries