Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/package-managers/conan/src/main/kotlin/Conan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ class Conan(
config.lockfileName?.let { hasLockfile(workingDir.resolve(it).path) } == true
}

handler.createConanProfileIfNeeded()
Copy link
Member

Choose a reason for hiding this comment

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

Commit message: s/-detect/--detect/


val handlerResults = handler.process(definitionFile, config.lockfileName)

val result = with(handlerResults) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ import org.ossreviewtoolkit.utils.ort.createOrtTempDir
internal class ConanV1Handler(private val conan: Conan) : ConanVersionHandler {
override fun getConanHome(): File = Os.userHomeDirectory.resolve(".conan")

override fun createConanProfileIfNeeded() {
if (!getConanHome().resolve("profiles/ort-default").isFile) {
conan.command.run("profile", "new", "ort-default", "--detect").requireSuccess()
Copy link
Member

Choose a reason for hiding this comment

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

The "ort-default" should only be added to the script in this commit which makes use of it.

}
}

override fun getConanStoragePath(): File = getConanHome().resolve("data")

override fun process(definitionFile: File, lockfileName: String?): HandlerResults {
Expand All @@ -64,7 +70,9 @@ internal class ConanV1Handler(private val conan: Conan) : ConanVersionHandler {
definitionFile.name,
"--json",
jsonFile.absolutePath,
*DUMMY_COMPILER_SETTINGS
*DUMMY_COMPILER_SETTINGS,
"--profile",
"ort-default"
).requireSuccess()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ import org.ossreviewtoolkit.utils.ort.createOrtTempDir
internal class ConanV2Handler(private val conan: Conan) : ConanVersionHandler {
override fun getConanHome(): File = Os.userHomeDirectory.resolve(".conan2")

override fun createConanProfileIfNeeded() {
if (!getConanHome().resolve("profiles/ort-default").isFile) {
conan.command.run("profile", "detect", "--name", "ort-default").requireSuccess()
}
}

override fun getConanStoragePath(): File = getConanHome().resolve("p")

override fun process(definitionFile: File, lockfileName: String?): HandlerResults {
val workingDir = definitionFile.parentFile

// Create a default build profile.
if (!getConanHome().resolve("profiles/default").isFile) {
conan.command.run(workingDir, "profile", "detect")
}

val jsonFile = createOrtTempDir().resolve("info.json")
if (lockfileName != null) {
conan.verifyLockfileBelongsToProject(workingDir, lockfileName)
Expand All @@ -71,6 +72,8 @@ internal class ConanV2Handler(private val conan: Conan) : ConanVersionHandler {
lockfileName,
"--out-file",
jsonFile.absolutePath,
"--profile:all",
"ort-default",
*DUMMY_COMPILER_SETTINGS,
definitionFile.name
).requireSuccess()
Expand All @@ -83,6 +86,8 @@ internal class ConanV2Handler(private val conan: Conan) : ConanVersionHandler {
"json",
"--out-file",
jsonFile.absolutePath,
"--profile:all",
"ort-default",
*DUMMY_COMPILER_SETTINGS,
definitionFile.name
).requireSuccess()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ internal interface ConanVersionHandler {
*/
fun getConanHome(): File

/**
* Create a default ORT Conan profile if it does not exist yet. This profile will contain the complication flags.
*/
fun createConanProfileIfNeeded()

/**
* Get the Conan storage path, i.e. the location where Conan caches downloaded packages.
*/
Expand Down