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 defe7af
Show file tree
Hide file tree
Showing 25 changed files with 2,950 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/depends.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
################################################################################
# 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
- os: ubuntu-22.04

# 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@v4

- name: Restore dependency build files
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/build-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.md 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)"
93 changes: 93 additions & 0 deletions tools/build-depends.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash
################################################################################
#
# 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.md for more information.
#
################################################################################

#
# Depends build scripting entry point
#
# Call via:
#
# build-depends.sh <task>
#
# See the function dispatch() for the available tasks that can be run.
#

# Enable strict mode
set -o errexit
set -o pipefail
set -o nounset

# Absolute path to this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

#
# Source includes
#

source "${SCRIPT_DIR}/npm-paths.sh"

#
# Dispatch function
#
# This function contains the available tasks. The first argument identifies
# which task to jump to.
#
function dispatch() {
case $1 in
all)
depends-all
;;
checkout)
depends-checkout
;;
build)
depends-build
;;
install)
depends-install
;;
*)
echo "Invalid task: $1"
exit 1
;;
esac
}

function depends-all() {
# Dependencies to build
BUILD_DEPENDS="emscripten "

# Build OpenCV
if [ ! -f "${GENERATED_SOURCE_DIR}/opencv.js" ] \
|| [ ! -f "${DISTRIBUTION_LIB_DIR}/libopencv_core.a" ]; then
rm -f "${STAMP_DIR}/build-opencv"
BUILD_DEPENDS+="opencv "
fi

make -C "${TOOL_DIR}" -j$(getconf _NPROCESSORS_ONLN) ${BUILD_DEPENDS}

# Build C++ libraries
"${CPP_LIBRARY_DIR}/build-ci.sh"
}

function depends-checkout() {
make -C "${TOOL_DIR}" checkout -j10
}

function depends-build() {
make -C "${TOOL_DIR}" build -j$(getconf _NPROCESSORS_ONLN)
}

function depends-install() {
make -C "${TOOL_DIR}" install
}

# Perform the dispatch
dispatch $1
51 changes: 51 additions & 0 deletions tools/build-paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
################################################################################
#
# 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.md for more information.
#
################################################################################

#
# Paths for depends build scripts
#
# Import via:
#
# source build-paths.sh
#

# Enable strict mode
set -o errexit
set -o pipefail
set -o nounset

#
# Directory definitions
#

# Typescript/Javascript source directory
SOURCE_DIR="src"

# Directory for generated source
GENERATED_SOURCE_DIR="${SOURCE_DIR}/generated"

# C++ libraries directory
CPP_LIBRARY_DIR="lib"

# Tooling directory
TOOL_DIR="tools"

# Depends directory
DEPENDS_DIR="${TOOL_DIR}/depends"

# Build system stamp directory
STAMP_DIR="${TOOL_DIR}/stamps"

# Location of installed dependency files
DISTRIBUTION_DIR="${TOOL_DIR}/dist"

# Location of installed dependency libraries
DISTRIBUTION_LIB_DIR="${DISTRIBUTION_DIR}/lib"
Loading

0 comments on commit defe7af

Please sign in to comment.