From 89c12e9da6438b5e3c99b4a46ef96a78b862f044 Mon Sep 17 00:00:00 2001 From: Manuel Wellmann Date: Tue, 6 Nov 2012 10:23:15 +0100 Subject: Fix splitting on case-insensitive file systems --- tools/split.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/split.py b/tools/split.py index ab1e97ca..f9e338aa 100755 --- a/tools/split.py +++ b/tools/split.py @@ -17,7 +17,8 @@ def split_javascript_file(input_filename, output_filename_prefix, max_part_size_ # Variable will contain the source of a Javascript function if we find one during parsing js_function = None - # Dictionary with source file as key and an array of functions associated to that source file as value + # Dictionary with lower case source file as key and a tupel of case sensitive source file name (first encountered case wins) + # and an array of functions associated to that source file as value function_buckets = {}; output_part_file = None @@ -37,10 +38,12 @@ def split_javascript_file(input_filename, output_filename_prefix, max_part_size_ # Functions with a known associated source file are stored in a file in the directory `output_filename_prefix` associated_source_file_base = output_filename_prefix + os.path.realpath(associated_source_file_base) + associated_source_file_base_lower = associated_source_file_base.lower() + # Add the function to its respective file - if associated_source_file_base not in function_buckets: - function_buckets[associated_source_file_base] = [] - function_buckets[associated_source_file_base] += [js_function] + if associated_source_file_base_lower not in function_buckets: + function_buckets[associated_source_file_base_lower] = [associated_source_file_base, []] + function_buckets[associated_source_file_base_lower][1] += [js_function] # Clear the function read cache js_function = None @@ -54,7 +57,7 @@ def split_javascript_file(input_filename, output_filename_prefix, max_part_size_ # An associated file is split into chunks of `max_part_size_in_bytes` for associated_source_file_base in function_buckets: # At first we try to name the Javascript source file to match the assoicated source file + `.js` - js_source_file = associated_source_file_base + ".js" + js_source_file = function_buckets[associated_source_file_base][0] + ".js" # Check if the directory of the Javascript source file exists js_source_dir = os.path.dirname(js_source_file) @@ -63,7 +66,7 @@ def split_javascript_file(input_filename, output_filename_prefix, max_part_size_ output_part_file_counter = 0 output_part_file = None - for js_function in function_buckets[associated_source_file_base]: + for js_function in function_buckets[associated_source_file_base][1]: if output_part_file is None: output_html_include_file.write("") output_part_file = open(js_source_file,'w') @@ -74,7 +77,7 @@ def split_javascript_file(input_filename, output_filename_prefix, max_part_size_ output_part_file.close() output_part_file = None output_part_file_counter += 1 - js_source_file = associated_source_file_base + ".part" + str(output_part_file_counter) + ".js" + js_source_file = function_buckets[associated_source_file_base][0] + ".part" + str(output_part_file_counter) + ".js" if output_part_file is not None: output_part_file.close() -- cgit v1.2.3-18-g5258