Includer

Last updated February 13, 2022.

When I started moving pieces of my development work to Rust, one of the things I missed were #include statements. This wasn't because Rust lacked its own way of organizing files, but because sometimes I just wanted to put files where they made sense to me personally, and include statements made that really easy. I'm getting better at working with modules (most days), but the underlying concept of including files in a larger piece without needing to have the whole thing there is one with a lot of possible uses, even outside of programming.

After an embarrassingly long while I realized that includes really aren't that complicated of a construct, and rather than searching online for somebody else to have solved my problem, I may as well just go ahead and write some code myself

Includer (such a creative name, isn't it) is my solution. Specifically, it takes an input file, and wherever a line begins with #include, processes the rest of that line as the name of a file you want included in your final product. Recursive includes are fully supported (at least until you stack overflow), so you could, for example, #include"include/list.txt", and in that file, have another include line for all the other bits and pieces you want to bring into your project.

Recursive includes are relative to the file currently being processed, so in the above example, #include"utils.txt" in list.txt would be the same as writing #include"includes/utils.txt" in your main one.

You can run the program directly to be prompted for input and output file names, or provide them both as arguments for it to run silently. It will reject common dangerous cases like input and output being the same file, or circular includes where file a references file b which in turn references file a.

If you find the program useful or have thoughts or suggestions for improvement, I'd very much like to hear from you. Please do let me know what you're using it for and how well it worked.

AI disclosure

The original includer was written entirely by me, and was available here for several years. It's fully functional and works, as long as you stick to a very narrow form of include statement. That began to be problematic when I started using it in a few larger projects and did things like put comments on the same line as my includes.

The version available below is part my original work, part a massively improved parser by GPT 5.5 (which writes Rust much faster than I). It allows comments in multiple languages, indenting, comma-separated includes if you want them, and include statements that don't have quotes. Future improvements will continue to be a mixture between Human and AI-written code.

Download Includer

I've compiled versions for Windows (7 and up), Linux, and Raspberry pi (Linux on Arm), and should be able to produce pretty much anything else folks could need, so long as it's supported by Rust. If you want something added to the downloads below, please use the link above to let me know.

Note that these downloads are named according to their platform, so you may wish to consider renaming them to something that suits your style better.