write project files into the build dir.
This commit is contained in:
parent
3ebb9676c1
commit
19819dcbc7
@ -26,11 +26,12 @@
|
||||
"""
|
||||
Example Win32 usage:
|
||||
c:\Python32\python.exe c:\blender_dev\blender\build_files\cmake\cmake_qtcreator_project.py c:\blender_dev\cmake_build
|
||||
|
||||
|
||||
example linux usage
|
||||
python .~/blenderSVN/blender/build_files/cmake/cmake_qtcreator_project.py ~/blenderSVN/cmake
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from os.path import join, dirname, normpath, abspath, splitext, relpath, exists
|
||||
|
||||
@ -40,6 +41,20 @@ base = abspath(base)
|
||||
|
||||
SIMPLE_PROJECTFILE = False
|
||||
|
||||
# get cmake path
|
||||
CMAKE_DIR = sys.argv[-1]
|
||||
|
||||
if not os.path.exists(os.path.join(CMAKE_DIR, "CMakeCache.txt")):
|
||||
CMAKE_DIR = os.getcwd()
|
||||
if not os.path.exists(os.path.join(CMAKE_DIR, "CMakeCache.txt")):
|
||||
print("CMakeCache.txt not found in %r or %r\n Pass CMake build dir as an argument, or run from that dir, aborting" % (CMAKE_DIR, os.getcwd()))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# could be either.
|
||||
# PROJECT_DIR = base
|
||||
PROJECT_DIR = CMAKE_DIR
|
||||
|
||||
|
||||
def source_list(path, filename_check=None):
|
||||
for dirpath, dirnames, filenames in os.walk(path):
|
||||
@ -69,10 +84,12 @@ def is_py(filename):
|
||||
ext = splitext(filename)[1]
|
||||
return (ext == ".py")
|
||||
|
||||
|
||||
def is_glsl(filename):
|
||||
ext = splitext(filename)[1]
|
||||
return (ext == ".glsl")
|
||||
|
||||
|
||||
|
||||
def is_c(filename):
|
||||
ext = splitext(filename)[1]
|
||||
return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc"))
|
||||
@ -96,12 +113,12 @@ def cmake_advanced_info():
|
||||
""" Extracr includes and defines from cmake.
|
||||
"""
|
||||
|
||||
def create_eclipse_project(cmake_dir):
|
||||
def create_eclipse_project(CMAKE_DIR):
|
||||
import sys
|
||||
if sys.platform == "win32":
|
||||
cmd = 'cmake %r -G"Eclipse CDT4 - MinGW Makefiles"' % cmake_dir
|
||||
cmd = 'cmake %r -G"Eclipse CDT4 - MinGW Makefiles"' % CMAKE_DIR
|
||||
else:
|
||||
cmd = 'cmake %r -G"Eclipse CDT4 - Unix Makefiles"' % cmake_dir
|
||||
cmd = 'cmake %r -G"Eclipse CDT4 - Unix Makefiles"' % CMAKE_DIR
|
||||
|
||||
os.system(cmd)
|
||||
|
||||
@ -111,18 +128,10 @@ def cmake_advanced_info():
|
||||
import os
|
||||
import sys
|
||||
|
||||
cmake_dir = sys.argv[-1]
|
||||
|
||||
if not os.path.exists(os.path.join(cmake_dir, "CMakeCache.txt")):
|
||||
cmake_dir = os.getcwd()
|
||||
if not os.path.exists(os.path.join(cmake_dir, "CMakeCache.txt")):
|
||||
print("CMakeCache.txt not found in %r or %r\n Pass CMake build dir as an argument, or run from that dir, aborting" % (cmake_dir, os.getcwd()))
|
||||
sys.exit(1)
|
||||
|
||||
create_eclipse_project(cmake_dir)
|
||||
create_eclipse_project(CMAKE_DIR)
|
||||
|
||||
from xml.dom.minidom import parse
|
||||
tree = parse(os.path.join(cmake_dir, ".cproject"))
|
||||
tree = parse(os.path.join(CMAKE_DIR, ".cproject"))
|
||||
'''
|
||||
f = open(".cproject_pretty", 'w')
|
||||
f.write(tree.toprettyxml(indent=" ", newl=""))
|
||||
@ -165,26 +174,27 @@ def cmake_advanced_info():
|
||||
|
||||
return includes, defines
|
||||
|
||||
|
||||
def create_qtc_project_main():
|
||||
files = list(source_list(base, filename_check=is_project_file))
|
||||
files_rel = [relpath(f, start=base) for f in files]
|
||||
files_rel = [relpath(f, start=PROJECT_DIR) for f in files]
|
||||
files_rel.sort()
|
||||
|
||||
# --- qtcreator specific, simple format
|
||||
if SIMPLE_PROJECTFILE:
|
||||
# --- qtcreator specific, simple format
|
||||
PROJECT_NAME = "Blender"
|
||||
f = open(join(base, "%s.files" % PROJECT_NAME), 'w')
|
||||
f = open(join(PROJECT_DIR, "%s.files" % PROJECT_NAME), 'w')
|
||||
f.write("\n".join(files_rel))
|
||||
|
||||
f = open(join(base, "%s.includes" % PROJECT_NAME), 'w')
|
||||
f = open(join(PROJECT_DIR, "%s.includes" % PROJECT_NAME), 'w')
|
||||
f.write("\n".join(sorted(list(set(dirname(f) for f in files_rel if is_c_header(f))))))
|
||||
|
||||
qtc_prj = join(base, "%s.creator" % PROJECT_NAME)
|
||||
qtc_prj = join(PROJECT_DIR, "%s.creator" % PROJECT_NAME)
|
||||
f = open(qtc_prj, 'w')
|
||||
f.write("[General]\n")
|
||||
|
||||
qtc_cfg = join(base, "%s.config" % PROJECT_NAME)
|
||||
qtc_cfg = join(PROJECT_DIR, "%s.config" % PROJECT_NAME)
|
||||
if not exists(qtc_cfg):
|
||||
f = open(qtc_cfg, 'w')
|
||||
f.write("// ADD PREDEFINED MACROS HERE!\n")
|
||||
@ -196,44 +206,47 @@ def create_qtc_project_main():
|
||||
includes.sort()
|
||||
|
||||
PROJECT_NAME = "Blender"
|
||||
f = open(join(base, "%s.files" % PROJECT_NAME), 'w')
|
||||
FILE_NAME = PROJECT_NAME.lower()
|
||||
f = open(join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w')
|
||||
f.write("\n".join(files_rel))
|
||||
|
||||
f = open(join(base, "%s.includes" % PROJECT_NAME), 'w')
|
||||
f = open(join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w')
|
||||
f.write("\n".join(sorted(includes)))
|
||||
|
||||
qtc_prj = join(base, "%s.creator" % PROJECT_NAME)
|
||||
qtc_prj = join(PROJECT_DIR, "%s.creator" % FILE_NAME)
|
||||
f = open(qtc_prj, 'w')
|
||||
f.write("[General]\n")
|
||||
|
||||
qtc_cfg = join(base, "%s.config" % PROJECT_NAME)
|
||||
qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME)
|
||||
f = open(qtc_cfg, 'w')
|
||||
f.write("// ADD PREDEFINED MACROS HERE!\n")
|
||||
f.write("\n".join([("#define %s %s" % item) for item in defines]))
|
||||
|
||||
print("Main Blender project file written to: %s" % qtc_prj)
|
||||
print("Blender project file written to: %s" % qtc_prj)
|
||||
# --- end
|
||||
|
||||
|
||||
def create_qtc_project_python():
|
||||
files = list(source_list(base, filename_check=is_py))
|
||||
files_rel = [relpath(f, start=base) for f in files]
|
||||
files_rel = [relpath(f, start=PROJECT_DIR) for f in files]
|
||||
files_rel.sort()
|
||||
|
||||
# --- qtcreator specific, simple format
|
||||
PROJECT_NAME = "Blender_Python"
|
||||
f = open(join(base, "%s.files" % PROJECT_NAME), 'w')
|
||||
FILE_NAME = PROJECT_NAME.lower()
|
||||
f = open(join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w')
|
||||
f.write("\n".join(files_rel))
|
||||
|
||||
qtc_prj = join(base, "%s.creator" % PROJECT_NAME)
|
||||
|
||||
qtc_prj = join(PROJECT_DIR, "%s.creator" % FILE_NAME)
|
||||
f = open(qtc_prj, 'w')
|
||||
f.write("[General]\n")
|
||||
|
||||
qtc_cfg = join(base, "%s.config" % PROJECT_NAME)
|
||||
|
||||
qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME)
|
||||
if not exists(qtc_cfg):
|
||||
f = open(qtc_cfg, 'w')
|
||||
f.write("// ADD PREDEFINED MACROS HERE!\n")
|
||||
|
||||
print("Blender python project file written to: %s" % qtc_prj)
|
||||
|
||||
print("Python project file written to: %s" % qtc_prj)
|
||||
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user