Skip to content

Commit e5b508e

Browse files
authored
Merge pull request #6535 from phadej/issue-6533
Correct casing of CURRENT_PACKAGE_KEY
2 parents 202a178 + 1624e53 commit e5b508e

File tree

7 files changed

+80
-10
lines changed

7 files changed

+80
-10
lines changed

Cabal/Distribution/Simple/Build/Macros/Z.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ render z_root = execWriter $ do
7272
tell " */\n"
7373
tell "\n"
7474
forM_ (zTools z_root) $ \z_var1_tool -> do
75-
tell "/* package "
75+
tell "/* tool "
7676
tell (ztoolName z_var1_tool)
7777
tell "-"
7878
tell (prettyShow (ztoolVersion z_var1_tool))
@@ -85,7 +85,7 @@ render z_root = execWriter $ do
8585
tell " \""
8686
tell (prettyShow (ztoolVersion z_var1_tool))
8787
tell "\"\n"
88-
tell "#endif /* VERSION_"
88+
tell "#endif /* TOOL_VERSION_"
8989
tell (zMangleStr z_root (ztoolName z_var1_tool))
9090
tell " */\n"
9191
tell "#ifndef MIN_TOOL_VERSION_"
@@ -109,14 +109,14 @@ render z_root = execWriter $ do
109109
tell " && (minor) <= "
110110
tell (ztoolZ z_var1_tool)
111111
tell ")\n"
112-
tell "#endif /* MIN_VERSION_"
112+
tell "#endif /* MIN_TOOL_VERSION_"
113113
tell (zMangleStr z_root (ztoolName z_var1_tool))
114114
tell " */\n"
115115
tell "\n"
116116
if (zNotNull z_root (zPackageKey z_root))
117117
then do
118-
tell "#ifndef CURRENT_packageKey\n"
119-
tell "#define CURRENT_packageKey \""
118+
tell "#ifndef CURRENT_PACKAGE_KEY\n"
119+
tell "#define CURRENT_PACKAGE_KEY \""
120120
tell (zPackageKey z_root)
121121
tell "\"\n"
122122
tell "#endif /* CURRENT_packageKey */\n"

boot/cabal_macros.template.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
{% endfor %}
1515

1616
{% for tool in tools %}
17-
/* package {{ tool.name }}-{{ tool.version }} */
17+
/* tool {{ tool.name }}-{{ tool.version }} */
1818
#ifndef TOOL_VERSION_{{ mangleStr tool.name }}
1919
#define TOOL_VERSION_{{ mangleStr tool.name }} "{{ tool.version }}"
20-
#endif /* VERSION_{{ mangleStr tool.name }} */
20+
#endif /* TOOL_VERSION_{{ mangleStr tool.name }} */
2121
#ifndef MIN_TOOL_VERSION_{{ mangleStr tool.name }}
2222
#define MIN_TOOL_VERSION_{{ mangleStr tool.name }}(major1,major2,minor) (\
2323
(major1) < {{ tool.x }} || \
2424
(major1) == {{ tool.x }} && (major2) < {{ tool.y }} || \
2525
(major1) == {{ tool.x }} && (major2) == {{ tool.y }} && (minor) <= {{ tool.z }})
26-
#endif /* MIN_VERSION_{{ mangleStr tool.name }} */
26+
#endif /* MIN_TOOL_VERSION_{{ mangleStr tool.name }} */
2727
{% endfor %}
2828

2929
{% if notNull packageKey %}
30-
#ifndef CURRENT_packageKey
31-
#define CURRENT_packageKey "{{ packageKey }}"
30+
#ifndef CURRENT_PACKAGE_KEY
31+
#define CURRENT_PACKAGE_KEY "{{ packageKey }}"
3232
#endif /* CURRENT_packageKey */
3333
{% endif %}
3434
{% if notNull componentId %}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{-# LANGUAGE CPP #-}
2+
module Mdl where
3+
4+
answer :: Int
5+
answer = 42
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cabal-version: 2.1
2+
name: CabalMacros
3+
version: 0.1
4+
license: BSD-3-Clause
5+
author: Oleg Grenrus
6+
stability: stable
7+
category: PackageTests
8+
build-type: Simple
9+
10+
description:
11+
Check that the generated cabal_macros.h is intact.
12+
13+
Library
14+
exposed-modules: Mdl
15+
build-depends: base
16+
default-language: Haskell2010
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Setup configure
2+
Resolving dependencies...
3+
Configuring CabalMacros-0.1...
4+
# Setup build
5+
Preprocessing library for CabalMacros-0.1..
6+
Building library for CabalMacros-0.1..
7+
# cabal_macros.h
8+
#ifndef CURRENT_PACKAGE_KEY
9+
#define CURRENT_PACKAGE_KEY "CabalMacros-0.1"
10+
#endif /* CURRENT_packageKey */
11+
#ifndef CURRENT_COMPONENT_ID
12+
#define CURRENT_COMPONENT_ID "CabalMacros-0.1"
13+
#endif /* CURRENT_COMPONENT_ID */
14+
#ifndef CURRENT_PACKAGE_VERSION
15+
#define CURRENT_PACKAGE_VERSION "0.1"
16+
#endif /* CURRENT_PACKAGE_VERSION */
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Setup configure
2+
Configuring CabalMacros-0.1...
3+
# Setup build
4+
Preprocessing library for CabalMacros-0.1..
5+
Building library for CabalMacros-0.1..
6+
# cabal_macros.h
7+
#ifndef CURRENT_PACKAGE_KEY
8+
#define CURRENT_PACKAGE_KEY "CabalMacros-0.1"
9+
#endif /* CURRENT_packageKey */
10+
#ifndef CURRENT_COMPONENT_ID
11+
#define CURRENT_COMPONENT_ID "CabalMacros-0.1"
12+
#endif /* CURRENT_COMPONENT_ID */
13+
#ifndef CURRENT_PACKAGE_VERSION
14+
#define CURRENT_PACKAGE_VERSION "0.1"
15+
#endif /* CURRENT_PACKAGE_VERSION */
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Test.Cabal.Prelude
2+
import qualified Data.ByteString.Char8 as BS8
3+
4+
main = setupAndCabalTest $ do
5+
env <- getTestEnv
6+
let mode = testRecordMode env
7+
8+
setup_build []
9+
let autogenDir = testDistDir env </> "build" </> "autogen"
10+
11+
defaultRecordMode RecordAll $ recordHeader ["cabal_macros.h"]
12+
contents <- liftIO $ BS8.readFile $ autogenDir </> "cabal_macros.h"
13+
-- we are only interested in CURRENT_ lines
14+
-- others change a lot based on available tools in the environment
15+
let contents' = BS8.unlines
16+
$ filter (BS8.isInfixOf $ BS8.pack "CURRENT")
17+
$ BS8.lines contents
18+
liftIO $ BS8.appendFile (testActualFile env) contents'

0 commit comments

Comments
 (0)