forked from openai/retro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e98034
commit 3a1e883
Showing
3 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
################################################################################ | ||
# | ||
# Copyright (C) 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 system for C++ libraries | ||
# | ||
# Required CMake variables: | ||
# | ||
# CMAKE_FIND_ROOT_PATH - Point this to dependencies compiled with Emscripten | ||
# CMAKE_INSTALL_PREFIX - Point this to the "public" folder | ||
# | ||
################################################################################ | ||
|
||
################################################################################ | ||
# | ||
# Project settings | ||
# | ||
################################################################################ | ||
|
||
project(retroai) | ||
|
||
cmake_minimum_required(VERSION 3.0.0) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
################################################################################ | ||
# | ||
# Dependencies | ||
# | ||
################################################################################ | ||
|
||
# TODO | ||
|
||
################################################################################ | ||
# | ||
# Define sources | ||
# | ||
################################################################################ | ||
|
||
set(RETRO_SOURCES | ||
retro_embinder.cpp | ||
) | ||
|
||
################################################################################ | ||
# | ||
# Build libraries | ||
# | ||
# TODO: | ||
# | ||
# * Build properly instead of shelling out | ||
# * Could refactor this into macros | ||
# | ||
################################################################################ | ||
|
||
include_directories( | ||
${CMAKE_SOURCE_DIR} | ||
) | ||
|
||
string(APPEND EMSCRIPTEN_LINK_FLAGS | ||
"--bind " | ||
# "-o dist/engine.js " | ||
# " -std=c++11 " | ||
# " -O2 " | ||
# " --preload-file textures " | ||
# " --preload-file shaders " | ||
# " --preload-file fonts " | ||
# " --pre-js pre-module.j " | ||
# " --post-js post-module.j " | ||
"-s ALLOW_MEMORY_GROWTH=1 " | ||
"-s ASSERTIONS=1 " | ||
# " -s DEMANGLE_SUPPORT=1 " | ||
# " -s DISABLE_EXCEPTION_CATCHING=0 " | ||
"-s ERROR_ON_UNDEFINED_SYMBOLS=0 " | ||
# " -s FULL_ES3=1 " | ||
# " -s GL_ASSERTIONS=1 " | ||
# " -s GL_UNSAFE_OPTS=0 " | ||
# " -s INVOKE_RUN=0 " | ||
# " -s LEGACY_GL_EMULATION=0 " | ||
#"-s LLD_REPORT_UNDEFINED " | ||
# " -s OFFSCREENCANVAS_SUPPORT=1 " | ||
# " -s SAFE_HEAP=1 " | ||
#"-s TOTAL_MEMORY=67108864 " | ||
# " -s USE_FREETYPE=1 " | ||
# " -s USE_GLFW=3 " | ||
# " -s USE_WEBGL2=1 " | ||
"-s USE_ZLIB=1 " | ||
# " -s WASM=1 " | ||
) | ||
|
||
# | ||
# Retro binary | ||
# | ||
|
||
add_executable(retro | ||
${RETRO_SOURCES} | ||
) | ||
|
||
if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") | ||
set_target_properties(retro PROPERTIES | ||
COMPILE_FLAGS " \ | ||
-O0 \ | ||
-g4 \ | ||
-s DISABLE_EXCEPTION_CATCHING=0 \ | ||
-s INITIAL_MEMORY=26214400 \ | ||
" | ||
# 26214400 is 25 MiB | ||
LINK_FLAGS " \ | ||
--bind \ | ||
--source-map-base https://retro.ai/retro/ \ | ||
-O0 \ | ||
-g4 \ | ||
-s DISABLE_EXCEPTION_CATCHING=0 \ | ||
-s INITIAL_MEMORY=26214400 \ | ||
" | ||
) | ||
endif () | ||
|
||
################################################################################ | ||
# | ||
# Install libraries | ||
# | ||
################################################################################ | ||
|
||
# | ||
# Motion tracker | ||
# | ||
|
||
INSTALL( | ||
FILES | ||
"${CMAKE_BINARY_DIR}/retro.js" | ||
"${CMAKE_BINARY_DIR}/retro.wasm" | ||
"${CMAKE_BINARY_DIR}/retro.wasm.map" | ||
DESTINATION | ||
retro | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
################################################################################ | ||
# | ||
# Copyright (C) 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. | ||
# | ||
################################################################################ | ||
|
||
################################################################################ | ||
# | ||
# Helper for CI infrastructure. Sets the appropriate paths and calls CMake. | ||
# | ||
################################################################################ | ||
|
||
# Enable strict shell mode | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# | ||
# Environment paths | ||
# | ||
|
||
# Get the absolute path to this script | ||
SOURCE_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# Directory of the depends build system | ||
TOOL_DIRECTORY="${SOURCE_DIRECTORY}/../tools" | ||
|
||
# Directory for intermediate build files | ||
BUILD_DIRECTORY="${TOOL_DIRECTORY}/build/cpp-libs" | ||
|
||
# Directory of the Emscripten SDK | ||
EMSDK_DIRECTORY="${TOOL_DIRECTORY}/repos/emsdk" | ||
|
||
# Directory of the installed dependency files | ||
DEPENDS_DIRECTORY="${TOOL_DIRECTORY}/dist" | ||
|
||
# Directory to place the generated libraries | ||
INSTALL_DIRECTORY="${SOURCE_DIRECTORY}/../public" | ||
|
||
# Ensure directories exist | ||
mkdir -p "${BUILD_DIRECTORY}" | ||
mkdir -p "${INSTALL_DIRECTORY}" | ||
|
||
# | ||
# Setup environment | ||
# | ||
|
||
source "${EMSDK_DIRECTORY}/emsdk_set_env.sh" | ||
|
||
# | ||
# Call CMake | ||
# | ||
|
||
cd "${BUILD_DIRECTORY}" | ||
|
||
emcmake cmake \ | ||
"${SOURCE_DIRECTORY}" \ | ||
-DCMAKE_FIND_ROOT_PATH="${DEPENDS_DIRECTORY}" \ | ||
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIRECTORY}" \ | ||
$(! command -v ccache &> /dev/null || echo "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache") \ | ||
|
||
#cmake --build "${BUILD_DIRECTORY}" --target install | ||
make -C "${BUILD_DIRECTORY}" -j8 install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2023 retro.ai | ||
* This file is part of retro-dapp - https://github.com/RetroAI/retro-dapp | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* See LICENSE.txt for more information. | ||
*/ | ||
|
||
#include <emscripten/bind.h> | ||
|
||
using namespace emscripten; | ||
|
||
EMSCRIPTEN_BINDINGS(retro) | ||
{ | ||
/* TODO | ||
value_object<FrameInfo>("FrameInfo") | ||
.field("sceneScore", &FrameInfo::sceneScore) | ||
.field("pointData", &FrameInfo::pointData) | ||
.field("pointSize", &FrameInfo::pointSize) | ||
.field("initialPointData", &FrameInfo::initialPointData) | ||
.field("initialPointSize", &FrameInfo::initialPointSize) | ||
.field("projectionMatrixData", &FrameInfo::projectionMatrixData) | ||
.field("projectionMatrixSize", &FrameInfo::projectionMatrixSize) | ||
; | ||
value_object<ConfigOptions>("ConfigOptions") | ||
.field("maxPointCount", &ConfigOptions::maxPointCount) | ||
.field("maxFrameCount", &ConfigOptions::maxFrameCount) | ||
; | ||
class_<MotionTracker>("MotionTracker") | ||
.constructor<>() | ||
.function("initialize", &MotionTracker::Initialize) | ||
.function("setConfig", &MotionTracker::SetConfig) | ||
.function("addVideoFrame", &MotionTracker::AddVideoFrame) | ||
.function("deinitialize", &MotionTracker::Deinitialize) | ||
; | ||
*/ | ||
} |