2017-03-06 02:30:46 +00:00
|
|
|
#!python
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
import os, subprocess, platform
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
|
|
|
|
def add_sources(sources, dir, extension):
|
|
|
|
for f in os.listdir(dir):
|
|
|
|
if f.endswith('.' + extension):
|
|
|
|
sources.append(dir + '/' + f)
|
|
|
|
|
|
|
|
|
|
|
|
env = Environment()
|
|
|
|
host_platform = platform.system()
|
|
|
|
target_platform = ARGUMENTS.get('p', ARGUMENTS.get('platform', 'linux'))
|
|
|
|
target_arch = ARGUMENTS.get('a', ARGUMENTS.get('arch', '64'))
|
|
|
|
# default to debug build, must be same setting as used for cpp_bindings
|
|
|
|
target = ARGUMENTS.get('target', 'debug')
|
2017-04-18 00:16:57 +00:00
|
|
|
# Local dependency paths, adapt them to your setup
|
2018-05-16 00:05:41 +00:00
|
|
|
godot_headers = ARGUMENTS.get('headers', 'godot_headers')
|
2018-02-25 15:25:42 +00:00
|
|
|
result_path = 'bin'
|
2018-02-22 22:16:25 +00:00
|
|
|
result_name = ARGUMENTS.get('n', ARGUMENTS.get('name', os.path.relpath('.', '..')))
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2017-07-29 12:25:57 +00:00
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
if target_platform == 'linux':
|
|
|
|
result_name += '.linux.' + target_arch
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2018-05-13 12:39:32 +00:00
|
|
|
env['CXX']='g++'
|
2018-02-25 16:03:55 +00:00
|
|
|
if ARGUMENTS.get('use_llvm', 'no') == 'yes':
|
|
|
|
env['CXX'] = 'clang++'
|
|
|
|
|
2018-05-13 13:17:49 +00:00
|
|
|
env.Append(CCFLAGS = [ '-fPIC', '-g', '-Og', '-std=c++14', '-Wwrite-strings' ])
|
2018-02-22 22:16:25 +00:00
|
|
|
env.Append(LINKFLAGS = [ '-Wl,-R,\'$$ORIGIN\'' ])
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2018-05-16 11:25:53 +00:00
|
|
|
if target == 'debug':
|
|
|
|
env.Append(CCFLAGS = ['-Og'])
|
|
|
|
else:
|
|
|
|
env.Append(CCFLAGS = ['-O3'])
|
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
if target_arch == '32':
|
|
|
|
env.Append(CCFLAGS = [ '-m32' ])
|
|
|
|
env.Append(LINKFLAGS = [ '-m32' ])
|
|
|
|
elif target_arch == '64':
|
|
|
|
env.Append(CCFLAGS = [ '-m64' ])
|
|
|
|
env.Append(LINKFLAGS = [ '-m64' ])
|
2017-06-16 13:50:48 +00:00
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
elif target_platform == 'windows':
|
2018-03-05 16:28:49 +00:00
|
|
|
# This makes sure to keep the session environment variables on windows,
|
|
|
|
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
|
|
|
if (target_arch == '64'):
|
|
|
|
env = Environment(ENV = os.environ, TARGET_ARCH='amd64')
|
|
|
|
else:
|
|
|
|
env = Environment(ENV = os.environ, TARGET_ARCH='x86')
|
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
result_name += '.windows.' + target_arch
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
if host_platform == 'Windows':
|
2018-02-25 15:25:42 +00:00
|
|
|
result_name += '.lib'
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
env.Append(LINKFLAGS = [ '/WX' ])
|
|
|
|
if target == 'debug':
|
2018-03-05 16:28:49 +00:00
|
|
|
env.Append(CCFLAGS = ['/EHsc', '/D_DEBUG', '/MDd' ])
|
2018-02-22 22:16:25 +00:00
|
|
|
else:
|
2018-03-05 16:28:49 +00:00
|
|
|
env.Append(CCFLAGS = ['/O2', '/EHsc', '/DNDEBUG', '/MD' ])
|
2017-07-30 12:22:30 +00:00
|
|
|
else:
|
2018-02-22 22:16:25 +00:00
|
|
|
if target_arch == '32':
|
|
|
|
env['CXX']='i686-w64-mingw32-g++'
|
|
|
|
elif target_arch == '64':
|
|
|
|
env['CXX']='x86_64-w64-mingw32-g++'
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
env.Append(CCFLAGS = [ '-g', '-O3', '-std=c++14', '-Wwrite-strings' ])
|
|
|
|
env.Append(LINKFLAGS = [ '--static', '-Wl,--no-undefined', '-static-libgcc', '-static-libstdc++' ])
|
|
|
|
|
2018-03-01 23:30:55 +00:00
|
|
|
elif target_platform == 'osx':
|
2018-02-25 16:03:55 +00:00
|
|
|
if ARGUMENTS.get('use_llvm', 'no') == 'yes':
|
|
|
|
env['CXX'] = 'clang++'
|
|
|
|
|
2018-04-08 16:00:54 +00:00
|
|
|
# Only 64-bits is supported for OS X
|
|
|
|
target_arch = '64'
|
|
|
|
result_name += '.osx.' + target_arch
|
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
env.Append(CCFLAGS = [ '-g','-O3', '-std=c++14', '-arch', 'x86_64' ])
|
|
|
|
env.Append(LINKFLAGS = [ '-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup' ])
|
2017-04-18 00:41:39 +00:00
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
|
2018-03-11 10:43:06 +00:00
|
|
|
env.Append(CPPPATH=['.', godot_headers, 'include', 'include/gen', 'include/core'])
|
2018-02-22 22:16:25 +00:00
|
|
|
|
2018-05-16 00:05:41 +00:00
|
|
|
# Generate bindings?
|
|
|
|
json_api_file = ''
|
2018-02-22 22:16:25 +00:00
|
|
|
|
2018-05-13 12:39:32 +00:00
|
|
|
# Generate bindings?
|
|
|
|
json_api_file = ''
|
|
|
|
|
2018-05-16 00:05:41 +00:00
|
|
|
if ARGUMENTS.get('use_custom_api_file', 'no') == 'yes':
|
|
|
|
json_api_file = ARGUMENTS.get('custom_api_file', '')
|
|
|
|
else:
|
2018-05-13 12:39:32 +00:00
|
|
|
json_api_file = os.path.join(os.getcwd(), 'godot_headers', 'api.json')
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2018-05-16 00:05:41 +00:00
|
|
|
if ARGUMENTS.get('generate_bindings', 'no') == 'yes':
|
2017-07-23 15:53:50 +00:00
|
|
|
# actually create the bindings here
|
|
|
|
|
|
|
|
import binding_generator
|
2017-04-18 00:16:57 +00:00
|
|
|
|
2017-07-23 15:53:50 +00:00
|
|
|
binding_generator.generate_bindings(json_api_file)
|
2017-03-06 07:49:24 +00:00
|
|
|
|
2018-05-13 12:39:32 +00:00
|
|
|
|
|
|
|
# source to compile
|
2018-02-22 22:16:25 +00:00
|
|
|
sources = []
|
|
|
|
add_sources(sources, 'src/core', 'cpp')
|
2018-03-11 10:43:06 +00:00
|
|
|
add_sources(sources, 'src/gen', 'cpp')
|
2017-03-06 02:30:46 +00:00
|
|
|
|
2018-02-22 22:16:25 +00:00
|
|
|
|
|
|
|
library = env.StaticLibrary(target=result_path + '/' + result_name, source=sources)
|
|
|
|
Default(library)
|