24 #include <gwenhywfar/gwenhywfar.h> 25 #include <gwenhywfar/cgui.h> 26 #include <gwenhywfar/debug.h> 27 #include <gwenhywfar/args.h> 28 #include <gwenhywfar/i18n.h> 29 #include <gwenhywfar/text.h> 30 #include <gwenhywfar/directory.h> 40 #define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg) 44 #define ARGS_COMMAND_SETUP 0x0001 45 #define ARGS_COMMAND_PREPARE 0x0002 46 #define ARGS_COMMAND_BUILD 0x0004 47 #define ARGS_COMMAND_REPEAT_SETUP 0x0008 48 #define ARGS_COMMAND_INSTALL 0x0010 49 #define ARGS_COMMAND_CLEAN 0x0020 50 #define ARGS_COMMAND_DIST 0x0040 55 static int _handleStringArgument(
int argc,
char **argv,
int *pIndex,
const char *sArg,
const char *sArgId,
64 struct sigaction sigActionChild;
67 void _signalHandler(
int s) {
73 fprintf(stderr,
"Received unhandled signal %d\n", s);
76 signal(s, _signalHandler);
81 int _setSingleSignalHandler(
struct sigaction *sa,
int sig)
83 sa->sa_handler=_signalHandler;
84 sigemptyset(&sa->sa_mask);
86 if (sigaction(sig, sa, 0)) {
87 DBG_ERROR(
NULL,
"Could not setup signal handler for signal %d", sig);
95 int _setSignalHandlers() {
98 rv=_setSingleSignalHandler(&sigActionChild, SIGCHLD);
112 int main(
int argc,
char **argv)
122 signal(SIGCHLD, _signalHandler);
128 fprintf(stderr,
"Could not initialize Gwenhywfar.\n");
169 fprintf(stderr,
"ERROR: Error on setup build environment.\n");
177 fprintf(stderr,
"ERROR: Error on repeating setup.\n");
185 fprintf(stderr,
"ERROR: Error on preparing build environment.\n");
193 fprintf(stderr,
"ERROR: Error on building.\n");
201 fprintf(stderr,
"ERROR: Error on installing.\n");
209 fprintf(stderr,
"ERROR: Error on creating dist file.\n");
217 fprintf(stderr,
"ERROR: Error on cleaning generated files.\n");
226 "WARNING: Could not deinitialize Gwenhywfar.\n");
275 if (strncmp(s,
"-O", 2)==0) {
280 if (strncmp(s,
"-B", 2)==0) {
285 if (strncmp(s,
"-L", 2)==0) {
290 if (strncmp(s,
"-C", 2)==0) {
295 else if (strcmp(s,
"--dump")==0)
297 else if (strcmp(s,
"--static")==0)
299 else if (strcmp(s,
"--help")==0) {
303 else if (strcmp(s,
"-p")==0)
305 else if (strcmp(s,
"-s")==0)
307 else if (strcmp(s,
"-r")==0)
309 else if (strcmp(s,
"-b")==0)
311 else if (strcmp(s,
"-i")==0)
313 else if (strcmp(s,
"-c")==0)
315 else if (strcmp(s,
"-d")==0)
317 else if (strncmp(s,
"-j", 2)==0) {
328 if (1!=sscanf(s,
"%d", &val)) {
355 "Building a project (e.g. compiling and linking) is done in multiple steps.\n" 357 "1. Setup Build Environment\n" 358 "-------------------------\n" 359 "A. Create files named 0BUILD inside your project (see project AqFinance for\n" 361 "B. Create an empty folder and change into it (all next commands are run\n" 363 "You might want to use a folder like 'build' inside the source tree of\n" 366 " gwbuild PATH_TO_SOURCE_TREE\n" 369 "2. Prepare Buidling\n" 370 "-------------------\n" 372 "This is only needed if your project uses typemaker2 to generate c-sources from\n" 374 "This command makes typemaker2 create its derived type description files needed\n" 376 "typemaker2 generated types inside another typemaker2 generated type.\n" 378 "3. Build Typemaker2 Files\n" 379 "-------------------------\n" 380 " gwbuild -Btm2builder\n" 381 "This also is only needed if typemaker2 files are used in your project.\n" 383 "4. Build All Other Targets\n" 384 "--------------------------\n" 386 "This uses a single process to compile and link the project files.\n" 387 "If you have multiple processor cores/threads you can build multiple files in\n" 390 "This command uses 14 processes in parallel.\n" 391 "The step can be repeated as often as needed. It will automatically check for\n" 392 "changed files and try to only re-compile/link those modified files and others\n" 393 "which depend on them.\n" 394 "If you change a 0BUILD file gwbuild will automatically call the setup step\n" 396 "arguments given to the last setup command (-s). This typically leads to all\n" 397 "files being re-build.\n" 401 "-s setup build environment\n" 402 "-p run preparation commands (needed e.g. if typemaker2 is used)\n" 405 "-c cleanup; delete generated files\n" 406 "-r repeat setup command using the same arguments given to last setup\n" 407 "-d make distribution folder (you need to run tar yourself for now)\n" 408 "-Oname=value specify options (can occur multiple times)\n" 409 "-Bname Only run commands for the given build (mostly used with\n" 411 "-Lname Set loglevel (debug, info, notice, warn, error)\n" 412 "-Cname Crosscompile for given environment (e-g- 'x86_64-w64-mingw32')\n" 413 "-jvalue Use the given number of parallel process for building\n" 414 "--static Generate static libs for InstallLibrary targets\n" #define GWEN_DB_FLAGS_OVERWRITE_VARS
#define ARGS_COMMAND_CLEAN
int GWB_Setup(GWEN_DB_NODE *dbArgs)
struct GWEN_DB_NODE GWEN_DB_NODE
int GWB_RepeatLastSetup(const char *fileName)
#define GWEN_ERROR_INVALID
void GWEN_Logger_SetLevel(const char *logDomain, GWEN_LOGGER_LEVEL l)
#define ARGS_COMMAND_REPEAT_SETUP
#define ARGS_COMMAND_SETUP
GWEN_LOGGER_LEVEL GWEN_Logger_Name2Level(const char *name)
#define ARGS_COMMAND_DIST
#define ARGS_COMMAND_INSTALL
int GWB_Build(GWEN_DB_NODE *dbArgs)
int GWB_Clean(const char *fname)
#define GWEN_ERROR_GENERIC
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
int GWEN_Logger_Open(const char *logDomain, const char *ident, const char *file, GWEN_LOGGER_LOGTYPE logtype, GWEN_LOGGER_FACILITY facility)
#define DBG_ERROR(dbg_logger, format, args...)
int GWB_Prepare(GWEN_UNUSED GWEN_DB_NODE *dbArgs)
#define ARGS_COMMAND_PREPARE
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
#define ARGS_COMMAND_BUILD
int main(int argc, char **argv)
#define DBG_INFO(dbg_logger, format, args...)
static int _readArgsIntoDb(int argc, char **argv, GWEN_DB_NODE *db)
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
int GWEN_DB_SetIntValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
#define GWENHYWFAR_VERSION_FULL_STRING
void GWEN_Gui_SetGui(GWEN_GUI *gui)
GWEN_GUI * GWEN_Gui_CGui_new(void)
int GWB_InstallFiles(const char *fileName, const char *destDir)
static void _printHelpScreen()
static int _handleStringArgument(int argc, char **argv, int *pIndex, const char *sArg, const char *sArgId, const char *sVarName, GWEN_DB_NODE *db)
#define GWEN_DB_FLAGS_DEFAULT