forked from carbon-language/carbon-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make driver find all prelude files. Add build rule for //examples:sie…
…ve. (carbon-language#3895) The driver now looks for all files under core/prelude/ and considers them all to be part of the prelude. The driver also now only processes the prelude in `--phase=check` and later, when it would actually be imported. With that done, add a simple `carbon_binary` build rule and use it to build the example in `//examples`. This should cause the example to be built as part of our continuous integration. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
- Loading branch information
Showing
13 changed files
with
185 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
# Exceptions. See /LICENSE for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
# Exceptions. See /LICENSE for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
"""Provides rules for building Carbon files using the toolchain.""" | ||
|
||
load("@bazel_skylib//rules:run_binary.bzl", "run_binary") | ||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import") | ||
|
||
def carbon_binary(name, srcs): | ||
"""Compiles a Carbon binary. | ||
Args: | ||
name: The name of the build target. | ||
srcs: List of Carbon source files to compile. | ||
""" | ||
for src in srcs: | ||
# Build each source file. For now, we pass all sources to each compile | ||
# because we don't have visibility into dependencies and have no way to | ||
# specify multiple output files. Object code for each input is written | ||
# into the output file in turn, so the final carbon source file | ||
# specified ends up determining the contents of the object file. | ||
# | ||
# TODO: This is a hack; replace with something better once the toolchain | ||
# supports doing so. | ||
out = src + ".o" | ||
srcs_reordered = [s for s in srcs if s != src] + [src] | ||
run_binary( | ||
name = src + ".compile", | ||
tool = "//toolchain/driver:carbon", | ||
args = (["compile"] + | ||
["$(location %s)" % s for s in srcs_reordered] + | ||
["--output=$(location %s)" % out]), | ||
srcs = srcs, | ||
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 | ||
# code, and don't include the .o files for //core/prelude... in the final | ||
# linked binary. | ||
# | ||
# TODO: This will need to be revisited eventually. | ||
cc_binary(name = name, deps = ["%s.objs" % name]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
// Exceptions. See /LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
package Core library "prelude/types" api; | ||
|
||
// TODO: Add a mechanism to re-export the names declared here. | ||
|
||
// TODO: Start importing `prelude/types/i32` here once we stop eagerly importing | ||
// all `impl`s from all imported files. Currently, this introduces too much | ||
// noise in the toolchain tests. | ||
// import library "prelude/types/i32"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
# Exceptions. See /LICENSE for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
load("//bazel/carbon_rules:defs.bzl", "carbon_binary") | ||
|
||
carbon_binary( | ||
name = "sieve", | ||
srcs = ["sieve.carbon"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.