Skip to content
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

cache generated file paths relative to the build directory (changed from project directory) #979

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

RBusarow
Copy link
Collaborator

A project's build directory can be reassigned to something other than <the project>/build. This would typically be done via some build logic that's checked in to source control and applied to any machine that builds the code. This would usually mean that all machines' build directories have the same path relative to the project root.

It's possible to build directory to be re-mapped in other ways, that result in a different relative path. When this happens, the paths for source/generated files must be cached as their paths relative to the build directory, instead of the project.

@RBusarow RBusarow force-pushed the rick/relative-build-dir branch 2 times, most recently from fedf561 to 7999b03 Compare April 23, 2024 23:44
@RBusarow RBusarow marked this pull request as ready for review April 24, 2024 18:50
@RBusarow
Copy link
Collaborator Author

RBusarow commented Apr 24, 2024

CI's red, but only because macos-latest runners have changed to ARM architecture and the instrumented test job can't find an emulator. The fix for that is here: #981

…rom project directory)

A project's build directory can be reassigned to something other than `<the project>/build`.  This would typically be done via some build logic that's checked in to source control and applied to any machine that builds the code.  This would usually mean that all machines' build directories have the same path relative to the project root.  However, it's possible to build directory to be re-mapped in other ways, that result in a different relative path.  When this happens, the paths for source/generated files must be cached as their paths relative to the build directory, instead of the project.
get() = tables.getSourceFilesWithoutGeneratedContent()
.filter { source -> source != RelativeFile.ANY }
.toSet()
.mapNotNullToSet { it.absolute() }
Copy link
Member

Choose a reason for hiding this comment

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

Do we not need to check for AbsoluteFile.ANY_ABSOLUTE like we were for the old RelativeFile marker? I couldn't tell from the other changes if this is just not needed anymore or if it's happening implicitly somewhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question. It's happening implicitly elsewhere, but it also doesn't matter since ANY_ABSOLUTE actually gets added to this set downstream in case it didn't exist already.

Comment on lines +117 to +118
@Deprecated("no", ReplaceWith("absolute"))
fun GeneratedFileWithSources.toSourceFile(): AbsoluteFile = absolute
Copy link
Member

Choose a reason for hiding this comment

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

Why deprecate this instead of just replacing the usages now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I sometimes do this to get IDE help with a simple migration, but I forgot to delete the leftover function afterwards. I'll clean this up in a followup PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Followup PR here: #979 (comment)

task(":compileKotlin")?.outcome shouldBe TaskOutcome.SUCCESS
}

rootA.path.deleteRecursivelyOrFail()
Copy link
Member

Choose a reason for hiding this comment

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

Why do we delete the rootA files here? My initial reaction based on the rest of the setup is that the project A files have been cached, and we're going to verify that those cached files can be used in project B, but that them still existing locally for project A shouldn't affect project B.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a sanity check, just to ensure that they aren't affecting project B.

@RBusarow RBusarow merged commit 70db021 into main Apr 24, 2024
17 checks passed
@RBusarow RBusarow deleted the rick/relative-build-dir branch April 24, 2024 22: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.

2 participants