-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force swift local debug option to be turned on so that framework search path has correct payload after project is built #101
Force swift local debug option to be turned on so that framework search path has correct payload after project is built #101
Conversation
rules/transition_support.bzl
Outdated
transition_support = struct( | ||
apple_rule_transition = _apple_rule_transition, | ||
current_apple_platform = _current_apple_platform, | ||
xcodeproj_rule_transition = _xcodeproj_rule_transition, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's a bit more clear to name this force_swift_local_debug_options_transition
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.bazelrc
Outdated
@@ -17,3 +17,7 @@ build --deleted_packages tests/ios/frameworks/sources-with-prebuilt-binaries | |||
# when swiftmodule caching is enabled. | |||
# build --features=swift.cacheable_swiftmodules | |||
# build --features=swift.use_global_module_cache | |||
|
|||
# Match this with the flag used in build-wrapper.sh | |||
build --compilation_mode=dbg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary? builds in this rules repo should work in all 3 compilation modes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm so the bazel-out
directory name is a composition of compilation mode and configruation hash and other architecture parameters, right? If we don't specify this one, the framework search path will be applebin.....-fastbuild-<somehash>
instead of applebin.....-debug-<somehash>
. Am I correct here? (the change inside fixture also confirms this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so unless we make the build-wrapper respect the compilation mode in first place instead of hardcoding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either the build wrapper should respect the compilation mode or, my hunch is, we'll need a split transition so we can get the full matrix of settings for {debug,release}/{simulator,device}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do the wrapper respect setting
one and do the split transition to get full matrix of settings for {debug,release}/{simulator,device} in future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay turns out adding the macro in the first place is not needed because if we specify compile mode to be dbg
under .bzelrc
, it will be respected inside the build-warpper. unless i missed some case previously discovered by @amberdixon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In its current form, this PR has removed compilation_mode=dbg
from the build-wrapper. Could you put it back? You can add it into the new BAZEL_RULES_IOS_OPTIONS
build setting you have created and are using.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have discussed and agree that above comment is invalid as now the single point of truth is on user's .bazelrc file @amberdixon
4d99616
to
aebd946
Compare
.github/workflows/tests.yml
Outdated
bazelisk query 'kind(xcodeproj, tests/macos/xcodeproj/...)' | xargs -n 1 bazelisk run | ||
bazelisk query 'attr(executable, 1, kind(genrule, tests/macos/xcodeproj/...))' | xargs -n 1 bazelisk run | ||
git diff --exit-code tests/macos/xcodeproj | ||
- name: Ensure hmap files do not exist (or remove if they do) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary? should we instead put this logic in ./tests/macos/xcodeproj/build.sh
so it can be used when running locally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new test case will fail if changes are not in :)
# prefix to the `local_debug_options_enabled` build flag | ||
$BAZEL_PATH build --experimental_execution_log_file=$BAZEL_BUILD_EXECUTION_LOG_FILENAME --build_event_text_file=$BAZEL_BUILD_EVENT_TEXT_FILENAME --build_event_publish_all_actions $1 --@build_bazel_rules_ios//rules:local_debug_options_enabled $BAZEL_DEBUG_SYMBOLS_FLAG 2>&1 | $BAZEL_OUTPUT_PROCESSOR | ||
$BAZEL_PATH build \ | ||
--experimental_execution_log_file=$BAZEL_BUILD_EXECUTION_LOG_FILENAME \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indent subsequent lines so it's visually clear they're part of a single command invocation
.github/workflows/tests.yml
Outdated
bazelisk query 'kind(xcodeproj, tests/ios/xcodeproj/...)' | xargs -n 1 bazelisk run | ||
bazelisk query 'attr(executable, 1, kind(genrule, tests/ios/xcodeproj/...))' | xargs -n 1 bazelisk run | ||
git diff --exit-code tests/ios/xcodeproj | ||
- name: Ensure hmap files do not exist (or remove if they do) | ||
run: | | ||
grep "HEADER_SEARCH_PATHS" tests/ios/xcodeproj/*.xcodeproj/project.pbxproj | grep -o "bazel-out\S*\.hmap" | xargs -I {} bash -c 'F=$0; echo $F; if [ -f $F ]; then rm $F; echo "removed file at $F"; fi' "{}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was brought by Sam earlier ... but can you move these steps into the build.sh ? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think these tests should all be referring to FRAMEWORK_SEARCH_PATHS, not HEADER_SEARCH_PATHS.
This is because in the lldb-settings.sh, we tell LLDB about the $FRAMEWORK_SEARCH_PATHS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now it does the same thing of checking against the hash value to see if what xcodeproj wants is what bazel build generates inside build-warapper.sh
This test case will fail if changes in this PR is reverted (the transitive rule) so i do see value in this test
and make build-wrapper more readable
…c setting instead
…tions_transition `
…deproj is referring to do exist
120955c
to
88e4598
Compare
@segiddins @amberdixon should be ready to review again 🙏 |
bazelisk query 'kind(xcodeproj, tests/ios/xcodeproj/...)' | xargs -n 1 bazelisk run | ||
bazelisk query 'attr(executable, 1, kind(genrule, tests/ios/xcodeproj/...))' | xargs -n 1 bazelisk run | ||
git diff --exit-code tests/ios/xcodeproj | ||
- name: Run pre build checks | ||
run: ./tests/ios/xcodeproj/pre_build_check.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not include these in the existing build
shell script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's added are not part of build process (aka removing them won't affect build). might as well use a pre_build and post_build hooks for future iteration on such checks
Why this change
With the change introduced in #98, when bazel builds behind the scene (inside
build-wrapper
), it will generates one that enables swift to be debuggable. However the framework search paths generated during the xcodeproj generation stage (bazel run some_xcodeprojec_rule
) will generate a different configuration cache than the one generated by bazel build (since inside build wrapper there are additional flags: 1. compilation mode and 2. local_debug_option)As evidenced by the test fixture changes, the search paths are changed in this PR because
compilation_mode
is set to debug to match with when xcode builds under debug config (not release config, so under release this is still broken)local_debug_option
is set to True for both xcode proj rule (through transition) and inside build-wrapperThe direct effect is that the framework search path is now pointing at the correct location.
Known issue:
Release config won't work with this change because compilation mode for debug is only set for Debug config, wondering if we should just have Release config pointing to
compilation_mode = dbg
too since the expectation is that ppl use release config under xcode is because they want to test the behaviors of the MACROS?Tests