From 0c448d94e9f5e4465e25302ec6963a4f5fb2a977 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 13 Aug 2020 20:59:39 -0500 Subject: [PATCH 1/4] Add formatting scripts for GitHub Actions These are from the main repo, but simplified. Also add FUNDING.yml --- .clang-format | 128 ++++++++++++++++++++++ .github/FUNDING.yml | 2 + .github/workflows/scripts/black_format.sh | 32 ++++++ .github/workflows/scripts/clang_format.sh | 37 +++++++ .github/workflows/scripts/file_format.sh | 57 ++++++++++ .github/workflows/static_checks.yml | 28 +++++ 6 files changed, 284 insertions(+) create mode 100644 .clang-format create mode 100644 .github/FUNDING.yml create mode 100755 .github/workflows/scripts/black_format.sh create mode 100755 .github/workflows/scripts/clang_format.sh create mode 100755 .github/workflows/scripts/file_format.sh create mode 100644 .github/workflows/static_checks.yml diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..1c26421 --- /dev/null +++ b/.clang-format @@ -0,0 +1,128 @@ +# Commented out parameters are those with the same value as base LLVM style +# We can uncomment them if we want to change their value, or enforce the +# chosen value in case the base style changes (last sync: Clang 6.0.1). +--- +### General config, applies to all languages ### +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +# AlignConsecutiveAssignments: false +# AlignConsecutiveDeclarations: false +# AlignEscapedNewlines: Right +# AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +# AllowShortBlocksOnASingleLine: false +# AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +# AllowShortIfStatementsOnASingleLine: false +# AllowShortLoopsOnASingleLine: false +# AlwaysBreakAfterDefinitionReturnType: None +# AlwaysBreakAfterReturnType: None +# AlwaysBreakBeforeMultilineStrings: false +# AlwaysBreakTemplateDeclarations: false +# BinPackArguments: true +# BinPackParameters: true +# BraceWrapping: +# AfterClass: false +# AfterControlStatement: false +# AfterEnum: false +# AfterFunction: false +# AfterNamespace: false +# AfterObjCDeclaration: false +# AfterStruct: false +# AfterUnion: false +# AfterExternBlock: false +# BeforeCatch: false +# BeforeElse: false +# IndentBraces: false +# SplitEmptyFunction: true +# SplitEmptyRecord: true +# SplitEmptyNamespace: true +# BreakBeforeBinaryOperators: None +# BreakBeforeBraces: Attach +# BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: false +# BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: AfterColon +# BreakStringLiterals: true +ColumnLimit: 0 +# CommentPragmas: '^ IWYU pragma:' +# CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +Cpp11BracedListStyle: false +# DerivePointerAlignment: false +# DisableFormat: false +# ExperimentalAutoDetectBinPacking: false +# FixNamespaceComments: true +# ForEachMacros: +# - foreach +# - Q_FOREACH +# - BOOST_FOREACH +# IncludeBlocks: Preserve +IncludeCategories: + - Regex: '".*"' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 2 + - Regex: '^<.*' + Priority: 3 +# IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: true +# IndentPPDirectives: None +IndentWidth: 4 +# IndentWrappedFunctionNames: false +# JavaScriptQuotes: Leave +# JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +# MacroBlockBegin: '' +# MacroBlockEnd: '' +# MaxEmptyLinesToKeep: 1 +# NamespaceIndentation: None +# PenaltyBreakAssignment: 2 +# PenaltyBreakBeforeFirstCallParameter: 19 +# PenaltyBreakComment: 300 +# PenaltyBreakFirstLessLess: 120 +# PenaltyBreakString: 1000 +# PenaltyExcessCharacter: 1000000 +# PenaltyReturnTypeOnItsOwnLine: 60 +# PointerAlignment: Right +# RawStringFormats: +# - Delimiter: pb +# Language: TextProto +# BasedOnStyle: google +# ReflowComments: true +# SortIncludes: true +# SortUsingDeclarations: true +# SpaceAfterCStyleCast: false +# SpaceAfterTemplateKeyword: true +# SpaceBeforeAssignmentOperators: true +# SpaceBeforeParens: ControlStatements +# SpaceInEmptyParentheses: false +# SpacesBeforeTrailingComments: 1 +# SpacesInAngles: false +# SpacesInContainerLiterals: true +# SpacesInCStyleCastParentheses: false +# SpacesInParentheses: false +# SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Always +--- +### C++ specific config ### +Language: Cpp +Standard: Cpp11 +--- +### ObjC specific config ### +Language: ObjC +Standard: Cpp11 +ObjCBlockIndentWidth: 4 +# ObjCSpaceAfterProperty: false +# ObjCSpaceBeforeProtocolList: true +--- +### Java specific config ### +Language: Java +# BreakAfterJavaFieldAnnotations: false +JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax'] +... diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..0820ab1 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +patreon: godotengine +custom: https://godotengine.org/donate diff --git a/.github/workflows/scripts/black_format.sh b/.github/workflows/scripts/black_format.sh new file mode 100755 index 0000000..fd3438d --- /dev/null +++ b/.github/workflows/scripts/black_format.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# This script runs black on all Python files in the repo. + +set -uo pipefail + +# Apply black. +echo -e "Formatting Python files..." +PY_FILES=$(find \( -path "./.git" \ + \) -prune \ + -o \( -name "SConstruct" \ + -o -name "SCsub" \ + -o -name "*.py" \ + \) -print) +black -l 120 $PY_FILES + +git diff > patch.patch + +# If no patch has been generated all is OK, clean up, and exit. +if [ ! -s patch.patch ] ; then + printf "Files in this commit comply with the black style rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 diff --git a/.github/workflows/scripts/clang_format.sh b/.github/workflows/scripts/clang_format.sh new file mode 100755 index 0000000..4d2acda --- /dev/null +++ b/.github/workflows/scripts/clang_format.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# This script runs clang-format on all relevant files in the repo. +# This is the primary script responsible for fixing style violations. + +set -uo pipefail +IFS=$'\n\t' + +CLANG_FORMAT_FILE_EXTS=(".c" ".h" ".cpp" ".hpp" ".cc" ".hh" ".cxx" ".m" ".mm" ".inc" ".java" ".glsl") + +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do + for extension in ${CLANG_FORMAT_FILE_EXTS[@]}; do + if [[ "$f" == *"$extension" ]]; then + # Run clang-format. + clang-format -i "$f" + fi + done +done + +git diff > patch.patch + +# If no patch has been generated all is OK, clean up, and exit. +if [ ! -s patch.patch ] ; then + printf "Files in this commit comply with the clang-format style rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 diff --git a/.github/workflows/scripts/file_format.sh b/.github/workflows/scripts/file_format.sh new file mode 100755 index 0000000..d25aa02 --- /dev/null +++ b/.github/workflows/scripts/file_format.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# This script ensures proper POSIX text file formatting and a few other things. +# This is supplementary to clang_format.sh and black_format.sh, but should be +# run before them. + +# We need dos2unix and recode. +if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v recode)" ]; then + printf "Install 'dos2unix' and 'recode' to use this script.\n" +fi + +set -uo pipefail +IFS=$'\n\t' + +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do + # Ensure that files are UTF-8 formatted. + recode UTF-8 "$f" 2> /dev/null + # Ensure that files have LF line endings and do not contain a BOM. + dos2unix "$f" 2> /dev/null + # Remove trailing space characters and ensures that files end + # with newline characters. -l option handles newlines conveniently. + perl -i -ple 's/\s*$//g' "$f" + # Remove the character sequence "== true" if it has a leading space. + perl -i -pe 's/\x20== true//g' "$f" + + # We don't want to change lines around braces in godot/tscn files. + if [[ "$f" == *"godot" ]]; then + continue + elif [[ "$f" == *"tscn" ]]; then + continue + fi + if [[ $(uname) == "Linux" ]] && [[ "$f" != *"xml" ]]; then + # Remove empty lines after the opening brace of indented blocks. + sed -z -i 's/\x7B\x0A\x0A\x09/\x7B\x0A\x09/g' "$f" + # Remove empty lines before the closing brace (in some cases). + sed -z -i 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f" + fi +done + +git diff > patch.patch + +# If no patch has been generated all is OK, clean up, and exit. +if [ ! -s patch.patch ] ; then + printf "Files in this commit comply with the formatting rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml new file mode 100644 index 0000000..9afc37b --- /dev/null +++ b/.github/workflows/static_checks.yml @@ -0,0 +1,28 @@ +name: Static Checks +on: [push, pull_request] + +jobs: + static-checks: + name: Formatting (clang-format, black format, file format) + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -qq dos2unix recode clang-format + sudo pip3 install git+https://github.com/psf/black@master + + - name: File formatting checks (file_format.sh) + run: | + bash ./.github/workflows/scripts/file_format.sh + + - name: C/C++ style checks via clang-format (clang_format.sh) + run: | + bash ./.github/workflows/scripts/clang_format.sh + + - name: Python style checks via black (black_format.sh) + run: | + bash ./.github/workflows/scripts/black_format.sh From 32cfbfd88acd05d417e0cd9ee17978029ae6e431 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 13 Aug 2020 20:53:31 -0500 Subject: [PATCH 2/4] Commit files changed by file_format.sh --- Readme.md | 2 +- c/GLFWDemo/Main.tscn | 6 +++--- c/InstanceBindingDemo/SConstruct | 2 +- c/InstanceBindingDemo/main.gd | 4 ++-- c/InstanceBindingDemo/src/instance_binding_demo.c | 1 - c/SimpleDemo/src/simple.c | 4 ++-- cpp/SimpleDemo/SConstruct | 4 ++-- cpp/SimpleDemo/main.gd | 2 +- cpp/SimpleDemo/src/Simple.hpp | 2 +- cpp/cpp_constructors/SConstruct | 4 ++-- cpp/cpp_constructors/src/TestClass.hpp | 3 +-- cpp/kinematic_character/README.md | 2 +- cpp/kinematic_character/Script/SConstruct | 4 ++-- cpp/kinematic_character/Script/bin/libkinematic_char.gdnlib | 2 +- cpp/kinematic_character/Script/src/common.cpp | 1 - 15 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Readme.md b/Readme.md index d9cbcaa..a7fab7d 100644 --- a/Readme.md +++ b/Readme.md @@ -10,7 +10,7 @@ git clone --recursive https://github.com/GodotNativeTools/godot-cpp ### Updating the api.json -Our api.json file contains meta data of all the classes that are part of the Godot core and are needed to generate the C++ binding classes for use in GDNative modules. +Our api.json file contains meta data of all the classes that are part of the Godot core and are needed to generate the C++ binding classes for use in GDNative modules. This file is supplied with our godot_headers repository for your convinience but if you are running a custom build of Godot and need access to classes that have recent changes a new api.json file must be generated. You do this by starting your Godot executable with the following parameters: diff --git a/c/GLFWDemo/Main.tscn b/c/GLFWDemo/Main.tscn index b45235d..0211a1b 100644 --- a/c/GLFWDemo/Main.tscn +++ b/c/GLFWDemo/Main.tscn @@ -9,12 +9,12 @@ onready var window = preload(\"res://GLFW.gdns\").new() func _ready(): - # create a 200x200 px window + # create a 200x200 px window window.create(200, 200, \"Hello from Godot!\") - + # connect the \"closed\" signal window.connect(\"closed\", self, \"on_window_close\") - + func on_window_close(): # the window emits a signal when the users requests # to close it. So let's close it :D diff --git a/c/InstanceBindingDemo/SConstruct b/c/InstanceBindingDemo/SConstruct index f07b1aa..76529f3 100644 --- a/c/InstanceBindingDemo/SConstruct +++ b/c/InstanceBindingDemo/SConstruct @@ -10,7 +10,7 @@ target = ARGUMENTS.get("target", "debug") platform = ARGUMENTS.get("p", "linux") platform = ARGUMENTS.get("platform", platform) -# This makes sure to keep the session environment variables on windows, +# 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 env = Environment() if platform == "windows": diff --git a/c/InstanceBindingDemo/main.gd b/c/InstanceBindingDemo/main.gd index d05d7a2..6f84ddb 100644 --- a/c/InstanceBindingDemo/main.gd +++ b/c/InstanceBindingDemo/main.gd @@ -6,5 +6,5 @@ onready var data = InstanceBindingDemo.new() func _on_Button_pressed(): # do the test here - - pass \ No newline at end of file + + pass diff --git a/c/InstanceBindingDemo/src/instance_binding_demo.c b/c/InstanceBindingDemo/src/instance_binding_demo.c index b1e16cb..b9e5b35 100644 --- a/c/InstanceBindingDemo/src/instance_binding_demo.c +++ b/c/InstanceBindingDemo/src/instance_binding_demo.c @@ -80,7 +80,6 @@ void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *optio void GDN_EXPORT godot_nativescript_init(void *handle) { - printf("nativescript_init\n"); fflush(stdout); diff --git a/c/SimpleDemo/src/simple.c b/c/SimpleDemo/src/simple.c index 9a4c880..5cba2c2 100644 --- a/c/SimpleDemo/src/simple.c +++ b/c/SimpleDemo/src/simple.c @@ -25,7 +25,7 @@ void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options) { }; break; default: break; }; - }; + }; } void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *p_options) { @@ -52,7 +52,7 @@ void GDN_EXPORT godot_nativescript_init(void *p_handle) { GDCALLINGCONV void *simple_constructor(godot_object *p_instance, void *p_method_data) { printf("SIMPLE._init()\n"); - + user_data_struct *user_data = api->godot_alloc(sizeof(user_data_struct)); strcpy(user_data->data, "World from GDNative!"); diff --git a/cpp/SimpleDemo/SConstruct b/cpp/SimpleDemo/SConstruct index 4aaa8e1..0300f6f 100644 --- a/cpp/SimpleDemo/SConstruct +++ b/cpp/SimpleDemo/SConstruct @@ -5,7 +5,7 @@ import os platform = ARGUMENTS.get("p", "linux") platform = ARGUMENTS.get("platform", platform) -# This makes sure to keep the session environment variables on windows, +# 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 env = Environment() if platform == "windows": @@ -21,7 +21,7 @@ target = ARGUMENTS.get("target", "debug") if ARGUMENTS.get("use_llvm", "no") == "yes": env["CXX"] = "clang++" -# put stuff that is the same for all first, saves duplication +# put stuff that is the same for all first, saves duplication if platform == "osx": env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-arch', 'x86_64']) env.Append(LINKFLAGS = ['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup']) diff --git a/cpp/SimpleDemo/main.gd b/cpp/SimpleDemo/main.gd index 072ebb9..5ab430d 100644 --- a/cpp/SimpleDemo/main.gd +++ b/cpp/SimpleDemo/main.gd @@ -6,4 +6,4 @@ onready var simple_instance = Simple.new() func _on_Button_pressed(): - $Label.text = "C++ code says: " + simple_instance.get_data() \ No newline at end of file + $Label.text = "C++ code says: " + simple_instance.get_data() diff --git a/cpp/SimpleDemo/src/Simple.hpp b/cpp/SimpleDemo/src/Simple.hpp index acd14b5..477a0fe 100644 --- a/cpp/SimpleDemo/src/Simple.hpp +++ b/cpp/SimpleDemo/src/Simple.hpp @@ -5,7 +5,7 @@ class Simple : public godot::Reference { GODOT_CLASS(Simple, godot::Reference) - + godot::String data; public: diff --git a/cpp/cpp_constructors/SConstruct b/cpp/cpp_constructors/SConstruct index 274bbdf..a3c1885 100644 --- a/cpp/cpp_constructors/SConstruct +++ b/cpp/cpp_constructors/SConstruct @@ -5,7 +5,7 @@ import os platform = ARGUMENTS.get("p", "linux") platform = ARGUMENTS.get("platform", platform) -# This makes sure to keep the session environment variables on windows, +# 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 env = Environment() if platform == "windows": @@ -21,7 +21,7 @@ target = ARGUMENTS.get("target", "debug") if ARGUMENTS.get("use_llvm", "no") == "yes": env["CXX"] = "clang++" -# put stuff that is the same for all first, saves duplication +# put stuff that is the same for all first, saves duplication if platform == "osx": env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-arch', 'x86_64']) env.Append(LINKFLAGS = ['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup']) diff --git a/cpp/cpp_constructors/src/TestClass.hpp b/cpp/cpp_constructors/src/TestClass.hpp index f717055..c14eb14 100644 --- a/cpp/cpp_constructors/src/TestClass.hpp +++ b/cpp/cpp_constructors/src/TestClass.hpp @@ -21,7 +21,6 @@ public: } int test_method(String s) { - Godot::print(s); count++; @@ -49,4 +48,4 @@ public: static void _register_methods() { register_method("test_method", &TestClass::test_method); } -}; +}; diff --git a/cpp/kinematic_character/README.md b/cpp/kinematic_character/README.md index 98ae68c..f588d39 100644 --- a/cpp/kinematic_character/README.md +++ b/cpp/kinematic_character/README.md @@ -1,6 +1,6 @@ # GDNative example of a kinematic character -This is a demo showing how to use GDNative together with the cpp_bindings layer to implement a couple of new nodes. +This is a demo showing how to use GDNative together with the cpp_bindings layer to implement a couple of new nodes. This demo was originally created by Ramesh Ravone. Before compiling this module you must clone https://github.com/GodotNativeTools/godot_headers and https://github.com/GodotNativeTools/godot-cpp diff --git a/cpp/kinematic_character/Script/SConstruct b/cpp/kinematic_character/Script/SConstruct index ea0e06f..1cbdf8f 100644 --- a/cpp/kinematic_character/Script/SConstruct +++ b/cpp/kinematic_character/Script/SConstruct @@ -5,7 +5,7 @@ import os platform = ARGUMENTS.get("p", "linux") platform = ARGUMENTS.get("platform", platform) -# This makes sure to keep the session environment variables on windows, +# 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 env = Environment() if platform == "windows": @@ -21,7 +21,7 @@ target = ARGUMENTS.get("target", "debug") if ARGUMENTS.get("use_llvm", "no") == "yes": env["CXX"] = "clang++" -# put stuff that is the same for all first, saves duplication +# put stuff that is the same for all first, saves duplication if platform == "osx": env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-arch', 'x86_64']) env.Append(LINKFLAGS = ['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup']) diff --git a/cpp/kinematic_character/Script/bin/libkinematic_char.gdnlib b/cpp/kinematic_character/Script/bin/libkinematic_char.gdnlib index b1a4778..a9b1be2 100644 --- a/cpp/kinematic_character/Script/bin/libkinematic_char.gdnlib +++ b/cpp/kinematic_character/Script/bin/libkinematic_char.gdnlib @@ -14,4 +14,4 @@ OSX.64="res://Script/bin/libkinematic_char.dylib" X11.64=[] Windows.64=[] -OSX.64=[] \ No newline at end of file +OSX.64=[] diff --git a/cpp/kinematic_character/Script/src/common.cpp b/cpp/kinematic_character/Script/src/common.cpp index 6db039a..0b0135d 100644 --- a/cpp/kinematic_character/Script/src/common.cpp +++ b/cpp/kinematic_character/Script/src/common.cpp @@ -30,7 +30,6 @@ extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_opt } extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) { - Godot::nativescript_init(handle); register_class(); From bba3ce54ce0816a7a9ebfb673a39ffa578b04468 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 13 Aug 2020 20:54:00 -0500 Subject: [PATCH 3/4] Commit files changed by clang_format.sh --- c/GLFWDemo/src/init.c | 68 +++++++------------ .../src/instance_binding_demo.c | 34 +++------- c/SimpleDemo/src/simple.c | 5 +- cpp/SimpleDemo/src/Simple.cpp | 18 ++--- cpp/SimpleDemo/src/Simple.hpp | 2 +- cpp/SimpleDemo/src/entry.cpp | 10 +-- cpp/cpp_constructors/src/TestClass.hpp | 4 +- cpp/cpp_constructors/src/init.cpp | 9 +-- cpp/kinematic_character/Script/src/colworld.h | 2 +- 9 files changed, 53 insertions(+), 99 deletions(-) diff --git a/c/GLFWDemo/src/init.c b/c/GLFWDemo/src/init.c index fd1387f..26b820c 100644 --- a/c/GLFWDemo/src/init.c +++ b/c/GLFWDemo/src/init.c @@ -10,8 +10,7 @@ struct glfw { const godot_gdnative_core_api_struct *api = NULL; const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL; -void window_close_callback(GLFWwindow* window) -{ +void window_close_callback(GLFWwindow *window) { godot_object *instance = glfwGetWindowUserPointer(window); // emit a signal @@ -61,25 +60,22 @@ void *glfw_constructor(godot_object *instance, void *method_data); void glfw_destructor(godot_object *instance, void *method_data, struct glfw *user_data); godot_variant glfw_create_window(godot_object *instance, void *method_data, - struct glfw *user_data, - int num_args, godot_variant **args); + struct glfw *user_data, + int num_args, godot_variant **args); godot_variant glfw_close(godot_object *instance, void *method_data, - struct glfw *user_data, - int num_args, godot_variant **args); + struct glfw *user_data, + int num_args, godot_variant **args); godot_variant glfw_poll_events(godot_object *instance, void *method_data, - struct glfw *user_data, - int num_args, godot_variant **args); - + struct glfw *user_data, + int num_args, godot_variant **args); godot_variant glfw_is_closed(godot_object *instance, void *method_data, - struct glfw *user_data, - int num_args, godot_variant **args); + struct glfw *user_data, + int num_args, godot_variant **args); - -void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options) -{ +void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options) { api = p_options->api_struct; // now find our extensions @@ -88,13 +84,13 @@ void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options) case GDNATIVE_EXT_NATIVESCRIPT: { nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i]; }; break; - default: break; + default: + break; }; }; } -void GDN_EXPORT godot_nativescript_init(void *p_handle) -{ +void GDN_EXPORT godot_nativescript_init(void *p_handle) { if (!glfwInit()) { fprintf(stderr, "can't initialize GLFW\n"); return; @@ -128,7 +124,6 @@ void GDN_EXPORT godot_nativescript_init(void *p_handle) nativescript_api->godot_nativescript_register_method(p_handle, "GLFW", "close", attributes, close_window); } - { godot_instance_method poll_events = {}; poll_events.method = &glfw_poll_events; @@ -162,15 +157,13 @@ void GDN_EXPORT godot_nativescript_init(void *p_handle) } } -void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *options) -{ +void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *options) { glfwTerminate(); } godot_variant glfw_create_window(godot_object *instance, void *method_data, - struct glfw *user_data, - int num_args, godot_variant **args) -{ + struct glfw *user_data, + int num_args, godot_variant **args) { godot_variant ret; api->godot_variant_new_nil(&ret); @@ -197,12 +190,9 @@ godot_variant glfw_create_window(godot_object *instance, void *method_data, return ret; } - - godot_variant glfw_close(godot_object *instance, void *method_data, - struct glfw *user_data, - int num_args, godot_variant **args) -{ + struct glfw *user_data, + int num_args, godot_variant **args) { godot_variant ret; api->godot_variant_new_nil(&ret); @@ -214,22 +204,18 @@ godot_variant glfw_close(godot_object *instance, void *method_data, return ret; } - godot_variant glfw_is_closed(godot_object *instance, void *method_data, - struct glfw *user_data, - int num_args, godot_variant **args) -{ + struct glfw *user_data, + int num_args, godot_variant **args) { godot_variant ret; api->godot_variant_new_bool(&ret, user_data->window == NULL); return ret; } - godot_variant glfw_poll_events(godot_object *instance, void *method_data, - struct glfw *user_data, - int num_args, godot_variant **args) -{ + struct glfw *user_data, + int num_args, godot_variant **args) { godot_variant ret; api->godot_variant_new_nil(&ret); @@ -238,12 +224,7 @@ godot_variant glfw_poll_events(godot_object *instance, void *method_data, return ret; } - - - - -void *glfw_constructor(godot_object *instance, void *method_data) -{ +void *glfw_constructor(godot_object *instance, void *method_data) { printf("GLFW._init()\n"); struct glfw *user_data = api->godot_alloc(sizeof(struct glfw)); @@ -252,8 +233,7 @@ void *glfw_constructor(godot_object *instance, void *method_data) return user_data; } -void glfw_destructor(godot_object *instance, void *method_data, struct glfw *user_data) -{ +void glfw_destructor(godot_object *instance, void *method_data, struct glfw *user_data) { // destroy window if (user_data->window) { diff --git a/c/InstanceBindingDemo/src/instance_binding_demo.c b/c/InstanceBindingDemo/src/instance_binding_demo.c index b9e5b35..18d3286 100644 --- a/c/InstanceBindingDemo/src/instance_binding_demo.c +++ b/c/InstanceBindingDemo/src/instance_binding_demo.c @@ -3,7 +3,6 @@ #include #include - const godot_gdnative_core_api_struct *api = NULL; const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL; const godot_gdnative_ext_nativescript_1_1_api_struct *nativescript_1_1_api = NULL; @@ -24,8 +23,7 @@ typedef struct wrapper_object { char *message; } wrapper_object; -void *create_wrapper_object(void *data, godot_object *object) -{ +void *create_wrapper_object(void *data, godot_object *object) { printf("we are now creating a wrapper object...\n"); fflush(stdout); @@ -38,17 +36,14 @@ void *create_wrapper_object(void *data, godot_object *object) return wrapper; } -void destroy_wrapper_object(void *data, void *wrapper) -{ +void destroy_wrapper_object(void *data, void *wrapper) { api->godot_free(wrapper); printf("the wrapper object got destroyed.\n"); fflush(stdout); } - -void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options) -{ +void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options) { api = options->api_struct; // now find our extensions @@ -61,25 +56,22 @@ void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options) break; if (nativescript_api->next->version.major == 1 && nativescript_api->next->version.minor == 1) { - nativescript_1_1_api = (const godot_gdnative_ext_nativescript_1_1_api_struct *) nativescript_api->next; + nativescript_1_1_api = (const godot_gdnative_ext_nativescript_1_1_api_struct *)nativescript_api->next; } }; break; - default: break; + default: + break; }; }; } -void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *options) -{ +void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *options) { api = NULL; nativescript_api = NULL; nativescript_1_1_api = NULL; } - - -void GDN_EXPORT godot_nativescript_init(void *handle) -{ +void GDN_EXPORT godot_nativescript_init(void *handle) { printf("nativescript_init\n"); fflush(stdout); @@ -102,17 +94,14 @@ void GDN_EXPORT godot_nativescript_init(void *handle) destructor.destroy_func = &ibd_destructor; nativescript_api->godot_nativescript_register_class(handle, "InstanceBindingDemo", "Reference", constructor, destructor); - } } -void GDN_EXPORT godot_nativescript_terminate(void *handle) -{ +void GDN_EXPORT godot_nativescript_terminate(void *handle) { nativescript_1_1_api->godot_nativescript_unregister_instance_binding_data_functions(language_binding_index); } -GDCALLINGCONV void *ibd_constructor(godot_object *instance, void *method_data) -{ +GDCALLINGCONV void *ibd_constructor(godot_object *instance, void *method_data) { wrapper_object *wrapper = nativescript_1_1_api->godot_nativescript_get_instance_binding_data(language_binding_index, instance); printf("message is: %s\n", wrapper->message); @@ -121,6 +110,5 @@ GDCALLINGCONV void *ibd_constructor(godot_object *instance, void *method_data) return NULL; } -GDCALLINGCONV void ibd_destructor(godot_object *instance, void *method_data, void *user_data) -{ +GDCALLINGCONV void ibd_destructor(godot_object *instance, void *method_data, void *user_data) { } diff --git a/c/SimpleDemo/src/simple.c b/c/SimpleDemo/src/simple.c index 5cba2c2..451d51b 100644 --- a/c/SimpleDemo/src/simple.c +++ b/c/SimpleDemo/src/simple.c @@ -23,7 +23,8 @@ void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options) { case GDNATIVE_EXT_NATIVESCRIPT: { nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i]; }; break; - default: break; + default: + break; }; }; } @@ -68,7 +69,7 @@ GDCALLINGCONV void simple_destructor(godot_object *p_instance, void *p_method_da godot_variant simple_get_data(godot_object *p_instance, void *p_method_data, void *p_user_data, int p_num_args, godot_variant **p_args) { godot_string data; godot_variant ret; - user_data_struct * user_data = (user_data_struct *) p_user_data; + user_data_struct *user_data = (user_data_struct *)p_user_data; api->godot_string_new(&data); api->godot_string_parse_utf8(&data, user_data->data); diff --git a/cpp/SimpleDemo/src/Simple.cpp b/cpp/SimpleDemo/src/Simple.cpp index 0089c6f..5e6e100 100644 --- a/cpp/SimpleDemo/src/Simple.cpp +++ b/cpp/SimpleDemo/src/Simple.cpp @@ -2,33 +2,27 @@ #include "Input.hpp" -void Simple::_register_methods() -{ +void Simple::_register_methods() { godot::register_method("get_data", &Simple::get_data); } -void Simple::_init() -{ +void Simple::_init() { data = "Hello World from C++"; } -godot::String Simple::get_data() const -{ +godot::String Simple::get_data() const { return data; } -void SimpleSprite::_register_methods() -{ +void SimpleSprite::_register_methods() { godot::register_method("_process", &SimpleSprite::_process); } -void SimpleSprite::_init() -{ +void SimpleSprite::_init() { godot::Godot::print("Wheeeeey"); } -void SimpleSprite::_process(double delta) -{ +void SimpleSprite::_process(double delta) { godot::Vector2 input_dir(0, 0); if (godot::Input::get_singleton()->is_action_pressed("ui_right")) { diff --git a/cpp/SimpleDemo/src/Simple.hpp b/cpp/SimpleDemo/src/Simple.hpp index 477a0fe..5b07c54 100644 --- a/cpp/SimpleDemo/src/Simple.hpp +++ b/cpp/SimpleDemo/src/Simple.hpp @@ -7,8 +7,8 @@ class Simple : public godot::Reference { GODOT_CLASS(Simple, godot::Reference) godot::String data; -public: +public: static void _register_methods(); void _init(); diff --git a/cpp/SimpleDemo/src/entry.cpp b/cpp/SimpleDemo/src/entry.cpp index 5b6f5a6..2035947 100644 --- a/cpp/SimpleDemo/src/entry.cpp +++ b/cpp/SimpleDemo/src/entry.cpp @@ -2,21 +2,17 @@ #include "Simple.hpp" -extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) -{ +extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) { godot::Godot::gdnative_init(o); } -extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) -{ +extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) { godot::Godot::gdnative_terminate(o); } -extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) -{ +extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) { godot::Godot::nativescript_init(handle); - godot::register_class(); godot::register_class(); } diff --git a/cpp/cpp_constructors/src/TestClass.hpp b/cpp/cpp_constructors/src/TestClass.hpp index c14eb14..fc0c34c 100644 --- a/cpp/cpp_constructors/src/TestClass.hpp +++ b/cpp/cpp_constructors/src/TestClass.hpp @@ -1,10 +1,9 @@ +#include #include #include -#include #include - #include using namespace godot; @@ -15,7 +14,6 @@ class TestClass : public Reference { int count; public: - void _init() { count = 34; } diff --git a/cpp/cpp_constructors/src/init.cpp b/cpp/cpp_constructors/src/init.cpp index 3c0c622..5d31ed8 100644 --- a/cpp/cpp_constructors/src/init.cpp +++ b/cpp/cpp_constructors/src/init.cpp @@ -2,18 +2,15 @@ #include "TestClass.hpp" -extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) -{ +extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) { godot::Godot::gdnative_init(o); } -extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) -{ +extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) { godot::Godot::gdnative_terminate(o); } -extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) -{ +extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) { godot::Godot::nativescript_init(handle); godot::register_class(); diff --git a/cpp/kinematic_character/Script/src/colworld.h b/cpp/kinematic_character/Script/src/colworld.h index fba6636..3331fd3 100644 --- a/cpp/kinematic_character/Script/src/colworld.h +++ b/cpp/kinematic_character/Script/src/colworld.h @@ -36,6 +36,6 @@ public: static void _register_methods(); }; -} +} // namespace godot #endif // COLWORLD_H From 9504d289e55cdaace7163397988612aa0d6242d9 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 13 Aug 2020 20:55:13 -0500 Subject: [PATCH 4/4] Commit files changed by black_format.sh --- c/InstanceBindingDemo/SConstruct | 22 +++---- c/SimpleDemo/SConstruct | 72 +++++++++++------------ cpp/SimpleDemo/SConstruct | 36 +++++++----- cpp/cpp_constructors/SConstruct | 36 +++++++----- cpp/kinematic_character/Script/SConstruct | 36 +++++++----- 5 files changed, 114 insertions(+), 88 deletions(-) diff --git a/c/InstanceBindingDemo/SConstruct b/c/InstanceBindingDemo/SConstruct index 76529f3..7f2d068 100644 --- a/c/InstanceBindingDemo/SConstruct +++ b/c/InstanceBindingDemo/SConstruct @@ -14,34 +14,36 @@ platform = ARGUMENTS.get("platform", platform) # that way you can run scons in a vs 2017 prompt and it will find all the required tools env = Environment() if platform == "windows": - env = Environment(ENV = os.environ) + env = Environment(ENV=os.environ) if ARGUMENTS.get("use_llvm", "no") == "yes": env["CC"] = "clang" + def add_sources(sources, directory): for file in os.listdir(directory): - if file.endswith('.c'): - sources.append(directory + '/' + file) + if file.endswith(".c"): + sources.append(directory + "/" + file) + if platform == "osx": - env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64']) - env.Append(LINKFLAGS = ['-arch', 'x86_64']) + env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64"]) + env.Append(LINKFLAGS=["-arch", "x86_64"]) if platform == "linux": - env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c11']) + env.Append(CCFLAGS=["-fPIC", "-g", "-O3", "-std=c11"]) if platform == "windows": if target == "debug": - env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '/MDd']) + env.Append(CCFLAGS=["-EHsc", "-D_DEBUG", "/MDd"]) else: - env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '/MD']) + env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "/MD"]) # , 'include', 'include/core' -env.Append(CPPPATH=['.', godot_headers_path]) +env.Append(CPPPATH=[".", godot_headers_path]) sources = [] add_sources(sources, "src") -library = env.SharedLibrary(target='bin/instance_binding_demo', source=sources) +library = env.SharedLibrary(target="bin/instance_binding_demo", source=sources) Default(library) diff --git a/c/SimpleDemo/SConstruct b/c/SimpleDemo/SConstruct index e7ead64..2d14720 100644 --- a/c/SimpleDemo/SConstruct +++ b/c/SimpleDemo/SConstruct @@ -7,12 +7,12 @@ opts = Variables([], ARGUMENTS) env = DefaultEnvironment() # Define our options -opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release'])) -opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx'])) -opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx'])) -opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no')) -opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/bin/')) -opts.Add(PathVariable('target_name', 'The library name.', 'libsimple', PathVariable.PathAccept)) +opts.Add(EnumVariable("target", "Compilation target", "debug", ["d", "debug", "r", "release"])) +opts.Add(EnumVariable("platform", "Compilation platform", "", ["", "windows", "x11", "linux", "osx"])) +opts.Add(EnumVariable("p", "Compilation target, alias for 'platform'", "", ["", "windows", "x11", "linux", "osx"])) +opts.Add(BoolVariable("use_llvm", "Use the LLVM / Clang compiler", "no")) +opts.Add(PathVariable("target_path", "The path where the lib is installed.", "demo/bin/")) +opts.Add(PathVariable("target_name", "The library name.", "libsimple", PathVariable.PathAccept)) # Local dependency paths, adapt them to your setup godot_headers_path = "godot_headers/" @@ -24,54 +24,54 @@ bits = 64 opts.Update(env) # Process some arguments -if env['use_llvm']: - env['CC'] = 'clang' - env['CXX'] = 'clang++' +if env["use_llvm"]: + env["CC"] = "clang" + env["CXX"] = "clang++" -if env['p'] != '': - env['platform'] = env['p'] +if env["p"] != "": + env["platform"] = env["p"] -if env['platform'] == '': +if env["platform"] == "": print("No valid target platform selected.") - quit(); + quit() # Check our platform specifics -if env['platform'] == "osx": - env['target_path'] += 'osx/' - if env['target'] in ('debug', 'd'): - env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64']) - env.Append(LINKFLAGS = ['-arch', 'x86_64']) +if env["platform"] == "osx": + env["target_path"] += "osx/" + if env["target"] in ("debug", "d"): + env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64"]) + env.Append(LINKFLAGS=["-arch", "x86_64"]) else: - env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64']) - env.Append(LINKFLAGS = ['-arch', 'x86_64']) + env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64"]) + env.Append(LINKFLAGS=["-arch", "x86_64"]) -elif env['platform'] in ('x11', 'linux'): - env['target_path'] += 'x11/' - if env['target'] in ('debug', 'd'): - env.Append(CCFLAGS = ['-fPIC', '-g3','-Og', '-std=c++17']) +elif env["platform"] in ("x11", "linux"): + env["target_path"] += "x11/" + if env["target"] in ("debug", "d"): + env.Append(CCFLAGS=["-fPIC", "-g3", "-Og", "-std=c++17"]) else: - env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c++17']) + env.Append(CCFLAGS=["-fPIC", "-g", "-O3", "-std=c++17"]) -elif env['platform'] == "windows": - env['target_path'] += 'win64/' +elif env["platform"] == "windows": + env["target_path"] += "win64/" # 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 - env.Append(ENV = os.environ) + env.Append(ENV=os.environ) - env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS']) - if env['target'] in ('debug', 'd'): - env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd']) + env.Append(CCFLAGS=["-DWIN32", "-D_WIN32", "-D_WINDOWS", "-W3", "-GR", "-D_CRT_SECURE_NO_WARNINGS"]) + if env["target"] in ("debug", "d"): + env.Append(CCFLAGS=["-EHsc", "-D_DEBUG", "-MDd"]) else: - env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '-MD']) + env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"]) # make sure our binding library is properly includes -env.Append(CPPPATH=['.', godot_headers_path]) +env.Append(CPPPATH=[".", godot_headers_path]) # tweak this if you want to use different folders, or more folders, to store your source code in. -env.Append(CPPPATH=['src/']) -sources = Glob('src/*.c') +env.Append(CPPPATH=["src/"]) +sources = Glob("src/*.c") -library = env.SharedLibrary(target=env['target_path'] + env['target_name'] , source=sources) +library = env.SharedLibrary(target=env["target_path"] + env["target_name"], source=sources) Default(library) diff --git a/cpp/SimpleDemo/SConstruct b/cpp/SimpleDemo/SConstruct index 0300f6f..7bfa4bc 100644 --- a/cpp/SimpleDemo/SConstruct +++ b/cpp/SimpleDemo/SConstruct @@ -9,7 +9,7 @@ platform = ARGUMENTS.get("platform", platform) # that way you can run scons in a vs 2017 prompt and it will find all the required tools env = Environment() if platform == "windows": - env = Environment(ENV = os.environ) + env = Environment(ENV=os.environ) godot_headers_path = ARGUMENTS.get("headers", os.getenv("GODOT_HEADERS", "godot-cpp/godot_headers")) godot_bindings_path = ARGUMENTS.get("cpp_bindings", os.getenv("CPP_BINDINGS", "godot-cpp")) @@ -23,36 +23,44 @@ if ARGUMENTS.get("use_llvm", "no") == "yes": # put stuff that is the same for all first, saves duplication if platform == "osx": - env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-arch', 'x86_64']) - env.Append(LINKFLAGS = ['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup']) + env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-arch", "x86_64"]) + env.Append(LINKFLAGS=["-arch", "x86_64", "-framework", "Cocoa", "-Wl,-undefined,dynamic_lookup"]) elif platform == "linux": - env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-Wno-writable-strings']) - env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\'']) + env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-Wno-writable-strings"]) + env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"]) elif platform == "windows": # need to add detection of msvc vs mingw, this is for msvc... - env.Append(LINKFLAGS = ['/WX']) + env.Append(LINKFLAGS=["/WX"]) if target == "debug": - env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '/MDd']) + env.Append(CCFLAGS=["-EHsc", "-D_DEBUG", "/MDd"]) else: - env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '/MD']) + env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "/MD"]) + def add_sources(sources, dir): for f in os.listdir(dir): if f.endswith(".cpp"): sources.append(dir + "/" + f) -env.Append(CPPPATH=[godot_headers_path, godot_bindings_path + '/include', godot_bindings_path + '/include/gen/', godot_bindings_path + '/include/core/']) + +env.Append( + CPPPATH=[ + godot_headers_path, + godot_bindings_path + "/include", + godot_bindings_path + "/include/gen/", + godot_bindings_path + "/include/core/", + ] +) if target == "debug": - env.Append(LIBS=['libgodot-cpp.linux.debug.64']) + env.Append(LIBS=["libgodot-cpp.linux.debug.64"]) else: - env.Append(LIBS=['libgodot-cpp.linux.release.64']) + env.Append(LIBS=["libgodot-cpp.linux.release.64"]) -env.Append(LIBPATH=[ godot_bindings_path + '/bin/' ]) +env.Append(LIBPATH=[godot_bindings_path + "/bin/"]) sources = [] add_sources(sources, "src") -library = env.SharedLibrary(target='bin/libsimple', source=sources) +library = env.SharedLibrary(target="bin/libsimple", source=sources) Default(library) - diff --git a/cpp/cpp_constructors/SConstruct b/cpp/cpp_constructors/SConstruct index a3c1885..75d5548 100644 --- a/cpp/cpp_constructors/SConstruct +++ b/cpp/cpp_constructors/SConstruct @@ -9,7 +9,7 @@ platform = ARGUMENTS.get("platform", platform) # that way you can run scons in a vs 2017 prompt and it will find all the required tools env = Environment() if platform == "windows": - env = Environment(ENV = os.environ) + env = Environment(ENV=os.environ) godot_headers_path = ARGUMENTS.get("headers", os.getenv("GODOT_HEADERS", "godot-cpp/godot_headers")) godot_bindings_path = ARGUMENTS.get("cpp_bindings", os.getenv("CPP_BINDINGS", "godot-cpp")) @@ -23,35 +23,43 @@ if ARGUMENTS.get("use_llvm", "no") == "yes": # put stuff that is the same for all first, saves duplication if platform == "osx": - env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-arch', 'x86_64']) - env.Append(LINKFLAGS = ['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup']) + env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-arch", "x86_64"]) + env.Append(LINKFLAGS=["-arch", "x86_64", "-framework", "Cocoa", "-Wl,-undefined,dynamic_lookup"]) elif platform == "linux": - env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-Wno-writable-strings']) - env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\'']) + env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-Wno-writable-strings"]) + env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"]) elif platform == "windows": # need to add detection of msvc vs mingw, this is for msvc... - env.Append(LINKFLAGS = ['/WX']) + env.Append(LINKFLAGS=["/WX"]) if target == "debug": - env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '/MDd']) + env.Append(CCFLAGS=["-EHsc", "-D_DEBUG", "/MDd"]) else: - env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '/MD']) + env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "/MD"]) + def add_sources(sources, dir): for f in os.listdir(dir): if f.endswith(".cpp"): sources.append(dir + "/" + f) -env.Append(CPPPATH=[godot_headers_path, godot_bindings_path + '/include', godot_bindings_path + '/include/gen/', godot_bindings_path + '/include/core/']) + +env.Append( + CPPPATH=[ + godot_headers_path, + godot_bindings_path + "/include", + godot_bindings_path + "/include/gen/", + godot_bindings_path + "/include/core/", + ] +) if target == "debug": - env.Append(LIBS=['libgodot-cpp.linux.debug.64']) + env.Append(LIBS=["libgodot-cpp.linux.debug.64"]) else: - env.Append(LIBS=['libgodot-cpp.linux.release.64']) -env.Append(LIBPATH=[ godot_bindings_path + '/bin/' ]) + env.Append(LIBS=["libgodot-cpp.linux.release.64"]) +env.Append(LIBPATH=[godot_bindings_path + "/bin/"]) sources = [] add_sources(sources, "src") -library = env.SharedLibrary(target='bin/libconstructor', source=sources) +library = env.SharedLibrary(target="bin/libconstructor", source=sources) Default(library) - diff --git a/cpp/kinematic_character/Script/SConstruct b/cpp/kinematic_character/Script/SConstruct index 1cbdf8f..364660c 100644 --- a/cpp/kinematic_character/Script/SConstruct +++ b/cpp/kinematic_character/Script/SConstruct @@ -9,7 +9,7 @@ platform = ARGUMENTS.get("platform", platform) # that way you can run scons in a vs 2017 prompt and it will find all the required tools env = Environment() if platform == "windows": - env = Environment(ENV = os.environ) + env = Environment(ENV=os.environ) godot_headers_path = ARGUMENTS.get("headers", os.getenv("GODOT_HEADERS", "godot-cpp/godot_headers")) godot_bindings_path = ARGUMENTS.get("cpp_bindings", os.getenv("CPP_BINDINGS", "godot-cpp")) @@ -23,35 +23,43 @@ if ARGUMENTS.get("use_llvm", "no") == "yes": # put stuff that is the same for all first, saves duplication if platform == "osx": - env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-arch', 'x86_64']) - env.Append(LINKFLAGS = ['-arch', 'x86_64', '-framework', 'Cocoa', '-Wl,-undefined,dynamic_lookup']) + env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-arch", "x86_64"]) + env.Append(LINKFLAGS=["-arch", "x86_64", "-framework", "Cocoa", "-Wl,-undefined,dynamic_lookup"]) elif platform == "linux": - env.Append(CCFLAGS = ['-g','-O3', '-std=c++14', '-Wno-writable-strings']) - env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN\'']) + env.Append(CCFLAGS=["-g", "-O3", "-std=c++14", "-Wno-writable-strings"]) + env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"]) elif platform == "windows": # need to add detection of msvc vs mingw, this is for msvc... - env.Append(LINKFLAGS = ['/WX']) + env.Append(LINKFLAGS=["/WX"]) if target == "debug": - env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '/MDd']) + env.Append(CCFLAGS=["-EHsc", "-D_DEBUG", "/MDd"]) else: - env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '/MD']) + env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "/MD"]) + def add_sources(sources, dir): for f in os.listdir(dir): if f.endswith(".cpp"): sources.append(dir + "/" + f) -env.Append(CPPPATH=[godot_headers_path, godot_bindings_path + '/include/gen/', godot_bindings_path + '/include/core/', godot_bindings_path + '/include/']) + +env.Append( + CPPPATH=[ + godot_headers_path, + godot_bindings_path + "/include/gen/", + godot_bindings_path + "/include/core/", + godot_bindings_path + "/include/", + ] +) if target == "debug": - env.Append(LIBS=['libgodot-cpp.linux.debug.64']) + env.Append(LIBS=["libgodot-cpp.linux.debug.64"]) else: - env.Append(LIBS=['libgodot-cpp.linux.release.64']) -env.Append(LIBPATH=[ godot_bindings_path + '/bin/' ]) + env.Append(LIBS=["libgodot-cpp.linux.release.64"]) +env.Append(LIBPATH=[godot_bindings_path + "/bin/"]) sources = [] add_sources(sources, "src") -library = env.SharedLibrary(target='bin/libkinematic_char', source=sources) +library = env.SharedLibrary(target="bin/libkinematic_char", source=sources) Default(library) -