|
@@ -102,6 +102,75 @@ env_mono = conf.Finish()
|
|
|
import os
|
|
|
|
|
|
|
|
|
+def find_nuget_unix():
|
|
|
+ import os.path
|
|
|
+ import sys
|
|
|
+
|
|
|
+ hint_dirs = ['/opt/novell/mono/bin']
|
|
|
+ if sys.platform == 'darwin':
|
|
|
+ hint_dirs = ['/Library/Frameworks/Mono.framework/Versions/Current/bin', '/usr/local/var/homebrew/linked/mono/bin'] + hint_dirs
|
|
|
+
|
|
|
+ for hint_dir in hint_dirs:
|
|
|
+ hint_path = os.path.join(hint_dir, 'nuget')
|
|
|
+ if os.path.isfile(hint_path):
|
|
|
+ return hint_path
|
|
|
+ elif os.path.isfile(hint_path + '.exe'):
|
|
|
+ return hint_path + '.exe'
|
|
|
+
|
|
|
+ for hint_dir in os.environ['PATH'].split(os.pathsep):
|
|
|
+ hint_dir = hint_dir.strip('"')
|
|
|
+ hint_path = os.path.join(hint_dir, 'nuget')
|
|
|
+ if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
|
|
|
+ return hint_path
|
|
|
+ if os.path.isfile(hint_path + '.exe') and os.access(hint_path + '.exe', os.X_OK):
|
|
|
+ return hint_path + '.exe'
|
|
|
+
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
+def find_nuget_windows():
|
|
|
+ import mono_reg_utils as monoreg
|
|
|
+
|
|
|
+ mono_root = ''
|
|
|
+ bits = env['bits']
|
|
|
+
|
|
|
+ if bits == '32':
|
|
|
+ if os.getenv('MONO32_PREFIX'):
|
|
|
+ mono_root = os.getenv('MONO32_PREFIX')
|
|
|
+ else:
|
|
|
+ mono_root = monoreg.find_mono_root_dir(bits)
|
|
|
+ else:
|
|
|
+ if os.getenv('MONO64_PREFIX'):
|
|
|
+ mono_root = os.getenv('MONO64_PREFIX')
|
|
|
+ else:
|
|
|
+ mono_root = monoreg.find_mono_root_dir(bits)
|
|
|
+
|
|
|
+ if mono_root:
|
|
|
+ mono_bin_dir = os.path.join(mono_root, 'bin')
|
|
|
+ nuget_mono = os.path.join(mono_bin_dir, 'nuget.bat')
|
|
|
+
|
|
|
+ if os.path.isfile(nuget_mono):
|
|
|
+ return nuget_mono
|
|
|
+
|
|
|
+ # Standalone NuGet
|
|
|
+
|
|
|
+ for hint_dir in os.environ['PATH'].split(os.pathsep):
|
|
|
+ hint_dir = hint_dir.strip('"')
|
|
|
+ hint_path = os.path.join(hint_dir, 'nuget.exe')
|
|
|
+ if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
|
|
|
+ return hint_path
|
|
|
+
|
|
|
+ if 'NUGET_PATH' in os.environ:
|
|
|
+ hint_path = os.environ['NUGET_PATH']
|
|
|
+ if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
|
|
|
+ return hint_path
|
|
|
+ hint_path = os.path.join(hint_path, 'nuget.exe')
|
|
|
+ if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
|
|
|
+ return hint_path
|
|
|
+
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
def find_msbuild_unix(filename):
|
|
|
import os.path
|
|
|
import sys
|
|
@@ -176,14 +245,17 @@ def mono_build_solution(source, target, env):
|
|
|
import mono_reg_utils as monoreg
|
|
|
from shutil import copyfile
|
|
|
|
|
|
- framework_path = ''
|
|
|
+ sln_path = os.path.abspath(str(source[0]))
|
|
|
+ target_path = os.path.abspath(str(target[0]))
|
|
|
|
|
|
+ framework_path = ''
|
|
|
msbuild_env = os.environ.copy()
|
|
|
|
|
|
# Needed when running from Developer Command Prompt for VS
|
|
|
if 'PLATFORM' in msbuild_env:
|
|
|
del msbuild_env['PLATFORM']
|
|
|
|
|
|
+ # Find MSBuild
|
|
|
if os.name == 'nt':
|
|
|
msbuild_info = find_msbuild_windows()
|
|
|
if msbuild_info is None:
|
|
@@ -213,11 +285,27 @@ def mono_build_solution(source, target, env):
|
|
|
|
|
|
print('MSBuild path: ' + msbuild_path)
|
|
|
|
|
|
+ # Find NuGet
|
|
|
+ nuget_path = find_nuget_windows() if os.name == 'nt' else find_nuget_unix()
|
|
|
+ if nuget_path is None:
|
|
|
+ raise RuntimeError('Cannot find NuGet executable')
|
|
|
+
|
|
|
+ print('NuGet path: ' + nuget_path)
|
|
|
+
|
|
|
+ # Do NuGet restore
|
|
|
+
|
|
|
+ try:
|
|
|
+ subprocess.check_call([nuget_path, 'restore', sln_path])
|
|
|
+ except subprocess.CalledProcessError:
|
|
|
+ raise RuntimeError('GodotSharpTools: NuGet restore failed')
|
|
|
+
|
|
|
+ # Build solution
|
|
|
+
|
|
|
build_config = 'Release'
|
|
|
|
|
|
msbuild_args = [
|
|
|
msbuild_path,
|
|
|
- os.path.abspath(str(source[0])),
|
|
|
+ sln_path,
|
|
|
'/p:Configuration=' + build_config,
|
|
|
]
|
|
|
|
|
@@ -227,20 +315,24 @@ def mono_build_solution(source, target, env):
|
|
|
try:
|
|
|
subprocess.check_call(msbuild_args, env=msbuild_env)
|
|
|
except subprocess.CalledProcessError:
|
|
|
- raise RuntimeError('GodotSharpTools build failed')
|
|
|
+ raise RuntimeError('GodotSharpTools: Build failed')
|
|
|
+
|
|
|
+ # Copy files
|
|
|
|
|
|
- src_dir = os.path.abspath(os.path.join(str(source[0]), os.pardir, 'bin', build_config))
|
|
|
- dst_dir = os.path.abspath(os.path.join(str(target[0]), os.pardir))
|
|
|
+ src_dir = os.path.abspath(os.path.join(sln_path, os.pardir, 'bin', build_config))
|
|
|
+ dst_dir = os.path.abspath(os.path.join(target_path, os.pardir))
|
|
|
+ asm_file = 'GodotSharpTools.dll'
|
|
|
|
|
|
if not os.path.isdir(dst_dir):
|
|
|
if os.path.exists(dst_dir):
|
|
|
raise RuntimeError('Target directory is a file')
|
|
|
os.makedirs(dst_dir)
|
|
|
|
|
|
- asm_file = 'GodotSharpTools.dll'
|
|
|
-
|
|
|
copyfile(os.path.join(src_dir, asm_file), os.path.join(dst_dir, asm_file))
|
|
|
|
|
|
+ # Dependencies
|
|
|
+ copyfile(os.path.join(src_dir, "DotNet.Glob.dll"), os.path.join(dst_dir, "DotNet.Glob.dll"))
|
|
|
+
|
|
|
if env['tools']:
|
|
|
output_dir = Dir('#bin').abspath
|
|
|
editor_tools_dir = os.path.join(output_dir, 'GodotSharp', 'Tools')
|