]> git.donarmstrong.com Git - lilypond.git/blob - scripts/build/create-version-itexi.py
Build: all @macro version -> create-version-itexi.py
[lilypond.git] / scripts / build / create-version-itexi.py
1 #!@PYTHON@
2 # create-version-itexi.py
3
4 """ when being called on lilypond.org, pass it the location of the
5 top source dir on the command-line. """
6
7 import sys
8 import os
9 import glob
10
11
12
13 ### just like depth in our GNUmakefiles
14 # these links are relative from /~graham/web/
15 depth = "../../"
16 # these links are relative from the v2.13 docs
17 #depth = "../../../../"
18
19 # FIXME: remove the user/lilypond-  when 2.14 becomes stable
20 WEB_DOCLINK_STABLE = depth + "doc/v2.12/Documentation/user/lilypond-"
21 WEB_DOCLINK_DEVEL  = depth + "doc/v2.13/Documentation/"
22
23
24
25 VERSION_STABLE = ""
26 VERSION_DEVEL = ""
27
28 try:
29         topDir = sys.argv[1]
30 except:
31         myDir = os.path.dirname(sys.argv[0])
32         # use two abspaths to work around some windows python bug
33         topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
34         topDir = os.path.abspath( topDir )
35
36
37 # TODO: this might be useful for other scripts; can we make it available?
38 manuals = map(lambda x: os.path.splitext(x)[0],
39               map(os.path.basename,
40                   glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
41 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
42 manuals.append('internals')
43
44
45 version_file_path = os.path.join(topDir, "VERSION")
46
47 version_contents = open(version_file_path).readlines()
48 major = 0
49 minor = 0
50 patch = 0
51 for line in version_contents:
52         if (line[0:13] == 'MAJOR_VERSION'):
53                 major = line[14:-1]
54         if (line[0:13] == 'MINOR_VERSION'):
55                 minor = line[14:-1]
56         if (line[0:11] == 'PATCH_LEVEL'):
57                 patch = line[12:-1]
58         if (line[0:14] == 'VERSION_STABLE'):
59                 VERSION_STABLE = line[15:-1]
60         if (line[0:13] == 'VERSION_DEVEL'):
61                 VERSION_DEVEL = line[14:-1]
62
63 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
64
65 def make_macro(name, string):
66         print "@macro", name
67         print string
68         print "@end macro"
69         print ""
70
71 def make_download(name, osA, osB, version, revision, text):
72         string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
73         string += osA + "lilypond-"
74         string += version + "-" + revision
75         string += "." + osB + ",\n"
76         string += text
77         string += ": LilyPond "
78         string += version + "-" + revision
79         string += "}"
80         make_macro(name, string)
81
82 def make_download_source(name, vstring, version):
83         string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
84         string += vstring + "/"
85         string += "lilypond-" + version + ".tar.gz"
86         string += ", "
87         string += "lilypond-" + version + ".tar.gz"
88         string += "}"
89         make_macro(name, string)
90
91 def make_all_downloads(macroName, version):
92         make_download("download"+macroName+"LinuxNormal", "linux-x86/",
93                 "linux-x86.sh", version, "1", "Linux x86")
94         make_download("download"+macroName+"LinuxBig", "linux-64/",
95                 "linux-64.sh", version, "1", "Linux 64")
96         make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
97                 "linux-ppc.sh", version, "1", "Linux PPC")
98         
99         make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
100                 "freebsd-x86.sh", version, "1", "FreeBSD i386")
101         make_download("download"+macroName+"FreeBSDBig", "freebsd-x86/",
102                 "freebsd-64.sh", version, "1", "FreeBSD amd64")
103         
104         make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
105                 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
106         make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
107                 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
108
109         make_download("download"+macroName+"Windows", "mingw/",
110                 "mingw.exe", version, "1", "Windows")
111
112 def make_ver_link(macroname, version, url, linktext):
113         string = "@uref{"
114         # TODO: generalize this
115         if (version[:4] == '2.13'):
116                 string += WEB_DOCLINK_DEVEL
117         if (version[:4] == '2.12'):
118                 string += WEB_DOCLINK_STABLE
119         string += url
120         string += ","
121         string += linktext
122         string += "}"
123         make_macro(macroname, string)
124
125 def make_manual_links(name, version):
126         for m in manuals:
127                 # FIXME: this is disgusting
128                 manual = m
129                 #mshort = 'glossary' if m=='music-glossary' else m
130                 # grr, GUB only has python 2.4.5.  :(
131                 if (m=='music-glossary'):
132                         mshort = 'glossary'
133                 else:
134                         mshort = m
135                 make_ver_link("manual"+name+mshort.capitalize()+'Pdf',
136                           version,
137                           manual + '.pdf',
138                           manual.capitalize() + '.pdf')
139                 make_ver_link("manual"+name+mshort.capitalize()+'Split',
140                           version,
141                           manual+'/index.html',
142                           manual.capitalize() + ' (split HTML)')
143                 make_ver_link("manual"+name+mshort.capitalize()+'Big',
144                           version,
145                           manual+'-big-page.html',
146                           manual.capitalize() + ' (big HTML)')
147
148
149 print "@c ************************ Version numbers ************"
150 make_macro("version", VERSION)
151 make_macro("versionStable", VERSION_STABLE)
152 make_macro("versionDevel", VERSION_DEVEL)
153
154 print "@c ************************ Download binaries ************"
155 make_all_downloads("Stable", VERSION_STABLE)
156 make_all_downloads("Devel", VERSION_DEVEL)
157
158 print "@c ************************ Download source ************"
159 # FIXME: icky hard-coding!  -gp
160 make_download_source("downloadStableSource", "v2.12", VERSION_STABLE)
161 make_download_source("downloadDevelSource", "v2.13", VERSION_DEVEL)
162
163 print "@c ************************ Manual links ************"
164 make_manual_links("Stable", VERSION_STABLE)
165 make_manual_links("Devel", VERSION_DEVEL)
166
167
168