From 24782b89907ab36fb5aef3a17584f4c10f1e2690 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 20 Jun 2019 18:04:30 -0400 Subject: Deduplicate "unique subdir" code between GHC and Cabal The code, including the generated module with the version, is now in ghc-boot. Config.hs reexports stuff as needed, ghc-pkg doesn't need any tricks at all. --- compiler/ghc.mk | 26 +++++++++++++------------- compiler/main/DynFlags.hs | 12 ++---------- 2 files changed, 15 insertions(+), 23 deletions(-) (limited to 'compiler') diff --git a/compiler/ghc.mk b/compiler/ghc.mk index 1cd82d1635..4e0fb9095b 100644 --- a/compiler/ghc.mk +++ b/compiler/ghc.mk @@ -49,33 +49,33 @@ compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/. $(call removeFiles,$@) @echo 'Creating $@ ... ' @echo '{-# LANGUAGE CPP #-}' >> $@ - @echo 'module Config where' >> $@ + @echo 'module Config' >> $@ + @echo ' ( module GHC.Version' >> $@ + @echo ' , cBuildPlatformString' >> $@ + @echo ' , cHostPlatformString' >> $@ + @echo ' , cProjectName' >> $@ + @echo ' , cBooterVersion' >> $@ + @echo ' , cStage' >> $@ + @echo ' ) where' >> $@ @echo >> $@ @echo 'import GhcPrelude' >> $@ @echo >> $@ + @echo 'import GHC.Version' >> $@ + @echo >> $@ @echo '#include "ghc_boot_platform.h"' >> $@ @echo >> $@ @echo 'cBuildPlatformString :: String' >> $@ @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@ + @echo >> $@ @echo 'cHostPlatformString :: String' >> $@ @echo 'cHostPlatformString = HostPlatform_NAME' >> $@ @echo >> $@ @echo 'cProjectName :: String' >> $@ @echo 'cProjectName = "$(ProjectName)"' >> $@ - @echo 'cProjectGitCommitId :: String' >> $@ - @echo 'cProjectGitCommitId = "$(ProjectGitCommitId)"' >> $@ - @echo 'cProjectVersion :: String' >> $@ - @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@ - @echo 'cProjectVersionInt :: String' >> $@ - @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@ - @echo 'cProjectPatchLevel :: String' >> $@ - @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@ - @echo 'cProjectPatchLevel1 :: String' >> $@ - @echo 'cProjectPatchLevel1 = "$(ProjectPatchLevel1)"' >> $@ - @echo 'cProjectPatchLevel2 :: String' >> $@ - @echo 'cProjectPatchLevel2 = "$(ProjectPatchLevel2)"' >> $@ + @echo >> $@ @echo 'cBooterVersion :: String' >> $@ @echo 'cBooterVersion = "$(GhcVersion)"' >> $@ + @echo >> $@ @echo 'cStage :: String' >> $@ @echo 'cStage = show (STAGE :: Int)' >> $@ @echo done. diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 2379f484e9..7009771aa4 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -250,6 +250,7 @@ module DynFlags ( import GhcPrelude import GHC.Platform +import GHC.UniqueSubdir (uniqueSubdir) import PlatformConstants import Module import PackageConfig @@ -1499,17 +1500,8 @@ versionedAppDir dflags = do appdir <- tryMaybeT $ getAppUserDataDirectory (programName dflags) return $ appdir versionedFilePath dflags --- | A filepath like @x86_64-linux-7.6.3@ with the platform string to use when --- constructing platform-version-dependent files that need to co-exist. --- versionedFilePath :: DynFlags -> FilePath -versionedFilePath dflags = intercalate "-" - [ stringEncodeArch $ platformArch $ targetPlatform dflags - , stringEncodeOS $ platformOS $ targetPlatform dflags - , projectVersion dflags - ] - -- NB: This functionality is reimplemented in Cabal, so if you - -- change it, be sure to update Cabal. +versionedFilePath dflags = uniqueSubdir $ targetPlatform dflags -- | The target code type of the compilation (if any). -- -- cgit v1.2.1