Skip to content

Commit

Permalink
Move //src/parse/rules to top-level //rules (#667)
Browse files Browse the repository at this point in the history
* Move src/parse/rules to top-level /rules

* rename everything

* lint all the things
  • Loading branch information
peterebden committed Jun 26, 2019
1 parent 31f23e1 commit 7d1e0a9
Show file tree
Hide file tree
Showing 42 changed files with 46 additions and 46 deletions.
14 changes: 7 additions & 7 deletions .plzconfig.bootstrap
@@ -1,12 +1,12 @@
; Used during initial bootstrap, mostly to get rules loaded.
[parse]
preloadbuilddefs = src/parse/rules/builtins.build_defs
preloadbuilddefs = src/parse/rules/go_rules.build_defs
preloadbuilddefs = src/parse/rules/misc_rules.build_defs
preloadbuilddefs = src/parse/rules/proto_rules.build_defs
preloadbuilddefs = src/parse/rules/python_rules.build_defs
preloadbuilddefs = src/parse/rules/subrepo_rules.build_defs
preloadbuilddefs = src/parse/rules/sh_rules.build_defs
preloadbuilddefs = rules/builtins.build_defs
preloadbuilddefs = rules/go_rules.build_defs
preloadbuilddefs = rules/misc_rules.build_defs
preloadbuilddefs = rules/proto_rules.build_defs
preloadbuilddefs = rules/python_rules.build_defs
preloadbuilddefs = rules/subrepo_rules.build_defs
preloadbuilddefs = rules/sh_rules.build_defs
preloadbuilddefs = build_defs/go_bindata.build_defs

[display]
Expand Down
2 changes: 1 addition & 1 deletion docs/post_build.html
Expand Up @@ -28,7 +28,7 @@ <h2>Pre-build function</h2>
returned values). Having got these, one can then call <code>set_command(name, cmd)</code>
to alter the command for your rule.</p>

<p>The built-in C++ rules for Please (<code><a href="https://github.com/thought-machine/please/blob/master/src/parse/rules/cc_rules.build_defs">src/parse/rules/cc_rules.build_defs</a></code>) are a reasonably good example of how to use this.</p>
<p>The built-in C++ rules for Please (<code><a href="https://github.com/thought-machine/please/blob/master/rules/cc_rules.build_defs">rules/cc_rules.build_defs</a></code>) are a reasonably good example of how to use this.</p>

<h2>Post-build function</h2>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/core/build_label.go
Expand Up @@ -192,7 +192,7 @@ func parseBuildLabelSubrepo(target, currentPath string, subrepo *Subrepo) (strin
return pkg, name, target[:idx]
}

// As above, but allows parsing of relative labels (eg. src/parse/rules:python_rules)
// As above, but allows parsing of relative labels (eg. rules:python_rules)
// which is convenient at the shell prompt
func parseMaybeRelativeBuildLabel(target, subdir string) (BuildLabel, error) {
// Try the ones that don't need locating the repo root first.
Expand Down
4 changes: 2 additions & 2 deletions src/parse/BUILD
Expand Up @@ -8,12 +8,12 @@ go_library(
],
visibility = ["PUBLIC"],
deps = [
"//rules",
"//rules/bazel",
"//src/cli",
"//src/core",
"//src/fs",
"//src/parse/asp",
"//src/parse/rules",
"//src/parse/rules/bazel",
"//src/utils",
"//src/worker",
"//third_party/go:logging",
Expand Down
4 changes: 2 additions & 2 deletions src/parse/asp/BUILD
Expand Up @@ -41,8 +41,8 @@ go_test(
data = ["test_data"],
deps = [
":asp",
"//rules",
"//src/core",
"//src/parse/rules",
"//third_party/go:testify",
],
)
Expand All @@ -53,8 +53,8 @@ go_test(
data = ["test_data"],
deps = [
":asp",
"//rules",
"//src/core",
"//src/parse/rules",
"//third_party/go:logging",
"//third_party/go:testify",
],
Expand Down
2 changes: 1 addition & 1 deletion src/parse/asp/fuzz/BUILD
Expand Up @@ -11,9 +11,9 @@ genrule(
],
tools = ["//third_party/go:go-fuzz-build"],
deps = [
"//rules",
"//src/core",
"//src/parse/asp",
"//src/parse/rules",
"//third_party/go:go-fuzz-dep",
],
)
4 changes: 2 additions & 2 deletions src/parse/asp/fuzz/fuzz.go
Expand Up @@ -6,9 +6,9 @@ import (
"sort"
"strings"

"github.com/thought-machine/please/rules"
"github.com/thought-machine/please/src/core"
"github.com/thought-machine/please/src/parse/asp"
"github.com/thought-machine/please/src/parse/rules"
)

func isWhitelisted(err error) bool {
Expand Down Expand Up @@ -68,7 +68,7 @@ func Fuzz(data []byte) int {
if strings.HasSuffix(filename, ".gob") {
srcFile := strings.TrimSuffix(filename, ".gob")
src, _ := rules.Asset(srcFile)
p.MustLoadBuiltins("src/parse/rules/"+srcFile, src, rules.MustAsset(filename))
p.MustLoadBuiltins("rules/"+srcFile, src, rules.MustAsset(filename))
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/parse/asp/interpreter.go
Expand Up @@ -43,11 +43,11 @@ func (i *interpreter) LoadBuiltins(filename string, contents []byte, statements
// Gentle hack - attach the native code once we have loaded the correct file.
// Needs to be after this file is loaded but before any of the others that will
// use functions from it.
if filename == "builtins.build_defs" || filename == "src/parse/rules/builtins.build_defs" {
if filename == "builtins.build_defs" || filename == "rules/builtins.build_defs" {
defer registerBuiltins(s)
} else if filename == "misc_rules.build_defs" || filename == "src/parse/rules/misc_rules.build_defs" {
} else if filename == "misc_rules.build_defs" || filename == "rules/misc_rules.build_defs" {
defer registerSubincludePackage(s)
} else if filename == "config_rules.build_defs" || filename == "src/parse/rules/config_rules.build_defs" {
} else if filename == "config_rules.build_defs" || filename == "rules/config_rules.build_defs" {
defer setNativeCode(s, "select", selectFunc)
}
defer i.scope.SetAll(s.Freeze(), true)
Expand Down
2 changes: 1 addition & 1 deletion src/parse/asp/interpreter_test.go
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/thought-machine/please/src/core"
"github.com/thought-machine/please/src/parse/rules"
"github.com/thought-machine/please/rules"
)

func parseFileToStatements(filename string) (*scope, []*Statement, error) {
Expand Down
2 changes: 1 addition & 1 deletion src/parse/asp/logging_test.go
Expand Up @@ -12,7 +12,7 @@ import (
"gopkg.in/op/go-logging.v1"

"github.com/thought-machine/please/src/core"
"github.com/thought-machine/please/src/parse/rules"
"github.com/thought-machine/please/rules"
)

type record struct {
Expand Down
4 changes: 2 additions & 2 deletions src/parse/asp/main/BUILD
Expand Up @@ -2,10 +2,10 @@ go_binary(
name = "asp",
srcs = ["main.go"],
deps = [
"//rules",
"//src/cli",
"//src/core",
"//src/parse/asp",
"//src/parse/rules",
"//third_party/go:logging",
"//third_party/go:spew",
],
Expand All @@ -14,7 +14,7 @@ go_binary(
go_binary(
name = "compiler",
srcs = ["compiler.go"],
visibility = ["//src/parse/rules:all"],
visibility = ["//rules:all"],
deps = [
"//src/cli",
"//src/core",
Expand Down
4 changes: 2 additions & 2 deletions src/parse/asp/main/main.go
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/thought-machine/please/src/cli"
"github.com/thought-machine/please/src/core"
"github.com/thought-machine/please/src/parse/asp"
"github.com/thought-machine/please/src/parse/rules"
"github.com/thought-machine/please/rules"
)

var log = logging.MustGetLogger("parser")
Expand Down Expand Up @@ -114,7 +114,7 @@ func main() {
if strings.HasSuffix(filename, ".gob") {
srcFile := strings.TrimSuffix(filename, ".gob")
src, _ := rules.Asset(srcFile)
p.MustLoadBuiltins("src/parse/rules/"+srcFile, src, rules.MustAsset(filename))
p.MustLoadBuiltins("rules/"+srcFile, src, rules.MustAsset(filename))
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/parse/init.go
Expand Up @@ -9,10 +9,10 @@ import (
"sort"
"strings"

"github.com/thought-machine/please/rules"
"github.com/thought-machine/please/rules/bazel"
"github.com/thought-machine/please/src/core"
"github.com/thought-machine/please/src/parse/asp"
"github.com/thought-machine/please/src/parse/rules"
"github.com/thought-machine/please/src/parse/rules/bazel"
)

// InitParser initialises the parser engine. This is guaranteed to be called exactly once before any calls to Parse().
Expand All @@ -35,7 +35,7 @@ func newAspParser(state *core.BuildState) *asp.Parser {
if strings.HasSuffix(filename, ".gob") {
srcFile := strings.TrimSuffix(filename, ".gob")
src, _ := rules.Asset(srcFile)
p.MustLoadBuiltins("src/parse/rules/"+srcFile, src, rules.MustAsset(filename))
p.MustLoadBuiltins("rules/"+srcFile, src, rules.MustAsset(filename))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/parse/rules.go
Expand Up @@ -8,9 +8,9 @@ import (
"sort"
"strings"

"github.com/thought-machine/please/rules"
"github.com/thought-machine/please/src/core"
"github.com/thought-machine/please/src/parse/asp"
"github.com/thought-machine/please/src/parse/rules"
)

// PrintRuleArgs prints the arguments of all builtin rules (plus any associated ones from the given targets)
Expand Down
2 changes: 1 addition & 1 deletion src/query/query_step.go
Expand Up @@ -3,7 +3,7 @@
// Currently supported operations:
// 'deps': 'plz query deps //src:please'
// shows the dependency graph of this target.
// 'somepath': 'plz query somepath //src:please //src/parse/rules:java_rules_pyc'
// 'somepath': 'plz query somepath //src:please //rules:java_rules_pyc'
// finds a route between these two targets, if there is one.
// useful for saying 'why on earth do I depend on that thing?'
// 'alltargets': 'plz query alltargets //src/...'
Expand Down
4 changes: 2 additions & 2 deletions tools/build_langserver/langserver/BUILD
Expand Up @@ -6,13 +6,13 @@ go_library(
),
visibility = ["//tools/build_langserver/..."],
deps = [
"//rules",
"//src/build",
"//src/cli",
"//src/core",
"//src/fs",
"//src/parse",
"//src/parse/asp",
"//src/parse/rules",
"//src/plz",
"//src/query",
"//third_party/go:buildtools",
Expand All @@ -37,7 +37,7 @@ go_test(
sandbox = False,
deps = [
":langserver",
"//src/parse/rules",
"//rules",
"//third_party/go:testify",
],
)
Expand Down
2 changes: 1 addition & 1 deletion tools/build_langserver/langserver/analyzer.go
Expand Up @@ -11,11 +11,11 @@ import (
"strconv"
"strings"

"github.com/thought-machine/please/rules"
"github.com/thought-machine/please/src/cli"
"github.com/thought-machine/please/src/core"
"github.com/thought-machine/please/src/fs"
"github.com/thought-machine/please/src/parse/asp"
"github.com/thought-machine/please/src/parse/rules"
"github.com/thought-machine/please/src/plz"
"github.com/thought-machine/please/src/query"
"github.com/thought-machine/please/tools/build_langserver/lsp"
Expand Down
4 changes: 2 additions & 2 deletions tools/build_langserver/langserver/analyzer_test.go
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/thought-machine/please/src/core"
"github.com/thought-machine/please/src/parse/asp"
"github.com/thought-machine/please/src/parse/rules"
"github.com/thought-machine/please/rules"
"github.com/thought-machine/please/tools/build_langserver/lsp"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestBuildLabelFromString(t *testing.T) {
" \"//src/fs\",\n" +
" \"//src/parse\",\n" +
" \"//src/parse/asp\",\n" +
" \"//src/parse/rules\",\n" +
" \"//rules\",\n" +
" \"//third_party/go:jsonrpc2\",\n" +
" \"//third_party/go:logging\",\n" +
" \"//tools/build_langserver/lsp\",\n" +
Expand Down
4 changes: 2 additions & 2 deletions tools/build_langserver/langserver/diagnostics_test.go
Expand Up @@ -38,11 +38,11 @@ func TestDiagnosisInvalidBuildLabel(t *testing.T) {
// Test for invisible build label
expected = lsp.Range{
Start: lsp.Position{Line: 12, Character: 8},
End: lsp.Position{Line: 12, Character: 27},
End: lsp.Position{Line: 12, Character: 17},
}
diag = FindDiagnosticByRange(ds.stored, expected)
assert.NotNil(t, diag)
assert.Equal(t, "build label //src/parse/rules is not visible to current package", diag.Message)
assert.Equal(t, "build label //rules is not visible to current package", diag.Message)

}

Expand Down
Expand Up @@ -11,7 +11,7 @@ label_list_multi = [
"//src/core",
"//src/parse",
"//src/parse/asp",
"//src/parse/rules",
"//rules",
"//third_party/go:jsonrpc2",
"//third_party/go:logging",
"//tools/build_langserver/lsp",
Expand Down
Expand Up @@ -14,7 +14,7 @@ go_test(
data = ["test_data"],
deps = [
":",
"//src/parse/rules",
"//rules",
"//third_party/go:testify",
],
)
Expand Down
Expand Up @@ -9,7 +9,7 @@ randoms = [
"//src/fs",
"//src/parse",
"//src/parse/asp",
"//src/parse/rules",
"//rules",
"//third_party/go:jsonrpc2",
"//third_party/go:logging",
"//tools/build_langserver/lsp",
Expand Down
4 changes: 2 additions & 2 deletions tools/build_langserver/langserver/test_data/example.build
Expand Up @@ -10,7 +10,7 @@ go_library(
"//src/fs",
"//src/parse",
"//src/parse/asp",
"//src/parse/rules",
"//rules",
"//third_party/go:jsonrpc2",
"//third_party/go:logging",
"//tools/build_langserver/lsp",
Expand All @@ -26,7 +26,7 @@ go_test(
foo = ["test_data"],
deps = [
":langserver",
"//src/parse/rules",
"//rules",
"//third_party/go:testify",
"//dummy/buildlabels:foo",
],
Expand Down
4 changes: 2 additions & 2 deletions tools/build_langserver/langserver/test_data/example2.build
Expand Up @@ -12,7 +12,7 @@ go_library(
"//src/fs",
"//src/parse",
"//src/parse/asp",
"//src/parse/rules",
"//rules",
"//third_party/go:jsonrpc2",
"//third_party/go:logging",
"//tools/build_langserver/lsp",
Expand All @@ -28,7 +28,7 @@ go_test(
data = ["test_data"],
deps = [
":langserver",
"//src/parse/rules",
"//rules",
"//third_party/go:testify",
],
)
Expand Up @@ -6,7 +6,7 @@ go_test(
foo = ["test_data"],
deps = [
":langserver",
"//src/parse/rules",
"//rules",
"//third_party/go:testify",
"//dummy/buildlabels:foo",
],
Expand Down
2 changes: 1 addition & 1 deletion tools/misc/lint.sh
Expand Up @@ -18,7 +18,7 @@ for TARGET in `$plz query alltargets --include go_src --hidden | grep -v "_test#
exit 1
}
if [ "`gofmt -s -l $FILTERED`" != "" ]; then
echo "Files are not gofmt'd: gofmt -s -l" $FILTERED
echo "Files are not gofmt'd: gofmt -s -w" $FILTERED
exit 1
fi
fi
Expand Down

0 comments on commit 7d1e0a9

Please sign in to comment.