This repository was archived by the owner on Jan 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 766
build: add Bazel rules #964
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
af0bd91
build: add Bazel rules
CaerusKaru 5d8d592
fixup! build: add Bazel rules
CaerusKaru f3e8fac
fixup! build: add Bazel rules
CaerusKaru c9a5e06
fixup! build: add Bazel rules
CaerusKaru 373b7e6
fixup! build: add Bazel rules
CaerusKaru 9afec17
fixup! build: add Bazel rules
CaerusKaru e4959b2
fixup! build: add Bazel rules
CaerusKaru 084b2f0
fixup! build: add Bazel rules
CaerusKaru 0c69c65
fixup! build: add Bazel rules
CaerusKaru c907005
fixup! build: add Bazel rules
CaerusKaru 9ce8452
fixup! build: add Bazel rules
CaerusKaru 02d9f65
fixup! build: add Bazel rules
CaerusKaru e082964
fixup! build: add Bazel rules
CaerusKaru f56d5eb
fixup! build: add Bazel rules
CaerusKaru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,7 @@ | ||
node_modules | ||
src/apps/demo-app/node_modules | ||
src/apps/demo-app/package.json | ||
src/apps/universal-app/package.json | ||
src/apps/universal-app/node_modules | ||
src/apps/hello-world/node_modules | ||
.git |
This file contains hidden or 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,60 @@ | ||
############################### | ||
# Filesystem interactions # | ||
############################### | ||
|
||
# Don't create bazel-* symlinks in the WORKSPACE directory. | ||
# These require .gitignore and may scare users. Also, it's a workaround for | ||
# https://github.com/bazelbuild/rules_typescript/issues/12 which affects the common case of | ||
# having `tsconfig.json` in the WORKSPACE directory. Instead, you should run | ||
# `bazel info output_base` to find out where the outputs went. | ||
build --symlink_prefix=/ | ||
|
||
# Performance: avoid stat'ing input files | ||
build --watchfs | ||
|
||
# Turn off legacy external runfiles | ||
run --nolegacy_external_runfiles | ||
test --nolegacy_external_runfiles | ||
|
||
############################### | ||
# Output control # | ||
############################### | ||
|
||
# A more useful default output mode for bazel query | ||
# Prints eg. "ng_module rule //foo:bar" rather than just "//foo:bar" | ||
query --output=label_kind | ||
|
||
# By default, failing tests don't print any output, it goes to the log file | ||
test --test_output=errors | ||
|
||
# Show which actions are run under workers, | ||
# and print all the actions running in parallel. | ||
# Helps to demonstrate that bazel uses all the cores on the machine. | ||
build --experimental_ui | ||
test --experimental_ui | ||
|
||
################################# | ||
# Release configuration. # | ||
# Run with "--config=release" # | ||
################################# | ||
|
||
# Configures script to do version stamping. | ||
# See https://docs.bazel.build/versions/master/user-manual.html#flag--workspace_status_command | ||
build:release --workspace_status_command=./tools/bazel-stamp-vars.sh | ||
|
||
############################### | ||
# Typescript / Angular / Sass # | ||
############################### | ||
|
||
# Make compilation fast, by keeping a few copies of the compilers | ||
# running as daemons, and cache SourceFile AST's to reduce parse time. | ||
build --strategy=TypeScriptCompile=worker | ||
build --strategy=AngularTemplateCompile=worker | ||
|
||
################################ | ||
# Temporary Settings for Ivy # | ||
################################ | ||
|
||
# Use the legacy AOT compiler strategy. We don't want to compile with Ivy nor with "ngtsc" which | ||
# does not generate factory files which are needed for AOT. | ||
build --define=compile=legacy |
This file contains hidden or 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,7 @@ | ||
# Bazel configuration that will be copied to /etc/bazel.bazelrc in CircleCI containers. | ||
# This allows us adding specific configuration flags for builds within CircleCI. | ||
# See more: https://docs.bazel.build/versions/master/user-manual.html#where-are-the-bazelrc-files | ||
|
||
# Save downloaded repositories in a location that can be cached by CircleCI. This helps us | ||
# speeding up the analysis time significantly with Bazel managed node dependencies on the CI. | ||
build --experimental_repository_cache=/home/circleci/bazel_repository_cache |
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
exports_files(["tsconfig.json"]) |
This file contains hidden or 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,127 @@ | ||
workspace(name = "angular_layout") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
# Add NodeJS rules (explicitly used for sass bundle rules) | ||
http_archive( | ||
name = "build_bazel_rules_nodejs", | ||
url = "https://github.com/gregmagolan/rules_nodejs/archive/c8b92cee7e7ed404d7daf49d2379cd6feda799b8.zip", | ||
strip_prefix = "rules_nodejs-c8b92cee7e7ed404d7daf49d2379cd6feda799b8", | ||
) | ||
|
||
# Add TypeScript rules | ||
http_archive( | ||
name = "build_bazel_rules_typescript", | ||
strip_prefix = "rules_typescript-0.22.1", | ||
url = "https://github.com/bazelbuild/rules_typescript/archive/0.22.1.zip", | ||
) | ||
|
||
# Add Angular source and Bazel rules. | ||
http_archive( | ||
name = "angular", | ||
url = "https://github.com/angular/angular/archive/7.2.4.zip", | ||
strip_prefix = "angular-7.2.4", | ||
) | ||
|
||
# Add RxJS as repository because those are needed in order to build Angular from source. | ||
# Also we cannot refer to the RxJS version from the node modules because self-managed | ||
# node modules are not guaranteed to be installed. | ||
# TODO(gmagolan): remove this once rxjs ships with an named UMD bundle and we | ||
# are no longer building it from source. | ||
http_archive( | ||
name = "rxjs", | ||
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz", | ||
strip_prefix = "package/src", | ||
sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403", | ||
) | ||
|
||
# Angular material | ||
http_archive( | ||
name = "angular_material", | ||
strip_prefix = "material2-7.3.1", | ||
url = "https://github.com/angular/material2/archive/7.3.1.zip", | ||
) | ||
|
||
# We need to create a local repository called "npm" because currently Angular Layout | ||
# stores all of it's NPM dependencies in the "@layoutdeps" repository. This is necessary because | ||
# we don't want to reserve the "npm" repository that is commonly used by downstream projects. | ||
# Since we still need the "npm" repository in order to use the Angular or TypeScript Bazel | ||
# rules, we create a local repository that is just defined in **this** workspace and is not | ||
# being shipped to downstream projects. This can be removed once downstream projects can | ||
# consume Angular Layout completely from NPM. | ||
# TODO(CaerusKaru): remove once Angular Layout can be consumed from NPM with Bazel. | ||
local_repository( | ||
name = "npm", | ||
path = "tools/npm-workspace" | ||
) | ||
|
||
# Add sass rules | ||
http_archive( | ||
name = "io_bazel_rules_sass", | ||
url = "https://github.com/bazelbuild/rules_sass/archive/1.15.2.zip", | ||
strip_prefix = "rules_sass-1.15.2", | ||
) | ||
|
||
# Since we are explitly fetching @build_bazel_rules_typescript, we should explicitly ask for | ||
# its transitive dependencies in case those haven't been fetched yet. | ||
load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies") | ||
rules_typescript_dependencies() | ||
|
||
# Since we are explitly fetching @build_bazel_rules_nodejs, we should explicitly ask for | ||
# its transitive dependencies in case those haven't been fetched yet. | ||
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies") | ||
rules_nodejs_dependencies() | ||
|
||
# Fetch transitive dependencies which are needed by the Angular build targets. | ||
load("@angular//packages/bazel:package.bzl", "rules_angular_dependencies") | ||
rules_angular_dependencies() | ||
|
||
# Fetch transitive dependencies which are needed to use the Sass rules. | ||
load("@io_bazel_rules_sass//:package.bzl", "rules_sass_dependencies") | ||
rules_sass_dependencies() | ||
|
||
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories") | ||
|
||
# The minimum bazel version to use with this repo is 0.18.0 | ||
check_bazel_version("0.18.0") | ||
|
||
node_repositories( | ||
# For deterministic builds, specify explicit NodeJS and Yarn versions. | ||
node_version = "10.10.0", | ||
# Use latest yarn version to support integrity field (added in yarn 1.10) | ||
yarn_version = "1.12.1", | ||
) | ||
|
||
# Setup TypeScript Bazel workspace | ||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace") | ||
ts_setup_workspace() | ||
|
||
# Setup the Sass rule repositories. | ||
load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories") | ||
sass_repositories() | ||
|
||
# Setup Angular workspace for building (Bazel managed node modules) | ||
load("@angular//:index.bzl", "ng_setup_workspace") | ||
ng_setup_workspace() | ||
|
||
# Setup Material workspace for building (Bazel managed node modules) | ||
load("@angular_material//:index.bzl", "angular_material_setup_workspace") | ||
angular_material_setup_workspace() | ||
|
||
load("@angular_layout//:index.bzl", "angular_layout_setup_workspace") | ||
angular_layout_setup_workspace() | ||
|
||
# Setup Go toolchain (required for Bazel web testing rules) | ||
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains") | ||
go_rules_dependencies() | ||
go_register_toolchains() | ||
|
||
# Setup web testing. We need to setup a browser because the web testing rules for TypeScript need | ||
# a reference to a registered browser (ideally that's a hermetic version of a browser) | ||
load("@io_bazel_rules_webtesting//web:repositories.bzl", "browser_repositories", | ||
"web_test_repositories") | ||
|
||
web_test_repositories() | ||
browser_repositories( | ||
chromium = True, | ||
) |
This file contains hidden or 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,13 @@ | ||
# Copyright Google LLC All Rights Reserved. | ||
# | ||
# Use of this source code is governed by an MIT-style license that can be | ||
# found in the LICENSE file at https://angular.io/license | ||
"""Public API surface is re-exported here. | ||
This API is exported for users building Angular Layout from source in | ||
downstream projects. | ||
""" | ||
|
||
load("//tools:angular_layout_setup_workspace.bzl", | ||
_angular_layout_setup_workspace = "angular_layout_setup_workspace") | ||
|
||
angular_layout_setup_workspace = _angular_layout_setup_workspace |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.