Skip to content

Commit

Permalink
Import initial tooling framework for OpenCV and Ceres solver
Browse files Browse the repository at this point in the history
  • Loading branch information
squishyhuman committed Oct 4, 2023
1 parent 5020713 commit 813da34
Show file tree
Hide file tree
Showing 25 changed files with 2,953 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
################################################################################
# This workflow will do a clean install of node dependencies, build the source
# code and run tests across different versions of node.
#
# For more information see:
#
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
#
################################################################################

name: Node.js CI

# Controls when the action will run. Triggers the workflow on push or pull
# request events
on: [push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in
# parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
node-version: 16
- os: ubuntu-22.04
node-version: 20

# Steps represent a sequence of tasks that will be executed as part of the
# job
steps:
- name: Build environment information
run: 'echo "Matrix OS: ${{ matrix.os }} on $HOSTNAME with $(getconf _NPROCESSORS_ONLN) cores"'

# Check-out the repository under $GITHUB_WORKSPACE, so the job can
# access it
- name: Checkout main repo
uses: actions/checkout@v2

- name: Restore dependency libraries
id: restore-depends
uses: actions/cache@v3
with:
path: |
src/generated
tools/dist
key: restore-library-depends-${{ matrix.os }}-${{ hashFiles('tools/depends/ade/*', 'tools/depends/ceres-solver/*', 'tools/depends/eigen/*', 'tools/depends/emscripten/*', 'tools/depends/google-flags/*', 'tools/depends/google-log/*', 'tools/depends/opencv/*') }}

- name: Build depends
if: steps.restore-depends.outputs.cache-hit != 'true'
run: tools/npm-depends.sh all

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Generated dependencies
/src/generated

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
11 changes: 11 additions & 0 deletions tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Dependency build files
build/

# Installed dependency files
dist/

# Dependency repos
repos/

# Build system stamps
stamps/
167 changes: 167 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
################################################################################
#
# Copyright (C) 2020-2023 retro.ai
# This file is part of retro-dapp - https://github.com/RetroAI/retro-dapp
#
# SPDX-License-Identifier: Apache-2.0
# See the file LICENSE.txt for more information.
#
################################################################################

################################################################################
#
# Build chain for dependendies
#
# Make is used to run shell commands instead of bash to allow for parallel
# intermediary build stages.
#
# The primary build stages that can be specified on the command line are:
#
# 1. checkout
# 2. patch
# 3. build
# 4. install (default if no stage is given)
#
# Two stages are used for cleaning temoprary files:
#
# 1. clean
# 2. distclean
#
# "make clean" is used to remove temporary build artifacts. "make distclean" is
# used to remove all temporary files and reset the directory to an unused state.
#
# This Makefile depends on the following packages:
#
# - curl
# - patch
# - python3
# - unzip
#
################################################################################

# Build system setup
include setup_stages.mk
include setup_paths.mk

# Build parameter setup
include setup_environment.mk

# Define the shell used to execute commands
SHELL := /bin/bash

################################################################################
#
# Import package rules
#
################################################################################

include depends/ade/package.mk
include depends/android-sdk/package.mk
include depends/ceres-solver/package.mk
include depends/eigen/package.mk
include depends/emscripten/package.mk
include depends/google-flags/package.mk
include depends/google-log/package.mk
include depends/opencv/package.mk

################################################################################
#
# Build system targets
#
# Defines the targets that are build when "make" is run.
#
################################################################################

#
# Define targets for "make checkout"
#

CHECKOUT_DEPENDS = \
$(S)/checkout-ade \
$(S)/checkout-ceres \
$(S)/checkout-eigen \
$(S)/checkout-emsdk \
$(S)/checkout-gflags \
$(S)/checkout-glog \
$(S)/checkout-opencv \
$(S)/patch-opencv

ifeq ($(PLATFORM),darwin)
#CHECKOUT_DEPENDS += $(S)/checkout-android-sdk # TODO
endif

#
# Define targets for "make build"
#

BUILD_DEPENDS = \
$(S)/build-opencv \

#
# Define targets for "make install"
#

INSTALL_DEPENDS = \
$(S)/install-opencv \

#
# Inject targets
#

checkout: $(CHECKOUT_DEPENDS)
build: $(BUILD_DEPENDS)
install: $(INSTALL_DEPENDS)

#
# Define targets for building individual depends via "make <depend>"
#

.PHONY: ade
.PHONY: ceres
.PHONY: eigen
.PHONY: emscripten
.PHONY: gflags
.PHONY: glog
.PHONY: opencv

ade: \
$(S)/install-ade

ceres: \
$(S)/install-ceres

eigen: \
$(S)/install-eigen

emscripten: \
$(S)/build-emsdk

gflags: \
$(S)/install-gflags

glog: \
$(S)/install-glog

opencv: \
$(S)/install-opencv

################################################################################
#
# Build system procedures
#
################################################################################

#
# Clean stage
#

clean:
rm -rf "$(BUILD_DIR)"
rm -rf "$(S)"

#
# Distclean stage
#

distclean: clean
rm -rf "$(REPO_DIR)"
114 changes: 114 additions & 0 deletions tools/depends/ade/package.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
################################################################################
#
# Copyright (C) 2020-2023 retro.ai
# This file is part of retro-dapp - https://github.com/RetroAI/retro-dapp
#
# SPDX-License-Identifier: Apache-2.0
# See the file LICENSE.txt for more information.
#
################################################################################

################################################################################
#
# ADE Framework
#
# The ADE Framework is a graph construction, manipulation, and processing
# framework. ADE Framework is suitable for organizing data flow processing and
# execution.
#
# SPDX-License-Identifier: Apache-2.0
#
################################################################################

# Dependency name and version
ADE_REPO_NAME = ade
ADE_VERSION = 0.1.1f
ADE_REMOTE_REPO = https://github.com/opencv/$(ADE_REPO_NAME).git
ADE_LIB = libade.a

################################################################################
#
# Paths
#
################################################################################

# Checkout directory
REPO_DIR_ADE = $(REPO_DIR)/$(ADE_REPO_NAME)

# Build directory
BUILD_DIR_ADE = $(BUILD_DIR)/$(ADE_REPO_NAME)

# Build output
BUILD_FILE_ADE = $(BUILD_DIR_ADE)/lib/$(ADE_LIB)

# Install output
INSTALL_FILE_ADE = $(DEPENDS_DIR)/lib/$(ADE_LIB)

################################################################################
#
# Configuration
#
################################################################################

ADE_BUILD_DEPENDS = \
$(S)/checkout-ade \
$(S)/build-emsdk \

################################################################################
#
# Checkout
#
################################################################################

$(S)/checkout-ade: $(S)/.precheckout
[ -d "$(REPO_DIR_ADE)" ] || ( \
git clone -b v$(ADE_VERSION) "$(ADE_REMOTE_REPO)" "$(REPO_DIR_ADE)" \
)

@# TODO: Repository sync is delegated to the CI system.

touch "$@"

################################################################################
#
# Build
#
################################################################################

$(BUILD_FILE_ADE): $(S)/.prebuild $(ADE_BUILD_DEPENDS)
mkdir -p "$(BUILD_DIR_ADE)"

# Activate PATH and other environment variables in the current terminal and
# build ADE
. "$(REPO_DIR_EMSDK)/emsdk_set_env.sh" && \
cd "${BUILD_DIR_ADE}" && \
emcmake cmake "$(REPO_DIR_ADE)" \
-DCMAKE_INSTALL_PREFIX="$(DEPENDS_DIR)" \
-DCMAKE_BUILD_PARALLEL_LEVEL=$(shell getconf _NPROCESSORS_ONLN) \
$(shell ! command -v ccache &> /dev/null || echo "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache") \

#cmake --build "${BUILD_DIR_ADE}"
make -C "${BUILD_DIR_ADE}" -j$(shell getconf _NPROCESSORS_ONLN)

touch "$@"

$(S)/build-ade: $(BUILD_FILE_ADE)
touch "$@"

################################################################################
#
# Install
#
################################################################################

$(INSTALL_FILE_ADE): $(S)/.preinstall $(S)/build-ade
mkdir -p "$(DEPENDS_DIR)"

cmake \
--build "${BUILD_DIR_ADE}" \
--target install

touch "$@"

$(S)/install-ade: $(INSTALL_FILE_ADE)
touch "$@"
Loading

0 comments on commit 813da34

Please sign in to comment.