[Lsb-messages] /var/www/bzr/lsb/devel/build_env r1915: add lsbcpp features (bug 3442) and update the version display (bug 2977)

Mats Wichmann mats at linuxfoundation.org
Fri Mar 9 19:51:34 UTC 2012


------------------------------------------------------------
revno: 1915
committer: Mats Wichmann <mats at linuxfoundation.org>
branch nick: build_env
timestamp: Fri 2012-03-09 12:51:34 -0700
message:
  add lsbcpp features (bug 3442) and update the version display (bug 2977)
modified:
  lsbdev-cc/lsbcc.c
  lsbdev-cc/lsbcpp.c
  package/Makefile
-------------- next part --------------
=== modified file 'lsbdev-cc/lsbcc.c'
--- a/lsbdev-cc/lsbcc.c	2012-03-06 01:29:03 +0000
+++ b/lsbdev-cc/lsbcc.c	2012-03-09 19:51:34 +0000
@@ -29,11 +29,11 @@
  *
  * The approach taken here is to recognize enough of the regular options to
  * allow the extra options to be inserted into the right place. Fortunately,
- * the options can be grouped into a few catagories, and the order in which
- * the catagories are passed to gcc is not important, as long as the order of
- * items within each catagory is preserved.
+ * the options can be grouped into a few categories, and the order in which
+ * the categories are passed to gcc is not important, as long as the order of
+ * items within each category is preserved.
  *
- * The extra options are easily inserted in between the catagories.
+ * The extra options are easily inserted in between the categories.
  *
  * A couple of things that complicate this process (and this is what ended the
  * life of the shell script based lsbcc) is that some of the options have
@@ -809,8 +809,10 @@
 }
 
 /*
- * FIXME: If LSB ever gets around to including scandir get rid of
- * this code.
+ * FIXME: If LSB adds scandir, drop this code.
+ * UPDATE: as described in bug 1997, scandir was added @LSB 4.0,
+ * but LSB builds lsbcc "pessimistically" (targeting oldest possible
+ * LSB version), so the option to drop isn't available yet.
  */
 int lsbcc_scandir(
 	char *libpath,
@@ -974,50 +976,45 @@
             fprintf(stderr,"lsb version value set to %s\n", lsbcc_lsbversion );
         }
     } else {
-        fprintf(stderr,"LSBCC_LSBVERSION is set to unrecognized value %s\n", ptr);
+        fprintf(stderr,"LSBCC_LSBVERSION contains unrecognized value %s, ignored\n", ptr);
     }
 }
 
-optind_old = optind;
-opterr = 0;
 
 /*
  * Do we have '--lsb-target-version' option?
  * Override other settings, if this option provides a valid value
  */
+optind_old = optind;
+opterr = 0;
 while((c=getopt_long_only(argc,argv,optstr,long_options, &option_index))>=0 ) {
     if(c == 21) { /* --lsb-target-version=<LSB_version> */
         if (get_version_index(optarg) >= 0 ) {
             lsbcc_lsbversion = strdup(optarg);
         } else {
-            fprintf(stderr,"--lsb-target-version option has illegal value %s\n", optarg);
+            fprintf(stderr,"--lsb-target-version contains unrecognized value %s, ignored\n", optarg);
         }
     }
 }
 
-/*
- * Restore optind - we'll process all other options later
- */
+/* Restore optind - we'll process all other options later */
 optind = optind_old;
 
-/*
- * Index in the lsb_*_modules arrays corresponding to target LSB version
- */
+/* Index in the lsb_*_modules arrays corresponding to target LSB version */
 lsbversion_index = get_version_index(lsbcc_lsbversion);
 
-/*
- * Set up __LSB_VERSION__ define
- */
+/* Set up __LSB_VERSION__ define */
 lsbversion_option=(char*)malloc(sizeof(char)* (strlen("-D__LSB_VERSION__=") +
 		                               strlen(lsbcc_lsbversion) + 1));
 if(lsbversion_option == NULL) {
-    /*XXX FIXME no error message? */
+    /* FIXME no error message? */
     exit(EXIT_FAILURE);
 }
 strcpy(lsbversion_option, "-D__LSB_VERSION__=");
+
 /*
- * Normally, LSB_VERSION values contain dot - copy without the dot
- * this method would destroy lsbcc_lsbversion, so make a dup first
+ * LSB_VERSION values contain dots, we need a non-dotted version to
+ * append for the -D.  Make a copy first since strsep modifies its 1st arg.
  */
 ptr = strdup(lsbcc_lsbversion);
 strcat(lsbversion_option, strsep(&ptr,"."));
@@ -1031,8 +1028,7 @@
 #endif
 
 /*
- * Check for some other environment variables,
- * and adjust things if they are found.
+ * Check for more environment variables, and adjust things if they are found.
  */
 
 if( (ptr=getenv("LSBCC_WARN")) != NULL ) {
@@ -1152,9 +1148,8 @@
      }
 
      /*
-      * XXX temporary hack: accept names of deprecated
-      * modules - no need to do anything with them
-      * this is just for the Qt3 scripts, really;
+      * FIXME temporary hack: accept names of deprecated modules - 
+      * no need to do anything with them. This is just for the Qt3 scripts
       * until a better answer is developed
       */
      for (i = 0; i < lsb_num_deprecated_modules[lsbversion_index]; i++) {
@@ -1423,8 +1418,8 @@
 		argvaddstring(userlibs,argv[optind-1]);
 		break;
 	case 'V':
-	case 14:
-	case 15:
+	case 14:/* --verbose */
+	case 15:/* --version */
 	case 'v':
 		/* Handle a standalone --version, --verbose, '-v', and '-V'
 		 * argument specially to make sure it only
@@ -1433,13 +1428,18 @@
 		 * of having the compiler call the linker.  Unless of course
 		 * we need to call the linker, which will happen whenever
 		 * found_gcc_arg gets set.
+		 * Fall through to add this program's version.
 		 */
 		found_gcc_standalone = 1;
 		argvaddstring(gccstartargs,argv[optind-1]);
+	case 22:/* --lsbcc-version */
+		printf("%s (lsbcc) %s\n", argv[0], LSBCC_VERSION);
+		if (c == 22) {
+			exit(EXIT_SUCCESS);
+		}
 		break;
-	case 17:
-		/* -static
-		 * no -Wl,Bdynamic, add -Wl,--start-group, add -lgcc_eh */
+	case 17:/* -static */
+		/* no -Wl,Bdynamic, add -Wl,--start-group, add -lgcc_eh */
 		found_gcc_arg = 1;
 		b_dynamic = 0;
 		force_static = 1;
@@ -1460,10 +1460,6 @@
 		break;
 	case 21:/* --lsb-target-version */
 		/* We have already processed this option */
- 		break;
-	case 22: /* --lsbcc-version */
-		printf("%s\n", LSBCC_VERSION);
-		exit(EXIT_SUCCESS);
 		break;
 	case '?':
 		if (strncmp(argv[optind_old], "--lsb-",6) == 0) {
@@ -1570,7 +1566,6 @@
 		argvaddstring(options,featuresettings[i]);
 	}
 }
-
 argvaddstring(options,lsbversion_option);
 
 /* Gather together the non-options arguments */

=== modified file 'lsbdev-cc/lsbcpp.c'
--- a/lsbdev-cc/lsbcpp.c	2012-03-06 01:29:03 +0000
+++ b/lsbdev-cc/lsbcpp.c	2012-03-09 19:51:34 +0000
@@ -13,6 +13,7 @@
  * Set your CPP environment variable to lsbcpp to gain effect.
  *
  * This code is a stripped down version of lsbcc.c
+ * it needs to be kept in sync to some extent.
  */
 
 #include <sys/types.h>
@@ -31,10 +32,11 @@
 #include <errno.h>
 
 #include "lsbcc_version.h"
+#include "lsbcc_libs.h"
 #include "lsbcc_argv.h"
 
 /*
- * These are the catagories of options that we are going to be grouping
+ * These are the categories of options that we are going to be grouping
  * together.
  */
 
@@ -54,6 +56,11 @@
 char incpath[PATH_MAX];
 char cxxincpath[PATH_MAX];
 
+/* 'Normal' version name */
+char *lsbcc_lsbversion=DEFAULT_LSB_VERSION;
+/* Version name with dot removed */
+char *lsbversion_option;
+
 /*
  * Debugging interface: Set the environment variable LSBCC_DEBUG to a value
  * that corresponds to the bits defined below.
@@ -74,21 +81,31 @@
 int lsbcc_buildingshared=0;
 
 /*
- */
-char *optstr="-";
+ * Variable to store optind value - we'll have to process command line twice.
+ */
+int optind_old;
+
+/*
+ * options we need to reognize.  some of these are for this program,
+ * some are options for the compiler that need some knowledge while
+ * we're still in this program.  this list is a lot shorter than in lsbcc.
+ */
+char *optstr="vV:";
 struct option long_options[] = {
 	{"help",0, NULL,2},
 	{"lsb-help",0, NULL,3},
 	{"lsb-version",0, NULL,4},
+	{"lsb-verbose",no_argument,NULL,5},
 	{"lsb-cpp",0,NULL,6},
 	{"lsb-includepath",required_argument,NULL,9},
 	{"lsb-cxx-includepath",required_argument,NULL,10},
 	{"lsb-forcefeatures",no_argument,NULL,12},
 	{"verbose",required_argument,NULL,14},
 	{"version",required_argument,NULL,15},
+	{"lsb-target-version",required_argument,NULL,21},
 	{"lsbcc-version",no_argument,NULL,22},
 	{NULL,0,0,0}
-	};
+};
 
 void
 usage(const char *progname) {
@@ -108,6 +125,8 @@
 "  --lsb-cxx-includepath=<include_path>\n"
 "                       Set the path to the lsb c++ include directory\n"
 "                       (overrides the LSBCXX_INCLUDES environment setting)\n "
+"  --lsb-target-version=<target_lsb_version>\n"
+"                       Target LSB version.\n"
 "\n"
 "All other options are passed to the preprocessor more or less unmodified.\n"
 "  --lsb options should appear before system cpp options.\n"
@@ -136,7 +155,7 @@
 int	c,i;
 int	option_index;
 int	display_cmd = 0;
-int     feature_settings = 0;
+int	feature_settings = 0;
 char	*ptr;
 
 /*
@@ -152,9 +171,62 @@
 snprintf(cxxincpath, PATH_MAX-1, "%s/%s", BASE_PATH, "include/c++");
 
 /*
- * Check for some environment variable, and adjust things if they are found.
- */
-
+ * first figure out if the user has requested a change to the target LSB vers.
+ * In lsbcc, this has to happen first because it may affect other constructions
+ * like library paths.  In lsbcpp this should not be a problem, but it
+ * seems easier to keep the order in sync between the two.
+ */
+if( (ptr=getenv("LSBCC_LSBVERSION")) != NULL ) {
+    if (get_version_index(ptr) >= 0) {
+    lsbcc_lsbversion = strdup(ptr);
+	if( lsbcc_debug&DEBUG_ENV_OVERRIDES ) {
+	    fprintf(stderr,"lsb version value set to %s\n", lsbcc_lsbversion );
+	}
+    } else {
+	fprintf(stderr,"LSBCC_LSBVERSION contains unrecognized value %s, ignored\n", ptr);
+    }
+}
+
+/*
+ * Do we have '--lsb-target-version' option?
+ * Override other settings, if this option provides a valid value
+ */
+optind_old = optind;
+opterr = 0;
+while((c=getopt_long_only(argc,argv,optstr,long_options, &option_index))>=0 ) {
+    if(c == 21) { /* --lsb-target-version=<LSB_version> */
+	if (get_version_index(optarg) >= 0 ) {
+	    lsbcc_lsbversion = strdup(optarg);
+	} else {
+	    fprintf(stderr,"--lsb-target-version contains unrecognized value %s, ignored\n", optarg);
+	}
+    }
+}
+
+/* Restore optind - we'll process all other options later */
+optind = optind_old;
+
+/* Set up __LSB_VERSION__ define */
+lsbversion_option=(char*)malloc(sizeof(char)* (strlen("-D__LSB_VERSION__=") +
+                                               strlen(lsbcc_lsbversion) + 1));
+if(lsbversion_option == NULL) {
+    /*XXX FIXME no error message? */
+    exit(EXIT_FAILURE);
+}
+strcpy(lsbversion_option, "-D__LSB_VERSION__=");
+
+/*
+ * LSB_VERSION values contain dots, we need a non-dotted version to
+ * append for the -D.  Make a copy first since strsep modifies its 1st arg.
+ */
+ptr = strdup(lsbcc_lsbversion);
+strcat(lsbversion_option, strsep(&ptr,"."));
+if(ptr)
+    strcat(lsbversion_option, strsep(&ptr,"."));
+
+/*
+ * Check for more environment variables, and adjust things if they are found.
+ */
 if( (ptr=getenv("LSBCC_WARN")) != NULL ) {
 	lsbcc_warn=strtod(ptr,NULL);
 }
@@ -189,13 +261,16 @@
 	feature_settings = 1;
 }
 
+if( (ptr=getenv("LSBCC_VERBOSE")) != NULL ) {
+	display_cmd = 1;
+}
+
 if( lsbcc_debug&DEBUG_ARGUMENTS ) {
 	for(i=0;i<argc;i++) {
 		fprintf(stderr,"%3.3d: %s\n", i, argv[i] );
 	}
 }
 
-
 /* Process the options passed in */
 opterr = 0;
 
@@ -245,9 +320,20 @@
 	case 12:/* --lsb-forcefeatures */
 		feature_settings = 1;
 		break;
-	case 22: /* --lsbcc-version */
-		printf("%s\n", LSBCC_VERSION);
-		exit(EXIT_SUCCESS);
+	case 'V':
+	case 14:/* --verbose */
+	case 15:/* --version */
+	case 'v':
+		/* for these four, fall through to add this program's version */
+		argvaddstring(options,argv[optind-1]);
+	case 22:/* --lsbcc-version */
+		printf("%s (lsbcc) %s\n", argv[0], LSBCC_VERSION);
+		if (c == 22) {
+			exit(EXIT_SUCCESS);
+		}
+		break;
+	case 21:/* --lsb-target-version */
+		/* We have already processed this option */
 		break;
 	case '?':
 		if (strncmp(argv[optind-1], "--lsb-",6) == 0) {
@@ -303,7 +389,7 @@
 		argvaddstring(options,featuresettings[i]);
 	}
 }
-
+argvaddstring(options,lsbversion_option);
 
 /*
  * set the compiler

=== modified file 'package/Makefile'
--- a/package/Makefile	2012-03-06 01:29:03 +0000
+++ b/package/Makefile	2012-03-09 19:51:34 +0000
@@ -13,7 +13,7 @@
 
 # We define this here instead of directly in the spec file as
 # we need to be able to work out what the produced rpm files will be called
-RPM_PACKAGE_RELEASE=2
+RPM_PACKAGE_RELEASE=3
 
 # Derive date string for daily snapshots
 ISO_DATE:=$(shell date +"%Y%m%d")



More information about the lsb-messages mailing list