-- | Gathering information about the build environment.moduleBuildBox.Command.Environment(-- * Build EnvironmentEnvironment(..),getEnvironmentWith-- * Build platform,Platform(..),getHostPlatform,getHostName,getHostArch,getHostProcessor,getHostOS,getHostRelease-- * Software versions,getVersionGHC,getVersionGCC)whereimportBuildBox.BuildimportBuildBox.Command.SystemimportBuildBox.Command.FileimportBuildBox.Pretty-- Environment -------------------------------------------------------------------------------------- | The environment consists of the `Platform`, and some tool versions.dataEnvironment=Environment{environmentPlatform::Platform,environmentVersions::[(String,String)]}deriving(Show,Read)instancePrettyEnvironmentwherepprenv=hang(ppr"Environment")2$vcat[ppr$environmentPlatformenv,hang(ppr"Versions")2$vcat$map(\(name,ver)->pprname<+>pprver)$environmentVersionsenv]-- | Get the current environment, including versions of these tools.getEnvironmentWith::[(String,BuildString)]-- ^ List of tool names and commands to get their versions.->BuildEnvironmentgetEnvironmentWithnameGets=doplatform<-getHostPlatformversions<-mapM(\(name,get)->dover<-getreturn(name,ver))$nameGetsreturn$Environment{environmentPlatform=platform,environmentVersions=versions}-- Platform ----------------------------------------------------------------------------------------- | Generic information about the platform we're running on.dataPlatform=Platform{platformHostName::String,platformHostArch::String,platformHostProcessor::String,platformHostOS::String,platformHostRelease::String}deriving(Show,Read)instancePrettyPlatformwherepprplat=hang(ppr"Platform")2$vcat[ppr"host: "<>(ppr$platformHostNameplat),ppr"arch: "<>(ppr$platformHostArchplat),ppr"processor: "<>(ppr$platformHostProcessorplat),ppr"system: "<>(ppr$platformHostOSplat)<+>(ppr$platformHostReleaseplat)]-- | Get information about the host platform.getHostPlatform::BuildPlatformgetHostPlatform=doname<-getHostNamearch<-getHostArchprocessor<-getHostProcessoros<-getHostOSrelease<-getHostReleasereturn$Platform{platformHostName=name,platformHostArch=arch,platformHostProcessor=processor,platformHostOS=os,platformHostRelease=release}-- Platform Tests ----------------------------------------------------------------------------------- | Get the name of this host, using @uname@.getHostName::BuildStringgetHostName=docheck$HasExecutable"uname"name<-sesystemq"uname -n"return$initname-- | Get the host architecture, using @uname@.getHostArch::BuildStringgetHostArch=docheck$HasExecutable"arch"name<-sesystemq"arch"return$initname-- | Get the host processor name, using @uname@.getHostProcessor::BuildStringgetHostProcessor=docheck$HasExecutable"uname"name<-sesystemq"uname -p"return$initname-- | Get the host operating system, using @uname@.getHostOS::BuildStringgetHostOS=docheck$HasExecutable"uname"name<-sesystemq"uname -s"return$initname-- | Get the host operating system release, using @uname@.getHostRelease::BuildStringgetHostRelease=docheck$HasExecutable"uname"str<-sesystemq"uname -r"return$initstr-- Software version tests --------------------------------------------------------------------------- | Get the version of this GHC, or throw an error if it can't be found.getVersionGHC::FilePath->BuildStringgetVersionGHCpath=docheck$HasExecutablepathstr<-sesystemq$path++" --version"return$initstr-- | Get the version of this GCC, or throw an error if it can't be found. getVersionGCC::FilePath->BuildStringgetVersionGCCpath=docheck$HasExecutablepathstr<-sesystemq$path++" --version"return$head$linesstr