comparison src/compiler.sml @ 1338:8c1996489265

Better treatment of relative paths in .urp files
author Adam Chlipala <adam@chlipala.net>
date Tue, 14 Dec 2010 10:21:51 -0500
parents 7eefe077075a
children caff0a4d5fc1
comparison
equal deleted inserted replaced
1337:b4b5788b20ea 1338:8c1996489265
366 val pathmap = ref (!pathmap) 366 val pathmap = ref (!pathmap)
367 val bigLibs = ref [] 367 val bigLibs = ref []
368 368
369 fun pu filename = 369 fun pu filename =
370 let 370 let
371 val filename = OS.Path.mkAbsolute {path = filename, relativeTo = OS.FileSys.getDir ()}
372
371 val dir = OS.Path.dir filename 373 val dir = OS.Path.dir filename
372 fun opener () = TextIO.openIn (OS.Path.joinBaseExt {base = filename, ext = SOME "urp"}) 374 fun opener () = TextIO.openIn (OS.Path.joinBaseExt {base = filename, ext = SOME "urp"})
373 375
374 val inf = opener () 376 val inf = opener ()
375 377
703 libs := pu (libify (relify arg)) :: !libs 705 libs := pu (libify (relify arg)) :: !libs
704 else 706 else
705 bigLibs := libify' arg :: !bigLibs 707 bigLibs := libify' arg :: !bigLibs
706 | "path" => 708 | "path" =>
707 (case String.fields (fn ch => ch = #"=") arg of 709 (case String.fields (fn ch => ch = #"=") arg of
708 [n, v] => pathmap := M.insert (!pathmap, n, v) 710 [n, v] => ((pathmap := M.insert (!pathmap, n, OS.Path.mkAbsolute {path = v, relativeTo = dir}))
711 handle OS.Path.Path => ErrorMsg.error "Invalid 'path' directory argument")
709 | _ => ErrorMsg.error "path argument not of the form name=value'") 712 | _ => ErrorMsg.error "path argument not of the form name=value'")
710 | "onError" => 713 | "onError" =>
711 (case String.fields (fn ch => ch = #".") arg of 714 (case String.fields (fn ch => ch = #".") arg of
712 m1 :: (fs as _ :: _) => 715 m1 :: (fs as _ :: _) =>
713 onError := SOME (m1, List.take (fs, length fs - 1), List.last fs) 716 onError := SOME (m1, List.take (fs, length fs - 1), List.last fs)