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

Add cccc #14711

Closed
wants to merge 8 commits into from
Closed

Add cccc #14711

Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions recipes/cccc/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"3.2.0":
url: "https://github.com/sarnold/cccc/archive/refs/tags/3.2.0.tar.gz"
sha256: "C03B29D45F1ACB6F669B6D6D193DCDF5603F8C2758F0FB4BC1EEACEF92ECB78A"
71 changes: 71 additions & 0 deletions recipes/cccc/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os
import shutil
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools import files, build, scm
from conan.tools.microsoft import is_msvc

required_conan_version = ">=1.51.3"

class CCCCConan(ConanFile):
name = "cccc"
license = "GPL-2.0-or-later"
homepage = "https://sarnold.github.io/cccc/"
url = "https://github.com/conan-io/conan-center-index"
description = "CCCC - Source code counter "\
"and metrics tool for C++, C, and Java"
topics = ("metric", "static analyzer")

settings = "os", "arch", "compiler", "build_type"

@property
def _bin_package_folder(self):
return os.path.join(self.package_folder,"bin")

@property
def _license_folder(self):
return os.path.join(self.package_folder,"licenses")

@property
def _msbuild_bat_file(self):
return os.path.join(self.source_folder,"cccc","build_msvc.bat")

@property
def _cccc_binary_folder(self):
return os.path.join(self.source_folder,"cccc")

def export_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
files.copy(self,patch["patch_file"],self.recipe_folder, self.export_sources_folder)

def config_options(self):
pass

def configure(self):
pass

def validate(self):
if (not is_msvc(self) and (shutil.which("g++") == None)):
raise ConanInvalidConfiguration(f"{self.ref} requires msvc or "\
" g++")

def source(self):
files.get(self,**self.conan_data["sources"][self.version], strip_root=True,
destination=self.source_folder)

def build(self):
if is_msvc(self):
self.run(f"{self._msbuild_bat_file} --clean")
else:
self.run("make cccc")

def package(self):
files.copy(self, "cccc", self._cccc_binary_folder, self._bin_package_folder)
files.copy(self, "LICENSE", self.source_folder, self._license_folder)

def package_info(self):
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []

self.output.info("Append %s to environment variable PATH" % self._bin_package_folder)
self.env_info.PATH.append(self._bin_package_folder)
8 changes: 8 additions & 0 deletions recipes/cccc/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package CXX)

find_program(CCCC cccc)

if(NOT CCCC)
message(FATAL_ERROR "cccc not found")
endif()
24 changes: 24 additions & 0 deletions recipes/cccc/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run

class CCCCTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
# the cmake file shall error if cccc not present
pass
8 changes: 8 additions & 0 deletions recipes/cccc/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package CXX)

find_program(CCCC cccc)

if(NOT CCCC)
message(FATAL_ERROR "cccc not found")
endif()
16 changes: 16 additions & 0 deletions recipes/cccc/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
from conans import ConanFile, CMake
from conan.tools import build

class CCCCTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = ["cmake", "cmake_find_package_multi"]

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
# the cmake file shall error if cccc not present
pass
3 changes: 3 additions & 0 deletions recipes/cccc/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"3.2.0":
folder: all