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

Fix and improve development tooling #191

Merged
merged 8 commits into from
Dec 6, 2023
Merged
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
15 changes: 15 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
Checks: >
modernize-*,
bugprone-*,
cppcoreguidelines-*,
cert-*,
misc-*,
performance-*,
readability-*,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-modernize-use-trailing-return-type,
-readability-identifier-length,
-readability-redundant-access-specifiers,
-readability-else-after-return,
FormatStyle: file
14 changes: 5 additions & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,22 @@ insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[Makefile*]
indent_style = tab

[*.json]
[*.{json,yaml,yml}]
indent_size = 2
trim_trailing_whitespace = true

[*.{h,hpp,c,cc,cpp}]
[*.{h,hpp,c,cc,cpp,hxx,cxx}]
indent_size = 2
trim_trailing_whitespace = true

[*.json]
indent_size = 2
trim_trailing_whitespace = true
[*.lua]
indent_size = 4

[*.html]
indent_size = 2
trim_trailing_whitespace = true

[*.rst]
indent_size = 4
trim_trailing_whitespace = true
3 changes: 1 addition & 2 deletions Makefile.all
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ help::
echo

$(call make_select_target, all-select, "build selected packages", "[in-source]")
$(call make_select_target, conan-select, "configure Conan and get dependencies", "[in-source]")
$(call make_select_target, configure-select, "configure CMake packages", "[in-source]")
$(call make_select_target, configure-select, "install dependencies and configure packages", "[in-source]")
$(call make_select_target, test-select, "run CMake tests if they are available", "[in-source]")
$(call make_select_target, export-pkg-select, "export build artifacts to Conan cache", "[in-source]")
$(call make_select_target, clean-select, "remove build artifacts", "[in-source]")
Expand Down
27 changes: 11 additions & 16 deletions Makefile.package
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ BUILD_DIR := build

# Don't change these unless you know what you are doing.
BUILD_CONANINFO := ${BUILD_DIR}/conanbuildinfo.txt
BUILD_CMAKECACHE := ${BUILD_DIR}/CMakeCache.txt
BUILD_LOCKFILE := ${BUILD_DIR}/conan.lock

# Default Conan build policy to use when installing Conan dependencies
Expand Down Expand Up @@ -202,8 +201,7 @@ ifeq (${BUILD_IN_SOURCE}, true)
$(call print_help_target, uneditable, "instruct Conan to use local cache")
echo
$(call print_help_target, all, "build the package", "[in-source]")
$(call print_help_target, conan, "configure Conan and install dependencies", "[in-source]")
$(call print_help_target, configure, "configure CMake package", "[in-source]")
$(call print_help_target, configure, "install dependencies and configure package", "[in-source]")
$(call print_help_target, test, "run CMake tests if they are available", "[in-source]")
$(call print_help_target, export-pkg, "export build artifacts to Conan cache", "[in-source]")
ifeq (${CLEAN_SOURCE_DIR}, true)
Expand Down Expand Up @@ -423,13 +421,16 @@ clean:
#
rm -rf "${BUILD_DIR}"
rm -rf __pycache__
rm -f CMakeUserPresets.json
rm -f compile_commands.json
rm -f graph_info.json
ifeq (${CLEAN_SOURCE_DIR}, true)
[ "${SOURCE_DIR}" != "." ] && rm -rf "${SOURCE_DIR}"
endif

ifeq (${BUILD_IN_SOURCE}, false)
.PHONY: all conan configure test export-pkg
all conan configure test export-pkg ${SOURCE_DIR} ${SOURCE_CMAKELISTS} ${BUILD_CONANINFO} ${BUILD_CMAKECACHE}:
.PHONY: all configure test export-pkg
all configure test export-pkg ${SOURCE_DIR} ${SOURCE_CMAKELISTS} ${BUILD_CONANINFO}:
@echo "Error: [in-source] targets are not supported for this package."
@echo "Note: please use [conan-cache] targets, such as 'package'."
exit 1
Expand All @@ -440,11 +441,9 @@ all: ${BUILD_CONANINFO} | ${SOURCE_DIR}
#
conan build . --source-folder="${SOURCE_DIR}" --install-folder="${BUILD_DIR}"

.PHONY: conan
conan: ${BUILD_CONANINFO}

.PHONY: configure
configure: ${BUILD_CMAKECACHE}
configure: ${BUILD_CONANINFO}
ln -rsf "$$(dirname $$(dirname $$(jq -r '.include[0]' CMakeUserPresets.json)))/compile_commands.json"

.PHONY: test
test:
Expand Down Expand Up @@ -481,15 +480,11 @@ ${SOURCE_DIR}:

${SOURCE_CMAKELISTS}: | ${SOURCE_DIR}

${BUILD_CONANINFO}: ${SOURCE_CONANFILE} ${BUILD_LOCKFILE}
# Install package dependencies and prepare in-source build.
${BUILD_CONANINFO}: ${SOURCE_CONANFILE} ${BUILD_LOCKFILE} ${SOURCE_CMAKELISTS}
# Install package dependencies and configure in-source build.
#
mkdir -p "${BUILD_DIR}"
conan install . ${PACKAGE_FQN} --install-folder="${BUILD_DIR}" --build=${BUILD_POLICY} ${ALL_OPTIONS}
touch ${BUILD_CONANINFO}

${BUILD_CMAKECACHE}: ${SOURCE_CMAKELISTS} ${BUILD_CONANINFO}
# Configure in-source build with CMake.
#
conan build --configure . --source-folder="${SOURCE_DIR}" --install-folder="${BUILD_DIR}"
touch ${BUILD_CONANINFO}
endif
9 changes: 5 additions & 4 deletions Makefile.setup
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ setup-git:
.PHONY: setup-conan
setup-conan:
# Install Conan if it is not available.
if ! command -v conan >/dev/null 2>&1; then ${PIP} install --user conan; fi
if ! command -v conan >/dev/null 2>&1; then ${PIP} install --user --upgrade "conan<2"; fi
# Initialize Conan configuration if it doesn't already exist.
#
# Since running any conan command, even conan --help creates ${CONAN_DIR}
Expand Down Expand Up @@ -108,19 +108,20 @@ install-ubuntu-deps::
build-essential \
clang-format \
cmake \
doxygen \
curl \
doxygen \
file \
git \
graphviz \
jq \
netcat-openbsd \
patchelf \
psmisc \
python3-setuptools \
python3-pip \
python3-venv \
python3-setuptools \
time \
tmux \
python3-venv \
;

# Require GCC and G++ version >= 8
Expand Down
27 changes: 22 additions & 5 deletions engine/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,30 @@ def generate(self):

def build(self):
cm = cmake.CMake(self)
cm.configure()
cm.build()
cm.test()
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()

def package(self):
cm = cmake.CMake(self)
cm.install()
if self.should_install:
cm = cmake.CMake(self)
cm.install()

# Package license files for compliance
for meta, dep in self.dependencies.items():
if dep.package_folder is None:
continue
ref = str(meta.ref)
name = ref[: str(ref).index("/")]
files.copy(
self,
"*",
src=os.path.join(dep.package_folder, "licenses"),
dst=os.path.join(self.package_folder, "licenses", name),
)

def package_id(self):
self.info.requires["boost"].full_package_mode()
Expand Down
12 changes: 8 additions & 4 deletions fable/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ def generate(self):

def build(self):
cm = cmake.CMake(self)
cm.configure()
cm.build()
cm.test()
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()

def package(self):
cm = cmake.CMake(self)
cm.install()
if self.should_install:
cm.install()

def package_id(self):
self.info.requires["boost"].full_package_mode()
Expand Down
12 changes: 8 additions & 4 deletions models/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ def generate(self):

def build(self):
cm = cmake.CMake(self)
cm.configure()
cm.build()
cm.test()
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()

def package(self):
cm = cmake.CMake(self)
cm.install()
if self.should_install:
cm.install()

def package_id(self):
self.info.requires["boost"].full_package_mode()
Expand Down
12 changes: 8 additions & 4 deletions oak/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ def generate(self):

def build(self):
cm = cmake.CMake(self)
cm.configure()
cm.build()
cm.test()
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()

def package(self):
cm = cmake.CMake(self)
cm.install()
if self.should_install:
cm.install()

def package_id(self):
del self.info.options.pedantic
Expand Down
24 changes: 14 additions & 10 deletions optional/vtd/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,25 @@ def generate(self):

def build(self):
cm = cmake.CMake(self)
cm.configure()
cm.build()
cm.test()
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()

def package(self):
vtd_api_version = self.dependencies["vtd-api"].ref.version

cm = cmake.CMake(self)
cm.install()
self.copy("vtd-launch", dst="bin", src=f"{self.source_folder}/bin")
self.copy(
"*.tar",
dst=self._setup_folder,
src=f"{self.source_folder}/{self._setup_folder}/{vtd_api_version}"
)
if self.should_install:
cm.install()
self.copy("vtd-launch", dst="bin", src=f"{self.source_folder}/bin")
self.copy(
"*.tar",
dst=self._setup_folder,
src=f"{self.source_folder}/{self._setup_folder}/{vtd_api_version}"
)

def package_id(self):
# Changes in a dependency's package_id need to be accounted for since
Expand Down
11 changes: 7 additions & 4 deletions optional/vtd/vendor/vtd-api-2.2.0/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ def generate(self):

def build(self):
cm = cmake.CMake(self)
cm.configure()
cm.build()
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()

def package(self):
cm = cmake.CMake(self)
cm.install()
files.copy(self, "Develop", src="src", dst=".")
if self.should_install:
cm.install()
files.copy(self, "Develop", src="src", dst=".")

def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
Expand Down
11 changes: 7 additions & 4 deletions optional/vtd/vendor/vtd-api-2022.3/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ def generate(self):

def build(self):
cm = cmake.CMake(self)
cm.configure()
cm.build()
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()

def package(self):
cm = cmake.CMake(self)
cm.install()
files.copy(self, "Develop", src="src", dst=".")
if self.should_install:
cm.install()
files.copy(self, "Develop", src="src", dst=".")

def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
Expand Down
12 changes: 8 additions & 4 deletions plugins/basic/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ def generate(self):

def build(self):
cm = cmake.CMake(self)
cm.configure()
cm.build()
cm.test()
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()

def package(self):
cm = cmake.CMake(self)
cm.install()
if self.should_install:
cm.install()

def package_id(self):
self.info.requires["boost"].full_package_mode()
Expand Down
12 changes: 8 additions & 4 deletions plugins/gndtruth_extractor/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ def generate(self):

def build(self):
cm = cmake.CMake(self)
cm.configure()
cm.build()
cm.test()
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()

def package(self):
cm = cmake.CMake(self)
cm.install()
if self.should_install:
cm.install()

def package_id(self):
self.info.requires["boost"].full_package_mode()
Expand Down
Loading