From 9e5eacc9278de3c3fca8399ec476aed04340acab Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 9 Sep 2022 08:48:30 -0500 Subject: [PATCH 1/8] Add support for per-`xcodeproj` Bazel configurations --- .../fixtures/bwb.xcodeproj/project.pbxproj | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- .../integration/test/fixtures/bwb_spec.json | 1 + .../fixtures/bwx.xcodeproj/project.pbxproj | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- .../integration/test/fixtures/bwx_spec.json | 1 + .../fixtures/bwb.xcodeproj/project.pbxproj | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- examples/ios_app/test/fixtures/bwb_spec.json | 1 + .../fixtures/bwx.xcodeproj/project.pbxproj | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- examples/ios_app/test/fixtures/bwx_spec.json | 1 + .../fixtures/cc/bwb.xcodeproj/project.pbxproj | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- test/fixtures/cc/bwb_spec.json | 1 + .../fixtures/cc/bwx.xcodeproj/project.pbxproj | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- test/fixtures/cc/bwx_spec.json | 1 + .../generator/bwb.xcodeproj/project.pbxproj | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- test/fixtures/generator/bwb_spec.json | 1 + .../generator/bwx.xcodeproj/project.pbxproj | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- test/fixtures/generator/bwx_spec.json | 1 + .../simple/bwb.xcodeproj/project.pbxproj | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- test/fixtures/simple/bwb_spec.json | 1 + .../rules_xcodeproj/bazel/bazel_build.sh | 10 ++++---- test/fixtures/simple/bwx_spec.json | 1 + tools/generator/src/DTO/Project.swift | 1 + .../AddBazelDependenciesTarget.swift | 2 ++ .../generator/src/Generator/Environment.swift | 1 + tools/generator/src/Generator/Generator.swift | 1 + .../bazel_integration_files/bazel_build.sh | 10 ++++---- xcodeproj/internal/fixtures.bzl | 3 +++ xcodeproj/internal/runner.template.sh | 5 ++-- xcodeproj/internal/xcodeproj_macro.bzl | 18 +++++++++++++ xcodeproj/internal/xcodeproj_rule.bzl | 7 ++++++ xcodeproj/internal/xcodeproj_runner.bzl | 25 +++++++++++++++++++ 39 files changed, 134 insertions(+), 58 deletions(-) diff --git a/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj b/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj index 70b87a9596..9a52182580 100644 --- a/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj +++ b/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj @@ -4734,6 +4734,7 @@ 5AFD85147E5F7EEA259481C2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BAZEL_CONFIG = rules_xcodeproj; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures:xcodeproj_bwb.generator"; diff --git a/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/examples/integration/test/fixtures/bwb_spec.json b/examples/integration/test/fixtures/bwb_spec.json index 8da331f5a5..9fe32f9926 100644 --- a/examples/integration/test/fixtures/bwb_spec.json +++ b/examples/integration/test/fixtures/bwb_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "__main__", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/examples/integration/test/fixtures/bwx.xcodeproj/project.pbxproj b/examples/integration/test/fixtures/bwx.xcodeproj/project.pbxproj index d1735ddbb4..1d9ad54a5d 100644 --- a/examples/integration/test/fixtures/bwx.xcodeproj/project.pbxproj +++ b/examples/integration/test/fixtures/bwx.xcodeproj/project.pbxproj @@ -4324,6 +4324,7 @@ 67F44AB65FA7A2E38A56F5FB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BAZEL_CONFIG = rules_xcodeproj; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures:xcodeproj_bwx.generator"; diff --git a/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/examples/integration/test/fixtures/bwx_spec.json b/examples/integration/test/fixtures/bwx_spec.json index a02b1bda72..04c88ca25e 100644 --- a/examples/integration/test/fixtures/bwx_spec.json +++ b/examples/integration/test/fixtures/bwx_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "__main__", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/examples/ios_app/test/fixtures/bwb.xcodeproj/project.pbxproj b/examples/ios_app/test/fixtures/bwb.xcodeproj/project.pbxproj index a21dcbbd35..c8d3a8d3c8 100644 --- a/examples/ios_app/test/fixtures/bwb.xcodeproj/project.pbxproj +++ b/examples/ios_app/test/fixtures/bwb.xcodeproj/project.pbxproj @@ -1471,6 +1471,7 @@ 5AFD85147E5F7EEA259481C2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BAZEL_CONFIG = rules_xcodeproj; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures:xcodeproj_bwb.generator"; diff --git a/examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/examples/ios_app/test/fixtures/bwb_spec.json b/examples/ios_app/test/fixtures/bwb_spec.json index 30eb792d68..ee958ab1a1 100644 --- a/examples/ios_app/test/fixtures/bwb_spec.json +++ b/examples/ios_app/test/fixtures/bwb_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "__main__", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/examples/ios_app/test/fixtures/bwx.xcodeproj/project.pbxproj b/examples/ios_app/test/fixtures/bwx.xcodeproj/project.pbxproj index c65229eb0d..801e75d8e7 100644 --- a/examples/ios_app/test/fixtures/bwx.xcodeproj/project.pbxproj +++ b/examples/ios_app/test/fixtures/bwx.xcodeproj/project.pbxproj @@ -1873,6 +1873,7 @@ 67F44AB65FA7A2E38A56F5FB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BAZEL_CONFIG = rules_xcodeproj; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures:xcodeproj_bwx.generator"; diff --git a/examples/ios_app/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/examples/ios_app/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/examples/ios_app/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/examples/ios_app/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/examples/ios_app/test/fixtures/bwx_spec.json b/examples/ios_app/test/fixtures/bwx_spec.json index 438ee97b56..48cf64bb05 100644 --- a/examples/ios_app/test/fixtures/bwx_spec.json +++ b/examples/ios_app/test/fixtures/bwx_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "__main__", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/test/fixtures/cc/bwb.xcodeproj/project.pbxproj b/test/fixtures/cc/bwb.xcodeproj/project.pbxproj index 0f583c7d57..ea6a34cd1c 100644 --- a/test/fixtures/cc/bwb.xcodeproj/project.pbxproj +++ b/test/fixtures/cc/bwb.xcodeproj/project.pbxproj @@ -655,6 +655,7 @@ 5AFD85147E5F7EEA259481C2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BAZEL_CONFIG = rules_xcodeproj; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures/cc:xcodeproj_bwb.generator"; diff --git a/test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/test/fixtures/cc/bwb_spec.json b/test/fixtures/cc/bwb_spec.json index fc2a294a78..3f6dc3cd4b 100644 --- a/test/fixtures/cc/bwb_spec.json +++ b/test/fixtures/cc/bwb_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "com_github_buildbuddy_io_rules_xcodeproj", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/test/fixtures/cc/bwx.xcodeproj/project.pbxproj b/test/fixtures/cc/bwx.xcodeproj/project.pbxproj index b3923019a1..8a8099e8f8 100644 --- a/test/fixtures/cc/bwx.xcodeproj/project.pbxproj +++ b/test/fixtures/cc/bwx.xcodeproj/project.pbxproj @@ -577,6 +577,7 @@ 67F44AB65FA7A2E38A56F5FB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BAZEL_CONFIG = rules_xcodeproj; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures/cc:xcodeproj_bwx.generator"; diff --git a/test/fixtures/cc/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/test/fixtures/cc/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/test/fixtures/cc/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/test/fixtures/cc/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/test/fixtures/cc/bwx_spec.json b/test/fixtures/cc/bwx_spec.json index 0f9a220204..cb276446bb 100644 --- a/test/fixtures/cc/bwx_spec.json +++ b/test/fixtures/cc/bwx_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "com_github_buildbuddy_io_rules_xcodeproj", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/test/fixtures/generator/bwb.xcodeproj/project.pbxproj b/test/fixtures/generator/bwb.xcodeproj/project.pbxproj index 8b9b0b9603..309735b714 100644 --- a/test/fixtures/generator/bwb.xcodeproj/project.pbxproj +++ b/test/fixtures/generator/bwb.xcodeproj/project.pbxproj @@ -2438,6 +2438,7 @@ 5AFD85147E5F7EEA259481C2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BAZEL_CONFIG = rules_xcodeproj; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures/generator:xcodeproj_bwb.generator"; diff --git a/test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/test/fixtures/generator/bwb_spec.json b/test/fixtures/generator/bwb_spec.json index f72152f6cc..db135080f1 100644 --- a/test/fixtures/generator/bwb_spec.json +++ b/test/fixtures/generator/bwb_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "com_github_buildbuddy_io_rules_xcodeproj", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/test/fixtures/generator/bwx.xcodeproj/project.pbxproj b/test/fixtures/generator/bwx.xcodeproj/project.pbxproj index fc358d7571..ffb5567bd1 100644 --- a/test/fixtures/generator/bwx.xcodeproj/project.pbxproj +++ b/test/fixtures/generator/bwx.xcodeproj/project.pbxproj @@ -2411,6 +2411,7 @@ 67F44AB65FA7A2E38A56F5FB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BAZEL_CONFIG = rules_xcodeproj; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures/generator:xcodeproj_bwx.generator"; diff --git a/test/fixtures/generator/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/test/fixtures/generator/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/test/fixtures/generator/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/test/fixtures/generator/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/test/fixtures/generator/bwx_spec.json b/test/fixtures/generator/bwx_spec.json index 4a9fcee821..a2ffca8bba 100644 --- a/test/fixtures/generator/bwx_spec.json +++ b/test/fixtures/generator/bwx_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "com_github_buildbuddy_io_rules_xcodeproj", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/test/fixtures/simple/bwb.xcodeproj/project.pbxproj b/test/fixtures/simple/bwb.xcodeproj/project.pbxproj index 4358ff30a2..faf57a8b8e 100644 --- a/test/fixtures/simple/bwb.xcodeproj/project.pbxproj +++ b/test/fixtures/simple/bwb.xcodeproj/project.pbxproj @@ -299,6 +299,7 @@ 5AFD85147E5F7EEA259481C2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BAZEL_CONFIG = rules_xcodeproj; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures/simple:xcodeproj_bwb.generator"; diff --git a/test/fixtures/simple/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/test/fixtures/simple/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/test/fixtures/simple/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/test/fixtures/simple/bwb.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/test/fixtures/simple/bwb_spec.json b/test/fixtures/simple/bwb_spec.json index b5a1cbf681..8e2ba89a99 100644 --- a/test/fixtures/simple/bwb_spec.json +++ b/test/fixtures/simple/bwb_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "com_github_buildbuddy_io_rules_xcodeproj", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/test/fixtures/simple/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh b/test/fixtures/simple/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh index bb22735f36..2e54c345e2 100755 --- a/test/fixtures/simple/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh +++ b/test/fixtures/simple/bwx.xcodeproj/rules_xcodeproj/bazel/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/test/fixtures/simple/bwx_spec.json b/test/fixtures/simple/bwx_spec.json index a856a55ac9..a311d69851 100644 --- a/test/fixtures/simple/bwx_spec.json +++ b/test/fixtures/simple/bwx_spec.json @@ -1,4 +1,5 @@ { + "bazel_config": "rules_xcodeproj", "bazel_workspace_name": "com_github_buildbuddy_io_rules_xcodeproj", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/tools/generator/src/DTO/Project.swift b/tools/generator/src/DTO/Project.swift index 4aa5c11f79..257c19c3e7 100644 --- a/tools/generator/src/DTO/Project.swift +++ b/tools/generator/src/DTO/Project.swift @@ -1,6 +1,7 @@ struct Project: Equatable, Decodable { let name: String let bazelWorkspaceName: String + let bazelConfig: String let label: BazelLabel let configuration: String let buildSettings: [String: BuildSetting] diff --git a/tools/generator/src/Generator/AddBazelDependenciesTarget.swift b/tools/generator/src/Generator/AddBazelDependenciesTarget.swift index 29672b1c4f..868de782a5 100644 --- a/tools/generator/src/Generator/AddBazelDependenciesTarget.swift +++ b/tools/generator/src/Generator/AddBazelDependenciesTarget.swift @@ -25,6 +25,7 @@ extension Generator { files: [FilePath: File], filePathResolver: FilePathResolver, resolvedExternalRepositories: [(Path, Path)], + bazelConfig: String, xcodeprojBazelLabel: BazelLabel, xcodeprojConfiguration: String, consolidatedTargets: ConsolidatedTargets @@ -49,6 +50,7 @@ extension Generator { let debugConfiguration = XCBuildConfiguration( name: "Debug", buildSettings: [ + "BAZEL_CONFIG": bazelConfig, "BAZEL_PACKAGE_BIN_DIR": "rules_xcodeproj", "CALCULATE_OUTPUT_GROUPS_SCRIPT": """ $(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py diff --git a/tools/generator/src/Generator/Environment.swift b/tools/generator/src/Generator/Environment.swift index 0656093773..1e128df437 100644 --- a/tools/generator/src/Generator/Environment.swift +++ b/tools/generator/src/Generator/Environment.swift @@ -67,6 +67,7 @@ struct Environment { _ files: [FilePath: File], _ filePathResolver: FilePathResolver, _ resolvedExternalRepositories: [(Path, Path)], + _ bazelConfig: String, _ xcodeprojBazelLabel: BazelLabel, _ xcodeprojConfiguration: String, _ consolidatedTargets: ConsolidatedTargets diff --git a/tools/generator/src/Generator/Generator.swift b/tools/generator/src/Generator/Generator.swift index a4c3045d77..6e6b6927f3 100644 --- a/tools/generator/src/Generator/Generator.swift +++ b/tools/generator/src/Generator/Generator.swift @@ -129,6 +129,7 @@ class Generator { files, filePathResolver, resolvedExternalRepositories, + project.bazelConfig, project.label, project.configuration, consolidatedTargets diff --git a/xcodeproj/internal/bazel_integration_files/bazel_build.sh b/xcodeproj/internal/bazel_integration_files/bazel_build.sh index bb22735f36..2e54c345e2 100644 --- a/xcodeproj/internal/bazel_integration_files/bazel_build.sh +++ b/xcodeproj/internal/bazel_integration_files/bazel_build.sh @@ -111,7 +111,7 @@ fi output_path=$("${bazel_cmd[@]}" \ info \ - --config=rules_xcodeproj_info \ + --config="${BAZEL_CONFIG}_info" \ --color="$color" \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ @@ -162,11 +162,11 @@ EOF # Build if [ "$ACTION" == "indexbuild" ]; then - config=rules_xcodeproj_indexbuild + config="${BAZEL_CONFIG}_indexbuild" elif [ "${ENABLE_PREVIEWS:-}" == "YES" ]; then - config=rules_xcodeproj_swiftuipreviews + config="${BAZEL_CONFIG}_swiftuipreviews" else - config=rules_xcodeproj_build + config="${BAZEL_CONFIG}_build" fi mkdir -p /tmp/rules_xcodeproj @@ -178,7 +178,7 @@ touch "$build_marker" "$BAZEL_INTEGRATION_DIR/process_bazel_build_log.py" \ "${bazel_cmd[@]}" \ build \ - --config=$config \ + --config="$config" \ --color=yes \ --experimental_convenience_symlinks=ignore \ --symlink_prefix=/ \ diff --git a/xcodeproj/internal/fixtures.bzl b/xcodeproj/internal/fixtures.bzl index b3b2b6be03..8a0341116a 100644 --- a/xcodeproj/internal/fixtures.bzl +++ b/xcodeproj/internal/fixtures.bzl @@ -144,6 +144,7 @@ def xcodeproj_fixture( *, name = "xcodeproj", modes_and_suffixes = [("xcode", "bwx"), ("bazel", "bwb")], + config = "rules_xcodeproj", top_level_targets = [], focused_targets = [], unfocused_targets = [], @@ -159,6 +160,7 @@ def xcodeproj_fixture( modes_and_suffixes: A `list` of `tuple`s of `build_mode` and `suffix`. The `build_mode` will be pass to `xcodeproj.build_mode` and the `suffix` will be used as the suffix of the project and spec files. + config: Maps to `xcodeproj.config`. top_level_targets: Maps to `xcodeproj.top_level_targets`. focused_targets: Maps to `xcodeproj.focused_targets`. unfocused_targets: Maps to `xcodeproj.unfocused_targets`. @@ -182,6 +184,7 @@ def xcodeproj_fixture( xcodeproj( name = fixture_name, build_mode = mode, + config = config, focused_targets = focused_targets, project_name = suffix, top_level_targets = top_level_targets, diff --git a/xcodeproj/internal/runner.template.sh b/xcodeproj/internal/runner.template.sh index 3718e387fc..5745afc9e5 100644 --- a/xcodeproj/internal/runner.template.sh +++ b/xcodeproj/internal/runner.template.sh @@ -2,7 +2,6 @@ set -euo pipefail - # Functions # Echos the provided message to stderr and exits with an error (1) @@ -61,7 +60,7 @@ if [[ -z "${build_output_groups:-}" ]]; then "%bazel_path%" \ "${bazelrcs[@]}" \ run \ - --config=rules_xcodeproj_generator \ + "--config=%config%_generator" \ %extra_generator_flags% \ "%generator_label%" \ -- "${installer_flags[@]}" @@ -71,7 +70,7 @@ else "%bazel_path%" \ "${bazelrcs[@]}" \ build \ - --config=rules_xcodeproj_build \ + "--config=%config%_build" \ --output_groups="$build_output_groups" \ "%generator_label%" fi diff --git a/xcodeproj/internal/xcodeproj_macro.bzl b/xcodeproj/internal/xcodeproj_macro.bzl index 3630d73591..9d2269255e 100644 --- a/xcodeproj/internal/xcodeproj_macro.bzl +++ b/xcodeproj/internal/xcodeproj_macro.bzl @@ -13,6 +13,7 @@ def xcodeproj( archived_bundles_allowed = None, bazel_path = "bazel", build_mode = "bazel", + config = "rules_xcodeproj", focused_targets = [], ios_device_cpus = "arm64", ios_simulator_cpus = None, @@ -57,6 +58,21 @@ def xcodeproj( If this is set to `"bazel"`, the project will use Bazel to build targets, inside of Xcode. The Xcode build system still unavoidably orchestrates some things at a high level. + config: Optional. The Bazel configuration to use when generating the + project or invoking `bazel` inside of Xcode. This is the basename of + multiple configurations. For example, if this is set to + `"rules_xcodeproj"`, then the following configurations will be valid + for you to extend in your `.bazelrc` file: + + - rules_xcodeproj + - rules_xcodeproj_build + - rules_xcodeproj_generator + - rules_xcodeproj_indexbuild + - rules_xcodeproj_info + - rules_xcodeproj_swiftuipreviews + + See the [baseline `xcodeproj.bazelrc` file](../xcodeproj/internal/bazel_integration_files/xcodeproj.bazelrc) + that is used for more information on these configs. focused_targets: Optional. A `list` of target labels as `string` values. If specified, only these targets will be included in the generated project; all other targets will be excluded, as if they were @@ -225,6 +241,7 @@ in your `.bazelrc` or `xcodeproj.bazelrc` file.""") name = generator_name, build_mode = build_mode, bazel_path = bazel_path, + config = config, focused_targets = focused_targets, ios_device_cpus = ios_device_cpus, ios_simulator_cpus = ios_simulator_cpus, @@ -246,6 +263,7 @@ in your `.bazelrc` or `xcodeproj.bazelrc` file.""") xcodeproj_runner( name = name, bazel_path = bazel_path, + config = config, project_name = project_name, tags = tags, testonly = testonly, diff --git a/xcodeproj/internal/xcodeproj_rule.bzl b/xcodeproj/internal/xcodeproj_rule.bzl index abfcb015e0..dd85e860ef 100644 --- a/xcodeproj/internal/xcodeproj_rule.bzl +++ b/xcodeproj/internal/xcodeproj_rule.bzl @@ -225,6 +225,7 @@ def _write_json_spec( *, ctx, project_name, + config, configuration, targets, target_dtos, @@ -316,6 +317,7 @@ def _write_json_spec( # TODO: Strip fat frameworks instead of setting `VALIDATE_WORKSPACE` spec_json = """\ {{\ +"bazel_config":"{bazel_config}",\ "bazel_workspace_name":"{bazel_workspace_name}",\ "build_settings":{{\ "ALWAYS_SEARCH_USER_PATHS":false,\ @@ -340,6 +342,7 @@ def _write_json_spec( "targets":{targets}\ }} """.format( + bazel_config = config, bazel_path = ctx.attr.bazel_path, bazel_workspace_name = ctx.workspace_name, configuration = configuration, @@ -678,6 +681,7 @@ def _xcodeproj_impl(ctx): spec_file = _write_json_spec( ctx = ctx, project_name = project_name, + config = ctx.attr.config, configuration = configuration, targets = targets, target_dtos = target_dtos, @@ -779,6 +783,9 @@ high level. mandatory = True, values = ["xcode", "bazel"], ), + "config": attr.string( + mandatory = True, + ), "focused_targets": attr.string_list( doc = """\ A `list` of target labels as `string` values. If specified, only these targets diff --git a/xcodeproj/internal/xcodeproj_runner.bzl b/xcodeproj/internal/xcodeproj_runner.bzl index c6ee4c5c36..ce83ab0eb1 100644 --- a/xcodeproj/internal/xcodeproj_runner.bzl +++ b/xcodeproj/internal/xcodeproj_runner.bzl @@ -10,11 +10,33 @@ def _process_extra_flags(*, attr, content, setting, config, config_suffix): "build:{}{} {}".format(config, config_suffix, extra_flags), ) + if config != "rules_xcodeproj" and not config_suffix: + content.append( + """\ +build:{config}_build --config={config} +build:{config}_generator --config={config} +build:{config}_indexbuild --config={config} +build:{config}_info --config={config} +build:{config}_swiftuipreviews --config={config}\ +""".format(config = config), + ) + def _write_extra_flags_bazelrc(name, actions, attr, config): output = actions.declare_file("{}-extra-flags.bazelrc".format(name)) content = [] + if config != "rules_xcodeproj": + content.append( + """\ +build:{config}_build --config=rules_xcodeproj_build +build:{config}_generator --config=rules_xcodeproj_generator +build:{config}_indexbuild --config=rules_xcodeproj_indexbuild +build:{config}_info --config=rules_xcodeproj_info +build:{config}_swiftuipreviews --config=rules_xcodeproj_swiftuipreviews\ +""".format(config = config), + ) + _process_extra_flags( attr = attr, content = content, @@ -129,6 +151,9 @@ xcodeproj_runner = rule( "bazel_path": attr.string( mandatory = True, ), + "config": attr.string( + mandatory = True, + ), "project_name": attr.string( mandatory = True, ), From 646f487aa057f71cccf42583fb4fca79b46e65a6 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 9 Sep 2022 08:59:40 -0500 Subject: [PATCH 2/8] Fix + fixture --- examples/integration/BUILD | 3 ++- examples/integration/test/fixtures/BUILD | 3 ++- .../fixtures/bwb.xcodeproj/project.pbxproj | 2 +- .../bazel/xcodeproj_extra_flags.bazelrc | 18 ++++++++++++++---- .../integration/test/fixtures/bwb_spec.json | 2 +- .../fixtures/bwx.xcodeproj/project.pbxproj | 2 +- .../bazel/xcodeproj_extra_flags.bazelrc | 18 ++++++++++++++---- .../integration/test/fixtures/bwx_spec.json | 2 +- examples/integration/xcodeproj_targets.bzl | 2 ++ xcodeproj/internal/xcodeproj_runner.bzl | 2 +- 10 files changed, 39 insertions(+), 15 deletions(-) diff --git a/examples/integration/BUILD b/examples/integration/BUILD index 528a7f6be9..176ca2d433 100644 --- a/examples/integration/BUILD +++ b/examples/integration/BUILD @@ -2,11 +2,12 @@ load( "@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:xcodeproj.bzl", "xcodeproj", ) -load(":xcodeproj_targets.bzl", "XCODEPROJ_TARGETS") +load(":xcodeproj_targets.bzl", "CONFIG", "XCODEPROJ_TARGETS") xcodeproj( name = "xcodeproj", build_mode = "xcode", + config = CONFIG, project_name = "Integration", tags = ["manual"], top_level_targets = XCODEPROJ_TARGETS, diff --git a/examples/integration/test/fixtures/BUILD b/examples/integration/test/fixtures/BUILD index ee36e4b980..1f4272f758 100644 --- a/examples/integration/test/fixtures/BUILD +++ b/examples/integration/test/fixtures/BUILD @@ -4,9 +4,10 @@ load( "validate_fixtures", "xcodeproj_fixture", ) -load("//:xcodeproj_targets.bzl", "XCODEPROJ_TARGETS") +load("//:xcodeproj_targets.bzl", "CONFIG", "XCODEPROJ_TARGETS") xcodeproj_fixture( + config = CONFIG, top_level_targets = XCODEPROJ_TARGETS, ) diff --git a/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj b/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj index 9a52182580..c464e15aff 100644 --- a/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj +++ b/examples/integration/test/fixtures/bwb.xcodeproj/project.pbxproj @@ -4734,7 +4734,7 @@ 5AFD85147E5F7EEA259481C2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - BAZEL_CONFIG = rules_xcodeproj; + BAZEL_CONFIG = rules_xcodeproj_integration; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures:xcodeproj_bwb.generator"; diff --git a/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc b/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc index f4cbc1bed9..c156cd20e6 100755 --- a/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc +++ b/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc @@ -1,4 +1,14 @@ -build:rules_xcodeproj --config=cache -build:rules_xcodeproj_build --noverbose_failures -build:rules_xcodeproj_indexbuild --noverbose_failures -build:rules_xcodeproj_swiftuipreviews --noverbose_failures +build:rules_xcodeproj_integration_build --config=rules_xcodeproj_build +build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_generator +build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_indexbuild +build:rules_xcodeproj_integration_info --config=rules_xcodeproj_info +build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_swiftuipreviews +build:rules_xcodeproj_integration --config=cache +build:rules_xcodeproj_integration_build --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_info --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_build --noverbose_failures +build:rules_xcodeproj_integration_indexbuild --noverbose_failures +build:rules_xcodeproj_integration_swiftuipreviews --noverbose_failures diff --git a/examples/integration/test/fixtures/bwb_spec.json b/examples/integration/test/fixtures/bwb_spec.json index 9fe32f9926..b1e0715a92 100644 --- a/examples/integration/test/fixtures/bwb_spec.json +++ b/examples/integration/test/fixtures/bwb_spec.json @@ -1,5 +1,5 @@ { - "bazel_config": "rules_xcodeproj", + "bazel_config": "rules_xcodeproj_integration", "bazel_workspace_name": "__main__", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/examples/integration/test/fixtures/bwx.xcodeproj/project.pbxproj b/examples/integration/test/fixtures/bwx.xcodeproj/project.pbxproj index 1d9ad54a5d..6f8f83ac8a 100644 --- a/examples/integration/test/fixtures/bwx.xcodeproj/project.pbxproj +++ b/examples/integration/test/fixtures/bwx.xcodeproj/project.pbxproj @@ -4324,7 +4324,7 @@ 67F44AB65FA7A2E38A56F5FB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - BAZEL_CONFIG = rules_xcodeproj; + BAZEL_CONFIG = rules_xcodeproj_integration; BAZEL_PACKAGE_BIN_DIR = rules_xcodeproj; CALCULATE_OUTPUT_GROUPS_SCRIPT = "$(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py"; GENERATOR_LABEL = "//test/fixtures:xcodeproj_bwx.generator"; diff --git a/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc b/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc index f4cbc1bed9..c156cd20e6 100755 --- a/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc +++ b/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc @@ -1,4 +1,14 @@ -build:rules_xcodeproj --config=cache -build:rules_xcodeproj_build --noverbose_failures -build:rules_xcodeproj_indexbuild --noverbose_failures -build:rules_xcodeproj_swiftuipreviews --noverbose_failures +build:rules_xcodeproj_integration_build --config=rules_xcodeproj_build +build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_generator +build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_indexbuild +build:rules_xcodeproj_integration_info --config=rules_xcodeproj_info +build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_swiftuipreviews +build:rules_xcodeproj_integration --config=cache +build:rules_xcodeproj_integration_build --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_info --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_build --noverbose_failures +build:rules_xcodeproj_integration_indexbuild --noverbose_failures +build:rules_xcodeproj_integration_swiftuipreviews --noverbose_failures diff --git a/examples/integration/test/fixtures/bwx_spec.json b/examples/integration/test/fixtures/bwx_spec.json index 04c88ca25e..55a6978445 100644 --- a/examples/integration/test/fixtures/bwx_spec.json +++ b/examples/integration/test/fixtures/bwx_spec.json @@ -1,5 +1,5 @@ { - "bazel_config": "rules_xcodeproj", + "bazel_config": "rules_xcodeproj_integration", "bazel_workspace_name": "__main__", "build_settings": { "ALWAYS_SEARCH_USER_PATHS": false, diff --git a/examples/integration/xcodeproj_targets.bzl b/examples/integration/xcodeproj_targets.bzl index f367d8f661..85d829039e 100644 --- a/examples/integration/xcodeproj_targets.bzl +++ b/examples/integration/xcodeproj_targets.bzl @@ -5,6 +5,8 @@ load( "top_level_target", ) +CONFIG = "rules_xcodeproj_integration" + XCODEPROJ_TARGETS = [ top_level_target( label = "//CommandLine/CommandLineTool", diff --git a/xcodeproj/internal/xcodeproj_runner.bzl b/xcodeproj/internal/xcodeproj_runner.bzl index ce83ab0eb1..c80f749b5d 100644 --- a/xcodeproj/internal/xcodeproj_runner.bzl +++ b/xcodeproj/internal/xcodeproj_runner.bzl @@ -109,7 +109,7 @@ def _write_runner( def _xcodeproj_runner_impl(ctx): bazelrc = ctx.file._bazelrc - config = "rules_xcodeproj" + config = ctx.attr.config project_name = ctx.attr.project_name extra_flags_bazelrc = _write_extra_flags_bazelrc( From c134da01d82cb89ddc518405ec6b6119bf120620 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 9 Sep 2022 09:01:54 -0500 Subject: [PATCH 3/8] Docs --- doc/rules-xcodeproj.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/rules-xcodeproj.md b/doc/rules-xcodeproj.md index 3340522c71..552e601043 100755 --- a/doc/rules-xcodeproj.md +++ b/doc/rules-xcodeproj.md @@ -268,10 +268,10 @@ A `sequence` of values returned by `xcode_schemes.scheme`. ## xcodeproj
-xcodeproj(name, archived_bundles_allowed, bazel_path, build_mode, focused_targets, ios_device_cpus,
-          ios_simulator_cpus, project_name, scheme_autogeneration_mode, schemes, top_level_targets,
-          tvos_device_cpus, tvos_simulator_cpus, unfocused_targets, watchos_device_cpus,
-          watchos_simulator_cpus, kwargs)
+xcodeproj(name, archived_bundles_allowed, bazel_path, build_mode, config, focused_targets,
+          ios_device_cpus, ios_simulator_cpus, project_name, scheme_autogeneration_mode, schemes,
+          top_level_targets, tvos_device_cpus, tvos_simulator_cpus, unfocused_targets,
+          watchos_device_cpus, watchos_simulator_cpus, kwargs)
 
Creates an `.xcodeproj` file in the workspace when run. @@ -292,6 +292,7 @@ argument will pass forward values for globally available attributes (e.g. | archived_bundles_allowed | This argument is deprecated and is now a no-op. It will be removed in a future release. Adjust the setting of --define=apple.experimental.tree_artifact_outputs on build:rules_xcodeproj in your .bazelrc or xcodeproj.bazelrc file. | None | | bazel_path | Optional. The path the bazel binary or wrapper script. If the path is relative it will be resolved using the PATH environment variable (which is set to /opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin in Xcode). If you want to specify a path to a workspace-relative binary, you must prepend the path with ./ (e.g. "./bazelw"). | "bazel" | | build_mode | Optional. The build mode the generated project should use.

If this is set to "xcode", the project will use the Xcode build system to build targets. Generated files and unfocused targets (see the focused_targets and unfocused_targets arguments) will be built with Bazel.

If this is set to "bazel", the project will use Bazel to build targets, inside of Xcode. The Xcode build system still unavoidably orchestrates some things at a high level. | "bazel" | +| config | Optional. The Bazel configuration to use when generating the project or invoking bazel inside of Xcode. This is the basename of multiple configurations. For example, if this is set to "rules_xcodeproj", then the following configurations will be valid for you to extend in your .bazelrc file:

- rules_xcodeproj - rules_xcodeproj_build - rules_xcodeproj_generator - rules_xcodeproj_indexbuild - rules_xcodeproj_info - rules_xcodeproj_swiftuipreviews

See the [baseline xcodeproj.bazelrc file](../xcodeproj/internal/bazel_integration_files/xcodeproj.bazelrc) that is used for more information on these configs. | "rules_xcodeproj" | | focused_targets | Optional. A list of target labels as string values. If specified, only these targets will be included in the generated project; all other targets will be excluded, as if they were listed explicitly in the unfocused_targets argument. The labels must match transitive dependencies of the targets specified in the top_level_targets argument. | [] | | ios_device_cpus | Optional. The value to use for --ios_multi_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment.

**Warning:** Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment, even if they aren't iOS targets. | "arm64" | | ios_simulator_cpus | Optional. The value to use for --ios_multi_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment.

If no value is specified, it defaults to the simulator cpu that goes with --host_cpu (i.e. sim_arm64 on Apple Silicon and x86_64 on Intel).

**Warning:** Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment, even if they aren't iOS targets. | None | From c890c4aff571b72aed5b599d995998d7d4b9a563 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 9 Sep 2022 09:06:19 -0500 Subject: [PATCH 4/8] Tests --- tools/generator/test/Fixtures.swift | 1 + tools/generator/test/GeneratorTests.swift | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/tools/generator/test/Fixtures.swift b/tools/generator/test/Fixtures.swift index a59d35190b..d543f82790 100644 --- a/tools/generator/test/Fixtures.swift +++ b/tools/generator/test/Fixtures.swift @@ -8,6 +8,7 @@ enum Fixtures { static let project = Project( name: "Bazel", bazelWorkspaceName: "bazel_workspace", + bazelConfig: "rules_xcodeproj_fxitures", label: "//:xcodeproj", configuration: "z3y2z", buildSettings: [ diff --git a/tools/generator/test/GeneratorTests.swift b/tools/generator/test/GeneratorTests.swift index 861a5e59f0..61a1baf240 100644 --- a/tools/generator/test/GeneratorTests.swift +++ b/tools/generator/test/GeneratorTests.swift @@ -12,6 +12,7 @@ final class GeneratorTests: XCTestCase { let project = Project( name: "P", bazelWorkspaceName: "bazel_workspace", + bazelConfig: "rules_xcodeproj_test", label: "//a/P:xcodeproj", configuration: "abc123", buildSettings: [:], @@ -466,6 +467,7 @@ final class GeneratorTests: XCTestCase { let forceBazelDependencies: Bool let files: [FilePath: File] let filePathResolver: FilePathResolver + let bazelConfig: String let xcodeprojBazelLabel: BazelLabel let xcodeprojConfiguration: String let consolidatedTargets: ConsolidatedTargets @@ -480,6 +482,7 @@ final class GeneratorTests: XCTestCase { files: [FilePath: File], filePathResolver: FilePathResolver, resolvedExternalRepositories: [(Path, Path)], + bazelConfig: String, xcodeprojBazelLabel: BazelLabel, xcodeprojConfiguration: String, consolidatedTargets: ConsolidatedTargets @@ -490,6 +493,7 @@ final class GeneratorTests: XCTestCase { forceBazelDependencies: forceBazelDependencies, files: files, filePathResolver: filePathResolver, + bazelConfig: bazelConfig, xcodeprojBazelLabel: xcodeprojBazelLabel, xcodeprojConfiguration: xcodeprojConfiguration, consolidatedTargets: consolidatedTargets @@ -504,6 +508,7 @@ final class GeneratorTests: XCTestCase { forceBazelDependencies: project.forceBazelDependencies, files: files, filePathResolver: filePathResolver, + bazelConfig: project.bazelConfig, xcodeprojBazelLabel: project.label, xcodeprojConfiguration: project.configuration, consolidatedTargets: consolidatedTargets From f88cf6ba4cfe41a8e119616459b8dac4c20ef941 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 9 Sep 2022 09:06:41 -0500 Subject: [PATCH 5/8] Lint --- xcodeproj/internal/xcodeproj_runner.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcodeproj/internal/xcodeproj_runner.bzl b/xcodeproj/internal/xcodeproj_runner.bzl index c80f749b5d..156f14affe 100644 --- a/xcodeproj/internal/xcodeproj_runner.bzl +++ b/xcodeproj/internal/xcodeproj_runner.bzl @@ -12,14 +12,14 @@ def _process_extra_flags(*, attr, content, setting, config, config_suffix): if config != "rules_xcodeproj" and not config_suffix: content.append( - """\ + """\ build:{config}_build --config={config} build:{config}_generator --config={config} build:{config}_indexbuild --config={config} build:{config}_info --config={config} build:{config}_swiftuipreviews --config={config}\ """.format(config = config), - ) + ) def _write_extra_flags_bazelrc(name, actions, attr, config): output = actions.declare_file("{}-extra-flags.bazelrc".format(name)) From 38ac58286c8b5238f5e871a7353ac4b6b47a2c77 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 9 Sep 2022 10:41:49 -0500 Subject: [PATCH 6/8] Proper ordering --- examples/integration/.bazelrc | 2 + .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 17 +++++ .../bazel/xcodeproj_extra_flags.bazelrc | 10 --- .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 17 +++++ .../bazel/xcodeproj_extra_flags.bazelrc | 10 --- .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 2 + .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 2 + .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 2 + .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 2 + .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 2 + .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 2 + .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 2 + .../rules_xcodeproj/bazel/xcodeproj.bazelrc | 2 + xcodeproj/internal/BUILD | 4 +- .../internal/bazel_integration_files/BUILD | 5 -- xcodeproj/internal/installer.template.sh | 8 +++ xcodeproj/internal/runner.template.sh | 5 +- ...roj.bazelrc => xcodeproj.template.bazelrc} | 2 + xcodeproj/internal/xcodeproj_runner.bzl | 62 ++++++++++++------- 19 files changed, 108 insertions(+), 50 deletions(-) mode change 100644 => 100755 examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc mode change 100644 => 100755 examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc mode change 100644 => 100755 examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc mode change 100644 => 100755 examples/ios_app/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc mode change 100644 => 100755 test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc mode change 100644 => 100755 test/fixtures/cc/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc mode change 100644 => 100755 test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc mode change 100644 => 100755 test/fixtures/generator/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc mode change 100644 => 100755 test/fixtures/simple/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc mode change 100644 => 100755 test/fixtures/simple/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc rename xcodeproj/internal/{bazel_integration_files/xcodeproj.bazelrc => xcodeproj.template.bazelrc} (98%) diff --git a/examples/integration/.bazelrc b/examples/integration/.bazelrc index 209119f27d..6fa6ddb998 100644 --- a/examples/integration/.bazelrc +++ b/examples/integration/.bazelrc @@ -11,5 +11,7 @@ build --@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:extra_build_flags=' build --@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:extra_indexbuild_flags='--noverbose_failures' build --@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:extra_swiftuipreviews_flags='--noverbose_failures' +build:rules_xcodeproj_integration --define=foo=bar + # Use a user.bazelrc if it exists try-import %workspace%/user.bazelrc diff --git a/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..a603ebefa1 --- a/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,22 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + +# Set `--verbose_failures` on `info` as the closest to a "no-op" config as +# possible, until https://github.com/bazelbuild/bazel/issues/12844 is fixed +info:rules_xcodeproj_integration --verbose_failures + +build:rules_xcodeproj_integration_build --config=rules_xcodeproj_build +build:rules_xcodeproj_integration_build --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_generator +build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_indexbuild +build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_integration +info:rules_xcodeproj_integration_info --config=rules_xcodeproj_info +info:rules_xcodeproj_integration_info --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_swiftuipreviews +build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_integration + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc b/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc index c156cd20e6..edd64ab2ac 100755 --- a/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc +++ b/examples/integration/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc @@ -1,14 +1,4 @@ -build:rules_xcodeproj_integration_build --config=rules_xcodeproj_build -build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_generator -build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_indexbuild -build:rules_xcodeproj_integration_info --config=rules_xcodeproj_info -build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_swiftuipreviews build:rules_xcodeproj_integration --config=cache -build:rules_xcodeproj_integration_build --config=rules_xcodeproj_integration -build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_integration -build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_integration -build:rules_xcodeproj_integration_info --config=rules_xcodeproj_integration -build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_integration build:rules_xcodeproj_integration_build --noverbose_failures build:rules_xcodeproj_integration_indexbuild --noverbose_failures build:rules_xcodeproj_integration_swiftuipreviews --noverbose_failures diff --git a/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..a603ebefa1 --- a/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,22 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + +# Set `--verbose_failures` on `info` as the closest to a "no-op" config as +# possible, until https://github.com/bazelbuild/bazel/issues/12844 is fixed +info:rules_xcodeproj_integration --verbose_failures + +build:rules_xcodeproj_integration_build --config=rules_xcodeproj_build +build:rules_xcodeproj_integration_build --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_generator +build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_indexbuild +build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_integration +info:rules_xcodeproj_integration_info --config=rules_xcodeproj_info +info:rules_xcodeproj_integration_info --config=rules_xcodeproj_integration +build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_swiftuipreviews +build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_integration + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc b/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc index c156cd20e6..edd64ab2ac 100755 --- a/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc +++ b/examples/integration/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc @@ -1,14 +1,4 @@ -build:rules_xcodeproj_integration_build --config=rules_xcodeproj_build -build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_generator -build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_indexbuild -build:rules_xcodeproj_integration_info --config=rules_xcodeproj_info -build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_swiftuipreviews build:rules_xcodeproj_integration --config=cache -build:rules_xcodeproj_integration_build --config=rules_xcodeproj_integration -build:rules_xcodeproj_integration_generator --config=rules_xcodeproj_integration -build:rules_xcodeproj_integration_indexbuild --config=rules_xcodeproj_integration -build:rules_xcodeproj_integration_info --config=rules_xcodeproj_integration -build:rules_xcodeproj_integration_swiftuipreviews --config=rules_xcodeproj_integration build:rules_xcodeproj_integration_build --noverbose_failures build:rules_xcodeproj_integration_indexbuild --noverbose_failures build:rules_xcodeproj_integration_swiftuipreviews --noverbose_failures diff --git a/examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..9335b0ac36 --- a/examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,7 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/examples/ios_app/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/examples/ios_app/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..9335b0ac36 --- a/examples/ios_app/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/examples/ios_app/test/fixtures/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,7 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..9335b0ac36 --- a/test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,7 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/test/fixtures/cc/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/test/fixtures/cc/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..9335b0ac36 --- a/test/fixtures/cc/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/test/fixtures/cc/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,7 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..9335b0ac36 --- a/test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,7 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/test/fixtures/generator/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/test/fixtures/generator/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..9335b0ac36 --- a/test/fixtures/generator/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/test/fixtures/generator/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,7 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/test/fixtures/simple/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/test/fixtures/simple/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..9335b0ac36 --- a/test/fixtures/simple/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/test/fixtures/simple/bwb.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,7 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/test/fixtures/simple/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc b/test/fixtures/simple/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc old mode 100644 new mode 100755 index 1ea3876659..9335b0ac36 --- a/test/fixtures/simple/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc +++ b/test/fixtures/simple/bwx.xcodeproj/rules_xcodeproj/bazel/xcodeproj.bazelrc @@ -78,5 +78,7 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs + # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/xcodeproj/internal/BUILD b/xcodeproj/internal/BUILD index 8d11c22199..e95dee8efc 100644 --- a/xcodeproj/internal/BUILD +++ b/xcodeproj/internal/BUILD @@ -29,7 +29,7 @@ exports_files([ "installer.template.sh", "runner.template.sh", "updater.template.sh", - "xcodeproj.bazelrc", + "xcodeproj.template.bazelrc", ]) string_setting( @@ -55,8 +55,8 @@ filegroup( exclude = [ "fixtures.bzl", "updater.template.sh", - "xcodeproj_tests.bzl", "validator.template.sh", + "xcodeproj_tests.bzl", ], ) + [ "//" + package_name() + "/bazel_integration_files:release_files", diff --git a/xcodeproj/internal/bazel_integration_files/BUILD b/xcodeproj/internal/bazel_integration_files/BUILD index 4e7dc9959e..13ab2d5095 100644 --- a/xcodeproj/internal/bazel_integration_files/BUILD +++ b/xcodeproj/internal/bazel_integration_files/BUILD @@ -3,13 +3,8 @@ _BASE_FILES = [ "calculate_output_groups.py", "create_lldbinit.sh", "process_bazel_build_log.py", - "xcodeproj.bazelrc", ] -exports_files([ - "xcodeproj.bazelrc", -]) - filegroup( name = "base_integration_files", srcs = _BASE_FILES, diff --git a/xcodeproj/internal/installer.template.sh b/xcodeproj/internal/installer.template.sh index 8ff18df670..53ac9ab9a4 100644 --- a/xcodeproj/internal/installer.template.sh +++ b/xcodeproj/internal/installer.template.sh @@ -22,6 +22,10 @@ include_spec=0 while (("$#")); do case "${1}" in + "--bazelrc") + bazelrc="${2}" + shift 2 + ;; "--destination") dest="${2}" shift 2 @@ -79,6 +83,10 @@ if [[ -d "$dest/rules_xcodeproj/bazel" ]]; then chmod u+x "$dest/rules_xcodeproj/bazel/"*.{py,sh} fi +# Copy over xcodeproj.bazelrc +cp "$bazelrc" "$dest/rules_xcodeproj/bazel/xcodeproj.bazelrc" +chmod u+w "$dest/rules_xcodeproj/bazel/xcodeproj.bazelrc" + # Copy over xcodeproj_extra_flags.bazelrc if it exists # We can't include this file as an input to the generator, because it would # require setting ` --@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:extra_*_flags` diff --git a/xcodeproj/internal/runner.template.sh b/xcodeproj/internal/runner.template.sh index 5745afc9e5..4ff572f41e 100644 --- a/xcodeproj/internal/runner.template.sh +++ b/xcodeproj/internal/runner.template.sh @@ -21,7 +21,10 @@ fail() { readonly bazelrc="$PWD/%bazelrc%" readonly extra_flags_bazelrc="$PWD/%extra_flags_bazelrc%" -installer_flags=(--extra_flags_bazelrc "$extra_flags_bazelrc") +installer_flags=( + --bazelrc "$bazelrc" + --extra_flags_bazelrc "$extra_flags_bazelrc" +) while (("$#")); do case "$1" in diff --git a/xcodeproj/internal/bazel_integration_files/xcodeproj.bazelrc b/xcodeproj/internal/xcodeproj.template.bazelrc similarity index 98% rename from xcodeproj/internal/bazel_integration_files/xcodeproj.bazelrc rename to xcodeproj/internal/xcodeproj.template.bazelrc index 1ea3876659..1d066a82df 100644 --- a/xcodeproj/internal/bazel_integration_files/xcodeproj.bazelrc +++ b/xcodeproj/internal/xcodeproj.template.bazelrc @@ -78,5 +78,7 @@ build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-private-imports build:rules_xcodeproj_swiftuipreviews --swiftcopt=-Xfrontend --swiftcopt=-enable-dynamic-replacement-chaining +### Project specific configs +%project_configs% # Import `xcodeproj.bazelrc` if it exists try-import %workspace%/xcodeproj.bazelrc diff --git a/xcodeproj/internal/xcodeproj_runner.bzl b/xcodeproj/internal/xcodeproj_runner.bzl index 156f14affe..e0829b08c0 100644 --- a/xcodeproj/internal/xcodeproj_runner.bzl +++ b/xcodeproj/internal/xcodeproj_runner.bzl @@ -10,33 +10,44 @@ def _process_extra_flags(*, attr, content, setting, config, config_suffix): "build:{}{} {}".format(config, config_suffix, extra_flags), ) - if config != "rules_xcodeproj" and not config_suffix: - content.append( - """\ +def _write_xcodeproj_bazelrc(name, actions, config, template): + output = actions.declare_file("{}.bazelrc".format(name)) + + if config != "rules_xcodeproj": + project_configs = """ +# Set `--verbose_failures` on `info` as the closest to a "no-op" config as +# possible, until https://github.com/bazelbuild/bazel/issues/12844 is fixed +info:{config} --verbose_failures + +build:{config}_build --config=rules_xcodeproj_build build:{config}_build --config={config} +build:{config}_generator --config=rules_xcodeproj_generator build:{config}_generator --config={config} +build:{config}_indexbuild --config=rules_xcodeproj_indexbuild build:{config}_indexbuild --config={config} -build:{config}_info --config={config} -build:{config}_swiftuipreviews --config={config}\ -""".format(config = config), - ) +info:{config}_info --config=rules_xcodeproj_info +info:{config}_info --config={config} +build:{config}_swiftuipreviews --config=rules_xcodeproj_swiftuipreviews +build:{config}_swiftuipreviews --config={config} +""".format(config = config) + else: + project_configs = "" + + actions.expand_template( + template = template, + output = output, + substitutions = { + "%project_configs%": project_configs, + }, + ) + + return output def _write_extra_flags_bazelrc(name, actions, attr, config): output = actions.declare_file("{}-extra-flags.bazelrc".format(name)) content = [] - if config != "rules_xcodeproj": - content.append( - """\ -build:{config}_build --config=rules_xcodeproj_build -build:{config}_generator --config=rules_xcodeproj_generator -build:{config}_indexbuild --config=rules_xcodeproj_indexbuild -build:{config}_info --config=rules_xcodeproj_info -build:{config}_swiftuipreviews --config=rules_xcodeproj_swiftuipreviews\ -""".format(config = config), - ) - _process_extra_flags( attr = attr, content = content, @@ -108,10 +119,15 @@ def _write_runner( return output def _xcodeproj_runner_impl(ctx): - bazelrc = ctx.file._bazelrc config = ctx.attr.config project_name = ctx.attr.project_name + bazelrc = _write_xcodeproj_bazelrc( + name = ctx.attr.name, + actions = ctx.actions, + config = config, + template = ctx.file._bazelrc_template, + ) extra_flags_bazelrc = _write_extra_flags_bazelrc( name = ctx.attr.name, actions = ctx.actions, @@ -137,7 +153,9 @@ def _xcodeproj_runner_impl(ctx): return [ DefaultInfo( executable = runner, - runfiles = ctx.runfiles(files = [bazelrc, extra_flags_bazelrc]), + runfiles = ctx.runfiles( + files = [bazelrc, extra_flags_bazelrc], + ), ), XcodeProjRunnerOutputInfo( project_name = project_name, @@ -160,9 +178,9 @@ xcodeproj_runner = rule( "xcodeproj_target": attr.string( mandatory = True, ), - "_bazelrc": attr.label( + "_bazelrc_template": attr.label( allow_single_file = True, - default = Label("//xcodeproj/internal/bazel_integration_files:xcodeproj.bazelrc"), + default = Label("//xcodeproj/internal:xcodeproj.template.bazelrc"), ), "_extra_build_flags": attr.label( default = Label("//xcodeproj:extra_build_flags"), From 72d36ad510b6e3d9b88912bf33c69a0a14dce887 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 9 Sep 2022 10:57:45 -0500 Subject: [PATCH 7/8] Better docs formatting --- doc/rules-xcodeproj.md | 2 +- xcodeproj/internal/xcodeproj_macro.bzl | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/doc/rules-xcodeproj.md b/doc/rules-xcodeproj.md index 552e601043..96b4f2c17f 100755 --- a/doc/rules-xcodeproj.md +++ b/doc/rules-xcodeproj.md @@ -292,7 +292,7 @@ argument will pass forward values for globally available attributes (e.g. | archived_bundles_allowed | This argument is deprecated and is now a no-op. It will be removed in a future release. Adjust the setting of --define=apple.experimental.tree_artifact_outputs on build:rules_xcodeproj in your .bazelrc or xcodeproj.bazelrc file. | None | | bazel_path | Optional. The path the bazel binary or wrapper script. If the path is relative it will be resolved using the PATH environment variable (which is set to /opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin in Xcode). If you want to specify a path to a workspace-relative binary, you must prepend the path with ./ (e.g. "./bazelw"). | "bazel" | | build_mode | Optional. The build mode the generated project should use.

If this is set to "xcode", the project will use the Xcode build system to build targets. Generated files and unfocused targets (see the focused_targets and unfocused_targets arguments) will be built with Bazel.

If this is set to "bazel", the project will use Bazel to build targets, inside of Xcode. The Xcode build system still unavoidably orchestrates some things at a high level. | "bazel" | -| config | Optional. The Bazel configuration to use when generating the project or invoking bazel inside of Xcode. This is the basename of multiple configurations. For example, if this is set to "rules_xcodeproj", then the following configurations will be valid for you to extend in your .bazelrc file:

- rules_xcodeproj - rules_xcodeproj_build - rules_xcodeproj_generator - rules_xcodeproj_indexbuild - rules_xcodeproj_info - rules_xcodeproj_swiftuipreviews

See the [baseline xcodeproj.bazelrc file](../xcodeproj/internal/bazel_integration_files/xcodeproj.bazelrc) that is used for more information on these configs. | "rules_xcodeproj" | +| config | Optional. The Bazel configuration to use when generating the project or invoking bazel inside of Xcode. This is the basename of multiple configurations. For example, if this is set to "rules_xcodeproj", then the following configurations will be valid for you to extend in your .bazelrc file: rules_xcodeproj, rules_xcodeproj_build, rules_xcodeproj_indexbuild, rules_xcodeproj_info, and rules_xcodeproj_swiftuipreviews.

See the [baseline xcodeproj.bazelrc file](../xcodeproj/internal:xcodeproj.template.bazelrc) that is used for more information on these configs. | "rules_xcodeproj" | | focused_targets | Optional. A list of target labels as string values. If specified, only these targets will be included in the generated project; all other targets will be excluded, as if they were listed explicitly in the unfocused_targets argument. The labels must match transitive dependencies of the targets specified in the top_level_targets argument. | [] | | ios_device_cpus | Optional. The value to use for --ios_multi_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment.

**Warning:** Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment, even if they aren't iOS targets. | "arm64" | | ios_simulator_cpus | Optional. The value to use for --ios_multi_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment.

If no value is specified, it defaults to the simulator cpu that goes with --host_cpu (i.e. sim_arm64 on Apple Silicon and x86_64 on Intel).

**Warning:** Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment, even if they aren't iOS targets. | None | diff --git a/xcodeproj/internal/xcodeproj_macro.bzl b/xcodeproj/internal/xcodeproj_macro.bzl index 9d2269255e..0ea11cc6d6 100644 --- a/xcodeproj/internal/xcodeproj_macro.bzl +++ b/xcodeproj/internal/xcodeproj_macro.bzl @@ -62,16 +62,11 @@ def xcodeproj( project or invoking `bazel` inside of Xcode. This is the basename of multiple configurations. For example, if this is set to `"rules_xcodeproj"`, then the following configurations will be valid - for you to extend in your `.bazelrc` file: + for you to extend in your `.bazelrc` file: `rules_xcodeproj`, + `rules_xcodeproj_build`, `rules_xcodeproj_indexbuild`, + `rules_xcodeproj_info`, and `rules_xcodeproj_swiftuipreviews`. - - rules_xcodeproj - - rules_xcodeproj_build - - rules_xcodeproj_generator - - rules_xcodeproj_indexbuild - - rules_xcodeproj_info - - rules_xcodeproj_swiftuipreviews - - See the [baseline `xcodeproj.bazelrc` file](../xcodeproj/internal/bazel_integration_files/xcodeproj.bazelrc) + See the [baseline `xcodeproj.bazelrc` file](../xcodeproj/internal:xcodeproj.template.bazelrc) that is used for more information on these configs. focused_targets: Optional. A `list` of target labels as `string` values. If specified, only these targets will be included in the generated From 1762c9b25a994cead2cf01e6f8ec2e60ca10b92d Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Fri, 9 Sep 2022 10:58:48 -0500 Subject: [PATCH 8/8] Typo --- tools/generator/test/Fixtures.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/generator/test/Fixtures.swift b/tools/generator/test/Fixtures.swift index d543f82790..464806b525 100644 --- a/tools/generator/test/Fixtures.swift +++ b/tools/generator/test/Fixtures.swift @@ -8,7 +8,7 @@ enum Fixtures { static let project = Project( name: "Bazel", bazelWorkspaceName: "bazel_workspace", - bazelConfig: "rules_xcodeproj_fxitures", + bazelConfig: "rules_xcodeproj_fixtures", label: "//:xcodeproj", configuration: "z3y2z", buildSettings: [