[darwinbuild-changes] [122] trunk/darwinxref

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 4 01:48:23 PDT 2006


Revision: 122
          http://trac.macosforge.org/projects/darwinbuild/changeset/122
Author:   ssen
Date:     2006-10-04 01:48:22 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
centralize build version detection. On entry, darwinxref
determines the build to operate on using either the
explicit -b command-line option, the ".build/build" cookie
file, or the current host OS version, in that order.

Moving the code allows "darwinxref info" to print something
useful when there's no cookie file.

Modified Paths:
--------------
    trunk/darwinxref/DBPlugin.c
    trunk/darwinxref/main.c

Modified: trunk/darwinxref/DBPlugin.c
===================================================================
--- trunk/darwinxref/DBPlugin.c	2005-07-29 20:32:23 UTC (rev 121)
+++ trunk/darwinxref/DBPlugin.c	2006-10-04 08:48:22 UTC (rev 122)
@@ -262,7 +262,6 @@
 	return res;
 }
 
-extern CFDictionaryRef _CFCopySystemVersionDictionary();
 static CFStringRef currentBuild = NULL;
 
 void DBSetCurrentBuild(char* build) {
@@ -271,21 +270,5 @@
 }
 
 CFStringRef DBGetCurrentBuild() {
-	if (currentBuild) return currentBuild;
-
-	// The following is Private API.
-	// Please don't use this in your programs as it may break.
-	// Notice the careful dance around these symbols as they may
-	// someday disappear entirely, in which case this program
-	// will need to be revved.
-	CFDictionaryRef (*fptr)() = dlsym(RTLD_DEFAULT, "_CFCopySystemVersionDictionary");
-	if (fptr) {
-		CFDictionaryRef dict = fptr();
-		if (dict != NULL) {
-			CFStringRef str = CFDictionaryGetValue(dict, CFSTR("ProductBuildVersion"));
-			currentBuild = CFRetain(str);
-			CFRelease(dict);
-		}
-	}
 	return currentBuild;
 }

Modified: trunk/darwinxref/main.c
===================================================================
--- trunk/darwinxref/main.c	2005-07-29 20:32:23 UTC (rev 121)
+++ trunk/darwinxref/main.c	2006-10-04 08:48:22 UTC (rev 122)
@@ -34,6 +34,7 @@
 #include <stdlib.h>
 #include "sqlite3.h"
 #include <fcntl.h>
+#include <dlfcn.h>
 
 #include "DBPluginPriv.h"
 
@@ -48,6 +49,7 @@
 extern char** environ;
 
 char* readBuildFile();
+char* determineHostBuildVersion();
 
 int main(int argc, char* argv[]) {
 	char* progname = argv[0];
@@ -77,6 +79,7 @@
 	argv += optind;
 
 	if (build == NULL) build = readBuildFile();
+	if (build == NULL) build = determineHostBuildVersion();
 
 	// special built-in command
 	if (argc == 1 && strcmp(argv[0], "info") == 0) {
@@ -117,3 +120,25 @@
 	close(fd);
 	return build;
 }
+
+char* determineHostBuildVersion()
+{
+  char *currentBuild = NULL;
+
+  // The following is Private API.
+  // Please don't use this in your programs as it may break.
+  // Notice the careful dance around these symbols as they may
+  // someday disappear entirely, in which case this program
+  // will need to be revved.
+  CFDictionaryRef (*fptr)() = dlsym(RTLD_DEFAULT, "_CFCopySystemVersionDictionary");
+  if (fptr) {
+    CFDictionaryRef dict = fptr();
+    if (dict != NULL) {
+      CFStringRef str = CFDictionaryGetValue(dict, CFSTR("ProductBuildVersion"));
+      currentBuild = strdup_cfstr(str);
+      CFRelease(dict);
+    }
+  }
+
+  return currentBuild;
+}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/7285a78e/attachment.html


More information about the darwinbuild-changes mailing list