[m-rev.] diff: `--use-subdirs' shorthand Mmake rules

Simon Taylor stayl at cs.mu.OZ.AU
Thu May 16 17:47:59 AEST 2002


Estimated hours taken: 0.25
Branches: main

compiler/modules.m:
	With `--use-subdirs', allow users to type `mmake module.c'
	rather than `mmake Mercury/cs/module.c'.

Index: modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.230
diff -u -u -r1.230 modules.m
--- modules.m	9 May 2002 16:31:04 -0000	1.230
+++ modules.m	16 May 2002 07:45:48 -0000
@@ -2371,6 +2371,18 @@
 			"\t@:\n"
 		]),
 
+		globals__io_lookup_bool_option(use_subdirs, UseSubdirs),
+		( { UseSubdirs = yes } ->
+			io__nl(DepStream),
+			list__foldl(
+				write_subdirs_shorthand_rule(DepStream,
+					ModuleName),
+				[".c", ".$O", ".pic_o", ".s", ".pic_s",
+				".java", ".class", ".il", ".dll"])
+		;
+			[]
+		),
+
 		( { SourceFileName \= default_source_file(ModuleName) } ->
 			%
 			% The pattern rules in Mmake.rules won't work,
@@ -2556,6 +2568,22 @@
 		[]
 	).
 
+	% With `--use-subdirs', allow users to type `mmake module.c'
+	% rather than `mmake Mercury/cs/module.c'.
+:- pred write_subdirs_shorthand_rule(io__output_stream::in,
+	module_name::in, string::in, io__state::di, io__state::uo) is det.
+
+write_subdirs_shorthand_rule(DepStream, ModuleName, Ext) -->
+	{ prog_out__sym_name_to_string(ModuleName, ".", ModuleStr) },
+	module_name_to_file_name(ModuleName, Ext, no, Target),
+	{ ShorthandTarget = ModuleStr ++ Ext },
+	io__write_string(DepStream, ".PHONY: "),
+	io__write_string(DepStream, ShorthandTarget),
+	io__nl(DepStream),
+	io__write_string(DepStream, ShorthandTarget),
+	io__write_string(DepStream, ": "),
+	io__write_string(DepStream, Target),
+	io__nl(DepStream).
 
 maybe_read_dependency_file(ModuleName, MaybeTransOptDeps) -->
 	globals__io_lookup_bool_option(transitive_optimization, TransOpt),
--------------------------------------------------------------------------
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