2 {-# LANGUAGE DeriveGeneric #-}
3 module Distribution
.Simple
.Build
.Macros
.Z
(render
, Z
(..), ZPackage
(..), ZTool
(..)) where
4 import Distribution
.ZinzaPrelude
6 = Z
{zPackages
:: ([ZPackage
]),
9 zComponentId
:: String,
10 zPackageVersion
:: Version
,
11 zNotNull
:: (String -> Bool),
12 zManglePkgName
:: (PackageName
-> String),
13 zMangleStr
:: (String -> String)}
16 = ZPackage
{zpkgName
:: PackageName
,
17 zpkgVersion
:: Version
,
23 = ZTool
{ztoolName
:: String,
24 ztoolVersion
:: Version
,
30 render z_root
= execWriter
$ do
31 tell
"/* DO NOT EDIT: This file is automatically generated by Cabal */\n"
33 forM_
(zPackages z_root
) $ \z_var0_pkg
-> do
35 tell
(prettyShow
(zpkgName z_var0_pkg
))
37 tell
(prettyShow
(zpkgVersion z_var0_pkg
))
39 tell
"#ifndef VERSION_"
40 tell
(zManglePkgName z_root
(zpkgName z_var0_pkg
))
42 tell
"#define VERSION_"
43 tell
(zManglePkgName z_root
(zpkgName z_var0_pkg
))
45 tell
(prettyShow
(zpkgVersion z_var0_pkg
))
47 tell
"#endif /* VERSION_"
48 tell
(zManglePkgName z_root
(zpkgName z_var0_pkg
))
50 tell
"#ifndef MIN_VERSION_"
51 tell
(zManglePkgName z_root
(zpkgName z_var0_pkg
))
53 tell
"#define MIN_VERSION_"
54 tell
(zManglePkgName z_root
(zpkgName z_var0_pkg
))
55 tell
"(major1,major2,minor) (\\\n"
57 tell
(zpkgX z_var0_pkg
)
60 tell
(zpkgX z_var0_pkg
)
61 tell
" && (major2) < "
62 tell
(zpkgY z_var0_pkg
)
65 tell
(zpkgX z_var0_pkg
)
66 tell
" && (major2) == "
67 tell
(zpkgY z_var0_pkg
)
68 tell
" && (minor) <= "
69 tell
(zpkgZ z_var0_pkg
)
71 tell
"#endif /* MIN_VERSION_"
72 tell
(zManglePkgName z_root
(zpkgName z_var0_pkg
))
75 forM_
(zTools z_root
) $ \z_var1_tool
-> do
77 tell
(ztoolName z_var1_tool
)
79 tell
(prettyShow
(ztoolVersion z_var1_tool
))
81 tell
"#ifndef TOOL_VERSION_"
82 tell
(zMangleStr z_root
(ztoolName z_var1_tool
))
84 tell
"#define TOOL_VERSION_"
85 tell
(zMangleStr z_root
(ztoolName z_var1_tool
))
87 tell
(prettyShow
(ztoolVersion z_var1_tool
))
89 tell
"#endif /* TOOL_VERSION_"
90 tell
(zMangleStr z_root
(ztoolName z_var1_tool
))
92 tell
"#ifndef MIN_TOOL_VERSION_"
93 tell
(zMangleStr z_root
(ztoolName z_var1_tool
))
95 tell
"#define MIN_TOOL_VERSION_"
96 tell
(zMangleStr z_root
(ztoolName z_var1_tool
))
97 tell
"(major1,major2,minor) (\\\n"
99 tell
(ztoolX z_var1_tool
)
102 tell
(ztoolX z_var1_tool
)
103 tell
" && (major2) < "
104 tell
(ztoolY z_var1_tool
)
107 tell
(ztoolX z_var1_tool
)
108 tell
" && (major2) == "
109 tell
(ztoolY z_var1_tool
)
110 tell
" && (minor) <= "
111 tell
(ztoolZ z_var1_tool
)
113 tell
"#endif /* MIN_TOOL_VERSION_"
114 tell
(zMangleStr z_root
(ztoolName z_var1_tool
))
117 if (zNotNull z_root
(zPackageKey z_root
))
119 tell
"#ifndef CURRENT_PACKAGE_KEY\n"
120 tell
"#define CURRENT_PACKAGE_KEY \""
121 tell
(zPackageKey z_root
)
123 tell
"#endif /* CURRENT_packageKey */\n"
127 if (zNotNull z_root
(zComponentId z_root
))
129 tell
"#ifndef CURRENT_COMPONENT_ID\n"
130 tell
"#define CURRENT_COMPONENT_ID \""
131 tell
(zComponentId z_root
)
133 tell
"#endif /* CURRENT_COMPONENT_ID */\n"
137 tell
"#ifndef CURRENT_PACKAGE_VERSION\n"
138 tell
"#define CURRENT_PACKAGE_VERSION \""
139 tell
(prettyShow
(zPackageVersion z_root
))
141 tell
"#endif /* CURRENT_PACKAGE_VERSION */\n"