Skip to content

Commit

Permalink
Add Conan deployer to collect licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
Galarius committed Aug 26, 2023
1 parent d424f5d commit 2b3b5eb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ conan profile detect

| | |
|---|---|
| `./build.py conan-install` | Install dependencies |
| `./build.py conan-install` | Install dependencies and gathers licenses|
| `./build.py configure` | Configure the project |
| `./build.py` | Build the project |
| `./build.py conan-create` | Create the package |
Expand Down Expand Up @@ -81,4 +81,4 @@ Options:
Subcommands:
clinfo Show information about available OpenCL devices
diagnostics Provides an OpenCL kernel diagnostics
```
```
3 changes: 2 additions & 1 deletion builder/controllers/wrappers/conan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def install_dependencies(
".",
"--update",
f"--output-folder={install_folder}",
"--deployer=licenses",
*self.__get_configuration_args(host_profile, build_profile, with_tests),
],
check=True,
Expand All @@ -42,7 +43,7 @@ def __get_configuration_args(self, host_profile, build_profile, with_tests=False
args.extend(
[
"-o",
"opencl_language_server/*:enable_testing=True",
"opencl-language-server/*:enable_testing=True",
]
)
return args
8 changes: 4 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class OpenCLLanguageServerConanfile(ConanFile):
name = "opencl_language_server"
name = "opencl-language-server"
description = "OpenCL Language Server"
package_type = "application"
license = "MIT"
Expand All @@ -24,7 +24,7 @@ class OpenCLLanguageServerConanfile(ConanFile):
"nlohmann_json/[^3.11.2]",
"opencl-clhpp-headers/2022.09.30",
"spdlog/[^1.11.0]",
"uriparser/[^0.9.7]"
"uriparser/[^0.9.7]",
)
exports_sources = (
"include/**",
Expand Down Expand Up @@ -77,7 +77,7 @@ def package(self):
bin_ext = ".exe" if self.settings.os == "Windows" else ""
copy(
self,
f"opencl-language-server{bin_ext}",
f"{self.name}{bin_ext}",
build_folder,
os.path.join(self.package_folder, "bin"),
)
Expand All @@ -94,6 +94,6 @@ def package_info(self):

bin_ext = ".exe" if self.settings.os == "Windows" else ""
opencl_ls_bin = os.path.join(
self.package_folder, "bin", f"opencl-language-server{bin_ext}"
self.package_folder, "bin", f"{self.name}{bin_ext}"
).replace("\\", "/")
self.runenv_info.define_path("OPENCL_LANGUAGE_SERVER", opencl_ls_bin)
24 changes: 24 additions & 0 deletions licenses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Conan deployer that gathers licenses into the output_folder.
# Execute "conan install . --output-folder=.conan-install --deployer=licenses --build=missing"
# or use "./build.py conan-install"

from conan.tools.files import load, copy
from pathlib import Path
import logging


def deploy(graph, output_folder, **kwargs):
licenses_dir = Path(output_folder) / "licenses"
for _, dep in graph.root.conanfile.dependencies.items():
src = Path(dep.package_folder) / "licenses"
dst = licenses_dir / str(dep)
dst.mkdir(exist_ok=True, parents=True)
logging.info(f"Copy '{src}/*' to '{dst}'")
copy(graph.root.conanfile, "*", src, dst)

root_dir = Path(graph.root.path).parent
version = load(graph.root.conanfile, root_dir / "version").strip()
ocls_output = licenses_dir / "opencl-language-server" / version
ocls_output.mkdir(exist_ok=True, parents=True)
logging.info(f"Copy '{root_dir}/LICENSE' to '{ocls_output}'")
copy(graph.root.conanfile, "LICENSE", root_dir, ocls_output)

0 comments on commit 2b3b5eb

Please sign in to comment.