Compile the compiler into a .par file (#7)
diff --git a/compiler/BUILD b/compiler/BUILD
index bbc0f8d..b549c9e 100644
--- a/compiler/BUILD
+++ b/compiler/BUILD
@@ -2,6 +2,8 @@
package(default_visibility = ["//visibility:public"])
+load("//:subpar.bzl", "parfile")
+
py_library(
name = "compiler_lib",
srcs = [
@@ -33,13 +35,13 @@
deps = [":compiler_lib"],
)
-py_binary(
- name = "compiler3",
- srcs = ["compiler.py"],
- default_python_version = "PY3",
+# Compile the compiler while carefully avoiding a circular dependency
+parfile(
+ name = "compiler.par",
+ src = ":compiler",
+ compiler = ":compiler",
+ default_python_version = "PY2",
main = "compiler.py",
- srcs_version = "PY2AND3",
- deps = [":compiler_lib"],
)
[py_test(
diff --git a/subpar.bzl b/subpar.bzl
index e9f27ba..8506a8c 100644
--- a/subpar.bzl
+++ b/subpar.bzl
@@ -80,7 +80,7 @@
inputs=inputs + extra_inputs,
outputs=[ctx.outputs.executable],
progress_message='Building par file %s' % ctx.label,
- executable=ctx.executable._compiler,
+ executable=ctx.executable.compiler,
arguments=args,
mnemonic='PythonCompile',
)
@@ -110,8 +110,8 @@
),
"imports": attr.string_list(default = []),
"default_python_version": attr.string(mandatory = True),
- "_compiler": attr.label(
- default = Label("//compiler"),
+ "compiler": attr.label(
+ default = Label("//compiler:compiler.par"),
executable = True,
),
},