From 6480bd30464fdebbf065454c85b6748b2c7bfd4a Mon Sep 17 00:00:00 2001 From: Ilija Puaca Date: Fri, 10 Apr 2020 17:40:21 +0800 Subject: [PATCH 1/5] clang format settings explicitly listed, enabled macOS build --- .clang-format | 159 +++++++++++++++++- .travis.yml | 34 ++-- .../webgpu/src/backends/metal-binding.mm | 4 +- .../luma.gl/webgpu/src/webgpu-utils.cpp | 2 +- 4 files changed, 175 insertions(+), 24 deletions(-) diff --git a/.clang-format b/.clang-format index d9b1e9ed..b1ad9e58 100644 --- a/.clang-format +++ b/.clang-format @@ -1,3 +1,156 @@ -BasedOnStyle: Google -IndentWidth: 2 -ColumnLimit: 120 +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +--- +# Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + 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 +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + CanonicalDelimiter: '' + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseTab: Never +... diff --git a/.travis.yml b/.travis.yml index b1b6b845..5d8c8ca4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,23 +19,23 @@ matrix: packages: - clang-format-9 script: make format && git diff --exit-code - # TODO: Doesn't install arrow correctly on OSX - # - name: "Mac OSX (Xcode 11.3)" - # os: osx - # osx_image: xcode11.3 - - name: "Linux (Clang)" - os: linux - compiler: clang - - name: "Linux (GCC) with Valgrind" - os: linux - compiler: gcc - addons: - apt: - packages: - - valgrind - script: - - make -j - - valgrind --error-exitcode=99 ./tests + - name: "macOS (Xcode 11.3)" + os: osx + osx_image: xcode11.3 + # TODO: Does not build on Linux currently due to dependency issues + # - name: "Linux (Clang)" + # os: linux + # compiler: clang + # - name: "Linux (GCC) with Valgrind" + # os: linux + # compiler: gcc + # addons: + # apt: + # packages: + # - valgrind + # script: + # - make -j + # - valgrind --error-exitcode=99 ./tests before_script: # Build out of source diff --git a/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm b/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm index 63b7f2a5..affe802c 100644 --- a/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm +++ b/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm @@ -21,17 +21,15 @@ // Note: This file was inspired by the Dawn codebase at https://dawn.googlesource.com/dawn/ // Copyright 2017 The Dawn Authors http://www.apache.org/licenses/LICENSE-2.0 -#include "./backend-binding.h" - #import +#include "./backend-binding.h" #include "dawn/dawn_wsi.h" #include "dawn_native/MetalBackend.h" #define GLFW_EXPOSE_NATIVE_COCOA #include "GLFW/glfw3.h" #include "GLFW/glfw3native.h" - #include "luma.gl/core.h" #include "probe.gl/core.h" diff --git a/cpp/modules/luma.gl/webgpu/src/webgpu-utils.cpp b/cpp/modules/luma.gl/webgpu/src/webgpu-utils.cpp index b397d0dc..8338fe9d 100644 --- a/cpp/modules/luma.gl/webgpu/src/webgpu-utils.cpp +++ b/cpp/modules/luma.gl/webgpu/src/webgpu-utils.cpp @@ -39,7 +39,7 @@ auto getDefaultWebGPUBackendType() -> wgpu::BackendType { #elif defined(LUMAGL_ENABLE_BACKEND_NULL) return wgpu::BackendType::Null; #else - #error No backends enabled +#error No backends enabled #endif } From 0b774a287c88aae846632026ccfd2aaf32207df7 Mon Sep 17 00:00:00 2001 From: Ilija Puaca Date: Fri, 10 Apr 2020 20:07:51 +0800 Subject: [PATCH 2/5] clang-format linux fix, glfw missing macOS libs --- .clang-format | 2 +- cpp/modules/luma.gl/CMakeLists.txt | 18 +++++++++++++++--- cpp/modules/luma.gl/core.h | 1 + .../luma.gl/core/src/glfw-animation-loop.cpp | 2 ++ .../luma.gl/core/src/glfw-animation-loop.h | 4 ++-- .../webgpu/src/backends/backend-binding.cpp | 10 +++++----- .../webgpu/src/backends/backend-binding.h | 4 ++-- .../webgpu/src/backends/d3d12-binding.cpp | 9 +++++---- .../webgpu/src/backends/metal-binding.mm | 9 +++++---- .../webgpu/src/backends/opengl-binding.cpp | 7 ++++--- .../webgpu/src/backends/vulkan-binding.cpp | 7 ++++--- cpp/modules/math.gl/core/src/core.h | 12 ++++++++---- 12 files changed, 54 insertions(+), 31 deletions(-) diff --git a/.clang-format b/.clang-format index b1ad9e58..5f23388b 100644 --- a/.clang-format +++ b/.clang-format @@ -16,7 +16,7 @@ AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: All AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: true AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None diff --git a/cpp/modules/luma.gl/CMakeLists.txt b/cpp/modules/luma.gl/CMakeLists.txt index b049f275..8e68d307 100644 --- a/cpp/modules/luma.gl/CMakeLists.txt +++ b/cpp/modules/luma.gl/CMakeLists.txt @@ -70,6 +70,20 @@ target_link_libraries(luma.gl PUBLIC ${DECK_LINK_FLAGS} ) target_link_libraries(luma.gl PUBLIC ${DECK_CONFIG_LIBRARY}) +# GLFW dependencies +if (APPLE) + find_library(Cocoa_LIB Cocoa) + find_library(IOKit_LIB IOKit) + find_library(CoreFoundation_LIB CoreFoundation) + find_library(CoreVideo_LIB CoreVideo) + target_link_libraries(luma.gl PUBLIC ${DECK_LINK_FLAGS} + ${Cocoa_LIB} + ${IOKit_LIB} + ${CoreFoundation_LIB} + ${CoreVideo_LIB} + ) +endif() + # Backend specific files and libraries if (DECK_ENABLE_D3D12) list(APPEND WEBGPU_SOURCE_FILE_LIST webgpu/src/backends/d3d12-binding.cpp) @@ -81,13 +95,11 @@ if (DECK_ENABLE_METAL) # macOS frameworks related to Metal find_library(Metal_LIB Metal) find_library(QuartzCore_LIB QuartzCore) - find_library(Cocoa_LIB Cocoa) find_library(IOKit_LIB IOKit) find_library(IOSurface_LIB IOSurface) - target_link_libraries(luma.gl PUBLIC + target_link_libraries(luma.gl PUBLIC ${DECK_LINK_FLAGS} ${Metal_LIB} ${QuartzCore_LIB} - ${Cocoa_LIB} ${IOKit_LIB} ${IOSurface_LIB} ) diff --git a/cpp/modules/luma.gl/core.h b/cpp/modules/luma.gl/core.h index 1033a070..900c42b5 100644 --- a/cpp/modules/luma.gl/core.h +++ b/cpp/modules/luma.gl/core.h @@ -21,6 +21,7 @@ #ifndef LUMAGL_CORE_H #define LUMAGL_CORE_H +#include "./core/src/animation-loop.h" #include "./core/src/glfw-animation-loop.h" #include "./core/src/model.h" diff --git a/cpp/modules/luma.gl/core/src/glfw-animation-loop.cpp b/cpp/modules/luma.gl/core/src/glfw-animation-loop.cpp index a672cc15..1736f9bd 100644 --- a/cpp/modules/luma.gl/core/src/glfw-animation-loop.cpp +++ b/cpp/modules/luma.gl/core/src/glfw-animation-loop.cpp @@ -20,6 +20,7 @@ #include "./glfw-animation-loop.h" // NOLINT(build/include) +#include #include #include #include @@ -57,6 +58,7 @@ GLFWAnimationLoop::GLFWAnimationLoop(const wgpu::BackendType backendType, std::s } GLFWAnimationLoop::~GLFWAnimationLoop() { + glfwDestroyWindow(this->_window); glfwTerminate(); // TODO(ilija@unfolded.ai): Additional cleanup? diff --git a/cpp/modules/luma.gl/core/src/glfw-animation-loop.h b/cpp/modules/luma.gl/core/src/glfw-animation-loop.h index bef02b2f..88b7fe46 100644 --- a/cpp/modules/luma.gl/core/src/glfw-animation-loop.h +++ b/cpp/modules/luma.gl/core/src/glfw-animation-loop.h @@ -21,14 +21,14 @@ #ifndef LUMAGL_CORE_GLFW_ANIMATION_LOOP_H #define LUMAGL_CORE_GLFW_ANIMATION_LOOP_H -#include - #include #include "./animation-loop.h" #include "luma.gl/webgpu/src/backends/backend-binding.h" #include "luma.gl/webgpu/src/webgpu-utils.h" +struct GLFWwindow; + namespace lumagl { class GLFWAnimationLoop : public AnimationLoop { diff --git a/cpp/modules/luma.gl/webgpu/src/backends/backend-binding.cpp b/cpp/modules/luma.gl/webgpu/src/backends/backend-binding.cpp index c37b093c..09fbd5e5 100644 --- a/cpp/modules/luma.gl/webgpu/src/backends/backend-binding.cpp +++ b/cpp/modules/luma.gl/webgpu/src/backends/backend-binding.cpp @@ -23,14 +23,14 @@ #include "./backend-binding.h" // NOLINT(build/include) -#include "GLFW/glfw3.h" -#include "luma.gl/core.h" -#include "probe.gl/core.h" - +#include #if defined(LUMAGL_ENABLE_BACKEND_OPENGL) -#include "dawn_native/OpenGLBackend.h" +#include #endif // defined(LUMAGL_ENABLE_BACKEND_OPENGL) +#include "luma.gl/core.h" +#include "probe.gl/core.h" + namespace lumagl { namespace utils { diff --git a/cpp/modules/luma.gl/webgpu/src/backends/backend-binding.h b/cpp/modules/luma.gl/webgpu/src/backends/backend-binding.h index 393a2493..8b58afbf 100644 --- a/cpp/modules/luma.gl/webgpu/src/backends/backend-binding.h +++ b/cpp/modules/luma.gl/webgpu/src/backends/backend-binding.h @@ -24,8 +24,8 @@ #ifndef LUMAGL_WEBGPU_BACKENDS_BACKEND_BINDING_H #define LUMAGL_WEBGPU_BACKENDS_BACKEND_BINDING_H -#include "dawn/webgpu_cpp.h" -#include "dawn_native/DawnNative.h" +#include +#include struct GLFWwindow; diff --git a/cpp/modules/luma.gl/webgpu/src/backends/d3d12-binding.cpp b/cpp/modules/luma.gl/webgpu/src/backends/d3d12-binding.cpp index 73e4de99..074fd2ef 100644 --- a/cpp/modules/luma.gl/webgpu/src/backends/d3d12-binding.cpp +++ b/cpp/modules/luma.gl/webgpu/src/backends/d3d12-binding.cpp @@ -21,13 +21,14 @@ // Note: This file was inspired by the Dawn codebase at https://dawn.googlesource.com/dawn/ // Copyright 2017 The Dawn Authors http://www.apache.org/licenses/LICENSE-2.0 +#include +#include +#define GLFW_EXPOSE_NATIVE_WIN32 +#include + #include -#include "GLFW/glfw3.h" -#include "dawn_native/D3D12Backend.h" -#define GLFW_EXPOSE_NATIVE_WIN32 #include "./backend-binding.h" -#include "GLFW/glfw3native.h" #include "probe.gl/core.h" namespace lumagl { diff --git a/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm b/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm index affe802c..1a9757df 100644 --- a/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm +++ b/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm @@ -22,14 +22,15 @@ // Copyright 2017 The Dawn Authors http://www.apache.org/licenses/LICENSE-2.0 #import +#include +#include #include "./backend-binding.h" -#include "dawn/dawn_wsi.h" -#include "dawn_native/MetalBackend.h" #define GLFW_EXPOSE_NATIVE_COCOA -#include "GLFW/glfw3.h" -#include "GLFW/glfw3native.h" +#include +#include + #include "luma.gl/core.h" #include "probe.gl/core.h" diff --git a/cpp/modules/luma.gl/webgpu/src/backends/opengl-binding.cpp b/cpp/modules/luma.gl/webgpu/src/backends/opengl-binding.cpp index 6978b1cd..0bf0d63a 100644 --- a/cpp/modules/luma.gl/webgpu/src/backends/opengl-binding.cpp +++ b/cpp/modules/luma.gl/webgpu/src/backends/opengl-binding.cpp @@ -21,12 +21,13 @@ // Note: This file was inspired by the Dawn codebase at https://dawn.googlesource.com/dawn/ // Copyright 2017 The Dawn Authors http://www.apache.org/licenses/LICENSE-2.0 +#include +#include +#include + #include #include "./backend-binding.h" -#include "GLFW/glfw3.h" -#include "dawn/dawn_wsi.h" -#include "dawn_native/OpenGLBackend.h" #include "luma.gl/core.h" namespace lumagl { diff --git a/cpp/modules/luma.gl/webgpu/src/backends/vulkan-binding.cpp b/cpp/modules/luma.gl/webgpu/src/backends/vulkan-binding.cpp index c4767cf2..17a4e4d0 100644 --- a/cpp/modules/luma.gl/webgpu/src/backends/vulkan-binding.cpp +++ b/cpp/modules/luma.gl/webgpu/src/backends/vulkan-binding.cpp @@ -21,12 +21,13 @@ // Note: This file was inspired by the Dawn codebase at https://dawn.googlesource.com/dawn/ // Copyright 2017 The Dawn Authors http://www.apache.org/licenses/LICENSE-2.0 +#include +// Include GLFW after VulkanBackend so that it declares the Vulkan-specific functions +#include + #include -#include "dawn_native/VulkanBackend.h" -// Include GLFW after VulkanBackend so that it declares the Vulkan-specific functions #include "./backend-binding.h" -#include "GLFW/glfw3.h" namespace lumagl { namespace utils { diff --git a/cpp/modules/math.gl/core/src/core.h b/cpp/modules/math.gl/core/src/core.h index 66645d2a..e462ec39 100644 --- a/cpp/modules/math.gl/core/src/core.h +++ b/cpp/modules/math.gl/core/src/core.h @@ -425,14 +425,16 @@ auto Vector2::Length2() const -> coord { template auto Vector2::Angle() const -> coord { - if (x == static_cast(0) && y == static_cast(0)) return static_cast(0); + if (x == static_cast(0) && y == static_cast(0)) + return static_cast(0); return static_cast(atan2(y, x)); } template void Vector2::Normalize() { coord length = Length(); - if (length <= static_cast(0)) throw std::logic_error("normalize called on zero length vector"); + if (length <= static_cast(0)) + throw std::logic_error("normalize called on zero length vector"); x /= length; y /= length; } @@ -499,7 +501,8 @@ auto Vector3::toVector2() const -> Vector2 { template void Vector3::Normalize() { coord length = Length(); - if (length <= static_cast(0)) throw std::runtime_error("normalize called on zero length vector"); + if (length <= static_cast(0)) + throw std::runtime_error("normalize called on zero length vector"); x /= length; y /= length; z /= length; @@ -586,7 +589,8 @@ template auto Matrix2::Invert() const -> Matrix2 { // Cramers rule coord det = m[0][0] * m[1][1] - m[0][1] * m[1][0]; - if (det == static_cast(0)) throw std::runtime_error("Attempt to invert singular matrix"); + if (det == static_cast(0)) + throw std::runtime_error("Attempt to invert singular matrix"); det = 1 / det; return Matrix2(det * m[1][1], -det * m[0][1], -det * m[1][0], det * m[0][0]); } From c89d09495089086e89b8825cc7b86112cb58283a Mon Sep 17 00:00:00 2001 From: Ilija Puaca Date: Sat, 11 Apr 2020 20:22:53 +0800 Subject: [PATCH 3/5] Use the correct clang-format package on Linux --- .clang-format | 6 ++++-- CMakeLists.txt | 3 ++- cpp/modules/math.gl/core/src/core.h | 12 ++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.clang-format b/.clang-format index 5f23388b..0256e313 100644 --- a/.clang-format +++ b/.clang-format @@ -1,3 +1,4 @@ +# Generated by running clang-format -style=Google -dump-config > .clang-format, with a few Unfolded modifications at the bottom # https://clang.llvm.org/docs/ClangFormatStyleOptions.html --- # Language: Cpp @@ -16,7 +17,7 @@ AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: All AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: WithoutElse AllowShortLoopsOnASingleLine: true AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None @@ -50,7 +51,6 @@ BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeColon BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true -ColumnLimit: 120 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: true @@ -153,4 +153,6 @@ StatementMacros: - QT_REQUIRE_VERSION TabWidth: 8 UseTab: Never +# Unfolded +ColumnLimit: 120 ... diff --git a/CMakeLists.txt b/CMakeLists.txt index 954f40ec..d5493c18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,8 @@ option(DECK_BUILD_EXAMPLES "Enables building examples" ON) option(DECK_BUILD_TESTS "Enables building tests" ON) option(DECK_ENABLE_GRAPHICS "When set to OFF, no graphics libraries will be included. Useful for running on CI" ON) -find_program(CLANG_FORMAT_PATH clang-format) +# We're using clang-format-9 Linux package, which should have priority over any other version +find_program(CLANG_FORMAT_PATH NAMES clang-format-9 clang-format) cmake_dependent_option( DECK_ENABLE_FORMAT "Enable running clang-format before compiling" ON "CLANG_FORMAT_PATH" OFF diff --git a/cpp/modules/math.gl/core/src/core.h b/cpp/modules/math.gl/core/src/core.h index e462ec39..66645d2a 100644 --- a/cpp/modules/math.gl/core/src/core.h +++ b/cpp/modules/math.gl/core/src/core.h @@ -425,16 +425,14 @@ auto Vector2::Length2() const -> coord { template auto Vector2::Angle() const -> coord { - if (x == static_cast(0) && y == static_cast(0)) - return static_cast(0); + if (x == static_cast(0) && y == static_cast(0)) return static_cast(0); return static_cast(atan2(y, x)); } template void Vector2::Normalize() { coord length = Length(); - if (length <= static_cast(0)) - throw std::logic_error("normalize called on zero length vector"); + if (length <= static_cast(0)) throw std::logic_error("normalize called on zero length vector"); x /= length; y /= length; } @@ -501,8 +499,7 @@ auto Vector3::toVector2() const -> Vector2 { template void Vector3::Normalize() { coord length = Length(); - if (length <= static_cast(0)) - throw std::runtime_error("normalize called on zero length vector"); + if (length <= static_cast(0)) throw std::runtime_error("normalize called on zero length vector"); x /= length; y /= length; z /= length; @@ -589,8 +586,7 @@ template auto Matrix2::Invert() const -> Matrix2 { // Cramers rule coord det = m[0][0] * m[1][1] - m[0][1] * m[1][0]; - if (det == static_cast(0)) - throw std::runtime_error("Attempt to invert singular matrix"); + if (det == static_cast(0)) throw std::runtime_error("Attempt to invert singular matrix"); det = 1 / det; return Matrix2(det * m[1][1], -det * m[0][1], -det * m[1][0], det * m[0][0]); } From 593b8e19a4a418ea0023d1290eeafce26bf685d0 Mon Sep 17 00:00:00 2001 From: Ilija Puaca Date: Mon, 13 Apr 2020 12:22:40 +0800 Subject: [PATCH 4/5] Travis now uses https for submodules --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5d8c8ca4..f1a82c47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,17 @@ matrix: # - make -j # - valgrind --error-exitcode=99 ./tests +# Handle git submodules ourselves +git: + submodules: false + +# Use sed to replace the SSH URL with the public URL, then initialize submodules +# TODO: Temporary workaround for not having a ssh key in place for the CI user. Remove once User Key is in place +# https://docs.travis-ci.com/user/private-dependencies/#User-Key +before_install: + - sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules + - git submodule update --init --recursive + before_script: # Build out of source - mkdir build From 3ac8d76da311cf5ff6426cb28e5b10ecc6212c5a Mon Sep 17 00:00:00 2001 From: Ilija Puaca Date: Mon, 13 Apr 2020 12:43:14 +0800 Subject: [PATCH 5/5] Updated dependency submodule url to use https --- .gitmodules | 2 +- .travis.yml | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/.gitmodules b/.gitmodules index 1cdb51b8..7f8c90bf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "cpp/deps"] path = cpp/deps - url = git@github.com:UnfoldedInc/deck.gl-native-dependencies.git + url = https://github.com/UnfoldedInc/deck.gl-native-dependencies.git diff --git a/.travis.yml b/.travis.yml index f1a82c47..5d8c8ca4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,17 +37,6 @@ matrix: # - make -j # - valgrind --error-exitcode=99 ./tests -# Handle git submodules ourselves -git: - submodules: false - -# Use sed to replace the SSH URL with the public URL, then initialize submodules -# TODO: Temporary workaround for not having a ssh key in place for the CI user. Remove once User Key is in place -# https://docs.travis-ci.com/user/private-dependencies/#User-Key -before_install: - - sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules - - git submodule update --init --recursive - before_script: # Build out of source - mkdir build