diff options
-rw-r--r-- | .github/workflows/ci.yml | 8 | ||||
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | SConstruct | 26 |
3 files changed, 33 insertions, 14 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e67b700..129afd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: scons target=release generate_bindings=yes -j $(nproc) - name: Upload artifact - uses: actions/upload-artifact@v2.2.1 + uses: actions/upload-artifact@v2.2.2 with: name: godot-cpp-linux-glibc2.23-x86_64-release path: bin/libgodot-cpp.linux.release.64.a @@ -66,7 +66,7 @@ jobs: scons target=release generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS - name: Upload artifact - uses: actions/upload-artifact@v2.2.1 + uses: actions/upload-artifact@v2.2.2 with: name: godot-cpp-windows-msvc2019-x86_64-release path: bin/libgodot-cpp.windows.release.64.lib @@ -100,7 +100,7 @@ jobs: scons target=release generate_bindings=yes use_mingw=yes -j $env:NUMBER_OF_PROCESSORS - name: Upload artifact - uses: actions/upload-artifact@v2.2.1 + uses: actions/upload-artifact@v2.2.2 with: name: godot-cpp-linux-mingw-x86_64-release path: bin/libgodot-cpp.windows.release.64.a @@ -131,7 +131,7 @@ jobs: scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu) - name: Upload artifact - uses: actions/upload-artifact@v2.2.1 + uses: actions/upload-artifact@v2.2.2 with: name: godot-cpp-macos-x86_64-release path: bin/libgodot-cpp.osx.release.64.a diff --git a/CMakeLists.txt b/CMakeLists.txt index f48b5b3..773cbf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,8 @@ project(godot-cpp) cmake_minimum_required(VERSION 3.6) +option(GENERATE_TEMPLATE_GET_NODE "Generate a template version of the Node class's get_node." ON) + # Change the output directory to the bin directory set(BUILD_PATH ${CMAKE_SOURCE_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_PATH}") @@ -109,7 +111,7 @@ else() set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wchar-subscripts -Wcomment -Wdisabled-optimization") set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wformat -Wformat=2 -Wformat-security -Wformat-y2k") set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wimport -Winit-self -Winline -Winvalid-pch -Werror") - set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wlong-long -Wmissing-braces -Wmissing-format-attribute") + set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wmissing-braces -Wmissing-format-attribute") set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpointer-arith") set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wredundant-decls -Wreturn-type -Wsequence-point") set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wswitch -Wswitch-enum -Wtrigraphs") @@ -131,8 +133,15 @@ else() endif() # Generate source from the bindings file +find_package(PythonInterp REQUIRED) +if(GENERATE_TEMPLATE_GET_NODE) + set(GENERATE_BINDING_PARAMETERS "True") +else() + set(GENERATE_BINDING_PARAMETERS "False") +endif() + message(STATUS "Generating Bindings") -execute_process(COMMAND "python" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_CUSTOM_API_FILE}\")" +execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_CUSTOM_API_FILE}\", ${GENERATE_BINDING_PARAMETERS})" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE GENERATION_RESULT OUTPUT_VARIABLE GENERATION_OUTPUT) @@ -58,6 +58,8 @@ def add_sources(sources, dir, extension): # This is used if no `platform` argument is passed if sys.platform.startswith('linux'): host_platform = 'linux' +elif sys.platform.startswith('freebsd'): + host_platform = 'freebsd' elif sys.platform == 'darwin': host_platform = 'osx' elif sys.platform == 'win32' or sys.platform == 'msys': @@ -84,7 +86,7 @@ opts.Add(EnumVariable( 'platform', 'Target platform', host_platform, - allowed_values=('linux', 'osx', 'windows', 'android', 'ios'), + allowed_values=('linux', 'freebsd', 'osx', 'windows', 'android', 'ios'), ignorecase=2 )) opts.Add(EnumVariable( @@ -95,7 +97,7 @@ opts.Add(EnumVariable( )) opts.Add(BoolVariable( 'use_llvm', - 'Use the LLVM compiler - only effective when targeting Linux', + 'Use the LLVM compiler - only effective when targeting Linux or FreeBSD', False )) opts.Add(BoolVariable( @@ -123,10 +125,12 @@ opts.Add(PathVariable( None, PathVariable.PathIsFile )) -opts.Add(BoolVariable( +opts.Add(EnumVariable( 'generate_bindings', 'Generate GDNative API bindings', - False + 'auto', + allowed_values = ['yes', 'no', 'auto', 'true'], + ignorecase = 2 )) opts.Add(EnumVariable( 'android_arch', @@ -185,7 +189,7 @@ if host_platform == 'windows' and env['platform'] != 'android': opts.Update(env) -if env['platform'] == 'linux': +if env['platform'] == 'linux' or env['platform'] == 'freebsd': if env['use_llvm']: env['CXX'] = 'clang++' @@ -278,7 +282,7 @@ elif env['platform'] == 'windows': elif env['target'] == 'release': env.Append(CCFLAGS=['/O2', '/EHsc', '/DNDEBUG', '/MD']) - elif host_platform == 'linux' or host_platform == 'osx': + elif host_platform == 'linux' or host_platform == 'freebsd' or host_platform == 'osx': # Cross-compilation using MinGW if env['bits'] == '64': env['CXX'] = 'x86_64-w64-mingw32-g++' @@ -300,7 +304,7 @@ elif env['platform'] == 'windows': env["SPAWN"] = mySpawn # Native or cross-compilation using MinGW - if host_platform == 'linux' or host_platform == 'osx' or env['use_mingw']: + if host_platform == 'linux' or host_platform == 'freebsd' or host_platform == 'osx' or env['use_mingw']: # These options are for a release build even using target=debug env.Append(CCFLAGS=['-O3', '-std=c++14', '-Wwrite-strings']) env.Append(LINKFLAGS=[ @@ -387,7 +391,13 @@ if 'custom_api_file' in env: else: json_api_file = os.path.join(os.getcwd(), env['headers_dir'], 'api.json') -if env['generate_bindings']: +if env['generate_bindings'] == 'auto': + # Check if generated files exist + should_generate_bindings = not os.path.isfile(os.path.join(os.getcwd(), 'src', 'gen', 'Object.cpp')) +else: + should_generate_bindings = env['generate_bindings'] in ['yes', 'true'] + +if should_generate_bindings: # Actually create the bindings here import binding_generator |