build: Remove angular_src nested workspace (#21096)

PR Close #21096
This commit is contained in:
Alex Eagle 2017-12-19 15:03:29 -08:00
parent c8a1a14b87
commit a1492a73ce
25 changed files with 48 additions and 55 deletions

View File

@ -62,7 +62,7 @@ jobs:
# Use bazel query so that we explicitly ask for all buildable targets to be built as well
# This avoids waiting for a build command to finish before running the first test
# See https://github.com/bazelbuild/bazel/issues/4257
- run: bazel query --output=label '//modules/... union //packages/... union //tools/... union @angular//...' | xargs bazel test --config=ci
- run: bazel query --output=label '//modules/... union //packages/... union //tools/...' | xargs bazel test --config=ci
- save_cache:
key: *cache_key

View File

@ -1,4 +1,4 @@
workspace(name = "angular_src")
workspace(name = "angular")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
@ -24,11 +24,6 @@ load("@build_bazel_rules_typescript//:setup.bzl", "ts_setup_workspace")
ts_setup_workspace()
local_repository(
name = "angular",
path = "packages/bazel",
)
local_repository(
name = "rxjs",
path = "node_modules/rxjs/src",

View File

@ -416,9 +416,13 @@ if [[ ${BUILD_TOOLS} == true || ${BUILD_ALL} == true ]]; then
mkdir -p ./dist/packages-dist
rsync -a packages/bazel/ ./dist/packages-dist/bazel
echo "workspace(name=\"angular\")" > ./dist/packages-dist/bazel/WORKSPACE
# Remove BEGIN-INTERNAL...END-INTERAL blocks
# https://stackoverflow.com/questions/24175271/how-can-i-match-multi-line-patterns-in-the-command-line-with-perl-style-regex
perl -0777 -n -i -e "s/(?m)^.*BEGIN-INTERNAL[\w\W]*END-INTERNAL.*\n//g; print" $(grep -ril BEGIN-INTERNAL dist/packages-dist/bazel) < /dev/null 2> /dev/null
# Re-host //packages/bazel/ which is just // in the public distro
perl -0777 -n -i -e "s#//packages/bazel/#//#g; print" $(grep -ril packages/bazel dist/packages-dist/bazel) < /dev/null 2> /dev/null
perl -0777 -n -i -e "s#angular/packages/bazel/#angular/#g; print" $(grep -ril packages/bazel dist/packages-dist/bazel) < /dev/null 2> /dev/null
updateVersionReferences dist/packages-dist/bazel
fi

View File

@ -1,9 +0,0 @@
# By convention, the name should "describe the project in reverse-DNS form"
# https://docs.bazel.build/versions/master/be/functions.html#workspace
# But if we use "io_angular" then the loads used in BUILD files will
# be unfamiliar to Angular users who import from '@angular/pkg' in
# TypeScript files. We want to reduce the impedance between the Bazel
# and node naming schemes.
# We take the name "angular" so that users can write
# load("@angular//:index.bzl", "ng_module")
workspace(name = "angular")

View File

@ -268,13 +268,13 @@ NG_MODULE_ATTRIBUTES = {
"no_i18n": attr.bool(default = False),
"compiler": attr.label(
default = Label("//src/ngc-wrapped"),
default = Label("//packages/bazel/src/ngc-wrapped"),
executable = True,
cfg = "host",
),
"_ng_xi18n": attr.label(
default = Label("//src/ngc-wrapped:xi18n"),
default = Label("//packages/bazel/src/ngc-wrapped:xi18n"),
executable = True,
cfg = "host",
),

View File

@ -9,12 +9,12 @@ ts_library(
],
module_name = "@angular/bazel",
tsconfig = ":tsconfig.json",
visibility = ["//test/ngc-wrapped:__subpackages__"],
visibility = ["//packages/bazel/test/ngc-wrapped:__subpackages__"],
deps = [
# BEGIN-INTERNAL
# Only needed when compiling within the Angular repo.
# Users will get this dependency from node_modules.
"@//packages/compiler-cli",
# Only needed when compiling Angular from sources.
# Users with an npm depnedency will get this dependency from node_modules.
"//packages/compiler-cli",
# END-INTERNAL
"@build_bazel_rules_typescript//internal/tsc_wrapped",
],
@ -26,9 +26,7 @@ nodejs_binary(
":ngc_lib",
"@build_bazel_rules_typescript//internal:worker_protocol.proto",
],
# Entry point assumes the user is outside this WORKSPACE,
# and references our rules with @angular//src/ngc-wrapped
entry_point = "angular/src/ngc-wrapped/index.js",
entry_point = "angular/packages/bazel/src/ngc-wrapped/index.js",
node_modules = "@build_bazel_rules_typescript_deps//:node_modules",
visibility = ["//visibility:public"],
)
@ -38,8 +36,6 @@ nodejs_binary(
data = [
":ngc_lib",
],
# Entry point assumes the user is outside this WORKSPACE,
# and references our rules with @angular//src/ngc-wrapped
entry_point = "angular/src/ngc-wrapped/index.js/extract_i18n.js",
entry_point = "angular/packages/bazel/src/ngc-wrapped/index.js/extract_i18n.js",
visibility = ["//visibility:public"],
)

View File

@ -45,7 +45,13 @@ export function runOneBuild(args: string[], inputs?: {[path: string]: string}):
if (args[0] === '-p') args.shift();
// Strip leading at-signs, used to indicate a params file
const project = args[0].replace(/^@+/, '');
const [{options: tsOptions, bazelOpts, files, config}] = parseTsconfig(project);
const [parsedOptions, errors] = parseTsconfig(project);
if (errors && errors.length) {
console.error(ng.formatDiagnostics(errors));
return false;
}
const {options: tsOptions, bazelOpts, files, config} = parsedOptions;
const expectedOuts = config['angularCompilerOptions']['expectedOut'];
const {basePath} = ng.calcProjectFileAndBasePath(project);

View File

@ -13,9 +13,9 @@ ts_library(
# BEGIN-INTERNAL
# Only needed when compiling within the Angular repo.
# Users will get this dependency from node_modules.
"@//packages/compiler-cli",
"//packages/compiler-cli",
# END-INTERNAL
"//src/ngc-wrapped:ngc_lib",
"//packages/bazel/src/ngc-wrapped:ngc_lib",
],
)
@ -23,7 +23,7 @@ ts_library(
# .d.ts files (by default, jasmine_node_test would get the .js files).
filegroup(
name = "angular_core",
srcs = ["@//packages/core"],
srcs = ["//packages/core"],
)
jasmine_node_test(
@ -32,8 +32,8 @@ jasmine_node_test(
srcs = [":ngc_test_lib"],
data = [
":angular_core",
"//test/ngc-wrapped/empty:empty_tsconfig.json",
"//test/ngc-wrapped/empty:tsconfig.json",
"//packages/bazel/test/ngc-wrapped/empty:empty_tsconfig.json",
"//packages/bazel/test/ngc-wrapped/empty:tsconfig.json",
"@build_bazel_rules_typescript//internal:worker_protocol.proto",
],
)

View File

@ -1,10 +1,10 @@
load("@angular//:index.bzl", "ng_module")
load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//test:__subpackages__"])
package(default_visibility = ["//packages/bazel/test:__subpackages__"])
ng_module(
name = "empty",
srcs = ["empty.ts"],
tsconfig = ":tsconfig.json",
deps = ["@//packages/core"],
deps = ["//packages/core"],
)

View File

@ -47,7 +47,7 @@ export function setup(
const bazelBinPath = path.resolve(basePath, bazelBin);
fs.mkdirSync(bazelBinPath);
const angularCorePath = path.resolve(runfilesPath, 'angular_src', 'packages', 'core');
const angularCorePath = path.resolve(runfilesPath, 'angular', 'packages', 'core');
const ngFiles = listFilesRecursive(angularCorePath);
const tsConfigJsonPath = path.resolve(basePath, tsconfig);
@ -113,7 +113,8 @@ export function setup(
const emptyTsConfig = ts.readConfigFile(
path.resolve(
runfilesPath, 'angular', 'test', 'ngc-wrapped', 'empty', 'empty_tsconfig.json'),
runfilesPath, 'angular', 'packages', 'bazel', 'test', 'ngc-wrapped', 'empty',
'empty_tsconfig.json'),
read);
const tsconfig = createTsConfig({

View File

@ -32,7 +32,7 @@ export function createTsConfig(options: TsConfigOptions) {
const result = options.defaultTsConfig;
return {
'extends': '../angular/test/ngc-wrapped/empty/tsconfig',
'extends': '../angular/packages/bazel/test/ngc-wrapped/empty/tsconfig',
'compilerOptions': {
...result.compilerOptions,
'outDir': options.outDir,
@ -70,7 +70,7 @@ export function createTsConfig(options: TsConfigOptions) {
'tsickleExternsPath': '',
// we don't copy the node_modules into our tmp dir, so we should look in
// the original workspace directory for it
'nodeModulesPrefix': '../angular_src/node_modules',
'nodeModulesPrefix': '../angular/node_modules',
},
'files': options.files,
'angularCompilerOptions': {

View File

@ -23,7 +23,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//tools/testing:node",

View File

@ -36,7 +36,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
# dissable since tests are running but not yet passing
tags = ["manual"],
deps = [

View File

@ -50,7 +50,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
":test_node_only_lib",

View File

@ -46,7 +46,7 @@ ts_library(
jasmine_node_test(
name = "render3",
bootstrap = [
"angular_src/packages/core/test/render3/load_domino",
"angular/packages/core/test/render3/load_domino",
],
deps = [
":render3_node_lib",

View File

@ -18,7 +18,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//tools/testing:node",

View File

@ -19,7 +19,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//tools/testing:node",

View File

@ -15,7 +15,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
# dissable since tests are running but not yet passing
tags = ["manual"],
deps = [

View File

@ -19,7 +19,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
# dissable since tests are running but not yet passing
tags = ["manual"],
deps = [

View File

@ -25,7 +25,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
# dissable since tests are running but not yet passing
tags = ["manual"],
deps = [

View File

@ -25,7 +25,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//tools/testing:node",

View File

@ -21,7 +21,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//tools/testing:node",

View File

@ -22,7 +22,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//tools/testing:node",

View File

@ -20,7 +20,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["angular_src/tools/testing/init_node_spec.js"],
bootstrap = ["angular/tools/testing/init_node_spec.js"],
deps = [
":test_lib",
"//tools/testing:node",

View File

@ -1,6 +1,6 @@
"""Re-export of some bazel rules with repository-wide defaults."""
load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library")
load("@angular//:index.bzl", _ng_module = "ng_module")
load("//packages/bazel/src:ng_module.bzl", _ng_module = "ng_module")
DEFAULT_TSCONFIG = "//packages:tsconfig-build.json"