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

Implement single-project "super-build" #242

Merged
merged 7 commits into from
Jun 13, 2024
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
24 changes: 23 additions & 1 deletion .github/workflows/build-cloe.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
---
name: Build Cloe

on:
push:
branches:
- master
- develop
- "release/**"
paths-ignore:
- "*.md"
- ".gitignore"
- "LICENSE"
- "dist/**"
- "docs/**"
- "ui/**"
pull_request:
paths-ignore:
- "*.md"
Expand All @@ -22,7 +35,16 @@ jobs:
- "cloe-normal"
package_target:
# 1. Build each test configuration in Conan cache and run all tests
- "export export-vendor smoketest-deps smoketest"
- "export-vendor export-all smoketest-deps smoketest"

# 2. Build cloe super-package in editable mode and run tests
- "export-vendor editable all smoketest TEST_CONANFILES=tests/conanfile_superbuild.py"

# 3. TODO: Build individual packages in editable mode and run tests
# This cannot be currently enabled because of a Conan deficiency in v1.
# Once all build tooling is based on Conan v2, we can re-enable this use-case.
# Until then, use the previous target for this use-case.
# - "export-vendor editable-select build-all smoketest TEST_CONANFILES=tests/conanfile_deployment.py"
env:
CONAN_NON_INTERACTIVE: "yes"
DEBIAN_FRONTEND: noninteractive
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/build-docs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
---
name: Build Documentation

on:
push:
branches:
- master
- develop
- "release/**"
paths:
- "docs/**"
- "*.hpp"
pull_request:
paths:
- "docs/**"
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/build-ui.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
---
name: Build UI

on:
push:
branches:
- master
- develop
- "release/**"
paths:
- "ui/**"
pull_request:
paths:
- "ui/**"
Expand Down Expand Up @@ -29,8 +37,7 @@ jobs:
echo $version
if [[ $version == "v18"* ]]; then
npm run build_v18
else
else
npm run build
fi
shell: bash

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CMakeFiles/
compile_commands.json

# Files generated by Clang:
.cache/
.clangd/
.cache/

Expand Down
40 changes: 40 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This CMakeLists.txt configures a super-build containing everything
# from this repo.
#
# It is currently experimental.
#

cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR)

project(cloe LANGUAGES CXX)

option(CLOE_WITH_ESMINI "Build simulator_esmini plugin?" ON)
option(CLOE_WITH_VTD "Build simulator_vtd plugin?" OFF)

set(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/runtime/cmake")

# Since a super-build does not export packages individually via Conan,
# we cannot depend on Conan-generated CMake config files, instead we
# use the CMake targets directly as if they were already found.
set(CLOE_FIND_PACKAGES OFF CACHE BOOL "Call find_package() for cloe packages" FORCE)

# Ensure output goes to one place so cloe-launch can find the plugins
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)

# Ensure we can test from this level.
set(CMAKE_CTEST_ARGUMENTS "--output-on-failure")
include(CTest)

# Order matters:
add_subdirectory(fable)
add_subdirectory(runtime)
add_subdirectory(models)
add_subdirectory(osi)
add_subdirectory(oak)
add_subdirectory(engine)
add_subdirectory(plugins)

if(CLOE_WITH_VTD)
add_subdirectory(optional/vtd)
endif()
141 changes: 90 additions & 51 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
# This file contains Makefile targets for the cloe project.
#

# Make configuration:
SHELL := /bin/bash
GNUMAKEFLAGS := --no-print-directory
SUBMAKEFLAGS :=

CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch
CLOE_LAUNCH := PYTHONPATH="$(CLOE_ROOT)/cli" python3 -m cloe_launch

include ${CLOE_ROOT}/Makefile.help
include $(CLOE_ROOT)/Makefile.help

# Set the clang-format command line to use:
CLANG_FORMAT := $(shell command -v clang-format 2>/dev/null)
Expand All @@ -20,78 +25,96 @@ AG := $(or \

# Build configuration:
BUILD_DIR := build
LOCKFILE_SOURCE := conanfile.py
BUILD_LOCKFILE := ${BUILD_DIR}/conan.lock
LOCKFILE_OPTION := --lockfile="${CLOE_ROOT}/${BUILD_LOCKFILE}"
INSTALL_DIR := /usr/local
DEPLOY_DIR := deploy
CONAN_OPTIONS :=

# Lockfile for cloe-deployment:
DEPLOY_LOCKFILE_SOURCE := tests/conanfile_deployment.py
DEPLOY_BUILD_LOCKFILE := $(DEPLOY_DIR)/conan.lock
DEPLOY_LOCKFILE_OPTION := --lockfile="$(CLOE_ROOT)/$(DEPLOY_BUILD_LOCKFILE)"

.DEFAULT_GOAL := help
.PHONY: help
.SILENT: help
help::
$(call print_help_usage)
echo
$(call print_help_section, "Default target")
$(call print_help_target, help, "show this help on available targets")
echo

# Setup targets ---------------------------------------------------------------
include Makefile.setup

$(DEPLOY_BUILD_LOCKFILE):
mkdir -p "$(DEPLOY_DIR)"
conan lock create --lockfile-out "$(DEPLOY_BUILD_LOCKFILE)" --build -- "$(DEPLOY_LOCKFILE_SOURCE)"

.PHONY: lockfile
lockfile: $(DEPLOY_BUILD_LOCKFILE)

# Workspace targets -----------------------------------------------------------
help::
$(call print_help_section, "Available workspace targets")
$(call print_help_target, status, "show status of each of the Conan packages")
$(call print_help_target, smoketest-deps, "build system test pre-requisites")
$(call print_help_target, smoketest, "run system tests")
$(call print_help_target, docs, "generate documentation")
$(call print_help_target, deploy, "deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]")
$(call print_help_target, deploy-cli, "install ${_yel}cloe-launch${_rst} with ${_dim}${PIPX}${_rst}")
$(call print_help_target, export-cli, "export ${_yel}cloe-launch-profile${_rst} Conan recipe")
$(call print_help_target, docs, "generate Doxygen and Sphinx documentation")
echo

${BUILD_LOCKFILE}:
${MAKE} -f Makefile.package SOURCE_CONANFILE=/dev/null LOCKFILE_SOURCE=${LOCKFILE_SOURCE} ${BUILD_LOCKFILE}

.PHONY: lockfile
lockfile: ${BUILD_LOCKFILE}
.PHONY: docs
docs:
$(call print_header, "Generating Doxygen documentation...")
$(MAKE) -C docs doxygen
$(call print_header, "Generating Sphinx documentation...")
$(MAKE) -C docs html

.PHONY: status
status: ${BUILD_LOCKFILE}
@for pkg in ${ALL_PKGS}; do \
[ -d $${pkg} ] || continue; \
${MAKE} LOCKFILE_SOURCE="" LOCKFILE_OPTION=${LOCKFILE_OPTION} -C $${pkg} status || true; \
done
help::
$(call print_help_target, export-cli, "export $(_yel)cloe-launch-profile$(_rst) Conan recipe")
$(call print_help_target, deploy-cli, "install $(_yel)cloe-launch$(_rst) with $(_dim)$(PIPX)$(_rst)")
echo

.PHONY: deploy
deploy:
$(call print_header, "Deploying binaries to ${INSTALL_DIR}...")
conan install ${CONAN_OPTIONS} --install-folder ${BUILD_DIR}/deploy -g deploy .
mkdir -p ${INSTALL_DIR}
cp -r ${BUILD_DIR}/deploy/cloe-*/* ${INSTALL_DIR}/
.PHONY: export-cli
export-cli:
$(MAKE) -C cli export

.PHONY: deploy-cli
deploy-cli:
$(call print_header, "Deploying cloe-launch binary with pip...")
${MAKE} -C cli install
$(MAKE) -C cli install

.PHONY: export-cli
export-cli:
${MAKE} -C cli export
help::
$(call print_help_target, lockfile, "create a lockfile for cloe deployment packages")
$(call print_help_target, package-all, "package all cloe deployment packages")
$(call print_help_target, status-all, "show status of each of the Conan packages")
$(call print_help_target, export-all, "export all package sources to Conan cache")
$(call print_help_target, build-all, "build individual packages locally in-source")
$(call print_help_target, deploy-all, "deploy $(_yel)cloe$(_rst) to $(_grn)INSTALL_DIR$(_rst)=$(_dim)$(INSTALL_DIR)$(_rst)")
$(call print_help_target, clean-all, "clean entire repository of temporary files")
$(call print_help_target, purge-all, "remove all cloe packages (in any version) from Conan cache")
echo

export: export-cli
package: export-cli
.PHONY: build-all
build-all: lockfile
$(MAKE) all-select CONAN_OPTIONS="$(CONAN_OPTIONS) $(DEPLOY_LOCKFILE_OPTION)"

.PHONY: docs
docs:
$(call print_header, "Generating Doxygen documentation...")
${MAKE} -C docs doxygen
$(call print_header, "Generating Sphinx documentation...")
${MAKE} -C docs html
.PHONY: status-all
status-all: $(DEPLOY_BUILD_LOCKFILE)
@for pkg in $(ALL_PKGS); do \
$(MAKE) LOCKFILE_SOURCE="" LOCKFILE_OPTION=$(DEPLOY_LOCKFILE_OPTION) -C $${pkg} status || true; \
done

.PHONY: export-all
export-all:
$(call print_header, "Exporting all cloe Conan packages...")
$(MAKE) export-select export-cli export

.PHONY: smoketest-deps
smoketest-deps: export-cli smoketest-deps-select
.PHONY: deploy-all
deploy-all:
$(call print_header, "Deploying binaries to $(INSTALL_DIR)...")
$(CLOE_LAUNCH) deploy -D $(DEPLOY_DIR) $(DEPLOY_LOCKFILE_SOURCE) $(CONAN_OPTIONS)

.PHONY: smoketest
smoketest: smoketest-select
.PHONY: clean-all
clean-all:
$(MAKE) clean clean-select

.PHONY: purge-all
purge-all:
Expand All @@ -100,6 +123,10 @@ purge-all:
conan remove -f 'cloe'
conan remove -f 'fable'

.PHONY: package-all
package-all:
conan install $(CONAN_OPTIONS) --install-folder $(DEPLOY_DIR) --build=missing --build=outdated $(DEPLOY_LOCKFILE_SOURCE)

# Development targets ---------------------------------------------------------
help::
$(call print_help_section, "Available development targets")
Expand All @@ -114,17 +141,22 @@ format:
# continues to work as expected.
#
# See: https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame
find . -type f -not -path '*/\.git/*' -and \( -name '*.cpp' -o -name '*.hpp' \) -exec ${CLANG_FORMAT} ${CLANG_FORMAT_ARGS} -i {} \;
find . -type f -not -path '*/\.git/*' -and \( -name '*.cpp' -o -name '*.hpp' \) -exec $(CLANG_FORMAT) $(CLANG_FORMAT_ARGS) -i {} \;

.PHONY: todos
todos:
${AG} TODO
${AG} FIXME
${AG} XXX
$(AG) TODO
$(AG) FIXME
$(AG) XXX

# Hidden development targets --------------------------------------------------

.PHONY: grep-uuids
grep-uuids:
${AG} "\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b"
$(AG) "\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b"

grep-conan-requires:
@rg -t py '^.*requires\(f?["](.+/[0-9]+\.[^)]+)["].*\).*$$' -r '$$1' -I --no-heading --no-line-number | sort | uniq

.PHONY: find-missing-eol
find-missing-eol:
Expand All @@ -134,5 +166,12 @@ find-missing-eol:
sanitize-files:
git grep --cached -Ilz '' | while IFS= read -rd '' f; do tail -c1 < "$$f" | read -r _ || echo >> "$$f"; done

# Build targets ---------------------------------------------------------------
# Micro-packages build targets ------------------------------------------------
include Makefile.all

# Mono-package build targets --------------------------------------------------
DISABLE_HELP_PREAMBLE := true
help::
@printf "Available $(_yel)cloe$(_rst) package targets:\n"

include Makefile.package
Loading
Loading