Skip to content

Conversation

@MaxDesiatov
Copy link
Contributor

Currently, a lot of products defined in utils/swift_build_support contain duplicated code that checks for Darwin/Linux triples and generates an appropriate CMake toolchain file. Since all of these products inherit from the Product class, it makes sense to reduce this code duplication by refactoring it into a single function.

@MaxDesiatov
Copy link
Contributor Author

@swift-ci please smoke test

@MaxDesiatov MaxDesiatov force-pushed the maxd/generate-toolchain branch from d541e8c to c2f7bac Compare October 24, 2022 15:22
@MaxDesiatov
Copy link
Contributor Author

@swift-ci please smoke test

@MaxDesiatov MaxDesiatov force-pushed the maxd/generate-toolchain branch from c2f7bac to e7536f5 Compare October 24, 2022 16:39
@MaxDesiatov
Copy link
Contributor Author

@swift-ci please smoke test

@MaxDesiatov MaxDesiatov requested a review from edymtt October 24, 2022 20:44

return toolchain_file

def generate_toolchain_file(self, host_target):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the usage in the cmark product, could it make sense to explicitly state that the function targets darwin and linux only? e.g.

Suggested change
def generate_toolchain_file(self, host_target):
def generate_toolchain_file_for_darwin_and_linux(self, host_target):

self.cmake_options.define('CMAKE_CXX_FLAGS', common_c_flags)

toolchain_file = None
if self.is_darwin_host(host_target):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this refactoring, nice catch!

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Nice refactor.

@MaxDesiatov MaxDesiatov force-pushed the maxd/generate-toolchain branch from e7536f5 to 99dedee Compare November 30, 2022 11:50
@MaxDesiatov
Copy link
Contributor Author

@swift-ci please smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci please test Windows

1 similar comment
@MaxDesiatov
Copy link
Contributor Author

@swift-ci please test Windows

@MaxDesiatov
Copy link
Contributor Author

Verified that this builds successfully in different configurations.

@MaxDesiatov MaxDesiatov merged commit 0eeadff into main Dec 7, 2022
@MaxDesiatov MaxDesiatov deleted the maxd/generate-toolchain branch December 7, 2022 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants