Просмотр исходного кода

Fix too long input line for AzAutoGen (#8927)

* Fix too long input line for AzAutoGen

Signed-off-by: onecent1101 <[email protected]>

* Add missing parameter

Signed-off-by: onecent1101 <[email protected]>

* Address PR feedback

Signed-off-by: onecent1101 <[email protected]>
Vincent Liu 3 лет назад
Родитель
Сommit
fce6a7728b
2 измененных файлов с 17 добавлено и 4 удалено
  1. 12 2
      cmake/AzAutoGen.py
  2. 5 2
      cmake/LyAutoGen.cmake

+ 12 - 2
cmake/AzAutoGen.py

@@ -24,6 +24,16 @@ from xml.sax.saxutils import escape, unescape, quoteattr
 MAX_ERRORS = 100
 errorCount = 0
 
+def ParseInputFile(inputFilePath):
+    result = []
+    if inputFilePath:
+        with open(inputFilePath, 'r') as file:
+            # input files are expected to be separated by semicolon at first line
+            inputFileContent = file.readline()
+            inputFiles = inputFileContent.strip().split(";")
+            result = inputFiles
+    return result
+
 def PrintError(*objs):
     print(*objs, file=sys.stderr)
     global errorCount
@@ -339,7 +349,7 @@ if __name__ == '__main__':
     parser.add_argument("cacheDir", help="location to store jinja template cache files")
     parser.add_argument("outputDir", help="location to output generated files")
     parser.add_argument("projectDir", help="location to build directory against")
-    parser.add_argument("inputFiles", help="set of files to run azcg expansion rules against")
+    parser.add_argument("inputFilePath", help="input file which contains autogen required files to run azcg expansion rules against")
     parser.add_argument("expansionRules", help="set of azcg expansion rules for matching data files to template files")
     parser.add_argument("-n", "--dryrun", action='store_true', help="does not execute autogen, only outputs the set of files that autogen would generate")
     parser.add_argument("-v", "--verbose", action='store_true', help="output only the set of files that would be generated by an expansion run")
@@ -350,7 +360,7 @@ if __name__ == '__main__':
     cacheDir  = args.cacheDir
     outputDir = args.outputDir
     projectDir = args.projectDir
-    inputFiles = args.inputFiles.split(";")
+    inputFiles = ParseInputFile(args.inputFilePath.strip())
     expansionRules = args.expansionRules.split(";")
     dryrun = args.dryrun
     verbose = args.verbose

+ 5 - 2
cmake/LyAutoGen.cmake

@@ -23,9 +23,12 @@ function(ly_add_autogen)
     if(ly_add_autogen_AUTOGEN_RULES)
         set(AZCG_INPUTFILES ${ly_add_autogen_ALLFILES})
         list(FILTER AZCG_INPUTFILES INCLUDE REGEX ".*\.(xml|json|jinja)$")
+        # Writes AzAutoGen input files into tmp ${ly_add_autogen_NAME}_input_files.txt file to avoid long command error
+        set(input_files_path "${CMAKE_CURRENT_BINARY_DIR}/Azcg/Temp/${ly_add_autogen_NAME}_input_files.txt")
+        file(CONFIGURE OUTPUT "${input_files_path}" CONTENT [[@AZCG_INPUTFILES@]] @ONLY)
         target_include_directories(${ly_add_autogen_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/Azcg/Generated")
         execute_process(
-            COMMAND ${LY_PYTHON_CMD} "${LY_ROOT_FOLDER}/cmake/AzAutoGen.py" "${CMAKE_BINARY_DIR}/Azcg/TemplateCache/" "${CMAKE_CURRENT_BINARY_DIR}/Azcg/Generated/" "${CMAKE_CURRENT_SOURCE_DIR}" "${AZCG_INPUTFILES}" "${ly_add_autogen_AUTOGEN_RULES}" "-n"
+            COMMAND ${LY_PYTHON_CMD} "${LY_ROOT_FOLDER}/cmake/AzAutoGen.py" "${CMAKE_BINARY_DIR}/Azcg/TemplateCache/" "${CMAKE_CURRENT_BINARY_DIR}/Azcg/Generated/" "${CMAKE_CURRENT_SOURCE_DIR}" "${input_files_path}" "${ly_add_autogen_AUTOGEN_RULES}" "-n"
             OUTPUT_VARIABLE AUTOGEN_OUTPUTS
         )
         string(STRIP "${AUTOGEN_OUTPUTS}" AUTOGEN_OUTPUTS)
@@ -34,7 +37,7 @@ function(ly_add_autogen)
         add_custom_command(
             OUTPUT ${AUTOGEN_OUTPUTS}
             DEPENDS ${AZCG_DEPENDENCIES}
-            COMMAND ${LY_PYTHON_CMD} "${LY_ROOT_FOLDER}/cmake/AzAutoGen.py" "${CMAKE_BINARY_DIR}/Azcg/TemplateCache/" "${CMAKE_CURRENT_BINARY_DIR}/Azcg/Generated/" "${CMAKE_CURRENT_SOURCE_DIR}" "${AZCG_INPUTFILES}" "${ly_add_autogen_AUTOGEN_RULES}"
+            COMMAND ${LY_PYTHON_CMD} "${LY_ROOT_FOLDER}/cmake/AzAutoGen.py" "${CMAKE_BINARY_DIR}/Azcg/TemplateCache/" "${CMAKE_CURRENT_BINARY_DIR}/Azcg/Generated/" "${CMAKE_CURRENT_SOURCE_DIR}" "${input_files_path}" "${ly_add_autogen_AUTOGEN_RULES}"
             COMMENT "Running AutoGen for ${ly_add_autogen_NAME}"
             VERBATIM
         )