From 9cf4d8c014bd1c6dc6dae70057046f2191a207ea Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 6 Mar 2010 15:22:22 +0000 Subject: Starting to add IDE support for Makefile/autoconf. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7226 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- fluid/ide_maketools.cxx | 1632 +++++++++++++++++++++++++++++ ide/Xcode3/FLTK.xcodeproj/project.pbxproj | 2 +- 2 files changed, 1633 insertions(+), 1 deletion(-) create mode 100644 fluid/ide_maketools.cxx diff --git a/fluid/ide_maketools.cxx b/fluid/ide_maketools.cxx new file mode 100644 index 000000000..e71e51859 --- /dev/null +++ b/fluid/ide_maketools.cxx @@ -0,0 +1,1632 @@ +// +// "$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 $". +// diff --git a/ide/Xcode3/FLTK.xcodeproj/project.pbxproj b/ide/Xcode3/FLTK.xcodeproj/project.pbxproj index 8f5786468..4f81d4a41 100644 --- a/ide/Xcode3/FLTK.xcodeproj/project.pbxproj +++ b/ide/Xcode3/FLTK.xcodeproj/project.pbxproj @@ -5296,6 +5296,7 @@ 40C91D1AB7051A0D4BF38884 /* file.cxx */, 80B8A51F1B0E64482CB2723F /* fluid.cxx */, 1C0E3777F229938969F8E0E7 /* function_panel.cxx */, + B65FCD2B8489E2BBAA3F695A /* ide_maketools.cxx */, 77759BD79A674B0703F21C3E /* ide_support.cxx */, BE8AEC5B94A33E971A141F65 /* ide_support_ui.cxx */, B50524F41B3A568F8AD761C9 /* ide_visualc.cxx */, @@ -5303,7 +5304,6 @@ 82D70F7B9460C9797FF03089 /* template_panel.cxx */, 3F148981EF92A30C3D6D698E /* undo.cxx */, B0CFC7002EFFC3DD3E191940 /* widget_panel.cxx */, - B65FCD2B8489E2BBAA3F695A /* ide_maketools.cxx */, BDC84124E6CDF9D25B9505B6 /* fluid.icns */, ); name = Fluid; -- cgit v1.2.3