[darwinbuild-changes] [204] trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 4 01:58:33 PDT 2006
Revision: 204
http://trac.macosforge.org/projects/darwinbuild/changeset/204
Author: kevin
Date: 2006-10-04 01:58:33 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
- major code consolidation with default usage and run handlers for plugins
Modified Paths:
--------------
trunk/CHANGES
trunk/darwinxref/DBPlugin.c
trunk/darwinxref/DBPlugin.h
trunk/darwinxref/DBTclPlugin.c
trunk/darwinxref/plugins/binary_sites.tcl
trunk/darwinxref/plugins/darwin.tcl
trunk/darwinxref/plugins/dependencies.c
trunk/darwinxref/plugins/environment.c
trunk/darwinxref/plugins/inherits.c
trunk/darwinxref/plugins/macosx.tcl
trunk/darwinxref/plugins/original.c
trunk/darwinxref/plugins/patchfiles.c
trunk/darwinxref/plugins/plist_sites.c
trunk/darwinxref/plugins/source_sites.c
trunk/darwinxref/plugins/target.c
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/CHANGES 2006-10-04 08:58:33 UTC (rev 204)
@@ -2,6 +2,7 @@
-----------------------------------
Release X.Y.Z [now]
+ - darwinxref: added default handlers for plugins
- darwinbuild: redo_prebinding to create a canonical Mach-O prior to
registering for reproducible manifests.
- Added synthfat script to synthesize fat dylibs from thin dylibs
Modified: trunk/darwinxref/DBPlugin.c
===================================================================
--- trunk/darwinxref/DBPlugin.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/DBPlugin.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -50,6 +50,8 @@
switch (type) {
case kDBPluginBasicType:
case kDBPluginPropertyType:
+ case kDBPluginBuildPropertyType:
+ case kDBPluginProjectPropertyType:
plugin->type = type;
break;
default:
@@ -280,3 +282,56 @@
CFStringRef DBGetCurrentBuild() {
return currentBuild;
}
+
+
+int DBPluginPropertyDefaultRun(CFArrayRef argv) {
+ DBPlugin* plugin = _DBPluginGetCurrentPlugin();
+ assert(plugin != NULL);
+ assert(plugin->name != NULL);
+
+ CFStringRef build = DBGetCurrentBuild();
+ CFIndex argc = CFArrayGetCount(argv);
+ CFStringRef project = (argc > 0) ? CFArrayGetValueAtIndex(argv, 0) : NULL;
+
+ // kDBPluginProjectPropertyType must have project argument,
+ // kDBPluginBuildPropertyType must not have project argument,
+ // kDBPluginPropertyType may have project argument.
+ if (plugin->type == kDBPluginProjectPropertyType && argc != 1) return -1;
+ if (plugin->type == kDBPluginBuildPropertyType && argc != 0) return -1;
+ if (plugin->type == kDBPluginPropertyType && argc != 0 && argc != 1) return -1;
+
+ if (plugin->datatype == CFStringGetTypeID()) {
+ CFStringRef value = DBCopyPropString(build, project, plugin->name);
+ // kDBPluginPropertyType: if no value in project, look in build.
+ if (!value && project) value = DBCopyPropString(build, NULL, plugin->name);
+ if (value) cfprintf(stdout, "%@\n", value);
+
+ } else if (plugin->datatype == CFArrayGetTypeID()) {
+ CFArrayRef value = DBCopyPropArray(build, project, plugin->name);
+ CFIndex i, count = value ? CFArrayGetCount(value) : 0;
+ // kDBPluginPropertyType: if no value in project, look in build.
+ if ((!value || !count) && project) {
+ value = DBCopyPropArray(build, NULL, plugin->name);
+ count = value ? CFArrayGetCount(value) : 0;
+ }
+ for (i = 0; i < count; ++i) {
+ cfprintf(stdout, "%@\n", CFArrayGetValueAtIndex(value, i));
+ }
+
+ } else {
+ fprintf(stderr, "internal error: no default handler for CFDictionary type\n");
+ return -1;
+ }
+ return 0;
+}
+
+CFStringRef DBPluginPropertyDefaultUsage() {
+ DBPlugin* plugin = _DBPluginGetCurrentPlugin();
+ assert(plugin != NULL);
+ // kDBPluginProjectPropertyType must have project argument,
+ // kDBPluginBuildPropertyType must not have project argument,
+ // kDBPluginPropertyType may have project argument.
+ if (plugin->type == kDBPluginProjectPropertyType) return CFRetain(CFSTR("<project>"));
+ if (plugin->type == kDBPluginBuildPropertyType) return CFRetain(CFSTR(""));
+ if (plugin->type == kDBPluginPropertyType) return CFRetain(CFSTR("[<project>]"));
+}
Modified: trunk/darwinxref/DBPlugin.h
===================================================================
--- trunk/darwinxref/DBPlugin.h 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/DBPlugin.h 2006-10-04 08:58:33 UTC (rev 204)
@@ -80,11 +80,17 @@
command line.
@constant kDBPluginPropertyType
Plugin which adds a build or project property to the plist file.
+ @constant kDBPluginProjectPropertyType
+ Plugin which adds a per-project property to the plist file.
+ @constant kDBPluginBuildPropertyType
+ Plugin which adds a per-build property to the plist file.
*/
enum {
kDBPluginNullType = 0,
kDBPluginBasicType = 1,
kDBPluginPropertyType = 2,
+ kDBPluginProjectPropertyType = 3,
+ kDBPluginBuildPropertyType = 4,
};
/*!
@@ -124,6 +130,10 @@
void DBPluginSetDataType(CFTypeID type);
void DBPluginSetSubDictDataType(CFTypeID type);
+// default handlers
+int DBPluginPropertyDefaultRun(CFArrayRef argv);
+CFStringRef DBPluginPropertyDefaultUsage();
+
// generally available routines
CFStringRef DBGetCurrentBuild();
Modified: trunk/darwinxref/DBTclPlugin.c
===================================================================
--- trunk/darwinxref/DBTclPlugin.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/DBTclPlugin.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -130,6 +130,10 @@
plugin->type = kDBPluginBasicType;
} else if (strcmp(type, "property") == 0) {
plugin->type = kDBPluginPropertyType;
+ } else if (strcmp(type, "property.project") == 0) {
+ plugin->type = kDBPluginProjectPropertyType;
+ } else if (strcmp(type, "property.build") == 0) {
+ plugin->type = kDBPluginBuildPropertyType;
} else {
Tcl_AppendResult(interp, "Unknown type: ", type, NULL);
return TCL_ERROR;
@@ -339,12 +343,28 @@
}
CFStringRef call_tcl_usage(DBPlugin* plugin) {
+ // Test if the 'usage' proc exists, if not, use the default handler.
+ if (Tcl_Eval(plugin->interp, "info commands usage") == TCL_OK) {
+ const char* result = Tcl_GetStringResult(plugin->interp);
+ if (result && strcmp(result, "usage") != 0) {
+ return DBPluginPropertyDefaultUsage();
+ }
+ }
+
Tcl_Eval(plugin->interp, "usage");
Tcl_Obj* res = Tcl_GetObjResult(plugin->interp);
return cfstr_tcl(res);
}
int call_tcl_run(DBPlugin* plugin, CFArrayRef args) {
+ // Test if the 'run' proc exists, if not, use the default handler.
+ if (Tcl_Eval(plugin->interp, "info commands run") == TCL_OK) {
+ const char* result = Tcl_GetStringResult(plugin->interp);
+ if (result && strcmp(result, "run") != 0) {
+ return DBPluginPropertyDefaultRun(args);
+ }
+ }
+
Tcl_Obj* tcl_args = tcl_cfarray(args);
Tcl_Obj* varname = tcl_cfstr(CFSTR("__args__"));
Tcl_ObjSetVar2(plugin->interp, varname, NULL, tcl_args, TCL_GLOBAL_ONLY);
Modified: trunk/darwinxref/plugins/binary_sites.tcl
===================================================================
--- trunk/darwinxref/plugins/binary_sites.tcl 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/binary_sites.tcl 2006-10-04 08:58:33 UTC (rev 204)
@@ -1,20 +1,3 @@
DBPluginSetName binary_sites
DBPluginSetType property
DBPluginSetDatatype array
-
-proc usage {} {
- return {[<project>]}
-}
-
-proc run {args} {
- set project [lindex $args 0]
- set build [DBGetCurrentBuild]
- set sites [DBCopyPropArray $build $project binary_sites]
- if {$project != "" && [llength $sites] == 0} {
- # use build-wide settings if project settings not found
- set sites [DBCopyPropArray $build "" binary_sites]
- }
- foreach site $sites {
- puts "$site"
- }
-}
Modified: trunk/darwinxref/plugins/darwin.tcl
===================================================================
--- trunk/darwinxref/plugins/darwin.tcl 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/darwin.tcl 2006-10-04 08:58:33 UTC (rev 204)
@@ -1,13 +1,3 @@
DBPluginSetName darwin
-DBPluginSetType property
+DBPluginSetType property.build
DBPluginSetDatatype string
-
-proc usage {} {
- return {[<project>]}
-}
-
-proc run {args} {
- set project [lindex $args 0]
- set build [DBGetCurrentBuild]
- puts [DBCopyPropString $build $project darwin]
-}
Modified: trunk/darwinxref/plugins/dependencies.c
===================================================================
--- trunk/darwinxref/plugins/dependencies.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/dependencies.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -75,7 +75,7 @@
int initialize(int version) {
//if ( version < kDBPluginCurrentVersion ) return -1;
- DBPluginSetType(kDBPluginPropertyType);
+ DBPluginSetType(kDBPluginProjectPropertyType);
DBPluginSetName(CFSTR("dependencies"));
DBPluginSetRunFunc(&run);
DBPluginSetUsageFunc(&usage);
Modified: trunk/darwinxref/plugins/environment.c
===================================================================
--- trunk/darwinxref/plugins/environment.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/environment.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -92,17 +92,13 @@
return 0;
}
-static CFStringRef usage() {
- return CFRetain(CFSTR("[<project>]"));
-}
-
int initialize(int version) {
//if ( version < kDBPluginCurrentVersion ) return -1;
DBPluginSetType(kDBPluginPropertyType);
DBPluginSetName(CFSTR("environment"));
DBPluginSetRunFunc(&run);
- DBPluginSetUsageFunc(&usage);
+ DBPluginSetUsageFunc(&DBPluginPropertyDefaultUsage);
DBPluginSetDataType(CFDictionaryGetTypeID());
return 0;
}
Modified: trunk/darwinxref/plugins/inherits.c
===================================================================
--- trunk/darwinxref/plugins/inherits.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/inherits.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -32,25 +32,13 @@
#include "DBPlugin.h"
-static int run(CFArrayRef argv) {
- if (CFArrayGetCount(argv) != 0) return -1;
- CFStringRef build = DBGetCurrentBuild();
- CFStringRef inherits = DBCopyPropString(build, NULL, CFSTR("inherits"));
- if (inherits) cfprintf(stdout, "%@\n", inherits);
- return 0;
-}
-
-static CFStringRef usage() {
- return CFRetain(CFSTR(""));
-}
-
int initialize(int version) {
//if ( version < kDBPluginCurrentVersion ) return -1;
- DBPluginSetType(kDBPluginPropertyType);
+ DBPluginSetType(kDBPluginBuildPropertyType);
DBPluginSetName(CFSTR("inherits"));
- DBPluginSetRunFunc(&run);
- DBPluginSetUsageFunc(&usage);
+ DBPluginSetRunFunc(&DBPluginPropertyDefaultRun);
+ DBPluginSetUsageFunc(&DBPluginPropertyDefaultUsage);
DBPluginSetDataType(CFStringGetTypeID());
return 0;
}
Modified: trunk/darwinxref/plugins/macosx.tcl
===================================================================
--- trunk/darwinxref/plugins/macosx.tcl 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/macosx.tcl 2006-10-04 08:58:33 UTC (rev 204)
@@ -1,13 +1,3 @@
DBPluginSetName macosx
-DBPluginSetType property
+DBPluginSetType property.build
DBPluginSetDatatype string
-
-proc usage {} {
- return {[<project>]}
-}
-
-proc run {args} {
- set project [lindex $args 0]
- set build [DBGetCurrentBuild]
- puts [DBCopyPropString $build $project macosx]
-}
Modified: trunk/darwinxref/plugins/original.c
===================================================================
--- trunk/darwinxref/plugins/original.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/original.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -32,26 +32,13 @@
#include "DBPlugin.h"
-static int run(CFArrayRef argv) {
- if (CFArrayGetCount(argv) != 1) return -1;
- CFStringRef build = DBGetCurrentBuild();
- CFStringRef project = CFArrayGetValueAtIndex(argv, 0);
- CFStringRef original = DBCopyPropString(build, project, CFSTR("original"));
- if (original) cfprintf(stdout, "%@\n", original);
- return 0;
-}
-
-static CFStringRef usage() {
- return CFRetain(CFSTR("<project>"));
-}
-
int initialize(int version) {
//if ( version < kDBPluginCurrentVersion ) return -1;
- DBPluginSetType(kDBPluginPropertyType);
+ DBPluginSetType(kDBPluginProjectPropertyType);
DBPluginSetName(CFSTR("original"));
- DBPluginSetRunFunc(&run);
- DBPluginSetUsageFunc(&usage);
+ DBPluginSetRunFunc(&DBPluginPropertyDefaultRun);
+ DBPluginSetUsageFunc(&DBPluginPropertyDefaultUsage);
DBPluginSetDataType(CFStringGetTypeID());
return 0;
}
Modified: trunk/darwinxref/plugins/patchfiles.c
===================================================================
--- trunk/darwinxref/plugins/patchfiles.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/patchfiles.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -32,33 +32,13 @@
#include "DBPlugin.h"
-static int run(CFArrayRef argv) {
- CFIndex i, count = CFArrayGetCount(argv);
- CFStringRef build = DBGetCurrentBuild();
- CFStringRef project = NULL;
- if (count != 1) return -1;
-
- project = CFArrayGetValueAtIndex(argv, 0);
- CFArrayRef patchfiles = DBCopyPropArray(build, project, CFSTR("patchfiles"));
-
- count = patchfiles ? CFArrayGetCount(patchfiles) : 0;
- for (i = 0; i < count; ++i) {
- cfprintf(stdout, "%@\n", CFArrayGetValueAtIndex(patchfiles, i));
- }
- return 0;
-}
-
-static CFStringRef usage() {
- return CFRetain(CFSTR("<project>"));
-}
-
int initialize(int version) {
//if ( version < kDBPluginCurrentVersion ) return -1;
- DBPluginSetType(kDBPluginPropertyType);
+ DBPluginSetType(kDBPluginProjectPropertyType);
DBPluginSetName(CFSTR("patchfiles"));
- DBPluginSetRunFunc(&run);
- DBPluginSetUsageFunc(&usage);
+ DBPluginSetRunFunc(&DBPluginPropertyDefaultRun);
+ DBPluginSetUsageFunc(&DBPluginPropertyDefaultUsage);
DBPluginSetDataType(CFArrayGetTypeID());
return 0;
}
Modified: trunk/darwinxref/plugins/plist_sites.c
===================================================================
--- trunk/darwinxref/plugins/plist_sites.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/plist_sites.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -32,31 +32,13 @@
#include "DBPlugin.h"
-static int run(CFArrayRef argv) {
- CFIndex i, count = CFArrayGetCount(argv);
- CFStringRef build = DBGetCurrentBuild();
-
- if (count != 0) return -1;
-
- CFArrayRef plist_sites = DBCopyPropArray(build, NULL, CFSTR("plist_sites"));
- count = plist_sites ? CFArrayGetCount(plist_sites) : 0;
- for (i = 0; i < count; ++i) {
- cfprintf(stdout, "%@\n", CFArrayGetValueAtIndex(plist_sites, i));
- }
- return 0;
-}
-
-static CFStringRef usage() {
- return CFRetain(CFSTR(""));
-}
-
int initialize(int version) {
//if ( version < kDBPluginCurrentVersion ) return -1;
- DBPluginSetType(kDBPluginPropertyType);
+ DBPluginSetType(kDBPluginBuildPropertyType);
DBPluginSetName(CFSTR("plist_sites"));
- DBPluginSetRunFunc(&run);
- DBPluginSetUsageFunc(&usage);
+ DBPluginSetRunFunc(&DBPluginPropertyDefaultRun);
+ DBPluginSetUsageFunc(&DBPluginPropertyDefaultUsage);
DBPluginSetDataType(CFArrayGetTypeID());
return 0;
}
Modified: trunk/darwinxref/plugins/source_sites.c
===================================================================
--- trunk/darwinxref/plugins/source_sites.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/source_sites.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -32,37 +32,13 @@
#include "DBPlugin.h"
-static int run(CFArrayRef argv) {
- CFIndex i, count = CFArrayGetCount(argv);
- CFStringRef build = DBGetCurrentBuild();
- CFStringRef project = NULL;
- if (count > 1) return -1;
- if (count == 1) {
- project = CFArrayGetValueAtIndex(argv, 0);
- }
- CFArrayRef source_sites = DBCopyPropArray(build, project, CFSTR("source_sites"));
- count = source_sites ? CFArrayGetCount(source_sites) : 0;
- if (count == 0) {
- source_sites = DBCopyPropArray(build, NULL, CFSTR("source_sites"));
- count = CFArrayGetCount(source_sites);
- }
- for (i = 0; i < count; ++i) {
- cfprintf(stdout, "%@\n", CFArrayGetValueAtIndex(source_sites, i));
- }
- return 0;
-}
-
-static CFStringRef usage() {
- return CFRetain(CFSTR("[<project>]"));
-}
-
int initialize(int version) {
//if ( version < kDBPluginCurrentVersion ) return -1;
DBPluginSetType(kDBPluginPropertyType);
DBPluginSetName(CFSTR("source_sites"));
- DBPluginSetRunFunc(&run);
- DBPluginSetUsageFunc(&usage);
+ DBPluginSetRunFunc(&DBPluginPropertyDefaultRun);
+ DBPluginSetUsageFunc(&DBPluginPropertyDefaultUsage);
DBPluginSetDataType(CFArrayGetTypeID());
return 0;
}
Modified: trunk/darwinxref/plugins/target.c
===================================================================
--- trunk/darwinxref/plugins/target.c 2005-08-29 22:16:20 UTC (rev 203)
+++ trunk/darwinxref/plugins/target.c 2006-10-04 08:58:33 UTC (rev 204)
@@ -32,26 +32,13 @@
#include "DBPlugin.h"
-static int run(CFArrayRef argv) {
- if (CFArrayGetCount(argv) != 1) return -1;
- CFStringRef build = DBGetCurrentBuild();
- CFStringRef project = CFArrayGetValueAtIndex(argv, 0);
- CFStringRef target = DBCopyPropString(build, project, CFSTR("target"));
- if (target) cfprintf(stdout, "%@\n", target);
- return 0;
-}
-
-static CFStringRef usage() {
- return CFRetain(CFSTR("<project>"));
-}
-
int initialize(int version) {
//if ( version < kDBPluginCurrentVersion ) return -1;
- DBPluginSetType(kDBPluginPropertyType);
+ DBPluginSetType(kDBPluginProjectPropertyType);
DBPluginSetName(CFSTR("target"));
- DBPluginSetRunFunc(&run);
- DBPluginSetUsageFunc(&usage);
+ DBPluginSetRunFunc(&DBPluginPropertyDefaultRun);
+ DBPluginSetUsageFunc(&DBPluginPropertyDefaultUsage);
DBPluginSetDataType(CFStringGetTypeID());
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/d4901ae0/attachment-0001.html
More information about the darwinbuild-changes
mailing list