summaryrefslogtreecommitdiff
path: root/src/compiler.sml
diff options
context:
space:
mode:
authorGravatar Edward Z. Yang <ezyang@mit.edu>2012-05-02 17:17:57 -0400
committerGravatar Edward Z. Yang <ezyang@mit.edu>2012-05-02 17:17:57 -0400
commit53ab42ae386350fbcd0171c8ba630bb8dcb71c54 (patch)
tree91cc80e8e50847ab4c3b37714f133417df65f59a /src/compiler.sml
parent39df5b18cb633f6c83c06c2f9ddba3f9330aa06b (diff)
Add support for -boot flag, which allows in-tree execution of Ur/Web
The boot flag rewrites most hardcoded paths to point to the build directory, and also forces static compilation. This is convenient for developing Ur/Web, or if you cannot 'sudo make install' Ur/Web. The following changes were made: * Header files were moved to include/urweb instead of include; this lets FFI users point their C_INCLUDE_PATH at this directory at write <urweb/urweb.h>. For internal Ur/Web executables, we simply pass -I$PATH/include/urweb as normal. * Differentiate between LIB and SRCLIB; SRCLIB is Ur and JavaScript source files, while LIB is compiled products from libtool. For in-tree compilation these live in different places. * No longer reference Config for paths; instead use Settings; these settings can be changed dynamically by Compiler.enableBoot () (TODO: add a disableBoot function.) * config.h is now generated directly in include/urweb/config.h, for consistency's sake (especially since it gets installed along with the rest of the headers!) * All of the autotools build products got updated. * The linkStatic field in protocols now only contains the name of the build product, and not the absolute path. Future users have to be careful not to reference the Settings files to early, lest they get an old version (this was the source of two bugs during development of this patch.)
Diffstat (limited to 'src/compiler.sml')
-rw-r--r--src/compiler.sml34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/compiler.sml b/src/compiler.sml
index 45d87b6a..c92cd832 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -326,10 +326,25 @@ structure M = BinaryMapFn(struct
val compare = String.compare
end)
-val pathmap = ref (M.insert (M.empty, "", Config.libUr))
+(* XXX ezyang: pathmap gets initialized /really early/, before
+ * we do any options parsing. So libUr will always point to the
+ * default. We override it explicitly in enableBoot *)
+val pathmap = ref (M.insert (M.empty, "", Settings.libUr ()))
fun addPath (k, v) = pathmap := M.insert (!pathmap, k, v)
+(* XXX ezyang: this is not right; it probably doesn't work in
+ * the case of separate build and src trees *)
+fun enableBoot () =
+ (Settings.configBin := OS.Path.joinDirFile {dir = Config.builddir, file = "bin"};
+ Settings.configSrcLib := OS.Path.joinDirFile {dir = Config.builddir, file = "lib"};
+ (* joinDirFile is annoying... (ArcError; it doesn't like
+ * slashes in file) *)
+ Settings.configLib := Config.builddir ^ "/src/c/.libs";
+ Settings.configInclude := OS.Path.joinDirFile {dir = Config.builddir ^ "/include", file = "urweb"};
+ Settings.configSitelisp := Config.builddir ^ "/src/elisp";
+ addPath ("", Settings.libUr ()))
+
fun capitalize "" = ""
| capitalize s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
@@ -1098,16 +1113,11 @@ val parse = {
val toParse = transform parse "parse" o toParseJob
-fun libFile s = OS.Path.joinDirFile {dir = Config.libUr,
- file = s}
-fun clibFile s = OS.Path.joinDirFile {dir = Config.libC,
- file = s}
-
val elaborate = {
func = fn file => let
- val basisF = libFile "basis.urs"
- val topF = libFile "top.urs"
- val topF' = libFile "top.ur"
+ val basisF = Settings.libFile "basis.urs"
+ val topF = Settings.libFile "top.urs"
+ val topF' = Settings.libFile "top.ur"
val basis = #func parseUrs basisF
val topSgn = #func parseUrs topF
@@ -1389,9 +1399,9 @@ fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} =
val proto = Settings.currentProtocol ()
val lib = if Settings.getStaticLinking () then
- #linkStatic proto ^ " " ^ Config.lib ^ "/../liburweb.a"
+ " " ^ !Settings.configLib ^ "/" ^ #linkStatic proto ^ " " ^ !Settings.configLib ^ "/liburweb.a"
else
- "-L" ^ Config.lib ^ "/.. " ^ #linkDynamic proto ^ " -lurweb"
+ "-L" ^ !Settings.configLib ^ " " ^ #linkDynamic proto ^ " -lurweb"
val opt = if debug then
""
@@ -1399,7 +1409,7 @@ fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} =
" -O3"
val compile = Config.ccompiler ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadCflags ^ " -Wimplicit -Werror -Wno-unused-value"
- ^ opt ^ " -I " ^ Config.includ
+ ^ opt ^ " -I " ^ !Settings.configInclude
^ " " ^ #compile proto
^ " -c " ^ escapeFilename cname ^ " -o " ^ escapeFilename oname