Skip to content

Instantly share code, notes, and snippets.

@dcerisano
Created January 26, 2020 04:47
Show Gist options
  • Select an option

  • Save dcerisano/4058bd12aa78c86a6c7f2d44b69a95a0 to your computer and use it in GitHub Desktop.

Select an option

Save dcerisano/4058bd12aa78c86a6c7f2d44b69a95a0 to your computer and use it in GitHub Desktop.

Revisions

  1. dcerisano created this gist Jan 26, 2020.
    269 changes: 269 additions & 0 deletions binding-gyp.njk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,269 @@
    {
    "variables": {
    "root": "../../..",
    "platform": "<(OS)",
    "build": "<@(module_root_dir)/build",
    "release": "<(build)/Release",
    "dawn": "{{ DAWN_PATH | safe }}",
    "vkSDK": "/home/dcerisano/1.1.126.0/x86_64"
    },
    "conditions": [
    [ "platform == 'win'", { "variables": { "platform": "win" } } ],
    [ "platform == 'linux'", { "variables": { "platform": "linux" } } ],
    [ "platform == 'mac'", { "variables": { "platform": "darwin" } } ]
    ],
    "make_global_settings": [
    ['CXX','/usr/bin/clang++'],
    ['LINK','/usr/bin/clang++'],
    ],
    "targets": [
    {
    "target_name": "action_after_build",
    "type": "none",
    "conditions": []
    },
    {
    "conditions": [
    [

    "OS=='linux'",
    {
    "sources": [
    "src/index.cpp",
    "src/BackendBinding.cpp",
    "src/DescriptorDecoder.cpp",
    "src/GPU.cpp",
    "src/GPUAdapter.cpp",
    "src/GPUBindGroup.cpp",
    "src/GPUBindGroupLayout.cpp",
    "src/GPUBuffer.cpp",
    "src/GPUCanvasContext.cpp",
    "src/GPUCommandBuffer.cpp",
    "src/GPUCommandEncoder.cpp",
    "src/GPUComputePassEncoder.cpp",
    "src/GPUComputePipeline.cpp",
    "src/GPUDevice.cpp",
    "src/GPUFence.cpp",
    "src/GPUPipelineLayout.cpp",
    "src/GPUQueue.cpp",
    "src/GPURenderBundle.cpp",
    "src/GPURenderBundleEncoder.cpp",
    "src/GPURenderPassEncoder.cpp",
    "src/GPURenderPipeline.cpp",
    "src/GPUSampler.cpp",
    "src/GPUShaderModule.cpp",
    "src/GPUSwapChain.cpp",
    "src/GPUTexture.cpp",
    "src/GPUTextureView.cpp",
    "src/NullBinding.cpp",
    "src/VulkanBinding.cpp",
    "src/WebGPUWindow.cpp"
    ],
    "target_name": "addon-linux",
    "defines": [
    "DAWN_ENABLE_BACKEND_NULL",
    "DAWN_ENABLE_BACKEND_VULKAN",
    "DAWN_NATIVE_SHARED_LIBRARY",
    "DAWN_WIRE_SHARED_LIBRARY",
    "WGPU_SHARED_LIBRARY",
    "GLFW_INCLUDE_VULKAN",
    "NAPI_DISABLE_CPP_EXCEPTIONS"
    ],
    "include_dirs": [
    "<!@(node -p \"require('node-addon-api').include\")",
    "<(root)/lib/include",
    "<(vkSDK)/include",
    "<(dawn)/src/include",
    "<(dawn)/build/linux/debian_sid_amd64-sysroot/usr/include",
    "<(dawn)/out/Shared/gen/src/include"

    ],
    "cflags": [
    "-std=c++14",
    "-fexceptions",
    "-Wno-switch",
    "-Wno-unused",
    "-Wno-uninitialized"
    ],
    "cflags_cc": [
    "-std=c++14",
    "-fexceptions",
    "-Wno-switch",
    "-Wno-unused",
    "-Wno-uninitialized"
    ],
    "library_dirs": [
    "<(release)",
    "<(module_root_dir)/../../../lib/<(platform)/<(target_arch)",
    "<(module_root_dir)/../../../lib/<(platform)/<(target_arch)/GLFW"
    ],
    "libraries": ["-Wl,-rpath,<(release)",
    "-lvulkan",
    "-lglfw3",
    "-ldawn_native",
    "-ldawn_proc",
    "-ldawn_wire",
    "-lshaderc_spvc",
    "-lshaderc",
    "-lXrandr",
    "-lXi",
    "-lX11",
    "-lXxf86vm",
    "-lXinerama",
    "-lXcursor",
    "-ldl",
    "-pthread"
    ]
    },
    "OS=='win'",
    {
    "sources": [
    {{ SOURCE_INCLUDES | safe }}
    ],
    "target_name": "addon-win32",
    "cflags!": [
    "-fno-exceptions"
    ],
    "cflags_cc!": [
    "-fno-exceptions"
    ],
    "include_dirs": [
    "<!@(node -p \"require('node-addon-api').include\")",
    "<(vkSDK)/include",
    "<(root)/lib/include",
    "<(dawn)/src/include",
    "<(dawn)/out/Shared/gen/src/include",
    "<(dawn)/third_party/shaderc/libshaderc/include",
    "<(dawn)/third_party/shaderc/libshaderc/src/shaderc.cc",
    "<(dawn)/third_party/shaderc/libshaderc/src/shaderc_private.h"
    ],
    "library_dirs": [
    "<(root)/lib/<(platform)/<(target_arch)/GLFW",
    "<(build)/",
    "<(vkSDK)/lib"
    ],
    "link_settings": {
    "libraries": [
    "-lvulkan-1.lib",
    "-lglfw3dll.lib",
    "-llibdawn_native.dll.lib",
    "-llibdawn_proc.dll.lib",
    "-llibdawn_wire.dll.lib",
    "-llibshaderc.dll.lib",
    "-llibshaderc_spvc.dll.lib"
    ]
    },
    "defines": [
    "WIN32_LEAN_AND_MEAN",
    "NOMINMAX",
    "_UNICODE",
    "UNICODE",
    "DAWN_ENABLE_BACKEND_D3D12",
    "DAWN_ENABLE_BACKEND_NULL",
    "DAWN_ENABLE_BACKEND_VULKAN",
    "DAWN_NATIVE_SHARED_LIBRARY",
    "DAWN_WIRE_SHARED_LIBRARY",
    "WGPU_SHARED_LIBRARY",
    "_GLFW_WIN32",
    "VK_USE_PLATFORM_WIN32_KHR",
    "NAPI_CPP_EXCEPTIONS"
    ],
    "msvs_settings": {
    "VCCLCompilerTool": {
    "AdditionalOptions": ["/MP /EHsc"],
    "ExceptionHandling": 1
    },
    "VCLibrarianTool": {
    "AdditionalOptions" : []
    },
    "VCLinkerTool": {
    "AdditionalLibraryDirectories": [
    "../@PROJECT_SOURCE_DIR@/lib/<(platform)/<(target_arch)",
    "<(build)/"
    ]
    }
    }
    },
    "OS=='mac'",
    {
    "sources": [
    "src/index.cpp",
    "src/BackendBinding.cpp",
    "src/DescriptorDecoder.cpp",
    "src/GPU.cpp",
    "src/GPUAdapter.cpp",
    "src/GPUBindGroup.cpp",
    "src/GPUBindGroupLayout.cpp",
    "src/GPUBuffer.cpp",
    "src/GPUCanvasContext.cpp",
    "src/GPUCommandBuffer.cpp",
    "src/GPUCommandEncoder.cpp",
    "src/GPUComputePassEncoder.cpp",
    "src/GPUComputePipeline.cpp",
    "src/GPUDevice.cpp",
    "src/GPUFence.cpp",
    "src/GPUPipelineLayout.cpp",
    "src/GPUQueue.cpp",
    "src/GPURenderBundle.cpp",
    "src/GPURenderBundleEncoder.cpp",
    "src/GPURenderPassEncoder.cpp",
    "src/GPURenderPipeline.cpp",
    "src/GPUSampler.cpp",
    "src/GPUShaderModule.cpp",
    "src/GPUSwapChain.cpp",
    "src/GPUTexture.cpp",
    "src/GPUTextureView.cpp",
    "src/NullBinding.cpp",
    "src/WebGPUWindow.cpp",
    "src/MetalBinding.mm"
    ],
    "target_name": "addon-darwin",
    "defines": [
    "DAWN_ENABLE_BACKEND_NULL",
    "DAWN_ENABLE_BACKEND_METAL",
    "DAWN_NATIVE_SHARED_LIBRARY",
    "DAWN_WIRE_SHARED_LIBRARY",
    "WGPU_SHARED_LIBRARY",
    "NAPI_DISABLE_CPP_EXCEPTIONS"
    ],
    "include_dirs": [
    "<!@(node -p \"require('node-addon-api').include\")",
    "<(root)/lib/include",
    "<(dawn)/src/include",
    "<(dawn)/out/Shared/gen",
    "<(dawn)/out/Shared/gen/src/include",
    "<(dawn)/third_party/shaderc/libshaderc/include",
    "<(dawn)/third_party/shaderc/libshaderc/src/shaderc.cc",
    "<(dawn)/third_party/shaderc/libshaderc/src/shaderc_private.h"
    ],
    "libraries": [
    "<(release)/libdawn_native.dylib",
    "<(release)/libc++.dylib",
    "<(release)/libdawn_proc.dylib",
    "<(release)/libdawn_wire.dylib",
    "<(release)/libshaderc_spvc.dylib",
    "<(release)/libshaderc.dylib",
    "<(release)/../../<(root)/lib/<(platform)/<(target_arch)/GLFW/libglfw3.a"
    ],
    "xcode_settings": {
    "OTHER_CPLUSPLUSFLAGS": [
    "-std=c++14",
    "-stdlib=libc++"
    ],
    "OTHER_LDFLAGS": [
    "-Wl,-rpath,<(release)",
    "-framework Cocoa",
    "-framework IOKit",
    "-framework Metal",
    "-framework QuartzCore"
    ],
    "LIBRARY_SEARCH_PATHS": [
    "<(release)"
    ]
    }
    }
    ]
    ]
    }
    ]
    }