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

Conan improvements #4541

Merged
merged 9 commits into from
Oct 5, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ project:
- id: "Conan::openssl:3.0.0"
dependencies:
- id: "Conan::zlib:1.2.11"
- id: "Conan::zlib:1.2.11"
packages:
- id: "Conan::openssl:3.0.0"
purl: "pkg:conan/openssl@3.0.0"
Expand All @@ -45,18 +44,18 @@ packages:
value: ""
algorithm: ""
source_artifact:
url: ""
url: "https://www.openssl.org/source/openssl-3.0.0.tar.gz"
hash:
value: ""
algorithm: ""
value: "59eedfcb46c25214c9bd37ed6078297b4df01d012267fe9e9eee31f61bc70536"
algorithm: "SHA-256"
vcs:
type: "Git"
url: "https://github.com/conan-io/conan-center-index"
url: "https://github.com/openssl/openssl.git"
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/conan-io/conan-center-index.git"
url: "https://github.com/openssl/openssl.git"
revision: ""
path: ""
- id: "Conan::zlib:1.2.11"
Expand All @@ -74,17 +73,17 @@ packages:
value: ""
algorithm: ""
source_artifact:
url: ""
url: "https://zlib.net/zlib-1.2.11.tar.gz"
hash:
value: ""
algorithm: ""
value: "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
algorithm: "SHA-256"
vcs:
type: "Git"
url: "https://github.com/conan-io/conan-center-index"
type: ""
url: ""
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/conan-io/conan-center-index.git"
type: ""
url: ""
revision: ""
path: ""
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ project:
scopes:
- name: "build_requires"
dependencies:
- id: "Conan::libiconv:1.16"
- id: "Conan::libxml2:2.9.12"
- id: "Conan::libxslt:1.1.34"
dependencies:
- id: "Conan::zlib:1.2.11"
- id: "Conan::libxml2:2.9.12"
dependencies:
- id: "Conan::libiconv:1.16"
- id: "Conan::zlib:1.2.11"
- name: "requires"
dependencies:
- id: "Conan::libcurl:7.79.1"
dependencies:
- id: "Conan::openssl:1.1.1l"
- id: "Conan::zlib:1.2.11"
- id: "Conan::openssl:1.1.1l"
- id: "Conan::zlib:1.2.11"
packages:
- id: "Conan::libcurl:7.79.1"
purl: "pkg:conan/libcurl@7.79.1"
Expand All @@ -45,18 +45,18 @@ packages:
value: ""
algorithm: ""
source_artifact:
url: ""
url: "https://curl.se/download/curl-7.79.1.tar.gz"
hash:
value: ""
algorithm: ""
value: "370b11201349816287fb0ccc995e420277fbfcaf76206e309b3f60f0eda090c2"
algorithm: "SHA-256"
vcs:
type: "Git"
url: "https://github.com/conan-io/conan-center-index"
type: ""
url: ""
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/conan-io/conan-center-index.git"
type: ""
url: ""
revision: ""
path: ""
- id: "Conan::libiconv:1.16"
Expand All @@ -75,18 +75,18 @@ packages:
value: ""
algorithm: ""
source_artifact:
url: ""
url: "https://ftp.gnu.org/gnu/libiconv/libiconv-1.16.tar.gz"
hash:
value: ""
algorithm: ""
value: "e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04"
algorithm: "SHA-256"
vcs:
type: "Git"
url: "https://github.com/conan-io/conan-center-index"
type: ""
url: ""
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/conan-io/conan-center-index.git"
type: ""
url: ""
revision: ""
path: ""
- id: "Conan::libxml2:2.9.12"
Expand All @@ -103,18 +103,47 @@ packages:
value: ""
algorithm: ""
source_artifact:
url: "http://xmlsoft.org/sources/libxml2-2.9.12.tar.gz"
hash:
value: "c8d6681e38c56f172892c85ddc0852e1fd4b53b4209e7f4ebf17f7e2eae71d92"
algorithm: "SHA-256"
vcs:
type: ""
url: ""
revision: ""
path: ""
vcs_processed:
type: ""
url: ""
revision: ""
path: ""
- id: "Conan::libxslt:1.1.34"
purl: "pkg:conan/libxslt@1.1.34"
declared_licenses:
- "MIT"
declared_licenses_processed:
spdx_expression: "MIT"
description: "libxslt is a software library implementing XSLT processor, based on\
\ libxml2"
homepage_url: "https://xmlsoft.org"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: "http://xmlsoft.org/sources/libxslt-1.1.34.tar.gz"
hash:
value: "98b1bd46d6792925ad2dfe9a87452ea2adebf69dcb9919ffd55bf926a7f93f7f"
algorithm: "SHA-256"
vcs:
type: "Git"
url: "https://github.com/conan-io/conan-center-index"
type: ""
url: ""
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/conan-io/conan-center-index.git"
type: ""
url: ""
revision: ""
path: ""
- id: "Conan::openssl:1.1.1l"
Expand All @@ -132,18 +161,18 @@ packages:
value: ""
algorithm: ""
source_artifact:
url: ""
url: "https://www.openssl.org/source/openssl-1.1.1l.tar.gz"
hash:
value: ""
algorithm: ""
value: "0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1"
algorithm: "SHA-256"
vcs:
type: "Git"
url: "https://github.com/conan-io/conan-center-index"
url: "https://github.com/openssl/openssl.git"
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/conan-io/conan-center-index.git"
url: "https://github.com/openssl/openssl.git"
revision: ""
path: ""
- id: "Conan::zlib:1.2.11"
Expand All @@ -161,17 +190,17 @@ packages:
value: ""
algorithm: ""
source_artifact:
url: ""
url: "https://zlib.net/zlib-1.2.11.tar.gz"
hash:
value: ""
algorithm: ""
value: "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
algorithm: "SHA-256"
vcs:
type: "Git"
url: "https://github.com/conan-io/conan-center-index"
type: ""
url: ""
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/conan-io/conan-center-index.git"
type: ""
url: ""
revision: ""
path: ""
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build_requires]
libxml2/2.9.12
libxslt/1.1.34

[requires]
libcurl/7.79.1
Expand Down
47 changes: 24 additions & 23 deletions analyzer/src/main/kotlin/managers/Bower.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017-2019 HERE Europe B.V.
* Copyright (C) 2021 Bosch.IO GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,33 +65,33 @@ class Bower(
private const val SCOPE_NAME_DEPENDENCIES = "dependencies"
private const val SCOPE_NAME_DEV_DEPENDENCIES = "devDependencies"

private fun extractPackageId(node: JsonNode) =
private fun parsePackageId(node: JsonNode) =
Identifier(
type = "Bower",
namespace = "",
name = node["pkgMeta"]["name"].textValueOrEmpty(),
version = node["pkgMeta"]["version"].textValueOrEmpty()
)

private fun extractRepositoryType(node: JsonNode) =
private fun parseRepositoryType(node: JsonNode) =
VcsType(node["pkgMeta"]["repository"]?.get("type").textValueOrEmpty())

private fun extractRepositoryUrl(node: JsonNode) =
private fun parseRepositoryUrl(node: JsonNode) =
node["pkgMeta"]["repository"]?.get("url")?.textValue()
?: node["pkgMeta"]["_source"].textValueOrEmpty()

private fun extractRevision(node: JsonNode): String =
private fun parseRevision(node: JsonNode): String =
node["pkgMeta"]["_resolution"]?.get("commit")?.textValue()
?: node["pkgMeta"]["_resolution"]?.get("tag").textValueOrEmpty()

private fun extractVcsInfo(node: JsonNode) =
private fun parseVcsInfo(node: JsonNode) =
VcsInfo(
type = extractRepositoryType(node),
url = extractRepositoryUrl(node),
revision = extractRevision(node)
type = parseRepositoryType(node),
url = parseRepositoryUrl(node),
revision = parseRevision(node)
)

private fun extractDeclaredLicenses(node: JsonNode): SortedSet<String> =
private fun parseDeclaredLicenses(node: JsonNode): SortedSet<String> =
sortedSetOf<String>().apply {
val license = node["pkgMeta"]["license"].textValueOrEmpty()
if (license.isNotEmpty()) add(license)
Expand All @@ -112,30 +113,30 @@ class Bower(
}?.let { addAll(it) }
}

private fun extractPackage(node: JsonNode) =
private fun parsePackage(node: JsonNode) =
Package(
id = extractPackageId(node),
id = parsePackageId(node),
authors = parseAuthors(node),
declaredLicenses = extractDeclaredLicenses(node),
declaredLicenses = parseDeclaredLicenses(node),
description = node["pkgMeta"]["description"].textValueOrEmpty(),
homepageUrl = node["pkgMeta"]["homepage"].textValueOrEmpty(),
binaryArtifact = RemoteArtifact.EMPTY,
sourceArtifact = RemoteArtifact.EMPTY, // TODO: implement me!
vcs = extractVcsInfo(node)
vcs = parseVcsInfo(node)
)

private fun getDependencyNodes(node: JsonNode): Sequence<JsonNode> =
node["dependencies"].fieldsOrEmpty().asSequence().map { it.value }

private fun extractPackages(node: JsonNode): Map<String, Package> {
private fun parsePackages(node: JsonNode): Map<String, Package> {
val result = mutableMapOf<String, Package>()

val stack = Stack<JsonNode>()
stack += getDependencyNodes(node)

while (!stack.empty()) {
val currentNode = stack.pop()
val pkg = extractPackage(currentNode)
val pkg = parsePackage(currentNode)
result["${pkg.id.name}:${pkg.id.version}"] = pkg

stack += getDependencyNodes(currentNode)
Expand Down Expand Up @@ -181,7 +182,7 @@ class Bower(
return result
}

private fun extractDependencyTree(
private fun parseDependencyTree(
node: JsonNode,
scopeName: String,
alternativeNodes: Map<String, JsonNode> = getNodesWithCompleteDependencies(node)
Expand All @@ -195,15 +196,15 @@ class Bower(
// information.
// See https://github.com/bower/bower/blob/6bc778d/lib/core/Manager.js#L557 and below.
val alternativeNode = checkNotNull(alternativeNodes[dependencyKeyOf(node)])
return extractDependencyTree(alternativeNode, scopeName, alternativeNodes)
return parseDependencyTree(alternativeNode, scopeName, alternativeNodes)
}

node["pkgMeta"][scopeName].fieldNamesOrEmpty().forEach {
val childNode = node["dependencies"][it]
val childScope = SCOPE_NAME_DEPENDENCIES
val childDependencies = extractDependencyTree(childNode, childScope, alternativeNodes)
val childDependencies = parseDependencyTree(childNode, childScope, alternativeNodes)
val packageReference = PackageReference(
id = extractPackageId(childNode),
id = parsePackageId(childNode),
dependencies = childDependencies
)
result += packageReference
Expand Down Expand Up @@ -236,17 +237,17 @@ class Bower(
installDependencies(workingDir)
val dependenciesJson = listDependencies(workingDir)
val rootNode = jsonMapper.readTree(dependenciesJson)
val packages = extractPackages(rootNode)
val packages = parsePackages(rootNode)
val dependenciesScope = Scope(
name = SCOPE_NAME_DEPENDENCIES,
dependencies = extractDependencyTree(rootNode, SCOPE_NAME_DEPENDENCIES)
dependencies = parseDependencyTree(rootNode, SCOPE_NAME_DEPENDENCIES)
)
val devDependenciesScope = Scope(
name = SCOPE_NAME_DEV_DEPENDENCIES,
dependencies = extractDependencyTree(rootNode, SCOPE_NAME_DEV_DEPENDENCIES)
dependencies = parseDependencyTree(rootNode, SCOPE_NAME_DEV_DEPENDENCIES)
)

val projectPackage = extractPackage(rootNode)
val projectPackage = parsePackage(rootNode)
val project = Project(
id = projectPackage.id,
definitionFilePath = VersionControlSystem.getPathInfo(definitionFile).path,
Expand Down
Loading