Fix for error w/ QtCreator project builder
cmake_qtcreator_project.py now takes a '--build-dir' argument. Since introduction of argparse, accessing last argv from project_info is no longer working. Now require a call to project_info.init before use.
This commit is contained in:
@@ -29,6 +29,13 @@ Example linux usage
|
|||||||
Windows not supported so far
|
Windows not supported so far
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# until we have arg parsing
|
||||||
|
import project_info
|
||||||
|
if not project_info.init(sys.argv[-1]):
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
from project_info import (
|
from project_info import (
|
||||||
SIMPLE_PROJECTFILE,
|
SIMPLE_PROJECTFILE,
|
||||||
SOURCE_DIR,
|
SOURCE_DIR,
|
||||||
|
@@ -24,28 +24,14 @@
|
|||||||
|
|
||||||
r"""
|
r"""
|
||||||
Example Linux usage:
|
Example Linux usage:
|
||||||
python ~/blender-git/blender/build_files/cmake/cmake_qtcreator_project.py ~/blender-git/cmake
|
python ~/blender-git/blender/build_files/cmake/cmake_qtcreator_project.py --build-dir ~/blender-git/cmake
|
||||||
|
|
||||||
Example Win32 usage:
|
Example Win32 usage:
|
||||||
c:\Python32\python.exe c:\blender_dev\blender\build_files\cmake\cmake_qtcreator_project.py c:\blender_dev\cmake_build
|
c:\Python32\python.exe c:\blender_dev\blender\build_files\cmake\cmake_qtcreator_project.py --build-dir c:\blender_dev\cmake_build
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from project_info import (
|
|
||||||
SIMPLE_PROJECTFILE,
|
|
||||||
SOURCE_DIR,
|
|
||||||
# CMAKE_DIR,
|
|
||||||
PROJECT_DIR,
|
|
||||||
source_list,
|
|
||||||
is_project_file,
|
|
||||||
is_c_header,
|
|
||||||
is_py,
|
|
||||||
cmake_advanced_info,
|
|
||||||
cmake_compiler_defines,
|
|
||||||
project_name_get,
|
|
||||||
)
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def quote_define(define):
|
def quote_define(define):
|
||||||
@@ -56,6 +42,19 @@ def quote_define(define):
|
|||||||
|
|
||||||
|
|
||||||
def create_qtc_project_main(name):
|
def create_qtc_project_main(name):
|
||||||
|
from project_info import (
|
||||||
|
SIMPLE_PROJECTFILE,
|
||||||
|
SOURCE_DIR,
|
||||||
|
# CMAKE_DIR,
|
||||||
|
PROJECT_DIR,
|
||||||
|
source_list,
|
||||||
|
is_project_file,
|
||||||
|
is_c_header,
|
||||||
|
cmake_advanced_info,
|
||||||
|
cmake_compiler_defines,
|
||||||
|
project_name_get,
|
||||||
|
)
|
||||||
|
|
||||||
files = list(source_list(SOURCE_DIR, filename_check=is_project_file))
|
files = list(source_list(SOURCE_DIR, filename_check=is_project_file))
|
||||||
files_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files]
|
files_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files]
|
||||||
files_rel.sort()
|
files_rel.sort()
|
||||||
@@ -116,7 +115,7 @@ def create_qtc_project_main(name):
|
|||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
defines_final = [("#define %s %s" % (item[0], quote_define(item[1]))) for item in defines]
|
defines_final = [("#define %s %s" % (item[0], quote_define(item[1]))) for item in defines]
|
||||||
if sys.platform != "win32":
|
if os.name != "nt":
|
||||||
defines_final += cmake_compiler_defines()
|
defines_final += cmake_compiler_defines()
|
||||||
f.write("\n".join(defines_final))
|
f.write("\n".join(defines_final))
|
||||||
|
|
||||||
@@ -125,6 +124,15 @@ def create_qtc_project_main(name):
|
|||||||
|
|
||||||
|
|
||||||
def create_qtc_project_python(name):
|
def create_qtc_project_python(name):
|
||||||
|
from project_info import (
|
||||||
|
SOURCE_DIR,
|
||||||
|
# CMAKE_DIR,
|
||||||
|
PROJECT_DIR,
|
||||||
|
source_list,
|
||||||
|
is_py,
|
||||||
|
project_name_get,
|
||||||
|
)
|
||||||
|
|
||||||
files = list(source_list(SOURCE_DIR, filename_check=is_py))
|
files = list(source_list(SOURCE_DIR, filename_check=is_py))
|
||||||
files_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files]
|
files_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files]
|
||||||
files_rel.sort()
|
files_rel.sort()
|
||||||
@@ -161,6 +169,15 @@ def argparse_create():
|
|||||||
dest="name",
|
dest="name",
|
||||||
metavar='NAME', type=str,
|
metavar='NAME', type=str,
|
||||||
help="Override default project name (\"Blender\")",
|
help="Override default project name (\"Blender\")",
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"-b", "--build-dir",
|
||||||
|
dest="build_dir",
|
||||||
|
metavar='BUILD_DIR', type=str,
|
||||||
|
help="Specify the build path (or fallback to the $PWD)",
|
||||||
|
required=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
@@ -171,6 +188,10 @@ def main():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
name = args.name
|
name = args.name
|
||||||
|
|
||||||
|
import project_info
|
||||||
|
if not project_info.init(args.build_dir):
|
||||||
|
return
|
||||||
|
|
||||||
create_qtc_project_main(name)
|
create_qtc_project_main(name)
|
||||||
create_qtc_project_python(name)
|
create_qtc_project_python(name)
|
||||||
|
|
||||||
|
@@ -23,11 +23,9 @@
|
|||||||
# <pep8 compliant>
|
# <pep8 compliant>
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Example Win32 usage:
|
Module for accessing project file data for Blender.
|
||||||
c:\Python32\python.exe c:\blender_dev\blender\build_files\cmake\cmake_qtcreator_project.py c:\blender_dev\cmake_build
|
|
||||||
|
|
||||||
Example Linux usage:
|
Before use, call init(cmake_build_dir).
|
||||||
python ~/blenderSVN/blender/build_files/cmake/cmake_qtcreator_project.py ~/blenderSVN/cmake
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@@ -42,6 +40,7 @@ __all__ = (
|
|||||||
"cmake_advanced_info",
|
"cmake_advanced_info",
|
||||||
"cmake_compiler_defines",
|
"cmake_compiler_defines",
|
||||||
"project_name_get"
|
"project_name_get"
|
||||||
|
"init",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -61,19 +60,26 @@ SOURCE_DIR = abspath(SOURCE_DIR)
|
|||||||
|
|
||||||
SIMPLE_PROJECTFILE = False
|
SIMPLE_PROJECTFILE = False
|
||||||
|
|
||||||
# get cmake path
|
# must initialize from 'init'
|
||||||
CMAKE_DIR = sys.argv[-1]
|
CMAKE_DIR = None
|
||||||
|
|
||||||
if not exists(join(CMAKE_DIR, "CMakeCache.txt")):
|
|
||||||
CMAKE_DIR = os.getcwd()
|
|
||||||
if not exists(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.
|
def init(cmake_path):
|
||||||
# PROJECT_DIR = SOURCE_DIR
|
global CMAKE_DIR, PROJECT_DIR
|
||||||
PROJECT_DIR = CMAKE_DIR
|
|
||||||
|
# get cmake path
|
||||||
|
cmake_path = cmake_path or ""
|
||||||
|
|
||||||
|
if (not cmake_path) or (not exists(join(cmake_path, "CMakeCache.txt"))):
|
||||||
|
cmake_path = os.getcwd()
|
||||||
|
if not exists(join(cmake_path, "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_path, os.getcwd()))
|
||||||
|
return False
|
||||||
|
|
||||||
|
PROJECT_DIR = CMAKE_DIR = cmake_path
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def source_list(path, filename_check=None):
|
def source_list(path, filename_check=None):
|
||||||
|
Reference in New Issue
Block a user