Mercurial > urweb
diff src/compiler.sml @ 1739:c414850f206f
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.)
author | Edward Z. Yang <ezyang@mit.edu> |
---|---|
date | Wed, 02 May 2012 17:17:57 -0400 |
parents | 1a35e75b6967 |
children | 1e940643a5f0 |
line wrap: on
line diff
--- a/src/compiler.sml Thu May 03 09:56:41 2012 -0400 +++ b/src/compiler.sml Wed May 02 17:17:57 2012 -0400 @@ -326,10 +326,25 @@ 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 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 @@ 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 @@ " -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