3 # ***** BEGIN GPL LICENSE BLOCK *****
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # Contributor(s): Campbell Barton, M.G. Kishalmi
21 # ***** END GPL LICENSE BLOCK *****
27 c:\Python32\python.exe c:\blender_dev\blender\build_files\cmake\cmake_qtcreator_project.py c:\blender_dev\cmake_build
30 python .~/blenderSVN/blender/build_files/cmake/cmake_qtcreator_project.py ~/blenderSVN/cmake
33 from project_info import (SIMPLE_PROJECTFILE,
42 cmake_compiler_defines,
50 def quote_define(define):
51 if " " in define.strip():
52 return '"%s"' % define
57 def create_qtc_project_main():
58 files = list(source_list(SOURCE_DIR, filename_check=is_project_file))
59 files_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files]
62 # --- qtcreator specific, simple format
63 if SIMPLE_PROJECTFILE:
64 # --- qtcreator specific, simple format
65 PROJECT_NAME = "Blender"
66 f = open(os.path.join(PROJECT_DIR, "%s.files" % PROJECT_NAME), 'w')
67 f.write("\n".join(files_rel))
69 f = open(os.path.join(PROJECT_DIR, "%s.includes" % PROJECT_NAME), 'w')
70 f.write("\n".join(sorted(list(set(os.path.dirname(f)
71 for f in files_rel if is_c_header(f))))))
73 qtc_prj = os.path.join(PROJECT_DIR, "%s.creator" % PROJECT_NAME)
74 f = open(qtc_prj, 'w')
75 f.write("[General]\n")
77 qtc_cfg = os.path.join(PROJECT_DIR, "%s.config" % PROJECT_NAME)
78 if not os.path.exists(qtc_cfg):
79 f = open(qtc_cfg, 'w')
80 f.write("// ADD PREDEFINED MACROS HERE!\n")
82 includes, defines = cmake_advanced_info()
84 # for some reason it doesnt give all internal includes
85 includes = list(set(includes) | set(os.path.dirname(f)
86 for f in files_rel if is_c_header(f)))
90 PROJECT_NAME = "Blender"
92 # be tricky, get the project name from SVN if we can!
93 PROJECT_NAME = project_name_get(SOURCE_DIR)
95 FILE_NAME = PROJECT_NAME.lower()
96 f = open(os.path.join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w')
97 f.write("\n".join(files_rel))
99 f = open(os.path.join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w', encoding='utf-8')
100 f.write("\n".join(sorted(includes)))
102 qtc_prj = os.path.join(PROJECT_DIR, "%s.creator" % FILE_NAME)
103 f = open(qtc_prj, 'w')
104 f.write("[General]\n")
106 qtc_cfg = os.path.join(PROJECT_DIR, "%s.config" % FILE_NAME)
107 f = open(qtc_cfg, 'w')
108 f.write("// ADD PREDEFINED MACROS HERE!\n")
109 defines_final = [("#define %s %s" % (item[0], quote_define(item[1]))) for item in defines]
110 if sys.platform != "win32":
111 defines_final += cmake_compiler_defines()
112 f.write("\n".join(defines_final))
114 print("Blender project file written to: %r" % qtc_prj)
118 def create_qtc_project_python():
119 files = list(source_list(SOURCE_DIR, filename_check=is_py))
120 files_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files]
123 # --- qtcreator specific, simple format
125 PROJECT_NAME = "Blender_Python"
127 # be tricky, get the project name from SVN if we can!
128 PROJECT_NAME = project_name_get(SOURCE_DIR) + "_Python"
130 FILE_NAME = PROJECT_NAME.lower()
131 f = open(os.path.join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w')
132 f.write("\n".join(files_rel))
134 qtc_prj = os.path.join(PROJECT_DIR, "%s.creator" % FILE_NAME)
135 f = open(qtc_prj, 'w')
136 f.write("[General]\n")
138 qtc_cfg = os.path.join(PROJECT_DIR, "%s.config" % FILE_NAME)
139 if not os.path.exists(qtc_cfg):
140 f = open(qtc_cfg, 'w')
141 f.write("// ADD PREDEFINED MACROS HERE!\n")
143 print("Python project file written to: %r" % qtc_prj)
147 create_qtc_project_main()
148 create_qtc_project_python()
151 if __name__ == "__main__":