// // "$Id: ide_maketools.cxx 7169 2010-02-27 22:38:25Z matt $" // // IDE and Build FIle generation for the Fast Light Tool Kit (FLTK). // // Copyright 1998-2009 by Bill Spitzak and others. // // This library 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 library 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 // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // // Please report all bugs and problems on the following page: // // http://www.fltk.org/str.php // /* MAKETOOLS IDE FILES FLTK builds easily from the command line using the sequence: > autoconfig > ./configure > make > test/Demo > sudo make install This module creates all "Makefile" files that are required to create the project. Other files, for example "config.h.in" or "makeinclude.in", are not created. We expect them to exist already. This may change in later releases and for stand-alone application support. The Makefiles are pretty straight forward. Just read the source code below. There are some exceptions, particularly for handling OpenGL that are hard coded into the sources below. */ #include "ide_support.h" #include #include #include "../src/flstring.h" #include "Fl_Type.h" /* * This class creates all Makefile/autoconf files. */ class Maketools_IDE { char *rootDir; char projectName[80]; Fl_Preferences tgtAppsDB; int nTgtApps; Fl_Preferences tgtLibsDB; int nTgtLibs; Fl_Preferences tgtTestsDB; int nTgtTests; Fl_Preferences filesDB; int nFiles; Fl_Preferences ideDB; public: Maketools_IDE(Fl_Preferences &db, const char *rootDirA) : rootDir(strdup(rootDirA)), tgtAppsDB(db, "targets/apps"), tgtLibsDB(db, "targets/libs"), tgtTestsDB(db, "targets/tests"), filesDB(db, "files"), ideDB(db, "ide/Maketools") { db.get("projectName", projectName, "Unnamed", 80); nTgtApps = tgtAppsDB.groups(); nTgtLibs = tgtLibsDB.groups(); nTgtTests = tgtTestsDB.groups(); nFiles = filesDB.groups(); } ~Maketools_IDE() { if (rootDir) free(rootDir); } #if 0 /* * Write all files required during the actual build. * These are actually forwarding links from the build setup into the * files section. */ int writeBuildFiles(FILE *out, Fl_Preferences &targetDB) { // FIXME: also write .app, .plist, and maybe headers // --- write all references to sources from the given target Fl_Preferences sourcesDB(targetDB, "sources"); int i, n = sourcesDB.groups(); for (i=0; i\"; };\n", xcFileID, fullName, fullName, pathAndName ); filetype = 0L; } else if (strcmp(ext, ".framework")==0) { fprintf(out, "\t\t%s /* %s */ = {isa = PBXFileReference; " "lastKnownFileType = \"wrapper.framework\"; " "name = %s; path = %s; " "sourceTree = \"\"; };\n", xcFileID, fullName, fullName, pathAndName ); filetype = 0L; } else if (strcmp(ext, ".icns")==0) { fprintf(out, "\t\t%s /* %s */ = {isa = PBXFileReference; " "lastKnownFileType = \"image.icns\"; " "name = %s; path = %s; " "sourceTree = \"\"; };\n", xcFileID, fullName, fullName, pathAndName ); filetype = 0L; } else if (strcmp(ext, ".plist")==0) { filetype = "text.plist.xml"; } if (filetype) fprintf(out, "\t\t%s /* %s */ = {isa = PBXFileReference; fileEncoding = 4; " "lastKnownFileType = %s; name = %s; " "path = ../../%s; sourceTree = SOURCE_ROOT; };\n", xcFileID, fullName, filetype, fullName, pathAndName); } fprintf(out, "/* End PBXFileReference section */\n\n"); return 0; } /* * List all framework build phases */ int writeFrameworksBuildPhase(FILE *out, Fl_Preferences &targetDB) { MAKE_XCID(xcBuildFrameworksID, targetDB); fprintf(out, "\t\t%s /* Frameworks */ = {\n", xcBuildFrameworksID); fprintf(out, "\t\t\tisa = PBXFrameworksBuildPhase;\n"); fprintf(out, "\t\t\tbuildActionMask = 2147483647;\n"); fprintf(out, "\t\t\tfiles = (\n"); Fl_Preferences libsDB(targetDB, "libs"); int i, n = libsDB.groups(); for (i=0; i\";\n"); fprintf(out, "\t\t};\n"); return 0; } /* * Groups define the folder hierarchy in the "Groups & Files" panel */ int writeGroupSection(FILE *out) { int i; char name[80]; fprintf(out, "/* Begin PBXGroup section */\n"); // --- FIXME: missing "icons" group // --- main group fprintf(out, "\t\t%s = {\n", xcMainGroupID); fprintf(out, "\t\t\tisa = PBXGroup;\n"); fprintf(out, "\t\t\tchildren = (\n"); fprintf(out, "\t\t\t\t%s /* Applications */,\n", xcAppsGroupID); fprintf(out, "\t\t\t\t%s /* Frameworks */,\n", xcLibsGroupID); fprintf(out, "\t\t\t\t%s /* Tests */,\n", xcTestsGroupID); fprintf(out, "\t\t\t\t%s /* Products */,\n", xcProductsGroupID); // link to "Products" group fprintf(out, "\t\t\t);\n"); fprintf(out, "\t\t\tsourceTree = \"\";\n"); fprintf(out, "\t\t};\n"); // --- "Products" group fprintf(out, "\t\t%s /* Products */ = {\n", xcProductsGroupID); fprintf(out, "\t\t\tisa = PBXGroup;\n"); fprintf(out, "\t\t\tchildren = (\n"); for (i=0; i\";\n"); fprintf(out, "\t\t};\n"); // --- FIXME: missing "plists" group // --- "Applications" group fprintf(out, "\t\t%s /* Applications */ = {\n", xcAppsGroupID); fprintf(out, "\t\t\tisa = PBXGroup;\n"); fprintf(out, "\t\t\tchildren = (\n"); for (i=0; i\";\n"); fprintf(out, "\t\t};\n"); for (i=0; i\";\n"); fprintf(out, "\t\t};\n"); for (i=0; i\";\n"); fprintf(out, "\t\t};\n"); for (i=0; i\n#endif\n\n", f); fclose(f); return 0; } int createIcons(const char *filepath) { // FIXME: LATER: create a minimum set of icon files? return 0; } /* * create a single plists/[name]-Info.plist */ int writePList(const char *filepath, Fl_Preferences &target_db, int fmwk=0) { char name[80]; target_db.get("name", name, "DBERROR", 79); char filename[2048]; fl_snprintf(filename, 2047, "%s/%s-Info.plist", filepath, name); FILE *f = fopen(filename, "wb"); fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\tCFBundleDevelopmentRegion\n"); fprintf(f, "\tEnglish\n"); if (strcmp(name, "Fluid")==0) { // TODO: this option is not yet in the database fprintf(f, "\tCFBundleDocumentTypes\n"); fprintf(f, "\t\n"); fprintf(f, "\t\t\n"); fprintf(f, "\t\t\tCFBundleTypeExtensions\n"); fprintf(f, "\t\t\t\n"); fprintf(f, "\t\t\t\tfl\n"); fprintf(f, "\t\t\t\n"); fprintf(f, "\t\t\tCFBundleTypeIconFile\n"); fprintf(f, "\t\t\tfluid_doc\n"); fprintf(f, "\t\t\tCFBundleTypeName\n"); fprintf(f, "\t\t\tFluid Documents\n"); fprintf(f, "\t\t\tCFBundleTypeOSTypes\n"); fprintf(f, "\t\t\t\n"); fprintf(f, "\t\t\t\tflid\n"); fprintf(f, "\t\t\t\n"); fprintf(f, "\t\t\tCFBundleTypeRole\n"); fprintf(f, "\t\t\tEditor\n"); fprintf(f, "\t\t\tLSTypeIsPackage\n"); fprintf(f, "\t\t\t\n"); fprintf(f, "\t\t\tNSPersistentStoreTypeKey\n"); fprintf(f, "\t\t\tBinary\n"); fprintf(f, "\t\t\n"); fprintf(f, "\t\n"); } fprintf(f, "\tCFBundleExecutable\n"); fprintf(f, "\t${EXECUTABLE_NAME}\n"); // find the first suitable icon file if there is one Fl_Preferences extsDB(target_db, "externals"); int i, n = extsDB.groups(); for (i=0; iCFBundleIconFile\n\t%s", fileDB.fileName()); break; } } } fprintf(f, "\tCFBundleIdentifier\n"); fprintf(f, "\torg.fltk.%s\n", name); fprintf(f, "\tCFBundleInfoDictionaryVersion\n"); fprintf(f, "\t6.0\n"); fprintf(f, "\tCFBundlePackageType\n"); if (fmwk) fprintf(f, "\tFMWK\n"); else fprintf(f, "\tAPPL\n"); fprintf(f, "\tCFBundleSignature\n"); fprintf(f, "\tFLTK\n"); fprintf(f, "\tCFBundleVersion\n"); fprintf(f, "\t1.0\n"); fprintf(f, "\n"); fprintf(f, "\t\n"); fclose(f); return 0; } /* * Create the plist files for all apps and tests */ int writePLists(const char *filepath) { int i; for (i=0; i : create all IDE files for a Makefile/autoconf based project\n" " WARNING: --dbmake is not yet implemented completely.\n"; } int arg(int argc, char **argv, int &i) { if (argc>=i+1 && strcmp(argv[i], "--dbxcode3")==0) { if (argc>=i+3 && argv[i+1][0]!='-' && argv[i+2][0]!='-') { fprintf(stderr, "Creating Makefiles from %s in %s\n", argv[i+1], argv[i+2]); exit_early = 1; fprintf(stderr, "WARNING: --dbmake is not yet implemented completely.\n"); generate_fltk_maketools_support(argv[i+1], argv[i+2]); i = i+3; return 3; } else { fprintf(stderr, "Missing argument: --dbmake \n"); return 1; } } return 0; } int test(const char *a1, const char *a2, const char *a3) { generate_fltk_maketools_support(a1, a2); return 0; } }; Fl_IDE_Maketools_Plugin IDE_Maketools_Plugin; // // End of "$Id: ide_maketools.cxx 7169 2010-02-27 22:38:25Z matt $". //