int main(int argc, char **argv) { char *filename, *docFile, *codeDir, *srcSuffix, *flagFile, *consModule; char arg, *optarg, *buildFile, *apiFile, *xmlFile, *pyiFile; int optnr, exceptions, tracing, releaseGIL, parts, protHack, docs; int timestamp, was_flagFile; KwArgs kwArgs; FILE *file; sipSpec spec; stringList *versions, *backstops, *xfeatures, *extracts; /* Initialise. */ sipVersion = SIP_VERSION_STR; includeDirList = NULL; versions = NULL; backstops = NULL; xfeatures = NULL; buildFile = NULL; codeDir = NULL; docFile = NULL; srcSuffix = NULL; flagFile = NULL; was_flagFile = FALSE; apiFile = NULL; xmlFile = NULL; pyiFile = NULL; consModule = NULL; extracts = NULL; exceptions = FALSE; tracing = FALSE; releaseGIL = FALSE; parts = 0; kwArgs = NoKwArgs; protHack = FALSE; docs = FALSE; timestamp = TRUE; /* Parse the command line. */ optnr = 1; while ((arg = parseopt(argc, argv, "hVa:b:B:ec:d:fgI:j:km:op:Prs:t:Twx:X:y:z:", &flagFile, &optnr, &optarg)) != '\0') switch (arg) { case 'o': /* Generate docstrings. */ docs = TRUE; break; case 'p': /* The name of the consolidated module. */ consModule = optarg; break; case 'P': /* Enable the protected/public hack. */ protHack = TRUE; break; case 'a': /* Where to generate the API file. */ apiFile = optarg; break; case 'm': /* Where to generate the XML file. */ xmlFile = optarg; break; case 'y': /* Where to generate the .pyi file. */ pyiFile = optarg; break; case 'b': /* Generate a build file. */ buildFile = optarg; break; case 'B': /* Define a backstop. */ appendString(&backstops, optarg); break; case 'e': /* Enable exceptions. */ exceptions = TRUE; break; case 'g': /* Always release the GIL. */ releaseGIL = TRUE; break; case 'j': /* Generate the code in this number of parts. */ parts = parseInt(optarg,'j'); break; case 'z': /* Read a file for the next flags. */ if (flagFile != NULL) fatal("The -z flag cannot be specified in an argument file\n"); flagFile = optarg; was_flagFile = TRUE; break; case 'c': /* Where to generate the code. */ codeDir = optarg; break; case 'd': /* Where to generate the documentation. */ docFile = optarg; break; case 't': /* Which platform or version to generate code for. */ appendString(&versions,optarg); break; case 'T': /* * Disable the timestamp in the header of generated files. It is * now ignored apart from triggering a deprecation warning. */ timestamp = FALSE; break; case 'x': /* Which features are disabled. */ appendString(&xfeatures,optarg); break; case 'X': /* Which extracts are to be created. */ appendString(&extracts, optarg); break; case 'I': /* Where to get included files from. */ appendString(&includeDirList,optarg); break; case 'r': /* Enable tracing. */ tracing = TRUE; break; case 's': /* The suffix to use for source files. */ srcSuffix = optarg; break; case 'w': /* Enable warning messages. */ warnings = TRUE; break; case 'f': /* Warning messages are fatal. */ warnings_are_fatal = TRUE; break; case 'k': /* Allow keyword arguments in functions and methods. */ kwArgs = AllKwArgs; break; case 'h': /* Help message. */ help(); break; case 'V': /* Display the version number. */ version(); break; default: usage(); } if (optnr < argc) { file = NULL; filename = argv[optnr++]; if (optnr < argc) usage(); } else { file = stdin; filename = "stdin"; } /* Issue warnings after they (might) have been enabled. */ if (docFile != NULL) warning(DeprecationWarning, "the -d flag is deprecated\n"); if (kwArgs != NoKwArgs) warning(DeprecationWarning, "the -k flag is deprecated\n"); if (!timestamp) warning(DeprecationWarning, "the -T flag is ignored and deprecated\n"); if (was_flagFile) warning(DeprecationWarning, "the -z flag is deprecated\n"); /* Parse the input file. */ parse(&spec, file, filename, versions, backstops, xfeatures, kwArgs, protHack); /* Verify and transform the parse tree. */ transform(&spec); /* Generate code. */ generateCode(&spec, codeDir, buildFile, docFile, srcSuffix, exceptions, tracing, releaseGIL, parts, versions, xfeatures, consModule, docs, FALSE); /* Generate any extracts. */ generateExtracts(&spec, extracts); /* Generate the API file. */ if (apiFile != NULL) generateAPI(&spec, spec.module, apiFile); /* Generate the XML export. */ if (xmlFile != NULL) generateXML(&spec, spec.module, xmlFile); /* Generate the .pyi file. */ if (pyiFile != NULL) generateTypeHints(&spec, spec.module, pyiFile); /* All done. */ return 0; }
int main(int argc, char **argv) { char *filename, *docFile, *codeDir, *srcSuffix, *flagFile, *consModule; char arg, *optarg, *buildFile, *apiFile, *xmlFile; int optnr, exceptions, tracing, releaseGIL, parts; FILE *file; sipSpec spec; stringList *versions, *xfeatures; /* Initialise. */ sipVersion = VERSION; includeDirList = NULL; versions = NULL; xfeatures = NULL; buildFile = NULL; codeDir = NULL; docFile = NULL; srcSuffix = NULL; flagFile = NULL; apiFile = NULL; xmlFile = NULL; consModule = NULL; exceptions = FALSE; tracing = FALSE; releaseGIL = FALSE; parts = 0; /* Parse the command line. */ optnr = 1; while ((arg = parseopt(argc, argv, "hVa:b:ec:d:gI:j:m:p:rs:t:wx:z:", &flagFile, &optnr, &optarg)) != '\0') switch (arg) { case 'p': /* The name of the consolidated module. */ consModule = optarg; break; case 'a': /* Where to generate the API file. */ apiFile = optarg; break; case 'm': /* Where to generate the XML file. */ xmlFile = optarg; break; case 'b': /* Generate a build file. */ buildFile = optarg; break; case 'e': /* Enable exceptions. */ exceptions = TRUE; break; case 'g': /* Always release the GIL. */ releaseGIL = TRUE; break; case 'j': /* Generate the code in this number of parts. */ parts = parseInt(optarg,'j'); break; case 'z': /* Read a file for the next flags. */ if (flagFile != NULL) fatal("The -z flag cannot be specified in an argument file\n"); flagFile = optarg; break; case 'c': /* Where to generate the code. */ codeDir = optarg; break; case 'd': /* Where to generate the documentation. */ docFile = optarg; break; case 't': /* Which platform or version to generate code for. */ appendString(&versions,optarg); break; case 'x': /* Which features are disabled. */ appendString(&xfeatures,optarg); break; case 'I': /* Where to get included files from. */ appendString(&includeDirList,optarg); break; case 'r': /* Enable tracing. */ tracing = TRUE; break; case 's': /* The suffix to use for source files. */ srcSuffix = optarg; break; case 'w': /* Enable warning messages. */ warnings = TRUE; break; case 'h': /* Help message. */ help(); break; case 'V': /* Display the version number. */ version(); break; default: usage(); } if (optnr < argc) { file = NULL; filename = argv[optnr++]; if (optnr < argc) usage(); } else { file = stdin; filename = "stdin"; } /* Parse the input file. */ parse(&spec, file, filename, versions, xfeatures); /* Verify and transform the parse tree. */ transform(&spec); /* Generate code. */ generateCode(&spec, codeDir, buildFile, docFile, srcSuffix, exceptions, tracing, releaseGIL, parts, xfeatures, consModule); /* Generate the API file. */ if (apiFile != NULL) generateAPI(&spec, spec.module, apiFile); /* Generate the XML export. */ if (xmlFile != NULL) generateXML(&spec, spec.module, xmlFile); /* All done. */ return 0; }