Bug 865244 - Implement AudioContext.destination.maxChannelCount. r=ehsan
[gecko.git] / config / createprecomplete.py
blob7fe81093bc859862b8ba6625b9c0e9a64b458362
1 # Any copyright is dedicated to the Public Domain.
2 # http://creativecommons.org/publicdomain/zero/1.0/
4 # Creates the precomplete file containing the remove and rmdir application
5 # update instructions which is used to remove files and directories that are no
6 # longer present in a complete update. The current working directory is used for
7 # the location to enumerate and to create the precomplete file.
9 import sys
10 import os
12 def get_build_entries(root_path):
13 """ Iterates through the root_path, creating a list for each file and
14 directory. Excludes any path starting with extensions or distribution
15 and paths ending with channel-prefs.js.
16 """
17 rel_file_path_set = set()
18 rel_dir_path_set = set()
19 for root, dirs, files in os.walk(root_path):
20 for file_name in files:
21 parent_dir_rel_path = root[len(root_path)+1:]
22 rel_path_file = os.path.join(parent_dir_rel_path, file_name)
23 rel_path_file = rel_path_file.replace("\\", "/")
24 if not (rel_path_file.startswith("distribution/") or
25 rel_path_file.startswith("extensions/") or
26 rel_path_file.endswith("channel-prefs.js")):
27 rel_file_path_set.add(rel_path_file)
29 for dir_name in dirs:
30 parent_dir_rel_path = root[len(root_path)+1:]
31 rel_path_dir = os.path.join(parent_dir_rel_path, dir_name)
32 rel_path_dir = rel_path_dir.replace("\\", "/")+"/"
33 if not (rel_path_dir.startswith("distribution/") or
34 rel_path_dir.startswith("extensions/")):
35 rel_dir_path_set.add(rel_path_dir)
37 rel_file_path_list = list(rel_file_path_set)
38 rel_file_path_list.sort(reverse=True)
39 rel_dir_path_list = list(rel_dir_path_set)
40 rel_dir_path_list.sort(reverse=True)
42 return rel_file_path_list, rel_dir_path_list
44 def generate_precomplete(root_path):
45 """ Creates the precomplete file containing the remove and rmdir
46 application update instructions. The given directory is used
47 for the location to enumerate and to create the precomplete file.
48 """
49 # If inside a Mac bundle use the root of the bundle for the path.
50 if os.path.basename(root_path) == "MacOS":
51 root_path = os.path.abspath(os.path.join(root_path, '../../'))
53 rel_file_path_list, rel_dir_path_list = get_build_entries(root_path)
54 precomplete_file_path = os.path.join(root_path,"precomplete")
55 # open in binary mode to prevent OS specific line endings.
56 precomplete_file = open(precomplete_file_path, "wb")
57 for rel_file_path in rel_file_path_list:
58 precomplete_file.writelines("remove \""+rel_file_path+"\"\n")
60 for rel_dir_path in rel_dir_path_list:
61 precomplete_file.writelines("rmdir \""+rel_dir_path+"\"\n")
63 precomplete_file.close()
65 if __name__ == "__main__":
66 generate_precomplete(os.getcwd())