| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 
 | # -*- coding: utf-8 -*-import os
 import plistlib
 import re
 import getpass
 import datetime
 import codecs
 import logging
 import sys
 
 pro_name = "XXXGame"
 path = os.getcwd()
 files_path = path
 file_path = path
 head_file_name = 'CMakeLists.txt'
 file_context_str = ""
 # 所有文件夹,第一个字段是次目录的级别
 dirList = []
 # 所有文件
 allfiles = []
 
 file_context_h=""
 file_context_cpp=""
 
 def replaceContextToFile(replace_str):
 global file_context_str
 file_context_str = file_context_str + replace_str
 head_file = codecs.open(file_path+'/'+head_file_name,'wb',encoding='UTF-8')
 head_file.write(file_context_str)
 head_file.close()
 
 if not os.path.isdir(file_path):
 os.makedirs(file_path)
 #print "files_path",files_path
 listfile = os.listdir(files_path)
 
 
 def file_name(file_dir):
 for root, dirs, files in os.walk(file_dir):
 #print('root_dir:', root)  # 当前目录路径
 #print('sub_dirs:', dirs)  # 当前路径下所有子目录
 #print('files:', files)  # 当前路径下所有非目录子文件
 for f in files:
 # if(re.search('mp4$'),f):
 allfiles.append(os.path.join(root, f))
 #test
 def get_all_file(rawdir):
 for root,dirs,files in os.walk(rawdir):
 for f in files:
 #if(re.search('mp4$'),f):
 allfiles.append(os.path.join(root,f))
 for dirname in dirs:
 get_all_file(os.path.join(root,dirname))
 return allfiles
 #
 file_name(files_path)
 
 for i,value in enumerate(allfiles):
 ccb_name = value
 ccb_name = ccb_name.replace(files_path, '')
 ccb_name = ccb_name.replace("\\", '/')
 #file_name = files_path+"/"+ccb_name
 file_name = ccb_name
 list = file_name.rsplit('.',1)
 #print list
 #print file_name
 if len(list) >= 2:
 file_type = list[1]
 if file_type == "h":
 reuslt_str = '\n'
 reuslt_str += '	Classes/Common' # 新模块要对应修改
 reuslt_str += ccb_name
 file_context_h += reuslt_str
 elif file_type == "cpp":
 reuslt_str = '\n'
 reuslt_str += '	Classes/Common' # 新模块要对应修改
 reuslt_str += ccb_name
 file_context_cpp += reuslt_str
 # GD_COMMON_HEADER 为变量名,新模块要对应修改
 reuslt_str = 'set(GD_COMMON_HEADER'
 reuslt_str += file_context_h
 reuslt_str += '\n'
 reuslt_str += '	)'
 reuslt_str += '\n'
 reuslt_str += '\n'
 # GD_COMMON_SRC 为变量名,新模块要对应修改
 reuslt_str += 'set(GD_COMMON_SRC'
 reuslt_str += file_context_cpp
 reuslt_str += '\n'
 reuslt_str += '	)'
 replaceContextToFile(reuslt_str)
 
 |