Index: engine/SConscript =================================================================== --- engine/SConscript (revision 1859) +++ engine/SConscript (working copy) @@ -6,6 +6,8 @@ _sep = os.path.sep enginepath = upath('.') extensionpath = upath('./extensions') +msvcbuildpath = joinpath('build', 'win32', 'build_environments', 'visual_studio_8') +cbbuildpath = joinpath('build', 'win32', 'build_environments', 'code_blocks') def is_implfile(fname): return fname.endswith('.cpp') or fname.endswith('.cxx') or fname.endswith('.m') @@ -94,7 +96,7 @@ for l in dupes: print l Exit(1) -def generate_msvc_project(projectfiles): +def generate_msvc_project(target, source, env): def create_dict_tree(source_dict): for f in source_dict.keys(): parts = f.split(os.path.sep, 1) @@ -122,17 +124,17 @@ retstr.append(tabcount * '\t' + '' % newpath.replace('/','\\')) return '\n'.join(retstr) - msvcbuildpath = joinpath('..', 'build', 'win32', 'build_environments', 'visual_studio_8') - vcpaths = [os.path.abspath(f).split('%sengine%s' % (_sep, _sep))[-1] for f in projectfiles] + vcpaths = [os.path.abspath(str(f)).split('%sengine%s' % (_sep, _sep))[-1] for f in source] xmlstr = get_msvc_repr(create_dict_tree(dict([[p, {}] for p in vcpaths]))) projtxt = open(joinpath(msvcbuildpath, 'engine_template.xml'), 'r').read() projtxt = projtxt.replace('__FILE_INSERTION_POINT__', xmlstr) - vcprojfilename = joinpath(msvcbuildpath, 'fife.vcproj') - open(vcprojfilename, 'w').write(projtxt) - print "FIFE msvc project file succesfully created (%s)" % os.path.abspath(vcprojfilename) + open(str(target[0]), 'w').write(projtxt) + print "FIFE msvc project file succesfully created (%s)" % os.path.abspath(str(target[0])) +msvc_project_builder = Builder(action = generate_msvc_project, suffix = '.vcproj') +env.Append(BUILDERS = {'MSVCProject': msvc_project_builder}) -def generate_codeblocks_project(projectfiles): +def generate_codeblocks_project(target, source, env): codeblocksHeaderDef = \ ''' ''' - cbbuildpath = joinpath('..', 'build', 'win32', 'build_environments', 'code_blocks') xmlstr = [] - for f in projectfiles: - newf = os.path.abspath(f).split('%sengine%s' % (_sep, _sep))[-1] + for f in source: + newf = os.path.abspath(str(f)).split('%sengine%s' % (_sep, _sep))[-1] newf = newf.replace('/', '\\') if f in headerfiles: xmlstr.append(codeblocksHeaderDef % newf) @@ -157,11 +158,13 @@ xmlstr.append(codeblocksCppDef % newf) projtxt = open(joinpath(cbbuildpath, 'engine_template.xml'), 'r').read() projtxt = projtxt.replace('__FILE_INSERTION_POINT__', '\n'.join(xmlstr)) - cbprojfilename = joinpath(cbbuildpath, 'fife_engine.cbp') - open(cbprojfilename, 'w').write(projtxt) - print "FIFE code::blocks project file succesfully created (%s)" % os.path.abspath(cbprojfilename) + open(str(target[0]), 'w').write(projtxt) + print "FIFE code::blocks project file succesfully created (%s)" % os.path.abspath(str(target[0])) +codeblocks_project_builder = Builder(action = generate_codeblocks_project, suffix = '.cbp') +env.Append(BUILDERS = {'CodeblocksProject': codeblocks_project_builder}) + variated_dirs = eval(open(joinpath('config', 'variated_dirs'), 'r').read()) # filter out swigwrappers. fife_wrap.cxx is appended manually # as it might not exist yet during SConscript parsing @@ -189,17 +192,15 @@ implfiles = [f for f in allfiles if is_implfile(f)] extensionfiles = list(extensionpath.walkfiles('*.py')) -def generate_all_project_files(): +if not env.GetOption('clean'): filtered_prj_paths = eval(open(joinpath('config', 'removed_from_project_files'), 'r').read()) filtered_prj_paths = [joinpath(*p.split('/')) for p in filtered_prj_paths] - projectfiles = remove_based_on_dir_filter(filtered_prj_paths, headerfiles + implfiles) + projectfiles = [str(f) for f in remove_based_on_dir_filter(filtered_prj_paths, headerfiles + implfiles)] + projectfiles.append('./swigwrappers/%s/fife_wrap.cxx' % env['script']) projectfiles.sort() - - generate_msvc_project(projectfiles) - generate_codeblocks_project(projectfiles) -if not env.GetOption('clean'): - generate_all_project_files() + msvc = env.MSVCProject(joinpath(msvcbuildpath, 'fife'), projectfiles) + codeblocks = env.CodeblocksProject(joinpath(cbbuildpath, 'fife_engine'), projectfiles) if not env['projectfiles_only']: env.Append(CPPPATH = ['#/engine/core', '#/engine/swigwrappers'])