Update generated Cabal/src/Distribution/Simple/Build/Macros/Z.hs
[cabal.git] / Cabal / src / Distribution / Simple / Build / Macros / Z.hs
blobb43407f1b2ab7c8c85815d0a563fb508b1a7730a
1 {- FOURMOLU_DISABLE -}
2 {-# LANGUAGE DeriveGeneric #-}
3 module Distribution.Simple.Build.Macros.Z (render, Z(..), ZPackage (..), ZTool (..)) where
4 import Distribution.ZinzaPrelude
5 data Z
6 = Z {zPackages :: [ZPackage],
7 zTools :: [ZTool],
8 zPackageKey :: String,
9 zComponentId :: String,
10 zPackageVersion :: Version,
11 zNotNull :: (String -> Bool),
12 zManglePkgName :: (PackageName -> String),
13 zMangleStr :: (String -> String)}
14 deriving Generic
15 data ZPackage
16 = ZPackage {zpkgName :: PackageName,
17 zpkgVersion :: Version,
18 zpkgX :: String,
19 zpkgY :: String,
20 zpkgZ :: String}
21 deriving Generic
22 data ZTool
23 = ZTool {ztoolName :: String,
24 ztoolVersion :: Version,
25 ztoolX :: String,
26 ztoolY :: String,
27 ztoolZ :: String}
28 deriving Generic
29 render :: Z -> String
30 render z_root = execWriter $ do
31 tell "/* DO NOT EDIT: This file is automatically generated by Cabal */\n"
32 tell "\n"
33 forM_ (zPackages z_root) $ \z_var0_pkg -> do
34 tell "/* package "
35 tell (prettyShow (zpkgName z_var0_pkg))
36 tell "-"
37 tell (prettyShow (zpkgVersion z_var0_pkg))
38 tell " */\n"
39 tell "#ifndef VERSION_"
40 tell (zManglePkgName z_root (zpkgName z_var0_pkg))
41 tell "\n"
42 tell "#define VERSION_"
43 tell (zManglePkgName z_root (zpkgName z_var0_pkg))
44 tell " \""
45 tell (prettyShow (zpkgVersion z_var0_pkg))
46 tell "\"\n"
47 tell "#endif /* VERSION_"
48 tell (zManglePkgName z_root (zpkgName z_var0_pkg))
49 tell " */\n"
50 tell "#ifndef MIN_VERSION_"
51 tell (zManglePkgName z_root (zpkgName z_var0_pkg))
52 tell "\n"
53 tell "#define MIN_VERSION_"
54 tell (zManglePkgName z_root (zpkgName z_var0_pkg))
55 tell "(major1,major2,minor) (\\\n"
56 tell " (major1) < "
57 tell (zpkgX z_var0_pkg)
58 tell " || \\\n"
59 tell " (major1) == "
60 tell (zpkgX z_var0_pkg)
61 tell " && (major2) < "
62 tell (zpkgY z_var0_pkg)
63 tell " || \\\n"
64 tell " (major1) == "
65 tell (zpkgX z_var0_pkg)
66 tell " && (major2) == "
67 tell (zpkgY z_var0_pkg)
68 tell " && (minor) <= "
69 tell (zpkgZ z_var0_pkg)
70 tell ")\n"
71 tell "#endif /* MIN_VERSION_"
72 tell (zManglePkgName z_root (zpkgName z_var0_pkg))
73 tell " */\n"
74 tell "\n"
75 forM_ (zTools z_root) $ \z_var1_tool -> do
76 tell "/* tool "
77 tell (ztoolName z_var1_tool)
78 tell "-"
79 tell (prettyShow (ztoolVersion z_var1_tool))
80 tell " */\n"
81 tell "#ifndef TOOL_VERSION_"
82 tell (zMangleStr z_root (ztoolName z_var1_tool))
83 tell "\n"
84 tell "#define TOOL_VERSION_"
85 tell (zMangleStr z_root (ztoolName z_var1_tool))
86 tell " \""
87 tell (prettyShow (ztoolVersion z_var1_tool))
88 tell "\"\n"
89 tell "#endif /* TOOL_VERSION_"
90 tell (zMangleStr z_root (ztoolName z_var1_tool))
91 tell " */\n"
92 tell "#ifndef MIN_TOOL_VERSION_"
93 tell (zMangleStr z_root (ztoolName z_var1_tool))
94 tell "\n"
95 tell "#define MIN_TOOL_VERSION_"
96 tell (zMangleStr z_root (ztoolName z_var1_tool))
97 tell "(major1,major2,minor) (\\\n"
98 tell " (major1) < "
99 tell (ztoolX z_var1_tool)
100 tell " || \\\n"
101 tell " (major1) == "
102 tell (ztoolX z_var1_tool)
103 tell " && (major2) < "
104 tell (ztoolY z_var1_tool)
105 tell " || \\\n"
106 tell " (major1) == "
107 tell (ztoolX z_var1_tool)
108 tell " && (major2) == "
109 tell (ztoolY z_var1_tool)
110 tell " && (minor) <= "
111 tell (ztoolZ z_var1_tool)
112 tell ")\n"
113 tell "#endif /* MIN_TOOL_VERSION_"
114 tell (zMangleStr z_root (ztoolName z_var1_tool))
115 tell " */\n"
116 tell "\n"
117 if (zNotNull z_root (zPackageKey z_root))
118 then do
119 tell "#ifndef CURRENT_PACKAGE_KEY\n"
120 tell "#define CURRENT_PACKAGE_KEY \""
121 tell (zPackageKey z_root)
122 tell "\"\n"
123 tell "#endif /* CURRENT_packageKey */\n"
124 return ()
125 else do
126 return ()
127 if (zNotNull z_root (zComponentId z_root))
128 then do
129 tell "#ifndef CURRENT_COMPONENT_ID\n"
130 tell "#define CURRENT_COMPONENT_ID \""
131 tell (zComponentId z_root)
132 tell "\"\n"
133 tell "#endif /* CURRENT_COMPONENT_ID */\n"
134 return ()
135 else do
136 return ()
137 tell "#ifndef CURRENT_PACKAGE_VERSION\n"
138 tell "#define CURRENT_PACKAGE_VERSION \""
139 tell (prettyShow (zPackageVersion z_root))
140 tell "\"\n"
141 tell "#endif /* CURRENT_PACKAGE_VERSION */\n"