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

How to add a private toolchain (or any other lua script) #293

Closed
bmharper opened this issue Oct 20, 2017 · 3 comments
Closed

How to add a private toolchain (or any other lua script) #293

bmharper opened this issue Oct 20, 2017 · 3 comments

Comments

@bmharper
Copy link
Contributor

I have two cases where I need to make a tweaked toolchain - clang-analyze, and afl. In both cases, these programs work by replacing clang (or gcc) with their own wrapper program, which runs the regular compiler, and then add their own magic on top of that.

When using tundra, is there some official mechanism for defining your own toolchain (similar to clang.lua, or gcc.lua), which is part of your source code tree, and not part of the stock tundra distribution?

The best thing I've come up with so far is this (example here is for afl):

  1. Create a file in my project: build/tundra/tools/afl.lua
  2. Add a new Config that uses the afl toolchain.
  3. Run tundra like so, to compile my project called "Test": TUNDRA_LUA_PATH=`pwd`/build/?.lua tundra2 linux-afl-release Test

It would be useful if one didn't need to setup the TUNDRA_LUA_PATH environment variable. Does it make sense that one could add some kind of lua call, which would add a new directory to the lua search path? You could then call that function at the top of your tundra.lua file, to add in your project-specific lua scripts.

I know this may seem a bit pedantic - I mean what's wrong with just setting TUNDRA_LUA_PATH for this niche case? However, I think it would be a good principle if one could easily add extra augmentations on top of tundra, in the form of lua scripts that are private to the source tree.

afl.lua contents:

module(..., package.seeall)

function apply(env, options)
  tundra.unitgen.load_toolset("gcc", env)

  env:set_many {
    ["CC"] = "/home/ben/dev/afl-2.51b/afl-clang",
    ["CXX"] = "/home/ben/dev/afl-2.51b/afl-clang++",
    ["LD"] = "/home/ben/dev/afl-2.51b/afl-clang",
  }
end
@deplinenoise
Copy link
Owner

You can add tool paths using the ScriptDir property. This way they’re loaded just like built in tools and there’s no need for env hacks. Let me know if this doesn’t work for you.

@deplinenoise
Copy link
Owner

Sorry, ScriptDirs is the appropriate spelling. It adds to the Lua path and anything found there will be importable just like built in tools.

@bmharper
Copy link
Contributor Author

Thanks - that's exactly what I was looking for. Sent a one character PR that fixes the typo in the manual.

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

No branches or pull requests

2 participants