Skip to content

Commit 261993b

Browse files
sbogolepovSpace Team
authored andcommitted
[Native] Provide a hack (-PdisableBreakpad) to disable breakpad compilation
The next step is to provide a proper solution: KT-79587
1 parent f868aa3 commit 261993b

File tree

3 files changed

+73
-51
lines changed

3 files changed

+73
-51
lines changed

kotlin-native/runtime/build.gradle.kts

Lines changed: 69 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -84,48 +84,58 @@ bitcode {
8484
sourceSets {}
8585
}
8686

87-
module("breakpad") {
88-
srcRoot.set(downloadBreakpad.flatMap { it.outputDirectory })
89-
val sources = listOf(
90-
"client/mac/crash_generation/crash_generation_client.cc",
91-
"client/mac/handler/breakpad_nlist_64.cc",
92-
"client/mac/handler/dynamic_images.cc",
93-
"client/mac/handler/exception_handler.cc",
94-
"client/mac/handler/minidump_generator.cc",
95-
"client/mac/handler/protected_memory_allocator.cc",
96-
"client/minidump_file_writer.cc",
97-
"common/mac/MachIPC.mm",
98-
"common/mac/arch_utilities.cc",
99-
"common/mac/file_id.cc",
100-
"common/mac/macho_id.cc",
101-
"common/mac/macho_utilities.cc",
102-
"common/mac/macho_walker.cc",
103-
"common/mac/string_utilities.cc",
104-
"common/mac/bootstrap_compat.cc",
105-
"common/convert_UTF.cc",
106-
"common/md5.cc",
107-
"common/string_conversion.cc",
108-
)
109-
sourceSets {
110-
main {
111-
inputFiles.from(srcRoot.dir("src"))
112-
inputFiles.setIncludes(sources)
113-
headersDirs.setFrom(project.layout.projectDirectory.dir("src/breakpad/cpp"))
114-
// Fix Gradle Configuration Cache: support this task being configured before breakpad sources are actually downloaded.
115-
compileTask.configure {
116-
inputFiles.setFrom(sources.map { breakpadLocationNoDependency.get().dir("src").file(it) })
87+
if (!project.hasProperty("disableBreakpad")) {
88+
module("breakpad") {
89+
srcRoot.set(downloadBreakpad.flatMap { it.outputDirectory })
90+
val sources = listOf(
91+
"client/mac/crash_generation/crash_generation_client.cc",
92+
"client/mac/handler/breakpad_nlist_64.cc",
93+
"client/mac/handler/dynamic_images.cc",
94+
"client/mac/handler/exception_handler.cc",
95+
"client/mac/handler/minidump_generator.cc",
96+
"client/mac/handler/protected_memory_allocator.cc",
97+
"client/minidump_file_writer.cc",
98+
"common/mac/MachIPC.mm",
99+
"common/mac/arch_utilities.cc",
100+
"common/mac/file_id.cc",
101+
"common/mac/macho_id.cc",
102+
"common/mac/macho_utilities.cc",
103+
"common/mac/macho_walker.cc",
104+
"common/mac/string_utilities.cc",
105+
"common/mac/bootstrap_compat.cc",
106+
"common/convert_UTF.cc",
107+
"common/md5.cc",
108+
"common/string_conversion.cc",
109+
)
110+
sourceSets {
111+
main {
112+
inputFiles.from(srcRoot.dir("src"))
113+
inputFiles.setIncludes(sources)
114+
headersDirs.setFrom(project.layout.projectDirectory.dir("src/breakpad/cpp"))
115+
// Fix Gradle Configuration Cache: support this task being configured before breakpad sources are actually downloaded.
116+
compileTask.configure {
117+
inputFiles.setFrom(sources.map { breakpadLocationNoDependency.get().dir("src").file(it) })
118+
}
117119
}
118120
}
121+
// Make sure breakpad sources are downloaded when building the corresponding compilation database entry
122+
dependencies.add(downloadBreakpad)
123+
compilerArgs.set(listOf(
124+
"-std=c++17",
125+
"-DHAVE_MACH_O_NLIST_H",
126+
"-DHAVE_CONFIG_H",
127+
))
128+
129+
onlyIf { it.family == Family.OSX }
130+
}
131+
} else {
132+
// Compiler expects breakpad.bc file. Let's give it an empty one.
133+
module("breakpad") {
134+
srcRoot.set(project.layout.projectDirectory.dir("src/breakpad_stubs"))
135+
sourceSets {
136+
main {}
137+
}
119138
}
120-
// Make sure breakpad sources are downloaded when building the corresponding compilation database entry
121-
dependencies.add(downloadBreakpad)
122-
compilerArgs.set(listOf(
123-
"-std=c++17",
124-
"-DHAVE_MACH_O_NLIST_H",
125-
"-DHAVE_CONFIG_H",
126-
))
127-
128-
onlyIf { it.family == Family.OSX }
129139
}
130140

131141
module("libbacktrace") {
@@ -458,20 +468,29 @@ bitcode {
458468
}
459469
}
460470

461-
module("impl_crashHandler") {
462-
srcRoot.set(layout.projectDirectory.dir("src/crashHandler/impl"))
463-
// Cannot use output of `downloadBreakpad` to support Gradle Configuration Cache working before `downloadBreakpad`
464-
// actually had a chance to run.
465-
headersDirs.from("src/main/cpp", "src/breakpad/cpp", breakpadLocationNoDependency.get().dir("src"))
466-
sourceSets {
467-
main {
468-
// This task depends on breakpad headers being present.
469-
compileTask.configure {
470-
dependsOn(downloadBreakpad)
471+
if (!project.hasProperty("disableBreakpad")) {
472+
module("impl_crashHandler") {
473+
srcRoot.set(layout.projectDirectory.dir("src/crashHandler/impl"))
474+
// Cannot use output of `downloadBreakpad` to support Gradle Configuration Cache working before `downloadBreakpad`
475+
// actually had a chance to run.
476+
headersDirs.from("src/main/cpp", "src/breakpad/cpp", breakpadLocationNoDependency.get().dir("src"))
477+
sourceSets {
478+
main {
479+
// This task depends on breakpad headers being present.
480+
compileTask.configure {
481+
dependsOn(downloadBreakpad)
482+
}
471483
}
472484
}
485+
onlyIf { it.family == Family.OSX }
486+
}
487+
} else {
488+
module("impl_crashHandler") {
489+
srcRoot.set(layout.projectDirectory.dir("src/crashHandler/noop"))
490+
sourceSets {
491+
main {}
492+
}
473493
}
474-
onlyIf { it.family == Family.OSX }
475494
}
476495

477496
module("noop_crashHandler") {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace kotlin {
2+
void breakpad_stub() { }
3+
}

repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/nativeTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private open class NativeArgsProvider @Inject constructor(
225225
@get:PathSensitive(PathSensitivity.NONE) // it doesn't matter at all how is this analyzer named, or where it's placed
226226
@get:Optional
227227
protected val minidumpAnalyzer: ConfigurableFileCollection = objects.fileCollection().apply {
228-
if (HostManager.hostIsMac) {
228+
if (HostManager.hostIsMac && !project.hasProperty("disableBreakpad")) {
229229
val fileCollection = project.configurations.detachedConfiguration(
230230
project.dependencies.project(":kotlin-native:tools:minidump-analyzer"),
231231
).also {

0 commit comments

Comments
 (0)