]> git.donarmstrong.com Git - lilypond.git/blob - scripts/build/create-weblinks-itexi.py
Web build: add links for regtests.
[lilypond.git] / scripts / build / create-weblinks-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 # FIXME: if the depth depends on the type of build, figure it
14 #        out automatically.
15 ### just like depth in our GNUmakefiles
16 # these links are relative from /~graham/web/
17 depth = "../../"
18 # these links are relative from the v2.13 docs
19 #depth = "../../../../"
20
21
22
23 VERSION_STABLE = ""
24 VERSION_DEVEL = ""
25
26 try:
27     topDir = sys.argv[1]
28 except:
29     myDir = os.path.dirname(sys.argv[0])
30     # use two abspaths to work around some windows python bug
31     topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
32     topDir = os.path.abspath( topDir )
33
34
35 # TODO: this might be useful for other scripts; can we make it available?
36 manuals = map(lambda x: os.path.splitext(x)[0],
37               map(os.path.basename,
38                   glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
39 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
40 manuals.append('internals')
41
42
43 version_file_path = os.path.join(topDir, "VERSION")
44
45 version_contents = open(version_file_path).readlines()
46 major = 0
47 minor = 0
48 patch = 0
49 for line in version_contents:
50     if (line.startswith('MAJOR_VERSION')):
51         major = line[14:-1]
52     if (line.startswith('MINOR_VERSION')):
53         minor = line[14:-1]
54     if (line.startswith('PATCH_LEVEL')):
55         patch = line[12:-1]
56     if (line.startswith('VERSION_STABLE')):
57         VERSION_STABLE = line[15:-1]
58     if (line.startswith('VERSION_DEVEL')):
59         VERSION_DEVEL = line[14:-1]
60
61 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
62
63 def make_macro(name, string):
64     print "@macro", name
65     print string
66     print "@end macro"
67     print ""
68
69 def make_download(name, osA, osB, version, revision, text):
70     string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
71     string += osA + "lilypond-"
72     string += version + "-" + revision
73     string += "." + osB + ",\n"
74     string += text
75     string += ": LilyPond "
76     string += version + "-" + revision
77     string += "}"
78     make_macro(name, string)
79
80 def make_download_source(name, vstring, version):
81     string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
82     string += vstring + "/"
83     string += "lilypond-" + version + ".tar.gz"
84     string += ", "
85     string += "Source: lilypond-" + version + ".tar.gz"
86     string += "}"
87     make_macro(name, string)
88
89 def make_all_downloads(macroName, version):
90     make_download("download"+macroName+"LinuxNormal", "linux-x86/",
91         "linux-x86.sh",    version, "1", "Linux x86")
92     make_download("download"+macroName+"LinuxBig", "linux-64/",
93         "linux-64.sh", version, "1", "Linux 64")
94     make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
95         "linux-ppc.sh", version, "1", "Linux PPC")
96
97     make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
98         "freebsd-x86.sh", version, "1", "FreeBSD i386")
99     make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
100         "freebsd-64.sh", version, "1", "FreeBSD amd64")
101
102     make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
103         "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
104     make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
105         "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
106
107     make_download("download"+macroName+"Windows", "mingw/",
108         "mingw.exe", version, "1", "Windows")
109
110 def make_ver_link(macroname, url, linktext):
111     string = "@uref{"
112     string += url
113     string += ","
114     string += linktext
115     string += "}"
116     make_macro(macroname, string)
117
118 # TODO: this kind of thing should really be in a central place for
119 # lilypond python build scripts
120 def translateNameToUrl(manual, version):
121     ver_split = version.split('.')
122     ver_minor = ver_split[0] + '.' + ver_split[1]
123     url = depth + "doc/v" + ver_minor + "/Documentation/"
124
125     if (ver_minor == '2.13'):
126         return url+manual
127     if (ver_minor == '2.12'):
128         if (manual=='learning'):
129             return url+'user/lilypond-learning'
130         elif (manual=='internals'):
131             return url+'user/lilypond-internals'
132         elif (manual=='notation'):
133             return url+'user/lilypond'
134         elif (manual=='usage'):
135             return url+'user/lilypond-program'
136         elif (manual=='snippets'):
137             return url+'../input/lsr/lilypond-snippets'
138         elif (manual=='changes'):
139             return url+'topdocs/NEWS.html'
140         elif (manual=='music-glossary'):
141             return url+'user/music-glossary'
142         elif (manual=='essay'):
143             return url+'user/lilypond-learning/Background.html'
144         elif (manual=='extending'):
145             return url+'user/lilypond/Interfaces-for-programmers.html'
146         else:
147             return ''
148
149
150 def make_manual_links(name, version):
151     for m in manuals:
152         manual = m
153         if (m=='music-glossary'):
154             mshort = 'Glossary'
155         else:
156             mshort = m.capitalize()
157         url = translateNameToUrl(m, version)
158
159         if (url == ''):
160             # can't have a comma here due to texinfo
161             make_ver_link("manual"+name+mshort+'Pdf',
162                 "http://lilypond.org",
163                 mshort+" (did not exist in 2.12)")
164             make_ver_link("manual"+name+mshort+'Split',
165                 "http://lilypond.org",
166                 mshort+" (did not exist in 2.12)")
167             make_ver_link("manual"+name+mshort+'Big',
168                 "http://lilypond.org",
169                 mshort+" (did not exist in 2.12)")
170             make_ver_link("manual"+name+mshort+'SplitNoName',
171                 "http://lilypond.org",
172                 mshort+" (did not exist in 2.12)")
173             continue
174         make_ver_link("manual"+name+mshort+'Pdf',
175                   url + '.pdf',
176                   manual.capitalize() + '.pdf')
177         make_ver_link("manual"+name+mshort+'Split',
178                   url + '/index.html',
179                   manual.capitalize() + ' (split HTML)')
180         make_ver_link("manual"+name+mshort+'Big',
181                   url + '-big-page.html',
182                   manual.capitalize() + ' (big HTML)')
183         # this is stupid and I shouldn't have bothered trying
184         # to support the 2.12 docs and it will be deleted once
185         # 2.14 is out and the website won't be visible to users
186         # until 2.14 is out.  -gp
187         if (url.endswith('.html')):
188             newurl = url
189         else:
190             newurl = url + '/index.html'
191         make_ver_link("manual"+name+mshort+'SplitNoName',
192                   newurl,
193                   manual.capitalize())
194
195 def make_regtest_links(name, version):
196     ver_split = version.split('.')
197     ver_minor = ver_split[0] + '.' + ver_split[1]
198     url = depth + "doc/v" + ver_minor + "/input/regression/"
199
200     make_ver_link("regtest"+name, url+"collated-files.html",
201         "Regression tests for "+version)
202     make_ver_link("regtest"+name+"Pdf", url+"collated-files.pdf",
203         "pdf of "+version+" regtests")
204     make_ver_link("regtest"+name+"Xml", url+"musicxml/collated-files.html",
205         "MusicXML Regression tests for "+version)
206     make_ver_link("regtest"+name+"XmlPdf", url+"musicxml/collated-files.html",
207         "pdf of "+version+" musicxml regtests")
208
209 print "@c ************************ Download binaries ************"
210 make_all_downloads("Stable", VERSION_STABLE)
211 make_all_downloads("Devel", VERSION_DEVEL)
212
213 print "@c ************************ Download source ************"
214 # FIXME: icky hard-coding!  -gp
215 make_download_source("downloadStableSource", "v2.12", VERSION_STABLE)
216 make_download_source("downloadDevelSource", "v2.13", VERSION_DEVEL)
217
218 print "@c ************************ Manual links ************"
219 make_manual_links("Stable", VERSION_STABLE)
220 make_manual_links("Devel", VERSION_DEVEL)
221
222 print "@c ************************ Regtest links ************"
223 make_regtest_links("Stable", VERSION_STABLE)
224 make_regtest_links("Devel", VERSION_DEVEL)
225