-
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.
Merge pull request #1 from ila-embsys/dev
GOpenHMD base
- Loading branch information
Showing
32 changed files
with
2,381 additions
and
1 deletion.
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,69 @@ | ||
# TODO: replace build from sources to package install | ||
FROM mcr.microsoft.com/devcontainers/base:jammy as build-uncrustify | ||
|
||
ARG UNCRUSTIFY_VER=0.78.1 | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
g++ \ | ||
cmake \ | ||
make | ||
|
||
RUN cd /usr/src \ | ||
&& wget https://codeload.github.com/uncrustify/uncrustify/zip/refs/tags/uncrustify-${UNCRUSTIFY_VER} \ | ||
-O uncrustify.zip \ | ||
&& unzip uncrustify.zip \ | ||
&& cd uncrustify-uncrustify-${UNCRUSTIFY_VER} \ | ||
&& mkdir -p build \ | ||
&& cd build \ | ||
&& cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .. \ | ||
&& cmake --build . --target install --config Release \ | ||
&& cd /usr/src \ | ||
&& rm -rf uncrustify.zip uncrustify-uncrustify-${UNCRUSTIFY_VER} | ||
|
||
# TODO: replace build from sources to package install | ||
FROM mcr.microsoft.com/devcontainers/base:jammy as build-vala-lint | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
valac \ | ||
meson \ | ||
# vala-lint build deps | ||
libvala-0.56-dev \ | ||
libjson-glib-dev | ||
|
||
RUN cd /usr/src \ | ||
&& wget https://codeload.github.com/vala-lang/vala-lint/zip/refs/heads/master \ | ||
-O vala-lint.zip \ | ||
&& unzip vala-lint.zip \ | ||
&& cd vala-lint-master \ | ||
&& meson build --prefix=/usr \ | ||
&& cd build \ | ||
&& ninja \ | ||
&& ninja install \ | ||
&& cd /usr/src \ | ||
&& rm -rf vala-lint.zip vala-lint-master | ||
|
||
FROM mcr.microsoft.com/devcontainers/base:jammy | ||
|
||
COPY --from=build-vala-lint /usr/bin/io.elementary.vala-lint /usr/bin/ | ||
COPY --from=build-vala-lint /usr/lib/x86_64-linux-gnu/libvala-linter* /usr/lib/x86_64-linux-gnu/ | ||
|
||
COPY --from=build-uncrustify /usr/bin/uncrustify /usr/bin/ | ||
|
||
RUN echo 'deb http://download.opensuse.org/repositories/home:/Prince781/xUbuntu_22.04/ /' \ | ||
| sudo tee /etc/apt/sources.list.d/home:Prince781.list \ | ||
&& curl -fsSL https://download.opensuse.org/repositories/home:Prince781/xUbuntu_22.04/Release.key \ | ||
| gpg --dearmor | tee /etc/apt/trusted.gpg.d/home_Prince781.gpg > /dev/null | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
valac \ | ||
gjs \ | ||
meson \ | ||
libopenhmd-dev \ | ||
gobject-introspection \ | ||
libgirepository1.0-dev \ | ||
vala-language-server | ||
# Built newer version | ||
# uncrustify |
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,37 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||
{ | ||
"name": "Ubuntu", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
// "image": "mcr.microsoft.com/devcontainers/base:jammy" | ||
"build": { | ||
// Path is relative to the devcontainer.json file. | ||
"dockerfile": "../.dev-env.Dockerfile" | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"mesonbuild.mesonbuild", | ||
"prince781.vala", | ||
"vadimcn.vscode-lldb", | ||
"ColinKiama.linter-vala", | ||
"fnando.linter" | ||
] | ||
} | ||
} | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "uname -a", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
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,51 @@ | ||
name: tests | ||
on: [pull_request, workflow_dispatch] | ||
|
||
permissions: | ||
checks: write | ||
|
||
jobs: | ||
test: | ||
name: tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Update packages | ||
run: sudo apt-get update | ||
- name: Install packages | ||
uses: awalsh128/[email protected] | ||
with: | ||
packages: valac gjs meson libopenhmd-dev gobject-introspection libgirepository1.0-dev | ||
version: 1.0 | ||
- name: Meson Build | ||
uses: BSFishy/[email protected] | ||
with: | ||
action: build | ||
setup-options: --prefix=${{ github.workspace }}/dist-install | ||
- name: Meson Build 'typelib' target | ||
run: cd build && meson compile 'gopenhmd typelib' | ||
- name: Meson Test | ||
uses: BSFishy/[email protected] | ||
with: | ||
action: test | ||
- name: Meson Install | ||
uses: BSFishy/[email protected] | ||
with: | ||
action: install | ||
- name: Install typelib | ||
run: install -D ./build/GOpenHMD-*.typelib -t ./dist-install/share/girepository-1.0/ | ||
- name: Publish Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: ${{ !env.ACT }} | ||
with: | ||
comment_mode: off | ||
files: | | ||
build/meson-logs/*.junit.xml | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ !env.ACT }} | ||
with: | ||
name: dist-install | ||
path: | | ||
dist-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,11 @@ | ||
image: | ||
file: .dev-env.Dockerfile | ||
|
||
vscode: | ||
extensions: | ||
- mesonbuild.mesonbuild | ||
- prince781.vala | ||
- vadimcn.vscode-lldb | ||
- ColinKiama.linter-vala | ||
- fnando.linter | ||
|
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,43 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Vala : GOpenHMD : Device", | ||
"program": "./builddir/tests/vala-gopenhmd-device", | ||
"env": { "G_MESSAGES_DEBUG": "all" } | ||
}, | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Vala : GOpenHMD : Device descriptions", | ||
"program": "./builddir/tests/vala-gopenhmd-device-descriptions", | ||
"env": { "G_MESSAGES_DEBUG": "all" } | ||
}, | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Vala : GOpenHMD : Pose", | ||
"program": "./builddir/tests/vala-gopenhmd-pose", | ||
"env": { "G_MESSAGES_DEBUG": "all" } | ||
}, | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Vala : GOpenHMD : Probe", | ||
"program": "./builddir/tests/vala-gopenhmd-pose", | ||
"env": { "G_MESSAGES_DEBUG": "all" } | ||
}, | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Vala : OpenHMD : Info", | ||
"program": "./builddir/tests/vala-openhmd-info", | ||
"env": { "G_MESSAGES_DEBUG": "all" } | ||
} | ||
] | ||
} |
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,12 @@ | ||
{ | ||
"terminal.integrated.env.linux": { | ||
"G_MESSAGES_DEBUG": "all", | ||
"GI_TYPELIB_PATH": "${workspaceFolder}/builddir", | ||
"LD_LIBRARY_PATH": "${workspaceFolder}/builddir", | ||
}, | ||
"terminal.integrated.env.windows": { | ||
"G_MESSAGES_DEBUG": "all", | ||
"GI_TYPELIB_PATH": "${workspaceFolder}/builddir", | ||
"LD_LIBRARY_PATH": "${workspaceFolder}/builddir", | ||
}, | ||
} |
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
# GOpenHMD | ||
# GOpenHMD | ||
|
||
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ila-embsys/GOpenHMD) | ||
|
||
GOpenHMD is a wrapper of OpenHMD that uses GObject to provide language bindings by GObject introspection. |
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,35 @@ | ||
#!/usr/bin/env gjs | ||
|
||
const GOpenHMD = imports.gi.GOpenHMD; | ||
|
||
|
||
function devs_info(context) { | ||
devs = context.enumerate() | ||
|
||
for (var i = 0; i < devs.length; i++) { | ||
print("Discovered device:" + | ||
` vendor: '${devs[i].vendor}'` + | ||
` product': '${devs[i].product}'`) | ||
} | ||
} | ||
|
||
|
||
function dev_quat_info(context, dev) { | ||
context.update(); | ||
var quat = dev.rotation_quat(); | ||
console.debug(`quat: x=${quat.x}, y=${quat.y}, z=${quat.z}, w=${quat.w}`); | ||
GOpenHMD.sleep(0.01); | ||
} | ||
|
||
|
||
print(`Version: ${GOpenHMD.version().to_string()}`) | ||
|
||
var context = new GOpenHMD.Context(); | ||
|
||
devs_info(context); | ||
|
||
var dev = context.open_device(0, null) | ||
|
||
for(var i = 0; i < 300; i++){ | ||
dev_quat_info(context, dev) | ||
} |
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,32 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import gi | ||
|
||
gi.require_version('GOpenHMD', '1.0') | ||
from gi.repository import GOpenHMD | ||
|
||
|
||
def devs_info(context): | ||
for dev in context.enumerate(): | ||
print(f"Discovered device: vendor '{dev.get_vendor()}'" | ||
f", product '{dev.get_product()}'" | ||
) | ||
|
||
|
||
def dev_quat_info(context, dev): | ||
context.update() | ||
quat = dev.rotation_quat() | ||
print(f"quat: x={quat.x} y={quat.y} z={quat.z} w={quat.w}") | ||
GOpenHMD.sleep(0.01) | ||
|
||
|
||
print(f"Version: {GOpenHMD.version().to_string()}") | ||
|
||
context = GOpenHMD.Context() | ||
|
||
devs_info(context) | ||
|
||
dev = context.open_device(0) | ||
|
||
for i in range(0, 300): | ||
dev_quat_info(context, dev) |
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,46 @@ | ||
project('GOpenHMD', 'vala') | ||
|
||
vapi_dir = meson.current_source_dir() / 'openhmd-bindings' | ||
|
||
|
||
add_project_arguments(['--vapidir', vapi_dir], language: 'vala') | ||
|
||
gopenhmd_dep = [ | ||
dependency('glib-2.0'), | ||
dependency('gobject-2.0'), | ||
dependency('openhmd'), | ||
] | ||
|
||
sources = files( | ||
'src/gopenhmd.vala', | ||
'src/context.vala', | ||
'src/device_description.vala', | ||
'src/device_settings.vala', | ||
'src/device.vala', | ||
'src/interfaces.vala', | ||
) | ||
|
||
subdir('tests') | ||
|
||
gopenhmd_lib = shared_library('gopenhmd', | ||
vala_gir: 'GOpenHMD-1.0.gir', | ||
dependencies: gopenhmd_dep, | ||
sources: sources, | ||
install: true, | ||
install_dir: [true, true, true, true]) | ||
|
||
pkg = import('pkgconfig') | ||
pkg.generate(gopenhmd_lib) | ||
|
||
g_ir_compiler = find_program('g-ir-compiler') | ||
|
||
custom_target('gopenhmd typelib', command: [ | ||
g_ir_compiler, | ||
'--shared-library=libgopenhmd', | ||
'--output', '@OUTPUT@', '@INPUT@' | ||
], | ||
input: meson.current_build_dir() / 'GOpenHMD-1.0.gir', | ||
output: 'GOpenHMD-1.0.typelib', | ||
depends: gopenhmd_lib, | ||
install: false, | ||
install_dir: get_option('libdir') / 'girepository-1.0') |
Oops, something went wrong.