Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
2091b89a
by fendor at 2026-11-22T16:36:17-05:00
24 changed files:
- + changelog.d/make-depends-link-nodes
- compiler/GHC/Driver/MakeFile.hs
- docs/users_guide/make-depends-json-schema-1_0.json
- testsuite/tests/driver/mkdepend/all.T
- + testsuite/tests/driver/mkdepend/mhu04/app/Main.hs
- + testsuite/tests/driver/mkdepend/mhu04/app/Utils.hs
- + testsuite/tests/driver/mkdepend/mhu04/lib/Lib.hs
- + testsuite/tests/driver/mkdepend/mhu04/lib/Lib/Internal.hs
- + testsuite/tests/driver/mkdepend/mhu04/unitApp
- + testsuite/tests/driver/mkdepend/mhu04/unitLib
- + testsuite/tests/driver/mkdepend/mhu05/app/Main.hs
- + testsuite/tests/driver/mkdepend/mhu05/lib/Lib.hs
- + testsuite/tests/driver/mkdepend/mhu05/lib/Lib/Internal.hs
- + testsuite/tests/driver/mkdepend/mhu05/test/Spec.hs
- + testsuite/tests/driver/mkdepend/mhu05/unitApp
- + testsuite/tests/driver/mkdepend/mhu05/unitLib
- + testsuite/tests/driver/mkdepend/mhu05/unitTest
- + testsuite/tests/driver/mkdepend/mkdepend02.dep-json
- + testsuite/tests/driver/mkdepend/mkdepend02/Main.hs
- + testsuite/tests/driver/mkdepend/mkdepend_bkp_01/bkp01.bkp
- + testsuite/tests/driver/mkdepend/mkdepend_mhu04.dep-json
- + testsuite/tests/driver/mkdepend/mkdepend_mhu04.dep-makefile
- + testsuite/tests/driver/mkdepend/mkdepend_mhu05.dep-json
- + testsuite/tests/driver/mkdepend/mkdepend_mhu05.dep-makefile
Changes:
| 1 | +section: compiler
|
|
| 2 | +synopsis: Expose link nodes in `ghc -M -dep-json` output
|
|
| 3 | +issues: #28007
|
|
| 4 | +mrs: !16848 |
| ... | ... | @@ -44,6 +44,7 @@ import GHC.Types.Unique.Set (UniqSet) |
| 44 | 44 | import GHC.Types.Unique.Set qualified as UniqSet
|
| 45 | 45 | import GHC.Types.UnresolvedImport
|
| 46 | 46 | |
| 47 | +import GHC.Unit.Env qualified as UnitEnv
|
|
| 47 | 48 | import GHC.Unit.Finder
|
| 48 | 49 | import GHC.Unit.Home.Graph (HomeUnitEnv (homeUnitEnv_dflags))
|
| 49 | 50 | import GHC.Unit.Info
|
| ... | ... | @@ -189,9 +190,11 @@ doMkDependModuleGraph dflags module_graph = do |
| 189 | 190 | |
| 190 | 191 | -- | A 'DepNode' is a direct translation of a 'ModuleGraphNode' that
|
| 191 | 192 | -- can be serialised to a Makefile or json lines format.
|
| 192 | -data DepNode =
|
|
| 193 | - ModuleDepNode HomeModuleNode [Dep]
|
|
| 194 | - -- ^ A dependency node of a home module with its dependencies
|
|
| 193 | +data DepNode
|
|
| 194 | + = ModuleDepNode HomeModuleNode [Dep]
|
|
| 195 | + -- ^ A dependency node of a home module with its dependencies.
|
|
| 196 | + | LinkDepNode DepLink [DepLinkNode]
|
|
| 197 | + -- ^ A link node is the result of linking some elements from the module graph.
|
|
| 195 | 198 | |
| 196 | 199 | -- | A home module node.
|
| 197 | 200 | -- Everything we know about home modules that can be serialised.
|
| ... | ... | @@ -221,6 +224,7 @@ data PreprocessingNode = PreprocessingNode |
| 221 | 224 | { pn_preprocessor :: String
|
| 222 | 225 | -- ^ The preprocessor.
|
| 223 | 226 | , pn_arguments :: [String]
|
| 227 | + -- ^ Arguments to be passed to the preprocessor.
|
|
| 224 | 228 | }
|
| 225 | 229 | |
| 226 | 230 | -- | A dependency edge on another module, or cpp path.
|
| ... | ... | @@ -249,6 +253,33 @@ data Dep |
| 249 | 253 | -- ^ Path to the @#include@d path.
|
| 250 | 254 | }
|
| 251 | 255 | |
| 256 | +-- | A link node in the module graph.
|
|
| 257 | +data DepLink
|
|
| 258 | + = DepLink
|
|
| 259 | + { link_output :: !UnitId
|
|
| 260 | + -- ^ The 'UnitId' of the home unit we are performing linking on.
|
|
| 261 | + , link_type :: !GhcLink
|
|
| 262 | + -- ^ What is the type of this link node?
|
|
| 263 | + }
|
|
| 264 | + |
|
| 265 | +-- | A linking dependency that makes up the requirements to link something.
|
|
| 266 | +data DepLinkNode
|
|
| 267 | + = DepLink_Unit !UnitId
|
|
| 268 | + -- ^ A dependency on an ad-hoc instantiated unit.
|
|
| 269 | + --
|
|
| 270 | + -- At this point of time, such a dependency won't be generated, as @-M@
|
|
| 271 | + -- doesn't work with backpack, thus there will never be an ad-hoc instantiated unit.
|
|
| 272 | + | DepLink_Module !ModuleNameWithIsBoot !UnitId
|
|
| 273 | + -- ^ A dependency on a home module.
|
|
| 274 | + | DepLink_HomeUnit {-# UNPACK #-} !UnitId
|
|
| 275 | + -- ^ A dependency on the linking node of a home unit.
|
|
| 276 | + -- This is useful when the linking output of a home unit depends on the linking node of
|
|
| 277 | + -- another home unit.
|
|
| 278 | + | DepLink_ExtUnit {-# UNPACK #-} !UnitId
|
|
| 279 | + -- ^ A dependency on an external unit, i.e. a dependency loaded from the 'UnitState'.
|
|
| 280 | + --
|
|
| 281 | + -- At this point of time, such a dependency won't be generated by 'downsweep'.
|
|
| 282 | + |
|
| 252 | 283 | -- | 'DependencyWriter' is a backend for outputting 'DepNode' in a specific
|
| 253 | 284 | -- output format.
|
| 254 | 285 | data DependencyWriter = DependencyWriter
|
| ... | ... | @@ -386,7 +417,21 @@ processDeps hsc_env _ (AcyclicSCC (InstantiationNode _uid node)) |
| 386 | 417 | mkPlainErrorMsgEnvelope noSrcSpan $
|
| 387 | 418 | GhcDriverMessage $ DriverInstantiationNodeInDependencyGeneration node
|
| 388 | 419 | |
| 389 | -processDeps _ _ (AcyclicSCC (LinkNode {})) = return Nothing
|
|
| 420 | +processDeps hsc_env _ (AcyclicSCC (LinkNode keys unitId)) = do
|
|
| 421 | + let
|
|
| 422 | + toLinkNodeDep = \ case
|
|
| 423 | + NodeKey_Unit iu -> DepLink_Unit $ virtualUnitId iu
|
|
| 424 | + NodeKey_Module node -> DepLink_Module (mnkModuleName node) (mnkUnitId node)
|
|
| 425 | + NodeKey_Link uid -> DepLink_HomeUnit uid
|
|
| 426 | + NodeKey_ExternalUnit uid -> DepLink_ExtUnit uid
|
|
| 427 | + |
|
| 428 | + linkNode = DepLink
|
|
| 429 | + { link_output = unitId
|
|
| 430 | + , link_type = ghcLink $ UnitEnv.ue_unitFlags unitId (hsc_unit_env hsc_env)
|
|
| 431 | + }
|
|
| 432 | + |
|
| 433 | + pure $ Just $ LinkDepNode linkNode (map toLinkNodeDep keys)
|
|
| 434 | + |
|
| 390 | 435 | processDeps _ _ (AcyclicSCC (UnitNode {})) = return Nothing
|
| 391 | 436 | processDeps _ _ (AcyclicSCC (ModuleNode _ (ModuleNodeFixed {})))
|
| 392 | 437 | -- No dependencies needed for fixed modules (already compiled)
|
| ... | ... | @@ -507,6 +552,9 @@ initFileDepWriter logger root tmpfs tmpdir suffixes output = do |
| 507 | 552 | { dw_writeDependency = \ case
|
| 508 | 553 | ModuleDepNode node deps -> do
|
| 509 | 554 | traverse_ (depStream_write stream) (dependencyRules root suffixes node deps)
|
| 555 | + LinkDepNode _node _deps -> do
|
|
| 556 | + -- Makefile can't handle 'LinkDepNode'
|
|
| 557 | + pure ()
|
|
| 510 | 558 | , dw_endWriter = depStream_close stream
|
| 511 | 559 | , dw_onError = depStream_onError stream
|
| 512 | 560 | }
|
| ... | ... | @@ -690,6 +738,8 @@ initJsonDepWriter logger tmpfs tmpdir output = do |
| 690 | 738 | depStream_write stream (renderJsonl payload)
|
| 691 | 739 | -- Cache external deps we already reported in the past
|
| 692 | 740 | updateJson json_var $ cacheExternalDepsJson newExtUnits
|
| 741 | + LinkDepNode node deps -> do
|
|
| 742 | + depStream_write stream $ renderJsonl $ linkNodeJson node deps
|
|
| 693 | 743 | , dw_endWriter = depStream_close stream
|
| 694 | 744 | , dw_onError = depStream_onError stream
|
| 695 | 745 | }
|
| ... | ... | @@ -757,7 +807,7 @@ renderJsonl output = |
| 757 | 807 | -- Payload for -dep-json
|
| 758 | 808 | |
| 759 | 809 | -- | State of the @-dep-json@ dependency generation.
|
| 760 | -data DepJson = DepJson
|
|
| 810 | +newtype DepJson = DepJson
|
|
| 761 | 811 | { externalDeps :: Set.Set ExtUnitDep
|
| 762 | 812 | -- ^ The external units we have already published/generated.
|
| 763 | 813 | -- We show each external unit exactly once, before the first time they are referenced.
|
| ... | ... | @@ -769,13 +819,13 @@ data DepJson = DepJson |
| 769 | 819 | -- when a sensible default can be assumed.
|
| 770 | 820 | -- For example, the @boot@ is only present in the final json object, if it is 'IsBoot'.
|
| 771 | 821 | data HomeUnitDep = HomeUnitDep
|
| 772 | - { unitId :: UnitId
|
|
| 773 | - , packageName :: Maybe String
|
|
| 774 | - , modWithIsBoot :: ModuleWithIsBoot
|
|
| 775 | - , source :: OsPath
|
|
| 776 | - , imports :: ImportDeps
|
|
| 777 | - , cpp :: Set.Set OsPath
|
|
| 778 | - , preprocessor :: Maybe PreprocessingNode
|
|
| 822 | + { unitId :: !UnitId
|
|
| 823 | + , packageName :: !(Maybe String)
|
|
| 824 | + , modWithIsBoot :: !ModuleWithIsBoot
|
|
| 825 | + , source :: !OsPath
|
|
| 826 | + , imports :: !ImportDeps
|
|
| 827 | + , cpp :: !(Set.Set OsPath)
|
|
| 828 | + , preprocessor :: !(Maybe PreprocessingNode)
|
|
| 779 | 829 | }
|
| 780 | 830 | |
| 781 | 831 | addImport :: ImportDep -> HomeUnitDep -> HomeUnitDep
|
| ... | ... | @@ -805,9 +855,9 @@ newtype ImportDeps = ImportDeps |
| 805 | 855 | -- 'IsBootInterface' if it is 'IsBoot'. This allows us to express the default case (a normal, non-source import)
|
| 806 | 856 | -- as simply the module name.
|
| 807 | 857 | data ImportDep = ImportDep
|
| 808 | - { imp_mod :: Module
|
|
| 809 | - , imp_level :: ImportLevel
|
|
| 810 | - , imp_isBoot :: IsBootInterface
|
|
| 858 | + { imp_mod :: !Module
|
|
| 859 | + , imp_level :: !ImportLevel
|
|
| 860 | + , imp_isBoot :: !IsBootInterface
|
|
| 811 | 861 | } deriving (Eq, Ord)
|
| 812 | 862 | |
| 813 | 863 | mkImportDep :: Module -> ImportLevel -> IsBootInterface -> ImportDep
|
| ... | ... | @@ -818,10 +868,10 @@ mkImportDep modl level isBoot = ImportDep |
| 818 | 868 | }
|
| 819 | 869 | |
| 820 | 870 | data ExtUnitDep = ExtUnitDep
|
| 821 | - { extUnitId :: UnitId
|
|
| 871 | + { extUnitId :: !UnitId
|
|
| 822 | 872 | -- ^ The 'UnitId' of a unit. This is assumed to be globally unique.
|
| 823 | 873 | , extUnitName :: String
|
| 824 | - , extUnitPackageId :: DPackageId
|
|
| 874 | + , extUnitPackageId :: !DPackageId
|
|
| 825 | 875 | } deriving (Eq, Ord)
|
| 826 | 876 | |
| 827 | 877 | newtype DPackageId = DPackageId PackageId
|
| ... | ... | @@ -830,11 +880,30 @@ newtype DPackageId = DPackageId PackageId |
| 830 | 880 | instance Ord DPackageId where
|
| 831 | 881 | DPackageId (PackageId d1) `compare` DPackageId (PackageId d2) = d1 `lexicalCompareFS` d2
|
| 832 | 882 | |
| 883 | +-- | Json representation of a 'LinkNode'.
|
|
| 884 | +data LinkNodeDep = LinkNodeDep
|
|
| 885 | + { linkNodeUid :: !UnitId
|
|
| 886 | + -- ^ The 'UnitId' of the home unit we are producing a link node for.
|
|
| 887 | + , linkNodeType :: !GhcLink
|
|
| 888 | + , linkNodeModuleDeps :: !(Map.Map UnitId (Set.Set ModuleNameWithIsBoot))
|
|
| 889 | + -- ^ Module dependencies grouped by 'UnitId'.
|
|
| 890 | + , linkNodeUnitDeps :: !(Set.Set UnitId)
|
|
| 891 | + -- ^ Backpack unit instantiation.
|
|
| 892 | + , linkNodeHomeUnitDeps :: !(Set.Set UnitId)
|
|
| 893 | + -- ^ Dependencies on other home unit 'LinkNode's.
|
|
| 894 | + , linkNodeExtUnitDeps :: !(Set.Set UnitId)
|
|
| 895 | + -- ^ Dependencies on external 'UnitId's.
|
|
| 896 | + }
|
|
| 833 | 897 | |
| 834 | 898 | {- Note [ghc -M -dep-json output format]
|
| 835 | 899 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 836 | -The instance of 'ToJson' 'DepJson' must conform to the JSON schema
|
|
| 837 | -specified in docs/users_guide/make-depends-json-schema-1_0.json.
|
|
| 900 | +The following instances must conform to the JSON schema:
|
|
| 901 | + |
|
| 902 | +* 'ToJson' 'HomeUnitDep'
|
|
| 903 | +* 'ToJson' 'ExtUnitDep'
|
|
| 904 | +* 'ToJson' 'LinkNodeDep'
|
|
| 905 | + |
|
| 906 | +The instances must conform to docs/users_guide/make-depends-json-schema-1_0.json.
|
|
| 838 | 907 | When the schema is altered, please bump the version.
|
| 839 | 908 | If the content is altered in a backwards compatible way,
|
| 840 | 909 | update the minor version (e.g. 1.3 ~> 1.4).
|
| ... | ... | @@ -933,6 +1002,50 @@ instance ToJson ExtUnitDep where |
| 933 | 1002 | where
|
| 934 | 1003 | showPackageId (DPackageId (PackageId pid)) = unpackFS pid
|
| 935 | 1004 | |
| 1005 | +-- See Note [ghc -M -dep-json output format]
|
|
| 1006 | +instance ToJson LinkNodeDep where
|
|
| 1007 | + json LinkNodeDep{linkNodeUid, linkNodeType, linkNodeModuleDeps, linkNodeUnitDeps, linkNodeHomeUnitDeps, linkNodeExtUnitDeps} =
|
|
| 1008 | + JSObject
|
|
| 1009 | + [ ("unit-id", JSString $ unitIdString linkNodeUid)
|
|
| 1010 | + , ("link-type", linkTypeJson linkNodeType)
|
|
| 1011 | + , ("links", JSArray $ concat
|
|
| 1012 | + [ map renderMods (Map.toList linkNodeModuleDeps)
|
|
| 1013 | + , map (JSString . unitIdString) (Set.toList linkNodeUnitDeps)
|
|
| 1014 | + , map (JSString . unitIdString) (Set.toList linkNodeHomeUnitDeps)
|
|
| 1015 | + , map (JSString . unitIdString) (Set.toList linkNodeExtUnitDeps)
|
|
| 1016 | + ])
|
|
| 1017 | + ]
|
|
| 1018 | + where
|
|
| 1019 | + linkTypeJson :: GhcLink -> JsonDoc
|
|
| 1020 | + linkTypeJson = JSString . \ case
|
|
| 1021 | + NoLink{} -> panic "Received -no-link, but a link node must not exist with -no-link."
|
|
| 1022 | + LinkExecutable{} -> "executable"
|
|
| 1023 | + LinkInMemory{} -> "in-memory"
|
|
| 1024 | + LinkDynLib{} -> "dynamic-library"
|
|
| 1025 | + LinkBytecodeLib{} -> "bytecode-library"
|
|
| 1026 | + LinkStaticLib{} -> "static-library"
|
|
| 1027 | + LinkMergedObj{} -> "merged-object"
|
|
| 1028 | + |
|
| 1029 | + renderMods (u, ms) =
|
|
| 1030 | + JSObject
|
|
| 1031 | + [ ("unit-id", JSString $ unitIdString u)
|
|
| 1032 | + , ("modules", JSArray $ map moduleKey (Set.toList ms))
|
|
| 1033 | + ]
|
|
| 1034 | + |
|
| 1035 | + |
|
| 1036 | + moduleNameJson m = JSString $ moduleNameString m
|
|
| 1037 | + |
|
| 1038 | + moduleKey :: ModuleNameWithIsBoot -> JsonDoc
|
|
| 1039 | + moduleKey t =
|
|
| 1040 | + case gwib_isBoot t of
|
|
| 1041 | + NotBoot -> moduleNameJson (gwib_mod t)
|
|
| 1042 | + IsBoot -> JSObject
|
|
| 1043 | + [ ("module", moduleNameJson (gwib_mod t))
|
|
| 1044 | + -- Redundant check, but the compiler will fix it and
|
|
| 1045 | + -- this feels like it might avoid bugs in the future.
|
|
| 1046 | + , ("boot", JSBool $ gwib_isBoot t == IsBoot)
|
|
| 1047 | + ]
|
|
| 1048 | + |
|
| 936 | 1049 | cacheExternalDepsJson :: Set.Set ExtUnitDep -> DepJson -> DepJson
|
| 937 | 1050 | cacheExternalDepsJson extUnits (DepJson e0) =
|
| 938 | 1051 | DepJson
|
| ... | ... | @@ -955,7 +1068,7 @@ homeUnitDeps HomeModuleNode {..} deps = |
| 955 | 1068 | , imports = ImportDeps Map.empty
|
| 956 | 1069 | }
|
| 957 | 1070 | |
| 958 | - go (extDeps, node_data) = \ case
|
|
| 1071 | + go (!extDeps, node_data) = \ case
|
|
| 959 | 1072 | DepHi {dep_mod, dep_local, dep_unit, dep_boot, dep_level}
|
| 960 | 1073 | | dep_local
|
| 961 | 1074 | -> (extDeps, addImport (mkImportDep dep_mod dep_level dep_boot) node_data)
|
| ... | ... | @@ -982,6 +1095,32 @@ homeUnitDeps HomeModuleNode {..} deps = |
| 982 | 1095 | DepCpp {dep_path} ->
|
| 983 | 1096 | (extDeps, addCpp dep_path node_data)
|
| 984 | 1097 | |
| 1098 | +linkNodeJson :: DepLink -> [DepLinkNode] -> LinkNodeDep
|
|
| 1099 | +linkNodeJson (DepLink uid linkType) deps =
|
|
| 1100 | + LinkNodeDep
|
|
| 1101 | + { linkNodeUid = uid
|
|
| 1102 | + , linkNodeType = linkType
|
|
| 1103 | + , linkNodeModuleDeps = allMods
|
|
| 1104 | + , linkNodeUnitDeps = units
|
|
| 1105 | + , linkNodeHomeUnitDeps = homeUids
|
|
| 1106 | + , linkNodeExtUnitDeps = extUids
|
|
| 1107 | + }
|
|
| 1108 | + where
|
|
| 1109 | + (!extUids, !homeUids, !units, !allMods) = foldl' go (Set.empty, Set.empty, Set.empty, Map.empty) deps
|
|
| 1110 | + |
|
| 1111 | + go (ext, homeUid, unit, mods) = \ case
|
|
| 1112 | + DepLink_Module modName u ->
|
|
| 1113 | + let
|
|
| 1114 | + newMods = Map.insertWith (Set.union) u (Set.singleton modName) mods
|
|
| 1115 | + in
|
|
| 1116 | + (ext, homeUid, unit, newMods)
|
|
| 1117 | + DepLink_Unit uid ->
|
|
| 1118 | + (ext, homeUid, Set.insert uid unit, mods)
|
|
| 1119 | + DepLink_HomeUnit uid ->
|
|
| 1120 | + (ext, Set.insert uid homeUid, unit, mods)
|
|
| 1121 | + DepLink_ExtUnit uid ->
|
|
| 1122 | + (Set.insert uid ext, homeUid, unit, mods)
|
|
| 1123 | + |
|
| 985 | 1124 | -----------------------------------------------------------------
|
| 986 | 1125 | -- Module cycles
|
| 987 | 1126 | -----------------------------------------------------------------
|
| ... | ... | @@ -3,8 +3,9 @@ |
| 3 | 3 | "title": "GHC dependencies",
|
| 4 | 4 | "description": "The dependency graph of a Haskell program.",
|
| 5 | 5 | "oneOf": [
|
| 6 | - { "$ref": "#/definitions/home-module" },
|
|
| 7 | - { "$ref": "#/definitions/external-unit" }
|
|
| 6 | + { "$ref": "#/definitions/external-unit" },
|
|
| 7 | + { "$ref": "#/definitions/module" },
|
|
| 8 | + { "$ref": "#/definitions/link" }
|
|
| 8 | 9 | ],
|
| 9 | 10 | "definitions": {
|
| 10 | 11 | "external-unit": {
|
| ... | ... | @@ -29,17 +30,17 @@ |
| 29 | 30 | "module-name": {
|
| 30 | 31 | "type": "string"
|
| 31 | 32 | },
|
| 32 | - "home-module": {
|
|
| 33 | + "module": {
|
|
| 33 | 34 | "type": "object",
|
| 34 | 35 | "properties": {
|
| 35 | 36 | "module": { "$ref": "#/definitions/module-name" },
|
| 36 | 37 | "unit-id": { "$ref": "#/definitions/unit-id" },
|
| 37 | 38 | "package-name": { "$ref": "#/definitions/package-name" },
|
| 38 | - "source": { "$ref": "#/definitions/home-module-source" },
|
|
| 39 | - "boot": { "type": "boolean" },
|
|
| 39 | + "source": { "$ref": "#/definitions/module-source" },
|
|
| 40 | + "boot": { "$ref": "#/definitions/boot" },
|
|
| 40 | 41 | "includes": {
|
| 41 | 42 | "type": "array",
|
| 42 | - "items": { "$ref": "#/definitions/home-module-include" }
|
|
| 43 | + "items": { "$ref": "#/definitions/module-include" }
|
|
| 43 | 44 | },
|
| 44 | 45 | "imports": {
|
| 45 | 46 | "type": "object",
|
| ... | ... | @@ -48,15 +49,15 @@ |
| 48 | 49 | "items": { "$ref": "#/definitions/import" }
|
| 49 | 50 | }
|
| 50 | 51 | },
|
| 51 | - "preprocessor": { "$ref": "#/definitions/home-module-preprocessor" }
|
|
| 52 | + "preprocessor": { "$ref": "#/definitions/module-preprocessor" }
|
|
| 52 | 53 | },
|
| 53 | 54 | "required": ["module", "unit-id", "source"],
|
| 54 | 55 | "unevaluatedProperties": false
|
| 55 | 56 | },
|
| 56 | - "home-module-source": {
|
|
| 57 | + "module-source": {
|
|
| 57 | 58 | "type": "string"
|
| 58 | 59 | },
|
| 59 | - "home-module-include": {
|
|
| 60 | + "module-include": {
|
|
| 60 | 61 | "type": "string"
|
| 61 | 62 | },
|
| 62 | 63 | "home-module-preprocessor": {
|
| ... | ... | @@ -81,17 +82,66 @@ |
| 81 | 82 | "properties": {
|
| 82 | 83 | "module": { "$ref": "#/definitions/module-name" },
|
| 83 | 84 | "level": { "$ref": "#/definitions/import-level" },
|
| 84 | - "boot": { "type": "boolean" }
|
|
| 85 | + "boot": { "$ref": "#/definitions/boot" }
|
|
| 85 | 86 | },
|
| 86 | 87 | "required": ["module"],
|
| 87 | 88 | "unevaluatedProperties": false
|
| 88 | 89 | }
|
| 89 | 90 | ]
|
| 90 | 91 | },
|
| 92 | + "boot": {
|
|
| 93 | + "type": "boolean",
|
|
| 94 | + "default": false
|
|
| 95 | + },
|
|
| 91 | 96 | "import-level": {
|
| 92 | 97 | "type": "string",
|
| 93 | 98 | "enum": ["normal", "quote", "splice"],
|
| 94 | 99 | "default": "normal"
|
| 100 | + },
|
|
| 101 | + "link": {
|
|
| 102 | + "type": "object",
|
|
| 103 | + "link-type": { "$ref": "#/definitions/link-type" },
|
|
| 104 | + "properties": {
|
|
| 105 | + "links": {
|
|
| 106 | + "type": "array",
|
|
| 107 | + "items": { "$ref": "#/definitions/link-unit" }
|
|
| 108 | + }
|
|
| 109 | + }
|
|
| 110 | + },
|
|
| 111 | + "link-type": {
|
|
| 112 | + "type": "string",
|
|
| 113 | + "enum": [
|
|
| 114 | + "executable",
|
|
| 115 | + "in-memory",
|
|
| 116 | + "dynamic-library",
|
|
| 117 | + "bytecode-library",
|
|
| 118 | + "static-library",
|
|
| 119 | + "merged-object"
|
|
| 120 | + ]
|
|
| 121 | + },
|
|
| 122 | + "link-unit": {
|
|
| 123 | + "type": "object",
|
|
| 124 | + "properties": {
|
|
| 125 | + "unit-id": { "$ref": "#/definitions/unit-id" },
|
|
| 126 | + "modules": {
|
|
| 127 | + "type": "array",
|
|
| 128 | + "items": { "$ref": "#/definitions/link-module" }
|
|
| 129 | + }
|
|
| 130 | + },
|
|
| 131 | + "required": ["unit-id"]
|
|
| 132 | + },
|
|
| 133 | + "link-module": {
|
|
| 134 | + "oneOf": [
|
|
| 135 | + { "$ref": "#/definitions/module-name" },
|
|
| 136 | + {
|
|
| 137 | + "type": "object",
|
|
| 138 | + "properties": {
|
|
| 139 | + "module": { "$ref": "#/definitions/module-name" },
|
|
| 140 | + "boot": { "$ref": "#/definitions/boot" }
|
|
| 141 | + },
|
|
| 142 | + "required": ["module"]
|
|
| 143 | + }
|
|
| 144 | + ]
|
|
| 95 | 145 | }
|
| 96 | 146 | }
|
| 97 | 147 | } |
| ... | ... | @@ -41,9 +41,23 @@ test('mkdepend_mhu03', |
| 41 | 41 | , when(opsys('mingw32'), skip) # shell script preprocessor
|
| 42 | 42 | ],
|
| 43 | 43 | make_depend_multiunit, [['mhu03/unitA'], ''])
|
| 44 | +# Link nodes
|
|
| 45 | +test('mkdepend_mhu04',
|
|
| 46 | + [ extra_files(['mhu04/']), dep_makefile, dep_json ],
|
|
| 47 | + make_depend_multiunit, [['mhu04/unitLib', 'mhu04/unitApp'], ''])
|
|
| 48 | +test('mkdepend_mhu05',
|
|
| 49 | + [ extra_files(['mhu05/']), dep_makefile, dep_json ],
|
|
| 50 | + make_depend_multiunit, [['mhu05/unitLib', 'mhu05/unitApp', 'mhu05/unitTest'], ''])
|
|
| 44 | 51 | |
| 45 | 52 | # Honour -F
|
| 46 | 53 | test('mkdepend01',
|
| 47 | 54 | [ extra_files(['mkdepend01/']), dep_makefile, dep_json ],
|
| 48 | 55 | make_depend, [['mkdepend01/A.hs'], '-pgmF pp'])
|
| 49 | - |
|
| 56 | +# Link nodes
|
|
| 57 | +test('mkdepend02',
|
|
| 58 | + [ extra_files(['mkdepend02/']), dep_json ],
|
|
| 59 | + make_depend, [['mkdepend02/Main.hs'], ''])
|
|
| 60 | +# Backpack
|
|
| 61 | +test('mkdepend_bkp_01',
|
|
| 62 | + [ extra_files(['mkdepend_bkp_01/']), dep_json, expect_fail ],
|
|
| 63 | + make_depend, [['mkdepend_bkp_01/bkp01.bkp'], '']) |
| 1 | +module Main (main) where
|
|
| 2 | + |
|
| 3 | +import Lib (greeting)
|
|
| 4 | +import Utils (shout)
|
|
| 5 | + |
|
| 6 | +main :: IO ()
|
|
| 7 | +main = putStrLn (shout greeting) |
| 1 | +module Utils (shout) where
|
|
| 2 | + |
|
| 3 | +import Data.Char (toUpper)
|
|
| 4 | + |
|
| 5 | +shout :: String -> String
|
|
| 6 | +shout = map toUpper |
| 1 | +module Lib (greeting) where
|
|
| 2 | + |
|
| 3 | +import Lib.Internal (name)
|
|
| 4 | + |
|
| 5 | +greeting :: String
|
|
| 6 | +greeting = "Hello, " ++ name |
| 1 | +module Lib.Internal (name) where
|
|
| 2 | + |
|
| 3 | +name :: String
|
|
| 4 | +name = "world" |
| 1 | +-i -i. -working-dir=mhu04/app -this-unit-id app -this-package-name app -package-id lib -o app Main |
| 1 | +-i -i. -working-dir=mhu04/lib -this-unit-id lib -this-package-name lib Lib Lib.Internal |
| 1 | +module Main (main) where
|
|
| 2 | + |
|
| 3 | +import Lib (greeting)
|
|
| 4 | + |
|
| 5 | +main :: IO ()
|
|
| 6 | +main = putStrLn greeting |
| 1 | +module Lib (greeting) where
|
|
| 2 | + |
|
| 3 | +import Lib.Internal (name)
|
|
| 4 | + |
|
| 5 | +greeting :: String
|
|
| 6 | +greeting = "Hello, " ++ name |
| 1 | +module Lib.Internal (name) where
|
|
| 2 | + |
|
| 3 | +name :: String
|
|
| 4 | +name = "world" |
| 1 | +module Spec (main) where
|
|
| 2 | + |
|
| 3 | +import Lib (greeting)
|
|
| 4 | +import Lib.Internal (name)
|
|
| 5 | + |
|
| 6 | +main :: IO ()
|
|
| 7 | +main
|
|
| 8 | + | greeting == "Hello, " ++ name = putStrLn "OK"
|
|
| 9 | + | otherwise = error "unexpected greeting" |
| 1 | +-i -i. -working-dir=mhu05/app -this-unit-id app -this-package-name app -package-id lib -o app Main |
| 1 | +-i -i. -working-dir=mhu05/lib -this-unit-id lib -this-package-name lib -staticlib Lib Lib.Internal |
| 1 | +-i -i. -working-dir=mhu05/test -this-unit-id test -this-package-name test -package-id lib -main-is Spec -o test Spec |
| 1 | +{"module":"Main","unit-id":"main","imports":{},"source":"mkdepend02/Main.hs"}
|
|
| 2 | +{"unit-id":"main","link-type":"executable","links":[{"unit-id":"main","modules":["Main"]}]} |
| 1 | +module Main where
|
|
| 2 | + |
|
| 3 | +main = putStrLn "Hello, World" |
| 1 | +unit p where
|
|
| 2 | + signature H where
|
|
| 3 | + data T
|
|
| 4 | + x :: Bool
|
|
| 5 | + module A where
|
|
| 6 | + import H
|
|
| 7 | + data A = MkA T
|
|
| 8 | + y = x
|
|
| 9 | + |
|
| 10 | +unit q where
|
|
| 11 | + dependency p[H=<H>]
|
|
| 12 | + |
|
| 13 | +unit h where
|
|
| 14 | + module H where
|
|
| 15 | + data T = T
|
|
| 16 | + x = True
|
|
| 17 | + |
|
| 18 | +unit r where
|
|
| 19 | + dependency h
|
|
| 20 | + dependency q[H=h:H] |
| 1 | +{"module":"Lib.Internal","unit-id":"lib","imports":{},"package-name":"lib","source":"mhu04/lib/Lib/Internal.hs"}
|
|
| 2 | +{"module":"Lib","unit-id":"lib","imports":{"lib":["Lib.Internal"]},"package-name":"lib","source":"mhu04/lib/Lib.hs"}
|
|
| 3 | +{"module":"Utils","unit-id":"app","imports":{},"package-name":"app","source":"mhu04/app/Utils.hs"}
|
|
| 4 | +{"module":"Main","unit-id":"app","imports":{"app":["Utils"],"lib":["Lib"]},"package-name":"app","source":"mhu04/app/Main.hs"}
|
|
| 5 | +{"unit-id":"app","link-type":"executable","links":[{"unit-id":"app","modules":["Main","Utils"]}]} |
| 1 | +# DO NOT DELETE: Beginning of Haskell dependencies
|
|
| 2 | +mhu04/lib/Lib/Internal.o : mhu04/lib/Lib/Internal.hs
|
|
| 3 | +mhu04/lib/Lib.o : mhu04/lib/Lib.hs
|
|
| 4 | +mhu04/lib/Lib.o : mhu04/lib/Lib/Internal.hi
|
|
| 5 | +mhu04/app/Utils.o : mhu04/app/Utils.hs
|
|
| 6 | +mhu04/app/Main.o : mhu04/app/Main.hs
|
|
| 7 | +mhu04/app/Main.o : mhu04/app/Utils.hi
|
|
| 8 | +mhu04/app/Main.o : mhu04/lib/Lib.hi
|
|
| 9 | +# DO NOT DELETE: End of Haskell dependencies |
| 1 | +{"module":"Lib.Internal","unit-id":"lib","imports":{},"package-name":"lib","source":"mhu05/lib/Lib/Internal.hs"}
|
|
| 2 | +{"module":"Lib","unit-id":"lib","imports":{"lib":["Lib.Internal"]},"package-name":"lib","source":"mhu05/lib/Lib.hs"}
|
|
| 3 | +{"unit-id":"lib","link-type":"static-library","links":[{"unit-id":"lib","modules":["Lib","Lib.Internal"]}]}
|
|
| 4 | +{"module":"Main","unit-id":"app","imports":{"lib":["Lib"]},"package-name":"app","source":"mhu05/app/Main.hs"}
|
|
| 5 | +{"unit-id":"app","link-type":"executable","links":[{"unit-id":"app","modules":["Main"]}]}
|
|
| 6 | +{"module":"Spec","unit-id":"test","imports":{"lib":["Lib","Lib.Internal"]},"package-name":"test","source":"mhu05/test/Spec.hs"}
|
|
| 7 | +{"unit-id":"test","link-type":"executable","links":[{"unit-id":"test","modules":["Spec"]}]} |
| 1 | +# DO NOT DELETE: Beginning of Haskell dependencies
|
|
| 2 | +mhu05/lib/Lib/Internal.o : mhu05/lib/Lib/Internal.hs
|
|
| 3 | +mhu05/lib/Lib.o : mhu05/lib/Lib.hs
|
|
| 4 | +mhu05/lib/Lib.o : mhu05/lib/Lib/Internal.hi
|
|
| 5 | +mhu05/app/Main.o : mhu05/app/Main.hs
|
|
| 6 | +mhu05/app/Main.o : mhu05/lib/Lib.hi
|
|
| 7 | +mhu05/test/Spec.o : mhu05/test/Spec.hs
|
|
| 8 | +mhu05/test/Spec.o : mhu05/lib/Lib/Internal.hi
|
|
| 9 | +mhu05/test/Spec.o : mhu05/lib/Lib.hi
|
|
| 10 | +# DO NOT DELETE: End of Haskell dependencies |