mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-20 16:59:06 +00:00
fa5a5bf865
Both the data used to generate the archive and the archive itself were moved to dists/ instead of being in backends/. The script was also improved to optionally take a path as a command line argument to indicate where the wwwroot data are instead of assuming they are in the working directory. Finally a 'wwwroot' make target was also added to invoke the python script and generate the archive. with the expected path to
49 lines
1.2 KiB
Python
Executable File
49 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# encoding: utf-8
|
|
import sys
|
|
import re
|
|
import os
|
|
import zipfile
|
|
import argparse
|
|
|
|
ARCHIVE_FILE_EXTENSIONS = ('.html', '.css', '.js', '.ico', '.png')
|
|
|
|
def buildArchive(archiveName):
|
|
if not os.path.isdir(archiveName):
|
|
print ("Invalid archive name: " + archiveName)
|
|
return
|
|
|
|
zf = zipfile.ZipFile(archiveName + ".zip", 'w')
|
|
|
|
print ("Building '" + archiveName + "' archive:")
|
|
os.chdir(archiveName)
|
|
|
|
directories = ['.', './icons']
|
|
for d in directories:
|
|
filenames = os.listdir(d)
|
|
filenames.sort()
|
|
for filename in filenames:
|
|
if os.path.isfile(d + '/' + filename) and filename.endswith(ARCHIVE_FILE_EXTENSIONS):
|
|
zf.write(d + '/' + filename, d + '/' + filename)
|
|
print (" Adding file: " + d + '/' + filename)
|
|
|
|
os.chdir('../')
|
|
|
|
zf.close()
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description='Generates wwwroot archive')
|
|
parser.add_argument('path', nargs='?', help='path where the wwwroot source data can be found')
|
|
args = parser.parse_args()
|
|
if args.path != None:
|
|
if not os.path.isdir(args.path):
|
|
print ("Directory '" + args.path + "' does not exist!")
|
|
return
|
|
else:
|
|
os.chdir(args.path)
|
|
|
|
buildArchive("wwwroot")
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|