4 # ***** BEGIN GPL LICENSE BLOCK *****
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # Contributor(s): Campbell Barton, M.G. Kishalmi
22 # ***** END GPL LICENSE BLOCK *****
28 python .~/blenderSVN/blender/build_files/cmake/cmake_netbeans_project.py ~/blenderSVN/cmake
30 Windows not supported so far
33 from project_info import *
36 from os.path import join, dirname, normpath, abspath, splitext, relpath, exists
39 def create_nb_project_main():
40 files = list(source_list(SOURCE_DIR, filename_check=is_project_file))
41 files_rel = [relpath(f, start=PROJECT_DIR) for f in files]
44 if SIMPLE_PROJECTFILE:
47 includes, defines = cmake_advanced_info()
48 # for some reason it doesnt give all internal includes
49 includes = list(set(includes) | set(dirname(f) for f in files if is_c_header(f)))
52 PROJECT_NAME = "Blender"
53 FILE_NAME = PROJECT_NAME.lower()
55 # --------------- NB spesific
56 defines = [("%s=%s" % cdef) if cdef[1] else cdef[0] for cdef in defines]
57 defines += [cdef.replace("#define", "").strip() for cdef in cmake_compiler_defines()]
59 def file_list_to_nested(files):
60 # convert paths to hierarchy
63 def ensure_path(filepath):
64 filepath_split = filepath.split(os.sep)
67 for subdir in filepath_split[:-1]:
68 pn = pn.setdefault(subdir, {})
69 pn[filepath_split[-1]] = None
75 PROJECT_DIR_NB = join(PROJECT_DIR, "nbproject")
76 if not exists(PROJECT_DIR_NB):
77 os.mkdir(PROJECT_DIR_NB)
79 SOURCE_DIR_REL = relpath(SOURCE_DIR, PROJECT_DIR)
81 f = open(join(PROJECT_DIR_NB, "project.xml"), 'w')
83 f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
84 f.write('<project xmlns="http://www.netbeans.org/ns/project/1">\n')
85 f.write(' <type>org.netbeans.modules.cnd.makeproject</type>\n')
86 f.write(' <configuration>\n')
87 f.write(' <data xmlns="http://www.netbeans.org/ns/make-project/1">\n')
88 f.write(' <name>%s</name>\n' % PROJECT_NAME)
89 f.write(' <c-extensions>c,m</c-extensions>\n')
90 f.write(' <cpp-extensions>cpp,mm</cpp-extensions>\n')
91 f.write(' <header-extensions>h,hpp,inl</header-extensions>\n')
92 f.write(' <sourceEncoding>UTF-8</sourceEncoding>\n')
93 f.write(' <make-dep-projects/>\n')
94 f.write(' <sourceRootList>\n')
95 f.write(' <sourceRootElem>%s</sourceRootElem>\n' % SOURCE_DIR) # base_root_rel
96 f.write(' </sourceRootList>\n')
97 f.write(' <confList>\n')
98 f.write(' <confElem>\n')
99 f.write(' <name>Default</name>\n')
100 f.write(' <type>0</type>\n')
101 f.write(' </confElem>\n')
102 f.write(' </confList>\n')
103 f.write(' </data>\n')
104 f.write(' </configuration>\n')
105 f.write('</project>\n')
107 f = open(join(PROJECT_DIR_NB, "configurations.xml"), 'w')
109 f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
110 f.write('<configurationDescriptor version="79">\n')
111 f.write(' <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">\n')
112 f.write(' <df name="blender" root="%s">\n' % SOURCE_DIR) # base_root_rel
115 files_rel_local = [normpath(relpath(join(CMAKE_DIR, path), SOURCE_DIR)) for path in files_rel]
116 files_rel_hierarchy = file_list_to_nested(files_rel_local)
117 # print(files_rel_hierarchy)
119 def write_df(hdir, ident):
122 for key, item in sorted(hdir.items()):
126 dirs.append((key, item))
128 for key, item in dirs:
129 f.write('%s <df name="%s">\n' % (ident, key))
130 write_df(item, ident + " ")
131 f.write('%s </df>\n' % ident)
134 f.write('%s<in>%s</in>\n' % (ident, key))
136 write_df(files_rel_hierarchy, ident=" ")
140 f.write(' <logicalFolder name="ExternalFiles"\n')
141 f.write(' displayName="Important Files"\n')
142 f.write(' projectFiles="false"\n')
143 f.write(' kind="IMPORTANT_FILES_FOLDER">\n')
144 # f.write(' <itemPath>../GNUmakefile</itemPath>\n')
145 f.write(' </logicalFolder>\n')
147 f.write(' </logicalFolder>\n')
148 # default, but this dir is infact not in blender dir so we can ignore it
149 # f.write(' <sourceFolderFilter>^(nbproject)$</sourceFolderFilter>\n')
150 f.write(' <sourceFolderFilter>^(__pycache__|.*\.py)$</sourceFolderFilter>\n')
152 f.write(' <sourceRootList>\n')
153 f.write(' <Elem>%s</Elem>\n' % SOURCE_DIR) # base_root_rel
154 f.write(' </sourceRootList>\n')
156 f.write(' <projectmakefile>Makefile</projectmakefile>\n')
159 f.write(' <confs>\n')
160 f.write(' <conf name="Default" type="0">\n')
162 f.write(' <toolsSet>\n')
163 f.write(' <remote-sources-mode>LOCAL_SOURCES</remote-sources-mode>\n')
164 f.write(' <compilerSet>default</compilerSet>\n')
165 f.write(' </toolsSet>\n')
166 f.write(' <makefileType>\n')
168 f.write(' <makeTool>\n')
169 f.write(' <buildCommandWorkingDir>.</buildCommandWorkingDir>\n')
170 f.write(' <buildCommand>${MAKE} -f Makefile</buildCommand>\n')
171 f.write(' <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>\n')
172 f.write(' <executablePath>./bin/blender</executablePath>\n')
174 def write_toolinfo():
175 f.write(' <incDir>\n')
177 f.write(' <pElem>%s</pElem>\n' % inc)
178 f.write(' </incDir>\n')
179 f.write(' <preprocessorList>\n')
181 f.write(' <Elem>%s</Elem>\n' % cdef)
182 f.write(' </preprocessorList>\n')
184 f.write(' <cTool>\n')
186 f.write(' </cTool>\n')
188 f.write(' <ccTool>\n')
190 f.write(' </ccTool>\n')
192 f.write(' </makeTool>\n')
193 f.write(' </makefileType>\n')
194 # finishe makefle info
198 for path in files_rel_local:
199 f.write(' <item path="%s"\n' % path)
200 f.write(' ex="false"\n')
201 f.write(' tool="1"\n')
202 f.write(' flavor="0">\n')
203 f.write(' </item>\n')
205 f.write(' <runprofile version="9">\n')
206 f.write(' <runcommandpicklist>\n')
207 f.write(' </runcommandpicklist>\n')
208 f.write(' <runcommand>%s</runcommand>\n' % os.path.join(CMAKE_DIR, "bin/blender"))
209 f.write(' <rundir>%s</rundir>\n' % SOURCE_DIR)
210 f.write(' <buildfirst>false</buildfirst>\n')
211 f.write(' <terminal-type>0</terminal-type>\n')
212 f.write(' <remove-instrumentation>0</remove-instrumentation>\n')
213 f.write(' <environment>\n')
214 f.write(' </environment>\n')
215 f.write(' </runprofile>\n')
217 f.write(' </conf>\n')
218 f.write(' </confs>\n')
222 f.write('</configurationDescriptor>\n')
226 create_nb_project_main()
229 if __name__ == "__main__":