xmake-io / xmake-vscode

🍩 A XMake integration in Visual Studio Code
https://xmake.io
Apache License 2.0
223 stars 55 forks source link

add new commands #238

Closed ririyeye closed 7 months ago

ririyeye commented 7 months ago
def add_from_lua_api(my_path):
    # add all api from *.lua
    apis = set()
    files = glob.glob(my_path + '/**/*.lua', recursive=True)
    # files = ['xmake/languages/asm/load.lua']
    apireg = re.compile(r'^ +(, +)?"\w+\.(\w+)"$',re.MULTILINE)
    for fil in files:
        with io.open(fil , encoding='latin-1') as f:
            content = f.read()
            for match in apireg.finditer(content):
                # print(match[0] , match[2])
                apis.add(match[2])
    return apis

scan apis by regex '^ +(, +)?"\w+\.(\w+)"$' and add them to xmakeCommands