From 2f446b716151fb1aa970d92fbd3d4bc78d5e9466 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Sun, 16 Jan 2022 17:33:59 +0100 Subject: [PATCH] Use the same end of line for main.js generation as it was before. --- tools/lib/tools_lib.py | 7 +++++++ tools/update_engine_exports.py | 17 ++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/lib/tools_lib.py b/tools/lib/tools_lib.py index 8ef7dbd..d79ea61 100644 --- a/tools/lib/tools_lib.py +++ b/tools/lib/tools_lib.py @@ -13,6 +13,13 @@ def WriteContentToFile (filePath, content): fileObject.write (content) fileObject.close () +def GetEOLCharFromFile (filePath): + content = GetFileContent (filePath) + if content.count ('\r\n') > 0: + return '\r\n' + else: + return '\n' + def RunCommand (executable, arguments): command = executable + ' "' + '" "'.join (arguments) + '"' return os.system (command) diff --git a/tools/update_engine_exports.py b/tools/update_engine_exports.py index 82cd118..c7b3ea7 100644 --- a/tools/update_engine_exports.py +++ b/tools/update_engine_exports.py @@ -10,10 +10,6 @@ def Main (argv): rootDir = os.path.dirname (toolsDir) os.chdir (rootDir) - config = None - with open (os.path.join (toolsDir, 'config.json')) as configJson: - config = json.load (configJson) - engineFiles = [] sourceFolder = os.path.join (rootDir, 'source', 'engine') for dirName in os.listdir (sourceFolder): @@ -26,6 +22,9 @@ def Main (argv): 'fileName': fileName }) + mainFilePath = os.path.join (sourceFolder, 'main.js') + eolChar = Tools.GetEOLCharFromFile (mainFilePath) + exportedSymbols = [] mainFileContent = '' for engineFile in engineFiles: @@ -38,20 +37,20 @@ def Main (argv): if len (matches) == 0: continue relativePath = './' + engineFile['dirName'] + '/' + engineFile['fileName'] - mainFileContent += 'import { ' + ', '.join (matches) + ' } from \'' + relativePath + '\';\n' + mainFileContent += 'import { ' + ', '.join (matches) + ' } from \'' + relativePath + '\';' + eolChar for match in matches: exportedSymbols.append (match) - mainFileContent += '\nexport {\n' + mainFileContent += eolChar + 'export {' + eolChar for i in range (0, len (exportedSymbols)): exportedSymbol = exportedSymbols[i] mainFileContent += ' ' + exportedSymbol if i < len (exportedSymbols) - 1: mainFileContent += ',' - mainFileContent += '\n' - mainFileContent += '};\n' + mainFileContent += eolChar + mainFileContent += '};' + eolChar - Tools.WriteContentToFile (os.path.join (sourceFolder, 'main.js'), mainFileContent) + Tools.WriteContentToFile (mainFilePath, mainFileContent) return 0 sys.exit (Main (sys.argv))