]>
git.saurik.com Git - wxWidgets.git/blob - build/tools/create-archive.py
17 scriptDir
= os
.path
.join(sys
.path
[0])
18 rootDir
= os
.path
.abspath(os
.path
.join(scriptDir
, "..", ".."))
19 contribDir
= os
.path
.join("contrib", "src")
21 dirsToCopy
= ["art", "build", "demos", "distrib/mac", "docs", "include", "interface", "lib",
22 "locale", "samples", "src", "tests", "utils"]
24 dirsToIgnore
= [".svn", "CVS"]
25 excludeExtensions
= [".rej", ".orig", ".mine", ".tmp"]
28 "compression" : ("gzip", "Compression to use. Values are: gzip, bzip, zip, all (default: gzip)"),
29 "docs" : ("html", "Doc formats to build. Comma separated. Values are: none, html (default: html)"),
30 "name" : ("wxWidgets", "Name given to the tarball created (default: wxWidgets)"),
31 "postfix" : ("", "String appended to the version to indicate a special release (default: none)"),
32 "wxpython" : (False, "Produce wxPython source tarball (name defaults to wxPython-src)")
35 mswProjectFiles
= [ ".vcproj", ".sln", ".dsp", ".dsw", ".vc", ".bat"]
36 nativeLineEndingFiles
= [".cpp", ".h", ".c", ".txt"]
42 usage
="""usage: %prog [options] <output directory>\n
43 Create a wxWidgets archive and store it in <output directory>.
44 The output directory must be an absolute, existing path.
45 Type %prog --help for options.
48 parser
= optparse
.OptionParser(usage
, version
="%prog 1.0")
50 for opt
in option_dict
:
51 default
= option_dict
[opt
][0]
54 if type(default
) == types
.BooleanType
:
56 parser
.add_option("--" + opt
, default
=default
, action
=action
, dest
=opt
, help=option_dict
[opt
][1])
58 options
, arguments
= parser
.parse_args()
60 if len(arguments
) < 1 or not os
.path
.exists(arguments
[0]) or not os
.path
.isabs(arguments
[0]):
64 destDir
= arguments
[0]
65 if not os
.path
.exists(destDir
):
69 VERSION_FILE
= os
.path
.join(rootDir
, 'include/wx/version.h')
74 def makeDOSLineEndings(dir, extensions
):
76 for root
, subFolders
, files
in os
.walk(dir):
78 if os
.path
.splitext(file)[1] in extensions
:
79 os
.system("unix2dos %s" % os
.path
.join(root
, file))
81 def getVersion(includeSubrelease
=False):
82 """Returns wxWidgets version as a tuple: (major,minor,release)."""
90 f
= open(VERSION_FILE
, 'rt')
93 major
= minor
= release
= None
95 if not l
.startswith('#define'): continue
96 splitline
= l
.strip().split()
97 if splitline
[0] != '#define': continue
98 if len(splitline
) < 3: continue
101 if value
== None: continue
102 if name
== 'wxMAJOR_VERSION': major
= int(value
)
103 if name
== 'wxMINOR_VERSION': minor
= int(value
)
104 if name
== 'wxRELEASE_NUMBER': release
= int(value
)
105 if name
== 'wxSUBRELEASE_NUMBER': subrelease
= int(value
)
106 if major
!= None and minor
!= None and release
!= None:
107 if not includeSubrelease
or subrelease
!= None:
110 if includeSubrelease
:
111 wxVersion
= (major
, minor
, release
, subrelease
)
113 wxVersion
= (major
, minor
, release
)
116 def allFilesRecursive(dir):
118 for root
, subFolders
, files
in os
.walk(dir):
120 for ignoreDir
in dirsToIgnore
:
121 if ignoreDir
in root
:
126 path
= os
.path
.join(root
,file)
127 for exclude
in excludeExtensions
:
128 if not os
.path
.splitext(file)[1] in excludeExtensions
:
129 fileList
.append(os
.path
.join(root
,file))
135 str_version
= "" ##"%d.%d.%d" % getVersion()
136 archive_name
= options
.name
139 dirsToCopy
.append("wxPython")
140 archive_name
= "wxPython-src"
141 ## str_version = "%d.%d.%d.%d" % getVersion(includeSubrelease=True)
142 options
.docs
= "none"
144 if options
.postfix
!= "":
145 str_version
+= "-" + options
.postfix
147 full_name
= archive_name
## + "-" + str_version
149 copyDir
= tempfile
.mkdtemp()
150 wxCopyDir
= os
.path
.join(copyDir
, full_name
)
152 os
.makedirs(wxCopyDir
)
156 rootFiles
= glob
.glob("*")
157 for afile
in rootFiles
:
158 if os
.path
.isfile(os
.path
.abspath(afile
)):
159 fileList
.append(afile
)
161 for dir in dirsToCopy
:
162 print "Determining files to copy from %s..." % dir
163 fileList
.extend(allFilesRecursive(dir))
165 print "Copying files to the temporary folder %s..." % copyDir
166 for afile
in fileList
:
167 destFile
= os
.path
.join(wxCopyDir
, afile
)
168 dirName
= os
.path
.dirname(destFile
)
169 if not os
.path
.exists(dirName
):
171 shutil
.copy(os
.path
.join(rootDir
, afile
), destFile
)
173 # copy include/wx/msw/setup0.h -> include/wx/msw/setup.h
174 mswSetup0
= os
.path
.join(wxCopyDir
, "include","wx","msw","setup0.h")
175 shutil
.copy(mswSetup0
, mswSetup0
.replace("setup0.h", "setup.h")),
177 # compile gettext catalogs
178 print "Compiling gettext catalogs..."
179 os
.system("make -C %s/locale allmo" % wxCopyDir
)
181 all
= options
.compression
== "all"
183 # make sure they have the DOS line endings everywhere
184 ##print "Setting MSW Project files to use DOS line endings..."
185 ##makeDOSLineEndings(wxCopyDir, mswProjectFiles)
187 if all
or options
.compression
== "gzip":
188 print "Creating gzip archive..."
190 os
.system("tar -czvf %s/%s.tar.gz %s" % (destDir
, full_name
, "*"))
193 if all
or options
.compression
== "bzip":
194 print "Creating bzip archive..."
196 os
.system("tar -cjvf %s/%s.tar.bz2 %s" % (destDir
, full_name
, "*"))
199 if all
or options
.compression
== "zip":
201 print "Setting DOS line endings on source and text files..."
202 ## makeDOSLineEndings(copyDir, nativeLineEndingFiles)
203 print "Creating zip archive..."
204 os
.system("zip -9 -r %s/%s.zip %s" % (destDir
, full_name
, "*"))
207 shutil
.rmtree(copyDir
)
210 # build any docs packages:
211 doc_formats
= string
.split(options
.docs
, ",")
212 doxy_dir
= "docs/doxygen"
213 output_dir
= os
.path
.join(rootDir
,"docs/doxygen/out")
214 if not os
.path
.exists(output_dir
):
215 os
.makedirs(output_dir
)
217 for format
in doc_formats
:
218 if not format
== "none":
220 if platform
.system() == "Windows":
221 print "Windows platform"
222 os
.system("regen.bat %s" % format
)
224 os
.system("regen.sh %s" % format
)
230 docs_full_name
= "%s-%s" % (full_name
, format
.upper())
233 src
= "wx.%s" % format
234 docs_full_name
= "%s.%s" % (full_name
, format
.upper())
235 files_to_zip
= docs_full_name
237 os
.rename(src
, docs_full_name
)
238 os
.system("zip -9 -r %s/%s.zip %s" % (destDir
, docs_full_name
, files_to_zip
))
242 if os
.path
.exists(output_dir
):
243 shutil
.rmtree(output_dir
)