diff --git a/.clang-format b/.clang-format index d9b1e9ed..0256e313 100644 --- a/.clang-format +++ b/.clang-format @@ -1,3 +1,158 @@ -BasedOnStyle: Google -IndentWidth: 2 -ColumnLimit: 120 +# 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 +# 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 +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 +# Unfolded +ColumnLimit: 120 +... 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 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/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/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 63b7f2a5..1a9757df 100644 --- a/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm +++ b/cpp/modules/luma.gl/webgpu/src/backends/metal-binding.mm @@ -21,16 +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 +#include -#include "dawn/dawn_wsi.h" -#include "dawn_native/MetalBackend.h" +#include "./backend-binding.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/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 }