Skip to content

Commit b05db3d

Browse files
authored
Add BUILD.bazel files for the mmv1 compiler (#15739)
1 parent c0d20fb commit b05db3d

File tree

13 files changed

+218
-2
lines changed

13 files changed

+218
-2
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ go_sdk.download(version = "1.24.0")
66

77
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
88
go_deps.from_file(go_work = "//:go.work")
9-
use_repo(go_deps, "com_github_hashicorp_hcl", "com_github_golang_glog", "com_github_googlecloudplatform_declarative_resource_client_library", "com_github_kylelemons_godebug", "com_github_nasa9084_go_openapi", "in_gopkg_yaml_v2", "org_bitbucket_creachadair_stringset")
9+
use_repo(go_deps, "com_github_getkin_kin_openapi", "com_github_golang_glog", "com_github_googlecloudplatform_declarative_resource_client_library", "com_github_hashicorp_hcl", "com_github_kylelemons_godebug", "com_github_nasa9084_go_openapi", "com_github_otiai10_copy", "in_gopkg_yaml_v2", "in_gopkg_yaml_v3", "org_bitbucket_creachadair_stringset", "org_golang_x_exp")

mmv1/BUILD.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
load("@rules_go//go:def.bzl", "go_binary", "go_library")
2+
3+
go_library(
4+
name = "mmv1_lib",
5+
srcs = ["main.go"],
6+
importpath = "github.com/GoogleCloudPlatform/magic-modules/mmv1",
7+
visibility = ["//visibility:private"],
8+
deps = [
9+
"//mmv1/api",
10+
"//mmv1/loader",
11+
"//mmv1/openapi_generate",
12+
"//mmv1/provider",
13+
"@org_golang_x_exp//slices",
14+
],
15+
)
16+
17+
go_binary(
18+
name = "mmv1",
19+
embed = [":mmv1_lib"],
20+
visibility = ["//visibility:public"],
21+
)

mmv1/api/BUILD.bazel

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
load("@rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "api",
5+
srcs = [
6+
"async.go",
7+
"compiler.go",
8+
"product.go",
9+
"resource.go",
10+
"timeouts.go",
11+
"type.go",
12+
],
13+
importpath = "github.com/GoogleCloudPlatform/magic-modules/mmv1/api",
14+
visibility = ["//visibility:public"],
15+
deps = [
16+
"//mmv1/api/product",
17+
"//mmv1/api/resource",
18+
"//mmv1/api/utils",
19+
"//mmv1/google",
20+
"@com_github_golang_glog//:glog",
21+
"@in_gopkg_yaml_v3//:yaml_v3",
22+
"@org_golang_x_exp//slices",
23+
],
24+
)
25+
26+
go_test(
27+
name = "api_test",
28+
srcs = [
29+
"product_test.go",
30+
"resource_test.go",
31+
"type_test.go",
32+
],
33+
embed = [":api"],
34+
deps = ["//mmv1/api/product"],
35+
)

mmv1/api/product/BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@rules_go//go:def.bzl", "go_library")
2+
3+
go_library(
4+
name = "product",
5+
srcs = ["version.go"],
6+
importpath = "github.com/GoogleCloudPlatform/magic-modules/mmv1/api/product",
7+
visibility = ["//visibility:public"],
8+
deps = ["@org_golang_x_exp//slices"],
9+
)

mmv1/api/resource/BUILD.bazel

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
load("@rules_go//go:def.bzl", "go_library")
2+
3+
go_library(
4+
name = "resource",
5+
srcs = [
6+
"custom_code.go",
7+
"datasource.go",
8+
"docs.go",
9+
"examples.go",
10+
"iam_policy.go",
11+
"nested_query.go",
12+
"reference_links.go",
13+
"sample.go",
14+
"step.go",
15+
"sweeper.go",
16+
"tgc.go",
17+
"validation.go",
18+
],
19+
importpath = "github.com/GoogleCloudPlatform/magic-modules/mmv1/api/resource",
20+
visibility = ["//visibility:public"],
21+
deps = [
22+
"//mmv1/api/product",
23+
"//mmv1/api/utils",
24+
"//mmv1/google",
25+
"@com_github_golang_glog//:glog",
26+
"@in_gopkg_yaml_v3//:yaml_v3",
27+
],
28+
)

mmv1/api/resource_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,11 @@ func TestMagicianLocation(t *testing.T) {
343343
break
344344
}
345345

346+
// When running under bazel runtime paths are relative
347+
if dir == "." {
348+
break
349+
}
350+
346351
parentDir := filepath.Dir(dir)
347352
if parentDir == dir {
348353
t.Fatal("Could not find mmv1 directory in parent directories")

mmv1/api/utils/BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "utils",
5+
srcs = [
6+
"omit_defaults.go",
7+
"utils.go",
8+
],
9+
importpath = "github.com/GoogleCloudPlatform/magic-modules/mmv1/api/utils",
10+
visibility = ["//visibility:public"],
11+
)
12+
13+
go_test(
14+
name = "utils_test",
15+
srcs = [
16+
"omit_defaults_test.go",
17+
"utils_test.go",
18+
],
19+
embed = [":utils"],
20+
)

mmv1/google/BUILD.bazel

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load("@rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "google",
5+
srcs = [
6+
"slice_utils.go",
7+
"string_utils.go",
8+
"template_utils.go",
9+
"yaml_validator.go",
10+
],
11+
importpath = "github.com/GoogleCloudPlatform/magic-modules/mmv1/google",
12+
visibility = ["//visibility:public"],
13+
deps = [
14+
"@com_github_golang_glog//:glog",
15+
"@in_gopkg_yaml_v3//:yaml_v3",
16+
],
17+
)
18+
19+
go_test(
20+
name = "google_test",
21+
srcs = [
22+
"slice_utils_test.go",
23+
"string_utils_test.go",
24+
],
25+
embed = [":google"],
26+
)

mmv1/loader/BUILD.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
load("@rules_go//go:def.bzl", "go_library")
2+
3+
go_library(
4+
name = "loader",
5+
srcs = [
6+
"custom_errors.go",
7+
"file_ops.go",
8+
"loader.go",
9+
],
10+
importpath = "github.com/GoogleCloudPlatform/magic-modules/mmv1/loader",
11+
visibility = ["//visibility:public"],
12+
deps = [
13+
"//mmv1/api",
14+
"@com_github_golang_glog//:glog",
15+
"@org_golang_x_exp//slices",
16+
],
17+
)

mmv1/openapi_generate/BUILD.bazel

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
load("@rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "openapi_generate",
5+
srcs = ["parser.go"],
6+
embedsrcs = ["header.txt"],
7+
importpath = "github.com/GoogleCloudPlatform/magic-modules/mmv1/openapi_generate",
8+
visibility = ["//visibility:public"],
9+
deps = [
10+
"//mmv1/api",
11+
"//mmv1/api/product",
12+
"//mmv1/api/resource",
13+
"//mmv1/google",
14+
"@com_github_getkin_kin_openapi//openapi3",
15+
"@in_gopkg_yaml_v3//:yaml_v3",
16+
],
17+
)
18+
19+
go_test(
20+
name = "openapi_generate_test",
21+
srcs = ["parser_test.go"],
22+
embed = [":openapi_generate"],
23+
embedsrcs = ["test_data/test_api.yaml"],
24+
deps = ["@com_github_getkin_kin_openapi//openapi3"],
25+
)

0 commit comments

Comments
 (0)