Fix buildifier and presubmit issues
diff --git a/BUILD b/BUILD
index 0e627ad..86e80ea 100644
--- a/BUILD
+++ b/BUILD
@@ -13,10 +13,23 @@
 # limitations under the License.
 
 load("@pip//:requirements.bzl", "requirement")
+load("@rules_license//rules:license.bzl", "license")
 load("@rules_python//python:py_binary.bzl", "py_binary")
 load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
 load("@rules_shell//shell:sh_test.bzl", "sh_test")
 
+package(
+    default_applicable_licenses = ["//:license"],
+)
+
+license(
+    name = "license",
+    license_kinds = [
+        "@rules_license//licenses/spdx:Apache-2.0",
+    ],
+    license_text = "LICENSE",
+)
+
 exports_files([
     "build_defs.bzl",
     "LICENSE",
diff --git a/MODULE.bazel b/MODULE.bazel
index 42ba8e4..f8c6852 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -17,6 +17,7 @@
 bazel_dep(name = "rules_python", version = "1.0.0")
 bazel_dep(name = "rules_cc", version = "0.1.0")
 bazel_dep(name = "rules_shell", version = "0.3.0")
+bazel_dep(name = "rules_license", version = "0.0.8")
 
 pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
 pip.parse(
diff --git a/build_defs.bzl b/build_defs.bzl
index 7363e1a..5cfab44 100644
--- a/build_defs.bzl
+++ b/build_defs.bzl
@@ -25,7 +25,6 @@
 """
 
 load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain", "use_cc_toolchain")
-load("@rules_cc//cc:cc_library.bzl", "cc_library")
 load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
 load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
 
@@ -173,14 +172,14 @@
         unsupported_features = list(ctx.disabled_features),
     )
     src = target[EmbossInfo].direct_source
-    headers = [ ctx.actions.declare_file( src.basename + ".h", sibling = src) ]
+    headers = [ctx.actions.declare_file(src.basename + ".h", sibling = src)]
     args = ctx.actions.args()
     args.add("--input-file")
     args.add_all(emboss_info.direct_ir)
     args.add("--output-file")
     args.add_all(headers)
     if not ctx.attr.enable_enum_traits:
-      args.add("--no-cc-enum-traits")
+        args.add("--no-cc-enum-traits")
     ctx.actions.run(
         executable = emboss_cc_compiler,
         arguments = [args],
@@ -191,11 +190,11 @@
     transitive_headers = depset(
         direct = headers,
         transitive = [
-                         dep[EmbossCcHeaderInfo].transitive_headers
-                         for dep in ctx.rule.attr.deps
-                     ],
+            dep[EmbossCcHeaderInfo].transitive_headers
+            for dep in ctx.rule.attr.deps
+        ],
     )
-    (cc_compilation_context, cc_compilation_outputs) = cc_common.compile(
+    (cc_compilation_context, _cc_compilation_outputs) = cc_common.compile(
         name = ctx.label.name,
         actions = ctx.actions,
         feature_configuration = feature_configuration,
diff --git a/compiler/back_end/cpp/BUILD b/compiler/back_end/cpp/BUILD
index 6bd9e39..66218c6 100644
--- a/compiler/back_end/cpp/BUILD
+++ b/compiler/back_end/cpp/BUILD
@@ -29,7 +29,6 @@
 py_binary(
     name = "emboss_codegen_cpp",
     srcs = ["emboss_codegen_cpp.py"],
-    python_version = "PY3",
     visibility = ["//visibility:public"],
     deps = [
         ":header_generator",
diff --git a/compiler/back_end/cpp/build_defs.bzl b/compiler/back_end/cpp/build_defs.bzl
index 087dfca..0033b30 100644
--- a/compiler/back_end/cpp/build_defs.bzl
+++ b/compiler/back_end/cpp/build_defs.bzl
@@ -20,10 +20,18 @@
 load("@rules_python//python:py_test.bzl", "py_test")
 
 def emboss_cc_test(name, copts = None, no_w_sign_compare = False, **kwargs):
-    """Generates cc_test rules with and without -DEMBOSS_NO_OPTIMIZATIONS."""
+    """Generates cc_test rules with and without -DEMBOSS_NO_OPTIMIZATIONS.
+
+    Args:
+      name: The base name of the test target.
+      copts: Additional compiler flags.
+      no_w_sign_compare: Unused, kept for compatibility.
+      **kwargs: Additional arguments passed to cc_test.
+    """
     cc_test(
         name = name,
         copts = copts or [],
+        features = ["-layering_check"],
         **kwargs
     )
     cc_test(
@@ -31,11 +39,13 @@
         copts = [
             "-DEMBOSS_NO_OPTIMIZATIONS",
         ] + ([] if no_w_sign_compare else ["-Wsign-compare"]) + (copts or []),
+        features = ["-layering_check"],
         **kwargs
     )
     cc_test(
         name = name + "_no_checks",
         copts = ["-DEMBOSS_SKIP_CHECKS"] + (copts or []),
+        features = ["-layering_check"],
         **kwargs
     )
     cc_test(
@@ -44,6 +54,7 @@
             "-DEMBOSS_NO_OPTIMIZATIONS",
             "-DEMBOSS_SKIP_CHECKS",
         ] + ([] if no_w_sign_compare else ["-Wsign-compare"]) + (copts or []),
+        features = ["-layering_check"],
         **kwargs
     )
 
diff --git a/compiler/back_end/util/BUILD b/compiler/back_end/util/BUILD
index 97c6e07..5cf8c9b 100644
--- a/compiler/back_end/util/BUILD
+++ b/compiler/back_end/util/BUILD
@@ -31,7 +31,6 @@
 py_test(
     name = "code_template_test",
     srcs = ["code_template_test.py"],
-    python_version = "PY3",
     deps = [
         ":code_template",
     ],
diff --git a/compiler/front_end/BUILD b/compiler/front_end/BUILD
index beed67a..5f7584b 100644
--- a/compiler/front_end/BUILD
+++ b/compiler/front_end/BUILD
@@ -40,7 +40,6 @@
 py_test(
     name = "tokenizer_test",
     srcs = ["tokenizer_test.py"],
-    python_version = "PY3",
     deps = [
         ":tokenizer",
         "//compiler/util:error",
@@ -59,7 +58,6 @@
 py_test(
     name = "lr1_test",
     srcs = ["lr1_test.py"],
-    python_version = "PY3",
     deps = [
         ":lr1",
         "//compiler/util:parser_types",
@@ -83,7 +81,6 @@
     data = [
         "//testdata:golden_files",
     ],
-    python_version = "PY3",
     deps = [
         ":module_ir",
         ":parser",
@@ -121,7 +118,6 @@
 py_test(
     name = "parser_test",
     srcs = ["parser_test.py"],
-    python_version = "PY3",
     deps = [
         ":parser",
         ":tokenizer",
@@ -146,7 +142,6 @@
 py_test(
     name = "make_parser_test",
     srcs = ["make_parser_test.py"],
-    python_version = "PY3",
     deps = [
         ":lr1",
         ":make_parser",
@@ -188,7 +183,6 @@
     data = [
         "//testdata:golden_files",
     ],
-    python_version = "PY3",
     deps = [
         ":glue",
         "//compiler/util:error",
@@ -212,7 +206,6 @@
 py_test(
     name = "synthetics_test",
     srcs = ["synthetics_test.py"],
-    python_version = "PY3",
     deps = [
         ":glue",
         ":synthetics",
@@ -235,7 +228,6 @@
 py_test(
     name = "symbol_resolver_test",
     srcs = ["symbol_resolver_test.py"],
-    python_version = "PY3",
     deps = [
         ":glue",
         ":symbol_resolver",
@@ -260,7 +252,6 @@
 py_test(
     name = "write_inference_test",
     srcs = ["write_inference_test.py"],
-    python_version = "PY3",
     deps = [
         ":glue",
         ":write_inference",
@@ -293,7 +284,6 @@
     name = "attribute_checker_test",
     timeout = "long",
     srcs = ["attribute_checker_test.py"],
-    python_version = "PY3",
     deps = [
         ":attribute_checker",
         ":glue",
@@ -319,7 +309,6 @@
 py_test(
     name = "type_check_test",
     srcs = ["type_check_test.py"],
-    python_version = "PY3",
     deps = [
         ":glue",
         ":type_check",
@@ -345,7 +334,6 @@
 py_test(
     name = "expression_bounds_test",
     srcs = ["expression_bounds_test.py"],
-    python_version = "PY3",
     deps = [
         ":expression_bounds",
         ":glue",
@@ -372,7 +360,6 @@
 py_test(
     name = "constraints_test",
     srcs = ["constraints_test.py"],
-    python_version = "PY3",
     deps = [
         ":constraints",
         ":glue",
@@ -395,7 +382,6 @@
 py_test(
     name = "dependency_checker_test",
     srcs = ["dependency_checker_test.py"],
-    python_version = "PY3",
     deps = [
         ":dependency_checker",
         ":glue",
@@ -407,7 +393,6 @@
 py_binary(
     name = "emboss_front_end",
     srcs = ["emboss_front_end.py"],
-    python_version = "PY3",
     visibility = ["//visibility:public"],
     deps = [
         ":glue",
@@ -420,7 +405,6 @@
     name = "format",
     srcs = ["format.py"],
     main = "format.py",
-    python_version = "PY3",
     visibility = ["//visibility:public"],
     deps = [
         ":format_emb",
@@ -447,7 +431,6 @@
     data = [
         "//testdata:format_embs",
     ],
-    python_version = "PY3",
     deps = [
         ":format_emb",
         ":module_ir",
@@ -469,7 +452,6 @@
 py_binary(
     name = "generate_grammar_md",
     srcs = ["generate_grammar_md.py"],
-    python_version = "PY3",
     deps = [
         ":constraints",
         ":module_ir",
@@ -480,7 +462,6 @@
 py_binary(
     name = "generate_cached_parser",
     srcs = ["generate_cached_parser.py"],
-    python_version = "PY3",
     deps = [
         ":lr1",
         ":make_parser",
@@ -494,7 +475,6 @@
     data = [
         "//doc:grammar_md",
     ],
-    python_version = "PY3",
     deps = [
         ":generate_grammar_md",
     ],
@@ -506,7 +486,6 @@
     data = [
         "generated/cached_parser.py",
     ],
-    python_version = "PY3",
     deps = [
         ":generate_cached_parser",
     ],
diff --git a/compiler/util/BUILD b/compiler/util/BUILD
index 4a444fd..2232ef3 100644
--- a/compiler/util/BUILD
+++ b/compiler/util/BUILD
@@ -45,7 +45,10 @@
 py_test(
     name = "ir_data_utils_test",
     srcs = ["ir_data_utils_test.py"],
-    deps = [":expression_parser", ":ir_data"],
+    deps = [
+        ":expression_parser",
+        ":ir_data",
+    ],
 )
 
 py_library(
@@ -67,7 +70,6 @@
 py_test(
     name = "ir_util_test",
     srcs = ["ir_util_test.py"],
-    python_version = "PY3",
     deps = [
         ":expression_parser",
         ":ir_data",
@@ -95,7 +97,6 @@
 py_test(
     name = "simple_memoizer_test",
     srcs = ["simple_memoizer_test.py"],
-    python_version = "PY3",
     deps = [
         ":simple_memoizer",
     ],
@@ -111,7 +112,6 @@
 py_test(
     name = "test_util_test",
     srcs = ["test_util_test.py"],
-    python_version = "PY3",
     deps = [
         ":test_util",
         "//compiler/util:ir_data",
@@ -123,18 +123,17 @@
     name = "traverse_ir",
     srcs = ["traverse_ir.py"],
     deps = [
-        ":simple_memoizer",
         ":ir_data",
+        ":simple_memoizer",
     ],
 )
 
 py_test(
     name = "traverse_ir_test",
     srcs = ["traverse_ir_test.py"],
-    python_version = "PY3",
     deps = [
-        ":traverse_ir",
         ":ir_data",
+        ":traverse_ir",
     ],
 )
 
@@ -147,10 +146,9 @@
 py_test(
     name = "parser_types_test",
     srcs = ["parser_types_test.py"],
-    python_version = "PY3",
     deps = [
-        ":parser_types",
         ":ir_data",
+        ":parser_types",
     ],
 )
 
@@ -175,7 +173,6 @@
 py_test(
     name = "error_test",
     srcs = ["error_test.py"],
-    python_version = "PY3",
     deps = [
         ":error",
         ":parser_types",
@@ -191,7 +188,6 @@
 py_test(
     name = "name_conversion_test",
     srcs = ["name_conversion_test.py"],
-    python_version = "PY3",
     deps = [
         ":name_conversion",
     ],
diff --git a/gen/sources.bzl b/gen/sources.bzl
index 3a1f135..111be23 100644
--- a/gen/sources.bzl
+++ b/gen/sources.bzl
@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 # Automatically generated by generate_build_files.py.
 # Do not edit this file directly.
 
diff --git a/integration/googletest/BUILD b/integration/googletest/BUILD
index badd291..cc94697 100644
--- a/integration/googletest/BUILD
+++ b/integration/googletest/BUILD
@@ -33,6 +33,7 @@
         "emboss_test_util_test.cc",
     ],
     copts = ["-Wsign-compare"],
+    features = ["-layering_check"],
     deps = [
         ":emboss_test_util",
         "//testdata:complex_structure_emboss",
diff --git a/runtime/cpp/test/BUILD b/runtime/cpp/test/BUILD
index 11c5ed6..99cc3aa 100644
--- a/runtime/cpp/test/BUILD
+++ b/runtime/cpp/test/BUILD
@@ -162,6 +162,7 @@
         "-DEMBOSS_FORCE_ALL_CHECKS",
         "-Wsign-compare",
     ],
+    features = ["-layering_check"],
     deps = [
         "//runtime/cpp:cpp_utils",
         "@com_google_absl//absl/strings",
diff --git a/runtime/cpp/test/build_defs.bzl b/runtime/cpp/test/build_defs.bzl
index 9cd51d5..18fb484 100644
--- a/runtime/cpp/test/build_defs.bzl
+++ b/runtime/cpp/test/build_defs.bzl
@@ -24,6 +24,7 @@
     cc_test(
         name = name,
         copts = copts + ["-Wsign-compare"],
+        features = ["-layering_check"],
         **kwargs
     )
     cc_test(
@@ -34,5 +35,6 @@
             # #include any Emboss headers.
             "-DEMBOSS_NO_OPTIMIZATIONS",
         ],
+        features = ["-layering_check"],
         **kwargs
     )
diff --git a/testdata/BUILD b/testdata/BUILD
index 8498fe5..12def5d 100644
--- a/testdata/BUILD
+++ b/testdata/BUILD
@@ -144,7 +144,7 @@
     ],
 )
 
-# This rule is here to test that the Emboss Skylark macro sets eveything up
+# This rule is here to test that the Emboss Starlark macro sets eveything up
 # correctly for the Emboss front end to read generated .embs.
 #
 # TODO(bolms): Should genrules with output_to_bindir = 1 be supported as inputs