-
Notifications
You must be signed in to change notification settings - Fork 196
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
Support multiple execution platforms with system_cxx_toolchain #629
Open
Overhatted
wants to merge
11
commits into
facebook:main
Choose a base branch
from
Overhatted:multiple_target_platforms
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
27a221a
Added C source files to compile_commands.json
Overhatted d167511
Fixed install.ps1 script to work even if the directory doesn't exist
Overhatted 0c1b452
Added support for specifying the compiler in the system_cxx_toolchain
Overhatted a970f98
Updated visual studio example to support cross platform compilation u…
Overhatted bee4c24
Added some calls to clang's BUCK to pass the pipeline job
Overhatted 330e571
Renamed compiler to SystemCxxToolchainInfo
Overhatted a379dde
Renamed execution_platform to execution_platforms
Overhatted b28d493
Replaced functions with selects
Overhatted f07bed7
Renamed compiler to toolchain_info in system_cxx_toolchain
Overhatted d000ff8
Readded previously removed system_cxx_toolchain parameters
Overhatted a3e60dc
Removed .buckconfig in Visual Studio's example.
Overhatted File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,8 @@ begin | |
[parameter(Mandatory=$true)] [String] $SourcePath, | ||
[parameter(Mandatory=$true)] [String] $TargetPath | ||
) | ||
Copy-Item $SourcePath -Destination $TargetPath | ||
New-Item -ItemType File -Path $TargetPath -Force | Out-Null | ||
Copy-Item $SourcePath -Destination $TargetPath | Out-Null | ||
Comment on lines
+32
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why 2 steps instead of 1? |
||
} | ||
} | ||
process | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
load(":defs.bzl", "execution_platforms") | ||
|
||
execution_platforms( | ||
name = "default", | ||
visibility = ["PUBLIC"], | ||
) | ||
|
||
platform( | ||
name = "windows_debug", | ||
constraint_values = [ | ||
"config//os/constraints:windows", | ||
"root//buck2_utils/configuration:debug", | ||
], | ||
) | ||
|
||
platform( | ||
name = "windows_release", | ||
constraint_values = [ | ||
"config//os/constraints:windows", | ||
"root//buck2_utils/configuration:release", | ||
], | ||
) | ||
|
||
platform( | ||
name = "linux_debug", | ||
constraint_values = [ | ||
"config//os/constraints:linux", | ||
"root//buck2_utils/configuration:debug", | ||
], | ||
) | ||
|
||
platform( | ||
name = "linux_release", | ||
constraint_values = [ | ||
"config//os/constraints:linux", | ||
"root//buck2_utils/configuration:release", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
def is_remote_enabled() -> bool: | ||
re_enabled = read_config("buck2_re_client", "enabled", "false") | ||
return re_enabled == "true" | ||
|
||
def _execution_platforms_impl(ctx: AnalysisContext) -> list[Provider]: | ||
is_re_enabled = is_remote_enabled() | ||
|
||
name = ctx.label.raw_target() | ||
|
||
constraints_windows = dict() | ||
constraints_windows.update(ctx.attrs.os_configuration_windows[ConfigurationInfo].constraints) | ||
constraints_linux = dict() | ||
constraints_linux.update(ctx.attrs.os_configuration_linux[ConfigurationInfo].constraints) | ||
|
||
platforms_details = [ | ||
("windows", host_info().os.is_windows, constraints_windows), | ||
("linux", host_info().os.is_linux, constraints_linux), | ||
] | ||
|
||
platforms = [] | ||
for platform_name, is_local_enabled, constraints in platforms_details: | ||
if is_re_enabled or is_local_enabled: | ||
platforms.append( | ||
ExecutionPlatformInfo( | ||
label = name, | ||
configuration = ConfigurationInfo( | ||
constraints = constraints, | ||
values = {}, | ||
), | ||
executor_config = CommandExecutorConfig( | ||
local_enabled = is_local_enabled, | ||
remote_enabled = is_re_enabled, | ||
use_limited_hybrid = True, | ||
remote_execution_properties = { | ||
"OSFamily": platform_name, | ||
"container-image": "docker://" + platform_name + "_build", | ||
}, | ||
remote_execution_use_case = "buck2-default", | ||
use_windows_path_separators = platform_name == "windows", | ||
), | ||
) | ||
) | ||
|
||
return [ | ||
DefaultInfo(), | ||
ExecutionPlatformRegistrationInfo(platforms = platforms), | ||
] | ||
|
||
execution_platforms = rule( | ||
impl = _execution_platforms_impl, | ||
attrs = { | ||
"os_configuration_windows": attrs.dep( | ||
providers = [ConfigurationInfo], | ||
default = "config//os:windows", | ||
), | ||
"os_configuration_linux": attrs.dep( | ||
providers = [ConfigurationInfo], | ||
default = "config//os:linux", | ||
), | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
#else | ||
#define DLL_API __declspec(dllimport) | ||
#endif | ||
#else | ||
#define DLL_API | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 change this?