Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve custom toolchain to support unknown compiler/linker. #5554

Open
waruqi opened this issue Sep 1, 2024 · 1 comment
Open

Improve custom toolchain to support unknown compiler/linker. #5554

waruqi opened this issue Sep 1, 2024 · 1 comment

Comments

@waruqi
Copy link
Member

waruqi commented Sep 1, 2024

Is your feature request related to a problem? Please describe.

But I haven't figured out how to design the API yet.

Describe the solution you'd like

.

Describe alternatives you've considered

No response

Additional context

No response

@ArgoreOfficial
Copy link

ArgoreOfficial commented Sep 10, 2024

One idea I had would be to separate tools from the toolchain, giving essentially full control over the entire pipeline

tool("mycxx")
    set_bindir("path/to/bin") -- "mycxx.exe" is assumed
    set_kind("file")          -- run this per file
    set_filetypes("cpp")      -- run this only on .cpp files
    set_extension("o")        -- generate .o file for linker/archiver
    set_format("gcc")         -- use default gcc format 
                                --> mycxx -c -o file.o main.cpp -Wall

    -- alternatively, for custom formats
    set_format({ "-key $(key)", "-c -o $(outfile)", "$(flags)", "$(file)" })
        --> mycxx -key P -c -o main.o -Wall main.cpp
tool_end()

key thing to note here would be the set_kind, which would specify if the tool is run once per file, like compilers, or once per output, like the linker
it would determine what is input into the $(file) or $(files) keys.

creating the toolchain would then be more like

toolchain("MyToolchain") -- tools are run in order they are added
    add_tool("mycxx")
    add_tool("myar", { kind = "static" }) -- not sure how kinds should be handeled
    add_tool("myld", { kind = "binary" })
toolchain_end()

target("project")
    set_kind("binary")
    add_files("src/main.cpp")

    set_toolchain("MyToolchain")
    set_toolvar("key", "P") -- user variable
    set_flag("-Wall")
target_end()

In some aspects it's similar to the rule API.
This would at least satisfy the needs for some Sony platforms I've worked with.

This tool api could then be extended to other areas, like custom debuggers or specific platform tools

debugger("MyDebugger")
    set_filetypes("elf")
    add_tool("mydbg")
debugger_end()

target("project")
    set_kind("binary")
    add_files("src/main.cpp")

    set_toolchain("MyToolchain")
    set_toolchain("MyDebugger")
    set_toolvar("key", "P") -- user variable
    set_flag("-Wall")
target_end()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants