...

Text file src/cmd/vendor/github.com/google/pprof/third_party/d3flamegraph/update.sh

Documentation: cmd/vendor/github.com/google/pprof/third_party/d3flamegraph

     1#  Copyright 2021 Google Inc. All Rights Reserved.
     2#
     3#  Licensed under the Apache License, Version 2.0 (the "License");
     4#  you may not use this file except in compliance with the License.
     5#  You may obtain a copy of the License at
     6#
     7#      http://www.apache.org/licenses/LICENSE-2.0
     8#
     9#  Unless required by applicable law or agreed to in writing, software
    10#  distributed under the License is distributed on an "AS IS" BASIS,
    11#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12#  See the License for the specific language governing permissions and
    13#  limitations under the License.
    14
    15#!/usr/bin/env bash
    16
    17set -eu
    18set -o pipefail
    19
    20D3FLAMEGRAPH_CSS="d3-flamegraph.css"
    21
    22cd $(dirname $0)
    23
    24generate_d3_flame_graph_go() {
    25    npm install
    26    # https://stackoverflow.com/a/21199041/171898
    27    local d3_js=$(cat d3.js | sed 's/`/`+"`"+`/g')
    28    local d3_css=$(cat "node_modules/d3-flame-graph/dist/${D3FLAMEGRAPH_CSS}")
    29
    30    cat <<-EOF > d3_flame_graph.go
    31// D3.js is a JavaScript library for manipulating documents based on data.
    32// https://github.com/d3/d3
    33// See D3_LICENSE file for license details
    34
    35// d3-flame-graph is a D3.js plugin that produces flame graphs from hierarchical data.
    36// https://github.com/spiermar/d3-flame-graph
    37// See D3_FLAME_GRAPH_LICENSE file for license details
    38
    39package d3flamegraph
    40
    41// JSSource returns the d3 and d3-flame-graph JavaScript bundle
    42const JSSource = \`
    43
    44$d3_js
    45\`
    46
    47// CSSSource returns the $D3FLAMEGRAPH_CSS file
    48const CSSSource = \`
    49$d3_css
    50\`
    51
    52EOF
    53    gofmt -w d3_flame_graph.go
    54}
    55
    56get_licenses() {
    57    cp node_modules/d3-selection/LICENSE D3_LICENSE
    58    cp node_modules/d3-flame-graph/LICENSE D3_FLAME_GRAPH_LICENSE
    59}
    60
    61get_licenses
    62generate_d3_flame_graph_go

View as plain text