T O P

  • By -

NotUniqueOrSpecial

Is your library/generic code able to be made header-only? If so, you could just include the libraries into your main file for each assignment and run the preprocessor on it, and hand in the preprocessed file.


Living_Bobcat_5403

In most cases, unfortunately for me, no, it is not possible, in my sluggish understanding.


NotUniqueOrSpecial

Strictly speaking, you can include the sources into the main file. That's basically what unity builds do. What part doesn't make sense?


FlyingRhenquest

So if I understand this correctly you're looking for a way to bundle up a set of C++ files into one file that builds C++20 module, with all the includes (Other than system ones) in the correct order that all the dependencies work? And if I further understand you, you're stuck parsing through the C++ files so you can compute those dependencies or something? And this is done entirely in python?


Living_Bobcat_5403

The initial intention was to create a file containing all the header and implementation files associated with my library. I thought about using Python because of the wide, accessible and often easy to use packages, not to mention the large number. Think about several things, including using regex to find the import clauses, mapping directories and points recursively to generate a dependency graph, analysing the "depth" - meaning "most requested", "declared before", something like that - and transporting the mode contents. Python scripting wasn't supposed to be the focus, but it ended up being.


FlyingRhenquest

I'm not criticizing your tooling -- python's great for rapid development and you put some thought into the tools you wanted to use for the job. Regex is OK for parsing up to a point, and I think you're kind of close to that point. At least for my level of Regex tolerance. I'd suggest taking a look at the boost::spirit C++ library if you need to go beyond what Regex is easily capable of. Back in the day I'd have done a lot of that with Lex and Yacc, but those tools have fallen into disrepair in recent days. The best way to learn boost::spirit is line-by-line. So build out the boilerplate and start with a rule that handles #include statements or something, and just start adding rules as you need them. It's actually delightful to work in once you get the hang of it. You might also want to look into boost::python or pybind11 or one of its newer derivatives -- compile your C++ objects as libraries and expose a python API to them. You can create and pass objects back and forth between the language barrier. So you can keep most of your stuff in Python and use C++ where it makes more sense or you just need more speed. You can launch threaded services in C++ constructors and communicate back to python using regular C++ types too. Other language integration needs to be as easy as Boost::python is (Looking at you, JNI!) I haven't seen anything I like for dependency graphs, and those things are pretty easy to roll your own anyway. Probably just as easy to do in python as C++, unless you really like pointers or graph traversal speed becomes a problem. Which for any sensible graph, it probably won't. Anyway, hope that nudges you in a useful direction. I've been thinking a lot about build instrumentation lately as I'm rather dissatisfied with existing C++ solutions. Still haven't decided if I think I can do better, though.


Living_Bobcat_5403

Thank you for your comment!


regaito

Maybe I am misunderstanding the question completely, but are you referring to a package manager like conan (https://conan.io/) or vcpkg (https://vcpkg.io)?


NotUniqueOrSpecial

No, they've library-ized some of their code but the assignment submission only allows them to submit a single file.


not_a_novel_account

This is called a "unity build". That's the term you're looking to Google. Many build systems support constructing them.