Skip to content

Commit

Permalink
Better regularity between mlton and smlnj makefile process
Browse files Browse the repository at this point in the history
  • Loading branch information
robsimmons committed Oct 29, 2011
1 parent 00de36c commit 581ce23
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 30 deletions.
1 change: 0 additions & 1 deletion smack-nonposix.cm
Expand Up @@ -7,5 +7,4 @@ Group is
src/posix-symlink.sml
src/smackage-path.sml
src/smacklib.sml
src/configure.sml
src/main.sml
1 change: 0 additions & 1 deletion smack.cm
Expand Up @@ -7,5 +7,4 @@ Group is
src/posix-symlink.sml
src/smackage-path.sml
src/smacklib.sml
src/configure.sml
src/main.sml
16 changes: 8 additions & 8 deletions sources.cm
Expand Up @@ -2,20 +2,20 @@ Group is
$/basis.cm
util/sources.cm

(* Smackage data types *)
src/protocol.sml
src/semver.sml
src/spec.sml

(* Managing local data *)
src/fsutil.sml
src/version-index.sml
src/configure.sml
src/install.sml

(* Obtaining and manipulating code and packages *)
src/get-git.sml
src/conductor.sig
src/conductor.sml
src/get-git.sml
src/get-http.sml
(* src/smackage-path.sml *)
src/spec.sml
src/http-downloader.sig
src/curl-lib.sml
(* src/smacklib.sml *)

(* src/posix-symlink.sml *)
(* src/bullshit-symlink.sml*)
36 changes: 21 additions & 15 deletions sources.mlb
@@ -1,15 +1,21 @@
$(SML_LIB)/basis/basis.mlb
(*src/posix-symlink.sml*)
(*src/bullshit-symlink.sml*)

src/semver.sml
src/protocol.sml
src/spec.sml
src/install.sml
src/version-index.sml
src/get-git.sml
src/get-http.sml
src/conductor.sig
src/conductor.sml
(*src/smackage-path.sml*)
(*src/smacklib.sml*)

$(SML_LIB)/basis/basis.mlb
util/sources.mlb

(* Smackage data types *)
src/protocol.sml
src/semver.sml
src/spec.sml

(* Managing local data *)
src/fsutil.sml
src/version-index.sml
src/configure.sml
src/install.sml

(* Obtaining and manipulating code and packages *)
src/get-git.sml
src/conductor.sig
src/conductor.sml
src/http-downloader.sig
src/curl-lib.sml
67 changes: 67 additions & 0 deletions src/fsutil.sml
@@ -0,0 +1,67 @@

structure FSUtil:>
sig
(* Run a system command, get the output, clean up. *)
val systemStr: string -> string

(* Get all the lines from a file.
* Trims leading whitespace, trailing newlines, and #linecomments. *)
val getLines: string -> string list

(* Write lines to a file; adds newlines. *)
val putLines: string list -> string -> unit
end =
struct
fun systemStr cmd =
let
val tmpName = OS.FileSys.tmpName ()
val _ = OS.Process.system (cmd ^ " > " ^ tmpName)
val tmp = TextIO.openIn tmpName
val cleanup = fn () => OS.FileSys.remove tmpName
in
(TextIO.inputAll tmp before (TextIO.closeIn tmp; cleanup ()))
handle exn =>
( (TextIO.closeIn tmp; cleanup ()) handle _ => ()
; raise exn)
end

fun trim s =
let
fun trimStart (#" "::t) = trimStart t
| trimStart (#"\t"::t) = trimStart t
| trimStart l = l

fun trimEnd (#"#"::t) = []
| trimEnd (#"\n"::t) = []
| trimEnd (h::t) = h :: trimEnd t
| trimEnd [] = []
in
String.implode (trimEnd (trimStart (String.explode s)))
end

fun getLines' file accum =
case TextIO.inputLine file of
NONE => rev accum before TextIO.closeIn file
| SOME s => getLines' file (trim s :: accum)

fun getLines fileName =
let val file = TextIO.openIn fileName
in
getLines' file []
handle exn => (TextIO.closeIn file handle _ => (); raise exn)
end

fun putLines' file lines =
case lines of
[] => TextIO.closeOut file
| line :: lines =>
(TextIO.output (file, line ^ "\n"); putLines' file lines)

fun putLines lines fileName =
let val file = TextIO.openOut fileName
in
putLines' file []
handle exn => (TextIO.closeOut file handle _ => (); raise exn)
end

end
5 changes: 0 additions & 5 deletions src/get-http.sml

This file was deleted.

6 changes: 6 additions & 0 deletions util/sources.mlb
@@ -0,0 +1,6 @@

$(SML_LIB)/basis/basis.mlb
sort.sml
dict.sig
dict-list.sml

0 comments on commit 581ce23

Please sign in to comment.