|
@@ -5,7 +5,6 @@
|
|
|
"""Provides rules for building Carbon files using the toolchain."""
|
|
"""Provides rules for building Carbon files using the toolchain."""
|
|
|
|
|
|
|
|
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
|
|
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
|
|
|
-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import")
|
|
|
|
|
|
|
|
|
|
def carbon_binary(name, srcs):
|
|
def carbon_binary(name, srcs):
|
|
|
"""Compiles a Carbon binary.
|
|
"""Compiles a Carbon binary.
|
|
@@ -34,14 +33,21 @@ def carbon_binary(name, srcs):
|
|
|
srcs = srcs,
|
|
srcs = srcs,
|
|
|
outs = [out],
|
|
outs = [out],
|
|
|
)
|
|
)
|
|
|
- cc_import(
|
|
|
|
|
- name = "%s.objs" % name,
|
|
|
|
|
- objects = [src + ".compile" for src in srcs],
|
|
|
|
|
- )
|
|
|
|
|
|
|
|
|
|
# For now, we assume that the prelude doesn't produce any necessary object
|
|
# For now, we assume that the prelude doesn't produce any necessary object
|
|
|
# code, and don't include the .o files for //core/prelude... in the final
|
|
# code, and don't include the .o files for //core/prelude... in the final
|
|
|
# linked binary.
|
|
# linked binary.
|
|
|
#
|
|
#
|
|
|
# TODO: This will need to be revisited eventually.
|
|
# TODO: This will need to be revisited eventually.
|
|
|
- cc_binary(name = name, deps = ["%s.objs" % name])
|
|
|
|
|
|
|
+ objs = [s + ".o" for s in srcs]
|
|
|
|
|
+ run_binary(
|
|
|
|
|
+ name = name + ".link",
|
|
|
|
|
+ tool = "//toolchain/driver:carbon",
|
|
|
|
|
+ args = (["link"] +
|
|
|
|
|
+ ["$(location %s)" % s for s in objs] +
|
|
|
|
|
+ ["--output=$(location %s)" % name]),
|
|
|
|
|
+ srcs = objs,
|
|
|
|
|
+ outs = [name],
|
|
|
|
|
+ # `link` has a dependency on ld, which should be in /usr/bin.
|
|
|
|
|
+ env = {"PATH": "/usr/bin"},
|
|
|
|
|
+ )
|