/* Ċ Ġ* ĠCopyright Ġ 2 0 1 0 - 2 0 2 1 ĠJetBrains Ġs . r . o . Ġand ĠKotlin ĠProgramming ĠLanguage Ġcontributors . Ċ Ġ* ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe Ġlicense / LICENSE . txt Ġfile . Ċ Ġ*/ Ċ Ċ package Ġorg . jetbrains . kotlin . gradle . targets . native . internal Ċ Ċ import Ġorg . gradle . api . Project Ċ import Ġorg . jetbrains . kotlin . common izer . Shared Common izer Target Ċ import Ġorg . jetbrains . kotlin . gradle . dsl . multi platform Extension OrNull Ċ import Ġorg . jetbrains . kotlin . gradle . plugin . Kotlin Compilation Ċ import Ġorg . jetbrains . kotlin . gradle . plugin . Kotlin Source Set Ċ import Ġorg . jetbrains . kotlin . gradle . plugin . mpp . Compilation Source Set Util . comp il ations By Source Sets Ċ import Ġorg . jetbrains . kotlin . gradle . plugin . mpp . Kotlin Native Compilation Ċ import Ġorg . jetbrains . kotlin . gradle . plugin . mpp . Kotlin Shared Native Compilation Ċ import Ġorg . jetbrains . kotlin . gradle . plugin . mpp . associate With Trans itive Closure Ċ import Ġorg . jetbrains . kotlin . gradle . plugin . mpp . kotlin Source Sets In cluding Default Ċ import Ġorg . jetbrains . kotlin . gradle . plugin . sources . resolve All Dep ends On Source Sets Ċ import Ġorg . jetbrains . kotlin . gradle . targets . native . internal . C Interop Identifier . Scope Ċ import Ġorg . jetbrains . kotlin . gradle . utils . Unsafe Api Ċ Ċ internal Ġclass ĠC Interop Common izer Dependent Ġ@ Unsafe Api Ġconstructor ( ĊĠĠĠ Ġval Ġtarget : ĠShared Common izer Target , ĊĠĠĠ Ġval Ġscopes : ĠSet < Scope >, ĊĠĠĠ Ġval Ġinter ops : ĠSet < C Interop Identifier > Ċ ) Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġequals ( other : ĠAny ?): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( other Ġ! is ĠC Interop Common izer Dependent ) Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġif Ġ( this . target Ġ!= Ġother . target ) Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġif Ġ( this . scopes Ġ!= Ġother . scopes ) Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġif Ġ( this . inter ops Ġ!= Ġother . inter ops ) Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠhashCode (): ĠInt Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġresult Ġ= Ġtarget . hashCode () ĊĠĠĠĠĠĠĠ Ġresult Ġ= Ġ 3 1 Ġ* Ġresult Ġ+ Ġscopes . hashCode () ĊĠĠĠĠĠĠĠ Ġresult Ġ= Ġ 3 1 Ġ* Ġresult Ġ+ Ġinter ops . hashCode () ĊĠĠĠĠĠĠĠ Ġreturn Ġresult ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġrequire ( target . targets . isNotEmpty ()) Ġ{ Ġ" C Interop Common izer Dependent . target . targets . size Ġcan 't Ġbe Ġempty " Ġ} ĊĠĠĠĠĠĠĠ Ġrequire ( scopes . isNotEmpty ()) Ġ{ Ġ" C Interop Common izer Dependent . scopes Ġcan 't Ġbe Ġempty " Ġ} ĊĠĠĠĠĠĠĠ Ġrequire ( inter ops . isNotEmpty ()) Ġ{ Ġ" C Interop Common izer Dependent . inter ops Ġcan 't Ġbe Ġempty " Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject ĠFactory Ċ } Ċ Ċ @ Opt In ( Unsafe Api :: class ) Ċ internal Ġfun ĠC Interop Common izer Dependent . Factory . from ( ĊĠĠĠ Ġtarget : ĠShared Common izer Target , ĊĠĠĠ Ġcompil ations : ĠSet < Kotlin Native Compilation > Ċ ): ĠC Interop Common izer Dependent ? Ġ{ ĊĠĠĠ Ġtarget . targets . if Empty Ġ{ Ġreturn Ġnull Ġ} ĊĊĠĠĠ Ġ/* ĊĠĠĠĠ ĠFilter Ġout Ġcompil ations Ġthat Ġhave Ġtheir Ġassociate Ġalso Ġin Ġthe Ġset Ġof Ġcompil ations ĊĠĠĠĠ Ġe . g . Ġdo Ġnot Ġinclude Ġ'* test ' Ġif Ġtheir Ġmain Ġcounter part Ġis Ġalso Ġpresent . ĊĠĠĠĠ Ġ* test Ġand Ġ* main Ġcompil ations Ġwill Ġbe Ġincluded Ġwhen Ġbuild Ġauthors Ġdeclare Ġa Ġ* Test Ġdepends On Ġ* Main Ġsource Ġset Ġrelationship . ĊĠĠĠĠ ĠThis Ġrelationship Ġshould Ġnot Ġbe Ġdeclared , Ġbut Ġwe Ġtry Ġto Ġbe Ġlen ient Ġtowards Ġit Ġhere . ĊĠĠĠĠĠ Ġ*/ ĊĠĠĠ Ġval Ġfiltered Comp il ations Ġ= Ġcompil ations . filter Ġ{ Ġcompilation Ġ-> ĊĠĠĠĠĠĠĠ Ġcompilation . associate With Trans itive Closure . none Ġ{ Ġassociate Compilation Ġ-> Ġassociate Compilation Ġin Ġcompil ations Ġ} ĊĠĠĠ Ġ}. if Empty Ġ{ Ġreturn Ġnull Ġ}. toSet () ĊĊĠĠĠ Ġval Ġscopes : ĠSet < Scope > Ġ= Ġfiltered Comp il ations ĊĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġcompilation Ġ-> ĠScope . create ( compilation ) Ġ}. toSet () ĊĠĠĠĠĠĠĠ Ġ. if Empty Ġ{ Ġreturn Ġnull Ġ} ĊĊĠĠĠ Ġval Ġinter ops : ĠSet < C Interop Identifier > Ġ= Ġfiltered Comp il ations ĊĠĠĠĠĠĠĠ Ġ. flatMap Ġ{ Ġcompilation Ġ-> Ġcompilation . c inter ops . if Empty Ġ{ Ġreturn Ġnull Ġ} Ġ} ĊĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġc interop Ġ-> Ġc interop . identifier Ġ}. toSet () ĊĊĠĠĠ Ġreturn ĠC Interop Common izer Dependent ( target , Ġscopes , Ġinter ops ) Ċ } Ċ Ċ internal Ġfun ĠC Interop Common izer Dependent . Factory . from ( compilation : ĠKotlin Shared Native Compilation ): ĠC Interop Common izer Dependent ? Ġ{ ĊĠĠĠ Ġreturn Ġfrom ( ĊĠĠĠĠĠĠĠ Ġcompilation . project . get Common izer Target ( compilation ) Ġas ? ĠShared Common izer Target Ġ?: Ġreturn Ġnull , ĊĠĠĠĠĠĠĠ Ġcompilation . find Depend ing Native Comp il ations () ĊĠĠĠ Ġ) Ċ } Ċ Ċ internal Ġfun ĠC Interop Common izer Dependent . Factory . from ( project : ĠProject , Ġsource Set : ĠKotlin Source Set ): ĠC Interop Common izer Dependent ? Ġ{ ĊĠĠĠ Ġreturn Ġfrom ( ĊĠĠĠĠĠĠĠ Ġtarget Ġ= Ġproject . get Common izer Target ( source Set ) Ġas ? ĠShared Common izer Target Ġ?: Ġreturn Ġnull , ĊĠĠĠĠĠĠĠ Ġcompil ations Ġ= Ġ( comp il ations By Source Sets ( project )[ source Set ] Ġ?: Ġreturn Ġnull ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. filter Is Instance < Kotlin Native Compilation >(). toSet () ĊĠĠĠ Ġ) Ċ } Ċ Ċ internal Ġfun ĠC Interop Common izer Dependent . Factory . from Associate Comp il ations ( ĊĠĠĠ Ġproject : ĠProject , Ġsource Set : ĠKotlin Source Set Ċ ): ĠC Interop Common izer Dependent ? Ġ{ ĊĠĠĠ Ġreturn Ġfrom ( ĊĠĠĠĠĠĠĠ Ġtarget Ġ= Ġproject . get Common izer Target ( source Set ) Ġas ? ĠShared Common izer Target Ġ?: Ġreturn Ġnull , ĊĠĠĠĠĠĠĠ Ġcompil ations Ġ= Ġ( comp il ations By Source Sets ( project )[ source Set ] Ġ?: Ġreturn Ġnull ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. filter Is Instance < Kotlin Native Compilation >() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. flatMap Ġ{ Ġcompilation Ġ-> Ġcompilation . associate With Trans itive Closure Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. filter Is Instance < Kotlin Native Compilation >() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. toSet () ĊĠĠĠ Ġ) Ċ } Ċ Ċ private Ġfun ĠKotlin Shared Native Compilation . find Depend ing Native Comp il ations (): ĠSet < Kotlin Native Compilation > Ġ{ ĊĠĠĠ Ġval Ġmulti platform Extension Ġ= Ġproject . multi platform Extension OrNull Ġ?: Ġreturn Ġempty Set () ĊĠĠĠ Ġval Ġall Part icip ating Source Sets Of Compilation Ġ= Ġall Part icip ating Source Sets () ĊĊĠĠĠ Ġreturn Ġmulti platform Extension . targets ĊĠĠĠĠĠĠĠ Ġ. flatMap Ġ{ Ġtarget Ġ-> Ġtarget . comp il ations Ġ} ĊĠĠĠĠĠĠĠ Ġ. filter Is Instance < Kotlin Native Compilation >() ĊĠĠĠĠĠĠĠ Ġ. filter Ġ{ Ġnative Compilation Ġ-> Ġnative Compilation . all Part icip ating Source Sets (). contains All ( all Part icip ating Source Sets Of Compilation ) Ġ} ĊĠĠĠĠĠĠĠ Ġ. toSet () Ċ } Ċ Ċ /** Ċ Ġ* ĠSome Ġimplementations Ġof Ġ[ Kotlin Compilation ] Ġdo Ġnot Ġcontain Ġthe Ġdefault Ġsource Ġset Ġin Ċ Ġ* Ġ[ Kotlin Compilation . kotlin Source Sets ] Ġor Ġ[ Kotlin Compilation . all Kotlin Source Sets ] Ċ Ġ* Ġsee ĠK T - 4 5 4 1 2 Ċ Ġ*/ Ċ private Ġfun ĠKotlin Compilation <* >. all Part icip ating Source Sets (): ĠSet < Kotlin Source Set > Ġ{ ĊĠĠĠ Ġreturn Ġkotlin Source Sets In cluding Default Ġ+ Ġkotlin Source Sets In cluding Default . resolve All Dep ends On Source Sets () Ċ } Ċ