AC-BuildPlatform

Detect which OS you're running on.

Latest on Hackage:1.1.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Andrew Coppin
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AC-BuildPlatform v1.0.0: Read Me</title>
<style type="text/css">
body {background-color: rgb(80%, 100%, 80%); font-family: Georgia, Times, serif;}
</style>
</head>
<body>

<h1>Package <code>AC-BuildPlatform</code> version 1.0.0: Read me</h1>

<h2>Cleaning</h2>
<p>
Due to <a href="http://hackage.haskell.org/trac/hackage/ticket/303">Cabal bug #303</a>, under Windows you can't do &ldquo;<code>cabal clean</code>&rdquo;. In this instance, please use &ldquo;<code>runhaskell Setup clean</code>&rdquo; instead.
</p>
<p>
(Apparently Unix has some weird mis-feature whereby deleting a running executable file is not an error. Apparently cabal-install relies on this flaw. Obviously this means that on operating systems that actually support the concept of file locking, it doesn't work. In fairness, it's not obvious how to solve this little problem.)
</p>

<h2>Design assumptions</h2>
<ol>
<li>Any platform that isn't Windows is Unix. (This should be clear from the package description.)</li>
<li>The <code>{-# LANGUAGE CPP #-}</code> pragma works. (If not, you'll likely get random syntax errors.)</li>
</ol>

<h2>Platform detection</h2>
<p>
This package allows you to query at run-time what operating system and compiler are in use. This information is not easy to discover &mdash; hence why this package exists in the first place. The package runs some custom code during the &ldquo;configure&rdquo; stage. This code attempts to detect what platform it's running under. Note that the script <em>prints out</em> the values detected, so you don't have to actually build and install the package just to find out if platform detection is working right.
</p>
<p>
The platform detection code makes a number of assumptions, which are documented here. If these assumptions fail, it may not be possible to detect some or all of the platform values. Note that if the OS type cannot be detected, the configure step <em>will fail</em>, preventing the package from being built and installed.
</p>
<h2>Manual override</h2>
<p>
There is a small utility called <code>Manual.hs</code>. If you run this, it will let you set the platform values to whatever you like. This kludge lets you specify that your compiler is <em>Fred's Haskell Compiler</em> or whatever.
</p>
<p>
You must run this before the &ldquo;build&rdquo; and/or &ldquo;haddock&rdquo; stages, but you can run it before or after the &ldquo;configure&rdquo; stage. So if you run a &ldquo;configure&rdquo; and it fails, and you can't correct the failure, you can use a manual override to specify the correct values and then run &ldquo;configure&rdquo; again.
</p>
<p>
Note that performing a manual override turns off the auto-detection logic in &ldquo;configure&rdquo;. To turn it back on again, just perform a &ldquo;clean&rdquo; (which removes any manual values you specified). See the notes above about performing a &ldquo;clean&rdquo; operation though.
</p>

<h2>Platform detection assumptions</h2>
<p>
The platform detection logic makes a number of assumptions. The first two are the only ones that most users need to worry about.
</p>
<ol>
<li>
<p><b>You configure the package using &ldquo;<code>cabal configure</code>&rdquo;, not &ldquo;<code>runhaskell Setup configure</code>&rdquo;.</b></p>
<p>If this is not the case, no information is detected [and therefore configure fails].</p>
</li>
<li>
<p><b>Your compiler is GHC, version 6.8.1 or newer.</b></p>
<p>If this is not the case, most likely no information will be detected [and therefore configure will fail].</p>
<p>I realise that being able to query the compiler is a bit pointless when only one possible compiler is supported. Note though that if the compiler is <em>not</em> GHC, it will <em>not</em> be reported as GHC. So there is some small information content there.</p>
</li>
<li>
<p><b>The cabal-install tool compiles <code>Setup.hs</code> before running it.</b></p>
<p>(And, additionally, stores it in <code>./dist/setup/Setup[.exe]</code>. And, additionally, runs it with the package root folder as the current working folder.)</p>
<p>In theory, the path might change in future, breaking the detection code.</p>
</li>
<li>
<p><b>The compiler used for configuring is the same as the one used for building.</b></p>
<p>As far as I know, Cabal does not allow you to violate this assumption. But if you did, the detected information would refer to the compiler used for configuring and not the one used for building.</p>
</li>
<li>
<p><b>The GHC &ldquo;<code>+RTS --info</code>&rdquo; option is available.</b></p>
<p>This option was added in GHC 6.8.1; older versions do not support it. Additionally, as of GHC 7.0.1, most RTS options are disabled by default (but <em>not</em> this one). If in future this option is disabled as well, detection will break.</p>
<p>As far as I know, no other compilers support this option. But if they did, the existing detection logic is intended to respond gracefully. The detection script looks for only two keys: &ldquo;<code>GHC version</code>&rdquo; and &ldquo;<code>Target platform</code>&rdquo;. The latter might plausibly be available from other implementations, in which case OS detection would work.</p>
</li>
<li>
<p><b>GHC for Windows uses MinGW.</b></p>
<p>This has always been the case in the past, but it could potentially change in future. (Here's to hoping, anyway!)</p>
<p>Of course, the detection logic doesn't <em>really</em> care whether MinGW is in use or not. It only cares whether the target platform is reported as &ldquo;<code>mingw32</code>&rdquo;. If yes, it assumes the platform is <code>MS_Windows</code>. For <em>any other value</em> it assumes <code>Unix</code>. So if some day GHC actually reports Windows as being &ldquo;<code>Windows</code>&rdquo;, the detection logic will need updating.</p>
</li>
</ol>
<p>
In summary: The detection algorithm depends on precise details of GHC, the GHC RTS, the Cabal library, and the cabal-install tool. If any of these tools change in particularly unusual ways in the future, the detection code might break.
</p>

</body>
</html>
Depends on:
Used by 1 package:
comments powered byDisqus