Minor changes to update.sh and build.sh for chromedp-gen

This commit is contained in:
Kenneth Shaw 2017-06-18 09:46:51 +07:00
parent fa3cf26d37
commit 59b4e8a6af
5 changed files with 27 additions and 26 deletions

View File

@ -1,30 +1,8 @@
#!/bin/bash #!/bin/bash
UPDATE=0
LASTUPDATE=0
if [ -f .last ]; then
LASTUPDATE=$(cat .last)
fi
NOW=$(date +%s)
if (( "$NOW" >= $(($LASTUPDATE + 86400*5)) )); then
UPDATE=1
fi
if [[ "$UPDATE" == 1 ]]; then
go get -u \
golang.org/x/tools/cmd/goimports \
github.com/mailru/easyjson/easyjson \
github.com/valyala/quicktemplate/qtc
date +%s > .last
fi
set -ve set -ve
go generate go generate
gofmt -w -s templates/*.go
go build go build
time ./chromedp-gen $@ time ./chromedp-gen $@

View File

@ -61,6 +61,8 @@ func main() {
const ( const (
tpl = `package internal tpl = `package internal
// AUTOGENERATED. DO NOT EDIT.
import ( import (
"fmt" "fmt"
"strconv" "strconv"

View File

@ -1,5 +1,7 @@
package internal package internal
// AUTOGENERATED. DO NOT EDIT.
import ( import (
"fmt" "fmt"
"strconv" "strconv"

View File

@ -6,6 +6,7 @@ package main
//go:generate go run domain-gen.go //go:generate go run domain-gen.go
//go:generate qtc -dir templates -ext qtpl //go:generate qtc -dir templates -ext qtpl
//go:generate gofmt -w -s templates/
import ( import (
"bytes" "bytes"

View File

@ -22,7 +22,25 @@ curl -s $JS_PROTO | base64 -d > $JS_TMP
# merge browser_protocol.json and js_protocol.json # merge browser_protocol.json and js_protocol.json
jq -s '[.[] | to_entries] | flatten | reduce .[] as $dot ({}; .[$dot.key] += $dot.value)' $BROWSER_TMP $JS_TMP > $OUT jq -s '[.[] | to_entries] | flatten | reduce .[] as $dot ({}; .[$dot.key] += $dot.value)' $BROWSER_TMP $JS_TMP > $OUT
# convert boolean values listed as strings to real booleans UPDATE=0
# (this is not used in favor of using the custom Bool type that correctly JSON unmarshals the value) LASTUPDATE=0
# left here for completeness if [ -f .last ]; then
#perl -pi -e 's/"\s*:\s*"(true|false)"/": \1/g' $OUT LASTUPDATE=$(cat .last)
fi
NOW=$(date +%s)
if (( "$NOW" >= $(($LASTUPDATE + 86400*5)) )); then
UPDATE=1
fi
if [[ "$UPDATE" == 1 ]]; then
go get -u -d \
github.com/knq/chromedp/cmd/chromedp-gen
go get -u \
golang.org/x/tools/cmd/goimports \
github.com/mailru/easyjson/easyjson \
github.com/valyala/quicktemplate/qtc
date +%s > .last
fi