From c478111a98a390319c7af0b6784df9fa700840bc Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 15 Sep 2020 18:17:20 +0200 Subject: pkg/build, pkg/html: move generation logic into separate scripts Mentions of "// Code generated ... DO NOT EDIT." in these Go files somehow prevents golangci-lint from checking them. And github treats them as auto-generated as well. I guess some code somewhere has some imprecise heuristics. Move generation into separate shell scripts. Also cleaner. --- pkg/build/linux.go | 6 +----- pkg/build/linux_gen.sh | 11 +++++++++++ pkg/html/gen.sh | 14 ++++++++++++++ pkg/html/html.go | 9 +-------- 4 files changed, 27 insertions(+), 13 deletions(-) create mode 100755 pkg/build/linux_gen.sh create mode 100755 pkg/html/gen.sh (limited to 'pkg') diff --git a/pkg/build/linux.go b/pkg/build/linux.go index 5bc68bef9..34a980b20 100644 --- a/pkg/build/linux.go +++ b/pkg/build/linux.go @@ -1,11 +1,7 @@ // Copyright 2017 syzkaller project authors. All rights reserved. // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -//go:generate bash -c "echo -en '// Code generated by pkg/build/linux.go. DO NOT EDIT.\n\n' > linux_generated.go" -//go:generate bash -c "echo -en 'package build\n\n' >> linux_generated.go" -//go:generate bash -c "echo -en 'const createImageScript = `#!/bin/bash\n' >> linux_generated.go" -//go:generate bash -c "cat ../../tools/create-gce-image.sh | grep -v '#' >> linux_generated.go" -//go:generate bash -c "echo -en '`\n\n' >> linux_generated.go" +//go:generate ./linux_gen.sh package build diff --git a/pkg/build/linux_gen.sh b/pkg/build/linux_gen.sh new file mode 100755 index 000000000..47fe6cf59 --- /dev/null +++ b/pkg/build/linux_gen.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Copyright 2020 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +set -eu + +echo -en '// Code generated by pkg/build/linux.go. DO NOT EDIT.\n\n' > linux_generated.go +echo -en 'package build\n\n' >> linux_generated.go +echo -en 'const createImageScript = `#!/bin/bash\n' >> linux_generated.go +cat ../../tools/create-gce-image.sh | grep -v '#' >> linux_generated.go +echo -en '`\n\n' >> linux_generated.go diff --git a/pkg/html/gen.sh b/pkg/html/gen.sh new file mode 100755 index 000000000..52ffa0f64 --- /dev/null +++ b/pkg/html/gen.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Copyright 2020 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +set -eu + +echo '// Code generated by pkg/html/html.go. DO NOT EDIT.' > generated.go +echo 'package html' >> generated.go +echo 'const style = `' >> generated.go +cat ../../dashboard/app/static/style.css >> generated.go +echo '`' >> generated.go +echo 'const js = `' >> generated.go +cat ../../dashboard/app/static/common.js >> generated.go +echo '`' >> generated.go diff --git a/pkg/html/html.go b/pkg/html/html.go index 55df6d977..6f3779261 100644 --- a/pkg/html/html.go +++ b/pkg/html/html.go @@ -1,14 +1,7 @@ // Copyright 2018 syzkaller project authors. All rights reserved. // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -//go:generate bash -c "echo '// Code generated by pkg/html/html.go. DO NOT EDIT.' > generated.go" -//go:generate bash -c "echo 'package html' >> generated.go" -//go:generate bash -c "echo 'const style = `' >> generated.go" -//go:generate bash -c "cat ../../dashboard/app/static/style.css >> generated.go" -//go:generate bash -c "echo '`' >> generated.go" -//go:generate bash -c "echo 'const js = `' >> generated.go" -//go:generate bash -c "cat ../../dashboard/app/static/common.js >> generated.go" -//go:generate bash -c "echo '`' >> generated.go" +//go:generate ./gen.sh package html -- cgit mrf-deployment