Revision 1b2adaa6
b/.gitignore | ||
---|---|---|
77 | 77 |
|
78 | 78 |
# lib |
79 | 79 |
/lib/_autoconf.py |
80 |
/lib/_constants.py |
|
80 | 81 |
/lib/_vcsversion.py |
81 | 82 |
/lib/_generated_rpc.py |
82 | 83 |
/lib/opcodes.py |
... | ... | |
130 | 131 |
/src/hconfd |
131 | 132 |
/src/hluxid |
132 | 133 |
/src/hs2py |
134 |
/src/hs2py-constants |
|
133 | 135 |
/src/ganeti-confd |
134 | 136 |
/src/ganeti-luxid |
135 | 137 |
/src/ganeti-mond |
... | ... | |
137 | 139 |
|
138 | 140 |
# automatically-built Haskell files |
139 | 141 |
/src/Ganeti/Curl/Internal.hs |
142 |
/src/Ganeti/Hs2Py/ListConstants.hs |
|
140 | 143 |
/src/Ganeti/PyConstants.hs |
141 | 144 |
/src/Ganeti/Version.hs |
142 | 145 |
/test/hs/Test/Ganeti/TestImports.hs |
b/Makefile.am | ||
---|---|---|
240 | 240 |
src/ganeti-confd \ |
241 | 241 |
src/ganeti-luxid \ |
242 | 242 |
src/ganeti-mond \ |
243 |
src/hs2py-constants \ |
|
243 | 244 |
.hpc/*.mix src/*.tix test/hs/*.tix \ |
244 | 245 |
doc/hs-lint.html |
245 | 246 |
|
... | ... | |
266 | 267 |
|
267 | 268 |
built_python_base_sources = \ |
268 | 269 |
lib/_autoconf.py \ |
270 |
lib/_constants.py \ |
|
269 | 271 |
lib/_vcsversion.py \ |
270 | 272 |
lib/opcodes.py |
271 | 273 |
|
... | ... | |
549 | 551 |
test/hs/htest \ |
550 | 552 |
$(HS_COMPILE_PROGS) |
551 | 553 |
|
552 |
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS)) |
|
554 |
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS)) src/hs2py-constants.hs
|
|
553 | 555 |
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail |
554 | 556 |
|
555 | 557 |
HFLAGS = \ |
... | ... | |
634 | 636 |
src/Ganeti/Hs2Py/GenConstants.hs \ |
635 | 637 |
src/Ganeti/Hs2Py/GenOpCodes.hs \ |
636 | 638 |
src/Ganeti/Hs2Py/OpDoc.hs \ |
639 |
src/Ganeti/HsConstants.hs \ |
|
637 | 640 |
src/Ganeti/JQueue.hs \ |
638 | 641 |
src/Ganeti/JSON.hs \ |
639 | 642 |
src/Ganeti/Jobs.hs \ |
... | ... | |
722 | 725 |
|
723 | 726 |
HS_BUILT_SRCS = \ |
724 | 727 |
test/hs/Test/Ganeti/TestImports.hs \ |
728 |
src/Ganeti/Hs2Py/ListConstants.hs \ |
|
725 | 729 |
src/Ganeti/PyConstants.hs \ |
726 | 730 |
src/Ganeti/Curl/Internal.hs \ |
727 | 731 |
src/Ganeti/Version.hs |
728 | 732 |
HS_BUILT_SRCS_IN = \ |
729 | 733 |
$(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \ |
730 | 734 |
src/Ganeti/Curl/Internal.hsc \ |
735 |
lib/_constants.py.in \ |
|
731 | 736 |
lib/opcodes.py.in_after \ |
732 | 737 |
lib/opcodes.py.in_before |
733 | 738 |
|
... | ... | |
895 | 900 |
done |
896 | 901 |
endif |
897 | 902 |
|
903 |
# This target cannot be merged with the '$(HS_ALL_PROGS)' target |
|
904 |
# because 'hs2py-constants' cannot depend on 'Ganeti.Constants'. And |
|
905 |
# the reason for this is because 'hs2py-constants' needs to generate |
|
906 |
# Python code, and 'Ganeti.Constants' is generated by Python. |
|
907 |
src/hs2py-constants: src/hs2py-constants.hs src/Ganeti/BasicTypes.hs \ |
|
908 |
src/Ganeti/JSON.hs src/Ganeti/THH.hs \ |
|
909 |
src/Ganeti/Hs2Py/GenConstants.hs \ |
|
910 |
src/Ganeti/Hs2Py/ListConstants.hs \ |
|
911 |
src/Ganeti/HsConstants.hs \ |
|
912 |
src/Ganeti/PyValueInstances.hs \ |
|
913 |
| stamp-srclinks |
|
914 |
$(GHC) --make \ |
|
915 |
$(HFLAGS) \ |
|
916 |
-osuf $(notdir $@).o -hisuf $(notdir $@).hi \ |
|
917 |
$(HEXTRA) $(HEXTRA_INT) src/hs2py-constants.hs |
|
918 |
|
|
898 | 919 |
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTESTBUILT_SRCS) Makefile |
899 | 920 |
@if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \ |
900 | 921 |
echo "Error: cannot run unittests without the development" \ |
... | ... | |
1611 | 1632 |
VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \ |
1612 | 1633 |
sed -e "s/%ver%/$$VCSVER/" < $< > $@ |
1613 | 1634 |
|
1635 |
src/Ganeti/Hs2Py/ListConstants.hs: src/Ganeti/Hs2Py/ListConstants.hs.in \ |
|
1636 |
src/Ganeti/HsConstants.hs \ |
|
1637 |
| stamp-directories |
|
1638 |
@echo Generating $@ |
|
1639 |
@set -e; \ |
|
1640 |
## Extract constant names from 'HsConstants.hs' by extracting the left |
|
1641 |
## side of all lines containing an equal sign (i.e., '=') and |
|
1642 |
## prepending the apostrophe sign (i.e., "'"). |
|
1643 |
## |
|
1644 |
## For example, the constant |
|
1645 |
## adminstDown = ... |
|
1646 |
## becomes |
|
1647 |
## 'adminstDown |
|
1648 |
NAMES=$$(sed -n -e "/=/ s/\(.*\) =.*/ '\1:/g p" \ |
|
1649 |
$(abs_top_srcdir)/src/Ganeti/HsConstants.hs); \ |
|
1650 |
m4 -DPY_CONSTANT_NAMES="$$NAMES" $(abs_top_srcdir)/$< > $@ |
|
1651 |
|
|
1614 | 1652 |
src/Ganeti/PyConstants.hs: src/Ganeti/PyConstants.hs.in \ |
1615 | 1653 |
lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \ |
1616 | 1654 |
lib/jstore.py $(RUN_IN_TEMPDIR) \ |
... | ... | |
1716 | 1754 |
echo "}"; \ |
1717 | 1755 |
} > $@ |
1718 | 1756 |
|
1757 |
lib/_constants.py: Makefile lib/_constants.py.in src/hs2py-constants \ |
|
1758 |
| stamp-directories |
|
1759 |
cat $(abs_top_srcdir)/lib/_constants.py.in > $@ |
|
1760 |
src/hs2py-constants >> $@ |
|
1761 |
|
|
1762 |
lib/constants.py: lib/_constants.py |
|
1763 |
|
|
1719 | 1764 |
lib/_vcsversion.py: Makefile vcs-version | stamp-directories |
1720 | 1765 |
set -e; \ |
1721 | 1766 |
VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \ |
b/lib/_constants.py.in | ||
---|---|---|
1 |
# This file is automatically generated, do not edit! |
|
2 |
# |
|
3 |
|
|
4 |
"""Automatically generated constants for Python |
|
5 |
|
|
6 |
This file is autogenerated by the build process. |
|
7 |
For any changes you need to re-run ./configure (and |
|
8 |
not edit by hand). |
|
9 |
|
|
10 |
""" |
|
11 |
|
|
12 |
# pylint: disable=C0301,C0324 |
|
13 |
# because this is autogenerated, we do not want |
|
14 |
# style warnings |
|
15 |
|
b/src/Ganeti/Hs2Py/ListConstants.hs.in | ||
---|---|---|
1 |
{-| Contains the list of the Haskell to Python constants. |
|
2 |
|
|
3 |
-} |
|
4 |
|
|
5 |
{- |
|
6 |
|
|
7 |
Copyright (C) 2013 Google Inc. |
|
8 |
|
|
9 |
This program is free software; you can redistribute it and/or modify |
|
10 |
it under the terms of the GNU General Public License as published by |
|
11 |
the Free Software Foundation; either version 2 of the License, or |
|
12 |
(at your option) any later version. |
|
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, but |
|
15 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 |
General Public License for more details. |
|
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
|
20 |
along with this program; if not, write to the Free Software |
|
21 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
22 |
02110-1301, USA. |
|
23 |
|
|
24 |
-} |
|
25 |
{-# LANGUAGE TemplateHaskell #-} |
|
26 |
module Ganeti.Hs2Py.ListConstants where |
|
27 |
|
|
28 |
import Ganeti.Hs2Py.GenConstants |
|
29 |
import Ganeti.HsConstants |
|
30 |
import Ganeti.PyValueInstances () |
|
31 |
|
|
32 |
$(genPyConstants "pyConstants" |
|
33 |
( |
|
34 |
PY_CONSTANT_NAMES[])) |
|
35 |
|
|
36 |
putConstants :: IO () |
|
37 |
putConstants = |
|
38 |
sequence_ [ putStrLn (k ++ " = " ++ v) | (k, v) <- pyConstants ] |
b/src/Ganeti/HsConstants.hs | ||
---|---|---|
1 |
{-| HsConstants contains the Haskell constants |
|
2 |
|
|
3 |
This is a transitional module complementary to 'Ganeti.Constants'. It |
|
4 |
is intended to contain the Haskell constants that are meant to be |
|
5 |
generated in Python. |
|
6 |
|
|
7 |
-} |
|
8 |
|
|
9 |
{- |
|
10 |
|
|
11 |
Copyright (C) 2013 Google Inc. |
|
12 |
|
|
13 |
This program is free software; you can redistribute it and/or modify |
|
14 |
it under the terms of the GNU General Public License as published by |
|
15 |
the Free Software Foundation; either version 2 of the License, or |
|
16 |
(at your option) any later version. |
|
17 |
|
|
18 |
This program is distributed in the hope that it will be useful, but |
|
19 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
21 |
General Public License for more details. |
|
22 |
|
|
23 |
You should have received a copy of the GNU General Public License |
|
24 |
along with this program; if not, write to the Free Software |
|
25 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
26 |
02110-1301, USA. |
|
27 |
|
|
28 |
-} |
|
29 |
module Ganeti.HsConstants where |
|
30 |
|
|
31 |
-- | Admin states |
|
32 |
adminstDown :: String |
|
33 |
adminstDown = "down" |
|
34 |
|
|
35 |
-- | Admin states |
|
36 |
adminstOffline :: String |
|
37 |
adminstOffline = "offline" |
|
38 |
|
|
39 |
-- | Admin states |
|
40 |
adminstUp :: String |
|
41 |
adminstUp = "up" |
b/src/hs2py-constants.hs | ||
---|---|---|
1 |
{-| hs2py-constants |
|
2 |
|
|
3 |
This program outputs the all the converted Haskell to Python |
|
4 |
constants. |
|
5 |
|
|
6 |
-} |
|
7 |
|
|
8 |
{- |
|
9 |
|
|
10 |
Copyright (C) 2013 Google Inc. |
|
11 |
|
|
12 |
This program is free software; you can redistribute it and/or modify |
|
13 |
it under the terms of the GNU General Public License as published by |
|
14 |
the Free Software Foundation; either version 2 of the License, or |
|
15 |
(at your option) any later version. |
|
16 |
|
|
17 |
This program is distributed in the hope that it will be useful, but |
|
18 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
20 |
General Public License for more details. |
|
21 |
|
|
22 |
You should have received a copy of the GNU General Public License |
|
23 |
along with this program; if not, write to the Free Software |
|
24 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
25 |
02110-1301, USA. |
|
26 |
|
|
27 |
-} |
|
28 |
import Ganeti.Hs2Py.ListConstants |
|
29 |
|
|
30 |
main :: IO () |
|
31 |
main = putConstants |
Also available in: Unified diff