#include #include #include #include #include #include #include #include #include "analysis.h" #include "codegen.h" namespace fs = std::filesystem; int main(int argc, char** argv) { if (argc < 4) { fprintf(stderr, "Usage: autogen \n"); return 1; } AnalysisState state; fs::path srcRoot = argv[1]; fs::path srcPath = argv[2]; fs::path outPath = argv[3]; fs::path relpath = fs::relative(srcPath, srcRoot); printf("[AUTOGEN] Processing file %s...\n", relpath.c_str()); analyzeClasses(srcPath, srcRoot, &state); fs::create_directories(outPath.parent_path()); // Make sure generated dir exists before we try writing to it printf("[AUTOGEN] Generating file %s...\n", relpath.c_str()); std::ofstream outStream(outPath); for (auto& [_, clazz] : state.classes) { writeCodeForClass(outStream, clazz); } outStream.close(); return 0; }