Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-12-27 09:09:29 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-12-27 09:11:44 +0300
commit0cc98f9023d9d1d030959df5d7b67b01bbbbe618 (patch)
tree2843ce4da766d811ac1d32c2180ed379cd1278b4 /build_files/cmake
parent700c40e2f9b59b7e780429fdc10fb0d2d5d117a1 (diff)
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.
Diffstat (limited to 'build_files/cmake')
-rwxr-xr-xbuild_files/cmake/cmake_netbeans_project.py7
-rwxr-xr-xbuild_files/cmake/cmake_qtcreator_project.py55
-rwxr-xr-xbuild_files/cmake/project_info.py34
3 files changed, 65 insertions, 31 deletions
diff --git a/build_files/cmake/cmake_netbeans_project.py b/build_files/cmake/cmake_netbeans_project.py
index 9ff9d85504a..d57bce770b4 100755
--- a/build_files/cmake/cmake_netbeans_project.py
+++ b/build_files/cmake/cmake_netbeans_project.py
@@ -29,6 +29,13 @@ Example linux usage
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 (
SIMPLE_PROJECTFILE,
SOURCE_DIR,
diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py
index 55471f8ecc7..9c0a02a7a0c 100755
--- a/build_files/cmake/cmake_qtcreator_project.py
+++ b/build_files/cmake/cmake_qtcreator_project.py
@@ -24,28 +24,14 @@
r"""
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:
- 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 sys
def quote_define(define):
@@ -56,6 +42,19 @@ def quote_define(define):
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_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files]
files_rel.sort()
@@ -116,7 +115,7 @@ def create_qtc_project_main(name):
f.write("\n")
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()
f.write("\n".join(defines_final))
@@ -125,6 +124,15 @@ def create_qtc_project_main(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_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files]
files_rel.sort()
@@ -161,6 +169,15 @@ def argparse_create():
dest="name",
metavar='NAME', type=str,
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
@@ -171,6 +188,10 @@ def main():
args = parser.parse_args()
name = args.name
+ import project_info
+ if not project_info.init(args.build_dir):
+ return
+
create_qtc_project_main(name)
create_qtc_project_python(name)
diff --git a/build_files/cmake/project_info.py b/build_files/cmake/project_info.py
index c9ea2497987..cfcd9df65c8 100755
--- a/build_files/cmake/project_info.py
+++ b/build_files/cmake/project_info.py
@@ -23,11 +23,9 @@
# <pep8 compliant>
"""
-Example Win32 usage:
- c:\Python32\python.exe c:\blender_dev\blender\build_files\cmake\cmake_qtcreator_project.py c:\blender_dev\cmake_build
+Module for accessing project file data for Blender.
-Example Linux usage:
- python ~/blenderSVN/blender/build_files/cmake/cmake_qtcreator_project.py ~/blenderSVN/cmake
+Before use, call init(cmake_build_dir).
"""
__all__ = (
@@ -42,6 +40,7 @@ __all__ = (
"cmake_advanced_info",
"cmake_compiler_defines",
"project_name_get"
+ "init",
)
@@ -61,19 +60,26 @@ SOURCE_DIR = abspath(SOURCE_DIR)
SIMPLE_PROJECTFILE = False
-# get cmake path
-CMAKE_DIR = sys.argv[-1]
+# must initialize from 'init'
+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)
+def init(cmake_path):
+ global CMAKE_DIR, PROJECT_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
-# could be either.
-# PROJECT_DIR = SOURCE_DIR
-PROJECT_DIR = CMAKE_DIR
+ PROJECT_DIR = CMAKE_DIR = cmake_path
+ return True
def source_list(path, filename_check=None):