[m-rev.] diff: fix bug with --split-c-files --use-subdirs

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jun 26 00:21:43 AEST 2001


Estimated hours taken: 1
Branches: main, release

compiler/mercury_compile.m:
	Fix a bug which broke things when using `pragma export' and
	compiling with both --split-c-files and --use-subdirs:
	handle the relative path to the header file with --split-c-files
	by compiling with `-I.', like we do for --use-subdirs, rather than
	by inserting `../' in the #include line.
	In this case, the source files are in Mercury/dirs/foo.dir/foo_nnn.c
	and the header file is in the current directory so we need to use
	`../../../' rather than just `../' to get to it; it's simpler to
	just use `-I.'.

Workspace: /home/mars/fjh/ws1/mercury
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.204
diff -u -d -r1.204 mercury_compile.m
--- compiler/mercury_compile.m	2001/05/31 05:59:44	1.204
+++ compiler/mercury_compile.m	2001/06/25 14:18:12
@@ -2681,18 +2681,9 @@
 	;
 		{ C_ExportDecls = [_|_] },
 		module_name_to_file_name(ModuleName, ".h", no, HeaderFileName),
-                globals__io_lookup_bool_option(split_c_files, SplitFiles),
-                { 
-			SplitFiles = yes,
-                        string__append_list(
-                                ["#include ""../", HeaderFileName, """\n"],
-				IncludeString)
-                ;
-			SplitFiles = no,
-                        string__append_list(
-				["#include """, HeaderFileName, """\n"],
-				IncludeString)
-                },
+		{ string__append_list(
+			["#include """, HeaderFileName, """\n"],
+			IncludeString) },
 
 		{ term__context_init(Context) },
 		{ Include = foreign_decl_code(c, IncludeString, Context) },
@@ -2994,8 +2985,11 @@
 	{ join_string_list(C_Flags_List, "", "", " ", CFLAGS) },
 
 	globals__io_lookup_bool_option(use_subdirs, UseSubdirs),
-	{ UseSubdirs = yes ->
-		% the file will be compiled in the "Mercury/cs" subdir,
+	globals__io_lookup_bool_option(split_c_files, SplitCFiles),
+	{ (UseSubdirs = yes ; SplitCFiles = yes) ->
+		% the source file (foo.c) will be compiled in a subdirectory
+		% (either Mercury/cs, foo.dir, or Mercury/dirs/foo.dir,
+		% depending on which of these two options is set)
 		% so we need to add `-I.' so it can
 		% include header files in the source directory.
 		SubDirInclOpt = "-I. "

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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