Revision 88a0e24b

b/Makefile.am
269 269
	src/ganeti-confd \
270 270
	src/ganeti-luxid \
271 271
	src/ganeti-mond \
272
	src/hs2py-constants \
273 272
	.hpc/*.mix src/*.tix test/hs/*.tix *.tix \
274 273
	doc/hs-lint.html
275 274

  
......
600 599

  
601 600
HS_ALL_PROGS = $(HS_DEFAULT_PROGS) $(HS_MYEXECLIB_PROGS)
602 601

  
603
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_DEFAULT_PROGS)) \
604
	       src/mon-collector.hs \
605
	       src/hs2py-constants.hs
602
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_DEFAULT_PROGS)) src/mon-collector.hs
606 603
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
607 604

  
608 605
HFLAGS = \
......
969 966
	done
970 967
endif
971 968

  
972
# This target cannot be merged with the '$(HS_ALL_PROGS)' target
973
# because 'hs2py-constants' cannot depend on 'Ganeti.Constants'.  And
974
# the reason for this is because 'hs2py-constants' needs to generate
975
# Python code, and 'Ganeti.Constants' is generated by Python.
976
src/hs2py-constants: src/hs2py-constants.hs src/AutoConf.hs \
977
		     src/Ganeti/BasicTypes.hs \
978
		     src/Ganeti/Constants.hs \
979
		     src/Ganeti/ConstantUtils.hs \
980
		     src/Ganeti/JSON.hs src/Ganeti/THH.hs \
981
		     src/Ganeti/Hs2Py/GenConstants.hs \
982
		     src/Ganeti/Hs2Py/ListConstants.hs \
983
		     src/Ganeti/PyValueInstances.hs \
984
		   | stamp-srclinks
985
	$(GHC) --make \
986
	  $(HFLAGS) \
987
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
988
	  $(HEXTRA) $(HEXTRA_INT) src/hs2py-constants.hs
989

  
990 969
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTESTBUILT_SRCS) Makefile
991 970
	@if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \
992 971
	  echo "Error: cannot run unittests without the development" \
......
1769 1748
	  done ; \
1770 1749
	} > $@
1771 1750

  
1772
lib/_constants.py: Makefile lib/_constants.py.in src/hs2py-constants \
1773
		 | stamp-directories
1751
lib/_constants.py: Makefile src/hs2py lib/_constants.py.in | stamp-directories
1774 1752
	cat $(abs_top_srcdir)/lib/_constants.py.in > $@
1775
	src/hs2py-constants >> $@
1753
	src/hs2py --constants >> $@
1776 1754

  
1777 1755
lib/constants.py: lib/_constants.py
1778 1756

  
......
1867 1845
	  echo "VCS_VERSION = '$$VCSVER'"; \
1868 1846
	} > $@
1869 1847

  
1870
lib/opcodes.py: Makefile src/hs2py src/Ganeti/Constants.hs \
1871
		lib/opcodes.py.in_before lib/opcodes.py.in_after \
1872
		| stamp-directories
1848
lib/opcodes.py: Makefile src/hs2py lib/opcodes.py.in_before \
1849
		lib/opcodes.py.in_after | stamp-directories
1873 1850
	cat $(abs_top_srcdir)/lib/opcodes.py.in_before > $@
1874 1851
	src/hs2py --opcodes >> $@
1875 1852
	cat $(abs_top_srcdir)/lib/opcodes.py.in_after >> $@
/dev/null
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
b/src/hs2py.hs
24 24
-}
25 25

  
26 26
import Ganeti.Hs2Py.GenOpCodes
27
import Ganeti.Hs2Py.ListConstants
27 28

  
28 29
import System.Environment (getArgs)
29 30
import System.Exit (exitFailure)
......
34 35
  args <- getArgs
35 36
  case args of
36 37
    ["--opcodes"] -> putStrLn showPyClasses
38
    ["--constants"] -> putConstants
37 39
    _ -> do
38
      hPutStrLn stderr "Usage: hs2py --opcodes"
40
      hPutStrLn stderr "Usage: hs2py --opcodes | --constants"
39 41
      exitFailure

Also available in: Unified diff