parameters: ()
docstring: The main
docstring_summary: The main
docstring_tokens: The main
function: def main():
      """ The main """
  
      ctx = parse_commandline()
      this_script_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
  
      # Copy template
      project_dir = os.path.join(ctx.out_dir, "AndroidProject_%s" % ctx.target)
      if not os.path.isdir(project_dir):
          shutil.copytree(this_script_dir, project_dir)
      else:
          print("Project directory (%s) already exists. Won't copy template" % project_dir)
  
      # RM the script
      try:
          os.remove(os.path.join(project_dir, "GenerateAndroidProject.py"))
      except OSError:
          pass
  
      # Create the assets dir structure
      assets_dir = os.path.join(project_dir, "assets")
      if not os.path.isdir(assets_dir):
          os.mkdir(assets_dir)
          os.mkdir(os.path.join(project_dir, "assets/AnKi/"))
          os.symlink(os.path.join(this_script_dir, "../../AnKi/Shaders"),
                     os.path.join(project_dir, "assets/AnKi/Shaders"))
          os.symlink(os.path.join(this_script_dir, "../../EngineAssets"),
                     os.path.join(project_dir, "assets/EngineAssets"))
          os.mkdir(os.path.join(project_dir, "assets/ThirdParty/"))
          os.symlink(os.path.join(this_script_dir, "../../ThirdParty/FidelityFX"),
                     os.path.join(project_dir, "assets/ThirdParty/FidelityFX"))
          os.symlink(ctx.asserts_dir, os.path.join(project_dir, "assets/Assets"))
      else:
          print("Asset directory (%s) already exists. Skipping" % assets_dir)
  
      # Write the asset directory structure to a file
      dir_structure_file = open(os.path.join(assets_dir, "DirStructure.txt"), "w", newline="\n")
      for root, dirs, files in os.walk(assets_dir, followlinks=True):
          for f in files:
              if f.find("DirStructure.txt") >= 0:
                  continue
  
              filename = os.path.join(root, f)
              filename = filename.replace(assets_dir, "")
              filename = filename.replace("\\", "/")
              if filename[0] == '/':
                  filename = filename[1:]
              dir_structure_file.write("%s\n" % filename)
      dir_structure_file.close()
  
      # strings.xml
      replace_in_file(os.path.join(project_dir, "app/src/main/res/values/strings.xml"), "%APP_NAME%", ctx.target)
  
      # build.gradle
      build_gradle = os.path.join(project_dir, "app/build.gradle")
      replace_in_file(build_gradle, "%TARGET%", ctx.target)
      replace_in_file(build_gradle, "%PYTHON%", sys.executable)
      replace_in_file(build_gradle, "%CMAKE%", os.path.join(this_script_dir, "../../CMakeLists.txt"))
  
      # Manifest
      replace_in_file(os.path.join(project_dir, "app/src/main/AndroidManifest.xml"), "%TARGET%", ctx.target)
  
      # Done
      print("Generated project: %s" % project_dir)
function_tokens: def main ( ) : ctx = parse_commandline ( ) this_script_dir = os . path . abspath ( os . path . dirname ( os . path . realpath ( __file__ ) ) ) # Copy template project_dir = os . path . join ( ctx . out_dir , "AndroidProject_%s" % ctx . target ) if not os . path . isdir ( project_dir ) : shutil . copytree ( this_script_dir , project_dir ) else : print ( "Project directory (%s) already exists. Won't copy template" % project_dir ) # RM the script try : os . remove ( os . path . join ( project_dir , "GenerateAndroidProject.py" ) ) except OSError : pass # Create the assets dir structure assets_dir = os . path . join ( project_dir , "assets" ) if not os . path . isdir ( assets_dir ) : os . mkdir ( assets_dir ) os . mkdir ( os . path . join ( project_dir , "assets/AnKi/" ) ) os . symlink ( os . path . join ( this_script_dir , "../../AnKi/Shaders" ) , os . path . join ( project_dir , "assets/AnKi/Shaders" ) ) os . symlink ( os . path . join ( this_script_dir , "../../EngineAssets" ) , os . path . join ( project_dir , "assets/EngineAssets" ) ) os . mkdir ( os . path . join ( project_dir , "assets/ThirdParty/" ) ) os . symlink ( os . path . join ( this_script_dir , "../../ThirdParty/FidelityFX" ) , os . path . join ( project_dir , "assets/ThirdParty/FidelityFX" ) ) os . symlink ( ctx . asserts_dir , os . path . join ( project_dir , "assets/Assets" ) ) else : print ( "Asset directory (%s) already exists. Skipping" % assets_dir ) # Write the asset directory structure to a file dir_structure_file = open ( os . path . join ( assets_dir , "DirStructure.txt" ) , "w" , newline = "\n" ) for root , dirs , files in os . walk ( assets_dir , followlinks = True ) : for f in files : if f . find ( "DirStructure.txt" ) >= 0 : continue filename = os . path . join ( root , f ) filename = filename . replace ( assets_dir , "" ) filename = filename . replace ( "\\" , "/" ) if filename [ 0 ] == '/' : filename = filename [ 1 : ] dir_structure_file . write ( "%s\n" % filename ) dir_structure_file . close ( ) # strings.xml replace_in_file ( os . path . join ( project_dir , "app/src/main/res/values/strings.xml" ) , "%APP_NAME%" , ctx . target ) # build.gradle build_gradle = os . path . join ( project_dir , "app/build.gradle" ) replace_in_file ( build_gradle , "%TARGET%" , ctx . target ) replace_in_file ( build_gradle , "%PYTHON%" , sys . executable ) replace_in_file ( build_gradle , "%CMAKE%" , os . path . join ( this_script_dir , "../../CMakeLists.txt" ) ) # Manifest replace_in_file ( os . path . join ( project_dir , "app/src/main/AndroidManifest.xml" ) , "%TARGET%" , ctx . target ) # Done print ( "Generated project: %s" % project_dir )