25#include <gwenhywfar/gwenhywfar.h>
26#include <gwenhywfar/cgui.h>
27#include <gwenhywfar/debug.h>
28#include <gwenhywfar/args.h>
29#include <gwenhywfar/i18n.h>
30#include <gwenhywfar/text.h>
31#include <gwenhywfar/directory.h>
41#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg)
45#define ARGS_COMMAND_SETUP 0x0001
46#define ARGS_COMMAND_PREPARE 0x0002
47#define ARGS_COMMAND_BUILD 0x0004
48#define ARGS_COMMAND_REPEAT_SETUP 0x0008
49#define ARGS_COMMAND_INSTALL 0x0010
50#define ARGS_COMMAND_CLEAN 0x0020
51#define ARGS_COMMAND_DIST 0x0040
56static int _handleStringArgument(
int argc,
char **argv,
int *pIndex,
const char *sArg,
const char *sArgId,
65# ifdef _POSIX_C_SOURCE
66struct sigaction sigActionChild;
70void _signalHandler(
int s) {
78 fprintf(stderr,
"Received unhandled signal %d\n", s);
81 signal(s, _signalHandler);
87int _setSingleSignalHandler(
struct sigaction *sa,
int sig)
89 sa->sa_handler=_signalHandler;
90 sigemptyset(&sa->sa_mask);
92 if (sigaction(sig, sa, 0)) {
93 DBG_ERROR(
NULL,
"Could not setup signal handler for signal %d", sig);
102int _setSignalHandlers() {
103#ifdef _POSIX_C_SOURCE
106 rv=_setSingleSignalHandler(&sigActionChild, SIGCHLD);
130#if defined(HAVE_SIGNAL_H) && defined(_POSIX_C_SOURCE)
131 signal(SIGCHLD, _signalHandler);
137 fprintf(stderr,
"Could not initialize Gwenhywfar.\n");
178 fprintf(stderr,
"ERROR: Error on setup build environment.\n");
186 fprintf(stderr,
"ERROR: Error on repeating setup.\n");
194 fprintf(stderr,
"ERROR: Error on preparing build environment.\n");
202 fprintf(stderr,
"ERROR: Error on building.\n");
210 fprintf(stderr,
"ERROR: Error on installing.\n");
218 fprintf(stderr,
"ERROR: Error on creating dist file.\n");
226 fprintf(stderr,
"ERROR: Error on cleaning generated files.\n");
235 "WARNING: Could not deinitialize Gwenhywfar.\n");
280 fprintf(stderr,
"Specifying build target not yet supported.\n");
287 if (strncmp(s,
"-O", 2)==0) {
292 if (strncmp(s,
"-B", 2)==0) {
297 if (strncmp(s,
"-L", 2)==0) {
302 if (strncmp(s,
"-C", 2)==0) {
307 else if (strcmp(s,
"--dump")==0)
309 else if (strcmp(s,
"--static")==0)
311 else if (strcmp(s,
"--help")==0) {
315 else if (strcmp(s,
"-p")==0)
317 else if (strcmp(s,
"-s")==0) {
323 else if (strcmp(s,
"-r")==0)
325 else if (strcmp(s,
"-b")==0)
327 else if (strcmp(s,
"-i")==0)
329 else if (strcmp(s,
"-c")==0)
331 else if (strcmp(s,
"-d")==0)
333 else if (strncmp(s,
"-j", 2)==0) {
344 if (1!=sscanf(s,
"%d", &val)) {
371 "Building a project (e.g. compiling and linking) is done in multiple steps.\n"
373 "1. Setup Build Environment\n"
374 "-------------------------\n"
375 "A. Create files named 0BUILD inside your project (see project AqFinance for\n"
377 "B. Create an empty folder and change into it (all next commands are run\n"
379 "You might want to use a folder like 'build' inside the source tree of\n"
382 " gwbuild -s PATH_TO_SOURCE_TREE\n"
383 "e.g. gwbuild -s ..\n"
385 "2. Prepare Buidling\n"
386 "-------------------\n"
388 "This is only needed if your project uses typemaker2 to generate c-sources from\n"
390 "This command makes typemaker2 create its derived type description files needed\n"
392 "typemaker2 generated types inside another typemaker2 generated type.\n"
394 "3. Build All Targets\n"
395 "--------------------------\n"
397 "This command builds typemaker2 source files first (if needed) and then all\n"
399 "A single process is used to compile and link the project files.\n"
400 "If you have multiple processor cores/threads you can build multiple files in\n"
403 "This command uses 14 processes in parallel.\n"
404 "The step can be repeated as often as needed. It will automatically check for\n"
405 "changed files and try to only re-compile/link those modified files and others\n"
406 "which depend on them.\n"
407 "If you change a 0BUILD file gwbuild will automatically call the setup step\n"
409 "arguments given to the last setup command (-s). This typically leads to all\n"
410 "files being re-build.\n"
414 "-s FOLDER setup build environment (arg: source folder path)\n"
415 "-p run preparation commands (needed e.g. if typemaker2 is used)\n"
418 "-c cleanup; delete generated files\n"
419 "-r repeat setup command using the same arguments given to last setup\n"
420 "-d make distribution folder (you need to run tar yourself for now)\n"
421 "-Oname=value specify options (can occur multiple times)\n"
422 "-Bname Only run commands for the given build (mostly used with\n"
424 "-Lname Set loglevel (debug, info, notice, warn, error)\n"
425 "-Cname Crosscompile for given environment (e-g- 'x86_64-w64-mingw32')\n"
426 "-jvalue Use the given number of parallel process for building\n"
427 "--static Generate static libs for InstallLibrary targets\n"
int GWB_Build(GWEN_DB_NODE *dbArgs)
int GWB_Clean(const char *fname)
int GWB_InstallFiles(const char *fileName, const char *destDir)
int GWB_Prepare(GWEN_UNUSED GWEN_DB_NODE *dbArgs)
int GWB_Setup(GWEN_DB_NODE *dbArgs)
int GWB_RepeatLastSetup(const char *fileName)
GWEN_GUI * GWEN_Gui_CGui_new(void)
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *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)
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
#define GWEN_DB_FLAGS_DEFAULT
#define GWEN_DB_FLAGS_OVERWRITE_VARS
struct GWEN_DB_NODE GWEN_DB_NODE
#define DBG_INFO(dbg_logger, format, args...)
#define DBG_ERROR(dbg_logger, format, args...)
#define GWEN_ERROR_INVALID
#define GWEN_ERROR_GENERIC
#define GWBUILD_FILE_INSTALLFILES
#define GWBUILD_FILE_FILES
#define GWBUILD_FILE_ARGS
void GWEN_Gui_SetGui(GWEN_GUI *gui)
static int _readArgsIntoDb(int argc, char **argv, GWEN_DB_NODE *db)
int main(int argc, char **argv)
#define ARGS_COMMAND_SETUP
#define ARGS_COMMAND_DIST
#define ARGS_COMMAND_PREPARE
#define ARGS_COMMAND_BUILD
#define ARGS_COMMAND_REPEAT_SETUP
#define ARGS_COMMAND_INSTALL
static int _handleStringArgument(int argc, char **argv, int *pIndex, const char *sArg, const char *sArgId, const char *sVarName, GWEN_DB_NODE *db)
static void _printHelpScreen()
#define ARGS_COMMAND_CLEAN
GWEN_LOGGER_LEVEL GWEN_Logger_Name2Level(const char *name)
int GWEN_Logger_Open(const char *logDomain, const char *ident, const char *file, GWEN_LOGGER_LOGTYPE logtype, GWEN_LOGGER_FACILITY facility)
void GWEN_Logger_SetLevel(const char *logDomain, GWEN_LOGGER_LEVEL l)
@ GWEN_LoggerType_Console
@ GWEN_LoggerFacility_User
@ GWEN_LoggerLevel_Unknown
@ GWEN_LoggerLevel_Warning
#define GWENHYWFAR_VERSION_FULL_STRING