[m-rev.] diff: write grade to `module_init.c' file

Simon Taylor stayl at cs.mu.OZ.AU
Tue Dec 18 16:45:29 AEDT 2001


Estimated hours taken: 0.25
Branches: main

Write the grade in the header comment in the generated `<module>_init.c' file.
The `<module>_init.c' file contains grade dependent conditional compilation,
so the `<module>_init.o' file must be rebuilt when the grade changes.

util/mkinit.c:
	Add an option `-g' for the grade.
	Add the grade to the header comment.

scripts/c2init.in:
	Pass the grade to mkinit.

scripts/Mmakefile:
scripts/canonical_grade.sh-subr:
	canonical_grade.sh-subr is now used by c2init.

Index: util/mkinit.c
===================================================================
RCS file: /home/mercury1/repository/mercury/util/mkinit.c,v
retrieving revision 1.79
diff -u -u -r1.79 mkinit.c
--- util/mkinit.c	4 Dec 2001 00:44:41 -0000	1.79
+++ util/mkinit.c	18 Dec 2001 04:47:36 -0000
@@ -155,6 +155,7 @@
 static const char *output_file_name = NULL;
 static const char *entry_point = "mercury__main_2_0";
 static const char *hl_entry_point = "main_2_p_0";
+static const char *grade = "";
 static int maxcalls = MAXCALLS;
 static int num_files;
 static char **files;
@@ -180,6 +181,7 @@
 	"/*\n"
 	"** This code automatically generated by mkinit - do not edit.\n"
 	"**\n"
+	"** Grade: %s\n"
 	"** Input files:\n"
 	"**\n"
 	;
@@ -476,7 +478,7 @@
 	int		i;
 	String_List	*tmp_slist;
 
-	while ((c = getopt(argc, argv, "ac:iI:lo:tw:x")) != EOF) {
+	while ((c = getopt(argc, argv, "ac:g:iI:lo:tw:x")) != EOF) {
 		switch (c) {
 		case 'a':
 			aditi = TRUE;
@@ -487,6 +489,10 @@
 				usage();
 			break;
 
+		case 'g':
+			grade = optarg;
+			break;
+
 		case 'i':
 			need_initialization_code = TRUE;
 			break;
@@ -670,7 +676,7 @@
 {
 	int filenum;
 
-	fputs(header1, stdout);
+	printf(header1, grade);
 
 	for (filenum = 0; filenum < num_files; filenum++) {
 		fputs("** ", stdout);
Index: scripts/c2init.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/c2init.in,v
retrieving revision 1.33
diff -u -u -r1.33 c2init.in
--- scripts/c2init.in	3 Dec 2001 03:11:25 -0000	1.33
+++ scripts/c2init.in	18 Dec 2001 04:11:23 -0000
@@ -22,6 +22,8 @@
 # include the file `parse_ml_options.sh-subr'
 @PARSE_ML_OPTIONS@
 
+# include the file `canonical_grade.sh-subr'
+ at CANONICAL_GRADE@
 
 # If you change these, you will also need to change Mmake.common.in,
 # scripts/ml.in, tools/bootcheck, tools/binary, tools/binary_step and
@@ -66,12 +68,12 @@
 case $# in
 	0) exec $MKINIT $aditi_opt -c"$maxcalls" $init_opt $trace_opt \
 		$library_opt $defentry_opt $extra_inits_opt \
-		-o "$init_c_file" \
+		-g "$GRADE" -o "$init_c_file" \
 		$extra_init_dirs $EXTRA_INIT_FILES $MERCURY_ALL_LIB_MODS
 	   ;;
 	*) exec $MKINIT $aditi_opt -c"$maxcalls" $init_opt $trace_opt \
 		$library_opt $defentry_opt $extra_inits_opt \
-		-o "$init_c_file" \
+		-g "$GRADE" -o "$init_c_file" \
 		$extra_init_dirs "$@" $EXTRA_INIT_FILES $MERCURY_ALL_LIB_MODS
 	   ;;
 esac
Index: scripts/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmakefile,v
retrieving revision 1.25
diff -u -u -r1.25 Mmakefile
--- scripts/Mmakefile	3 Dec 2001 03:11:25 -0000	1.25
+++ scripts/Mmakefile	18 Dec 2001 04:00:54 -0000
@@ -43,7 +43,7 @@
 parse_ml_options.sh-subr mgnuc canonical_grade: parse_grade_options.sh-subr 
 parse_ml_options.sh-subr mgnuc canonical_grade: final_grade_options.sh-subr 
 ml c2init: parse_ml_options.sh-subr
-ml canonical_grade: canonical_grade.sh-subr 
+ml c2init canonical_grade: canonical_grade.sh-subr 
 
 #-----------------------------------------------------------------------------#
 
Index: scripts/canonical_grade.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/canonical_grade.sh-subr,v
retrieving revision 1.3
diff -u -u -r1.3 canonical_grade.sh-subr
--- scripts/canonical_grade.sh-subr	31 May 2001 06:00:20 -0000	1.3
+++ scripts/canonical_grade.sh-subr	18 Dec 2001 03:58:07 -0000
@@ -7,7 +7,7 @@
 # canonical_grade.sh-subr:
 #	An `sh' subroutine for computing a canonical grade string based on
 #	the values of grade-related options.
-#	It is used by the `ml' and `canonical_grade' scripts.
+#	It is used by the `ml', `c2init' and `canonical_grade' scripts.
 #
 #	The code here should be inserted after init_grade_options.sh-subr,
 #	parse_grade_options.sh-subr and final_grade_options.sh-subr, which
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list