Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:CobrA_SK
fcmake
main.cpp
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File main.cpp of Package fcmake
/*************************************************************************** * Copyright (C) 2008 Brno University of Technology, * * Faculty of Information Technology * * Author(s): Marek Vavrusa <xvavru00 AT stud.fit.vutbr.cz> * * Zdenek Vasicek <vasicek AT fit.vutbr.cz> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include <QCoreApplication> #include <QString> #include <QDir> #include <stdio.h> #include <stdlib.h> #include "tree.h" #include "app.h" #include "filelist.h" #include "getarg.h" /* Debugging */ #ifdef DEBUG #define DEBUG_MSG(fmt, args...) (fprintf(stderr, "debug: "),fprintf(stderr, fmt, ## args)) #else #define DEBUG_MSG(fmt, args...) #endif #define ERROR_MSG(fmt, args...) (fprintf(stderr, "error: "),fprintf(stderr, fmt, ## args)) using namespace FCMake; //TODO: XML v adresari BASE, ktery bude obsahovat nastavistelne veci? //TODO: pokud se zmeni XML, automaticky v makefile jej zavolat! /* fcmake --generate [project.xml] fcmake --clean [project.xml] fcmake --cleanall [project.xml] fcmake --updatelist [project.xml] (create a list of all files and store it in base/filelist.xml) */ int help(const char* name, Arg::List& args); int main(int argc, char *argv[]) { QCoreApplication mainApp(argc, argv); // Targets bool generate = false; bool genlist = false; bool clean = false; bool cleanAll = false; bool isError = false; QString appPath = QDir::current().absolutePath(); //current directory // Get arguments Arg::List args(argc, argv); args.push_back('g', "--generate", "Generate Makefile from project.xml. (default action)"); args.push_back('u', "--updatelist", "Create a list of all files and store it in base/filelist."); args.push_back('c', "--clean", "\tClean generated files excluding Makefile."); args.push_back('a', "--cleanall", "Clean all generated files including Makefile."); args.push_back('h', "--help", "\tShow this help."); // Scan arguments Arg::Param* arg = 0; while((arg = args.next()) != 0) { switch(arg->code) { case 'g': generate = true; break; case 'u': genlist = true; break; case 'a': cleanAll = true; // CleanAll includes clean case 'c': clean = true; break; case 'h': return help(argv[0], args); break; default: QFileInfo info(args.arg()); if(info.exists()) appPath = info.canonicalPath(); break; } } // default action - generate if ((!clean) && (!cleanAll) && (!genlist)) generate = true; // Initialize tree Tree tree((QFileInfo(appPath).isFile()) ? QFileInfo(appPath).absolutePath() : appPath); qDebug("App path: %s", appPath.toStdString().c_str()); qDebug("Tree path: %s", tree.root().absolutePath().toStdString().c_str()); // Initialize libfitkit App* libApp = tree.app(LIBFITKIT_PATH); if (libApp == 0) { ERROR_MSG("can't find libfitkit directory\n\n"); help(argv[0], args); return 1; } if (genlist) { qDebug("Generate file list (root directory: %s)", tree.root().absolutePath().toStdString().c_str()); FileList list(tree.root()); if (list.writeToXML()) qDebug("File list updated successfully"); else ERROR_MSG("unable to create the file base/filelist.xml\n"); return 0; } // Initialize application App app; if (!app.load(appPath)) { ERROR_MSG("can't find either project.xml or library.xml\n\n"); help(argv[0], args); return 1; } // Target: clean if (clean) { if (!app.clean(cleanAll)) { ERROR_MSG("can't clean\n"); isError = true; } } // Target: generate if (generate) { // Create Makefile if (app.createMakefile(mainApp.applicationFilePath())) { qDebug("Project make files successfully created."); // Check flags if (app.isCompiled()) qDebug("Project is compiled"); if (app.isUpdated()) qDebug("Project is up-to-date"); // refresh libfitkit Makefile if ((app.path() != libApp->path()) && (libApp->createMakefile(mainApp.applicationFilePath()))) { qDebug("libfitkit make files successfully created."); if (libApp->isCompiled()) qDebug("libfitkit is compiled"); if (libApp->isUpdated()) qDebug("libfitkit is up-to-date"); } } else { qDebug("Unable to create necessary files."); isError = true; } } delete libApp; return isError ? EXIT_FAILURE : EXIT_SUCCESS; } int help(const char* name, Arg::List& args) { // Show help printf("Usage: %s [options] [project.xml]\n", name); printf("Options:\n"); for(Arg::List::iterator it = args.begin(); it < args.end(); ++it) printf(" -%c, %s\t%s\n", (*it).code, (*it).name, (*it).desc); printf("\n"); printf("When no project.xml path given, FCMake looks in current directory.\n"); return 0; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor