Skip to content

Commit

Permalink
Separated asset files into their own folder with the correct file
Browse files Browse the repository at this point in the history
formats, and added a script to build them into required .go file using
go-bindata.
  • Loading branch information
ainsleyc committed Apr 21, 2016
1 parent 24b1bb0 commit 700c3d1
Show file tree
Hide file tree
Showing 14 changed files with 1,256 additions and 854 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ vet:

build:
@echo ">> building binaries"
@./build/assets.sh
@./build/build.sh

release: build
Expand Down
37 changes: 37 additions & 0 deletions build/assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

GIT_ROOT=$(dirname "${BASH_SOURCE}")/..
YEAR=$(date +%Y)

TMP_OUTPUT="/tmp/cadvisor_assets.go"
ASSETS_OUTPUT=$GIT_ROOT/pages/static/assets.go

go get -u github.com/jteeuwen/go-bindata/...

for f in $GIT_ROOT/pages/assets/**/*; do
if [ "$f" -nt $ASSETS_OUTPUT -o ! -e $ASSETS_OUTPUT ]; then
go-bindata -o $ASSETS_OUTPUT -pkg static $GIT_ROOT/pages/assets/...
cat build/boilerplate/boilerplate.go.txt | sed "s/YEAR/$YEAR/" > "${TMP_OUTPUT}"
echo -e "// generated by build/assets.sh; DO NOT EDIT\n" >> "${TMP_OUTPUT}"
cat "${ASSETS_OUTPUT}" >> "${TMP_OUTPUT}"
gofmt -w -s "${TMP_OUTPUT}"
mv "${TMP_OUTPUT}" "${ASSETS_OUTPUT}"
break
fi
done

exit 0
10 changes: 10 additions & 0 deletions docs/development/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,13 @@ Now you can run the built binary:
```
$GOPATH/src/github.com/google/cadvisor $ sudo ./cadvisor
```

## Compiling Assets

If you modify files in the /assets folder, you will need to rebuild the assets:

```
$GOPATH/src/github.com/google/cadvisor $ ./build/assets.sh
$GOPATH/src/github.com/google/cadvisor $ godep go build .
```

Large diffs are not rendered by default.

Loading

0 comments on commit 700c3d1

Please sign in to comment.