25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

61 lines
1.8 KiB

  1. # Copyright 2018 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. #!/usr/bin/env bash
  15. set -eu
  16. set -o pipefail
  17. D3FLAMEGRAPH_REPO="https://raw.githubusercontent.com/spiermar/d3-flame-graph"
  18. D3FLAMEGRAPH_VERSION="2.0.0-alpha4"
  19. D3FLAMEGRAPH_JS="d3-flamegraph.js"
  20. D3FLAMEGRAPH_CSS="d3-flamegraph.css"
  21. cd $(dirname $0)
  22. D3FLAMEGRAPH_DIR=d3flamegraph
  23. generate_d3flamegraph_go() {
  24. local d3_js=$(curl -s "${D3FLAMEGRAPH_REPO}/${D3FLAMEGRAPH_VERSION}/dist/${D3FLAMEGRAPH_JS}" | sed 's/`/`+"`"+`/g')
  25. local d3_css=$(curl -s "${D3FLAMEGRAPH_REPO}/${D3FLAMEGRAPH_VERSION}/dist/${D3FLAMEGRAPH_CSS}")
  26. cat <<-EOF > $D3FLAMEGRAPH_DIR/d3_flame_graph.go
  27. // A D3.js plugin that produces flame graphs from hierarchical data.
  28. // https://github.com/spiermar/d3-flame-graph
  29. // Version $D3FLAMEGRAPH_VERSION
  30. // See LICENSE file for license details
  31. package d3flamegraph
  32. // JSSource returns the $D3FLAMEGRAPH_JS file
  33. const JSSource = \`
  34. $d3_js
  35. \`
  36. // CSSSource returns the $D3FLAMEGRAPH_CSS file
  37. const CSSSource = \`
  38. $d3_css
  39. \`
  40. EOF
  41. gofmt -w $D3FLAMEGRAPH_DIR/d3_flame_graph.go
  42. }
  43. get_license() {
  44. curl -s -o $D3FLAMEGRAPH_DIR/LICENSE "${D3FLAMEGRAPH_REPO}/${D3FLAMEGRAPH_VERSION}/LICENSE"
  45. }
  46. mkdir -p $D3FLAMEGRAPH_DIR
  47. get_license
  48. generate_d3flamegraph_go