Skip to content

Commit

Permalink
Merge branch 'devcontainer' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
aous72 committed Dec 15, 2019
2 parents 12c6dba + bca3446 commit e349eba
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 6 deletions.
50 changes: 50 additions & 0 deletions .devcontainer/Dockerfile
@@ -0,0 +1,50 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

FROM debian:9

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
# this user's GID/UID must match your local user UID/GID to avoid permission issues
# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
# https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
#
# Verify git, process tools, lsb-release (useful for CLI installs) installed
&& apt-get -y install git iproute2 procps lsb-release \
#
# Install C++ tools
&& apt-get -y install build-essential cppcheck valgrind \
#
## Install newer version of CMake (OpenJPH requires 3.10+, debian has older version)
&& apt-get install wget \
&& wget https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz \
&& tar -zxvf cmake-3.15.2.tar.gz \
&& (cd /cmake-3.15.2; ./bootstrap; make -j2 install)\
&& rm -rf /cmake-3.15.2\
#
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
&& groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
# [Optional] Add sudo support for the non-root user
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
@@ -0,0 +1,31 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/cpp
{
"name": "C++",
"dockerFile": "Dockerfile",
"runArgs": [
// Uncomment the next line to use a non-root user. On Linux, this will prevent
// new files getting created as root, but you may need to update the USER_UID
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
// "-u", "vscode",

"--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"
],

// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Uncomment the next line if you want to publish any ports.
// "appPort": [],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "gcc -v",

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"ms-vscode.cpptools"
]
}
11 changes: 5 additions & 6 deletions README.md
Expand Up @@ -16,7 +16,8 @@ The provided command line tools ojph\_compress and ojph\_expand accepts and gene

# Compiling #

The code employs the *cmake* tool to generate a variety of build enviroments.
The code employs the *cmake* tool to generate a variety of build enviroments. A visual studio code container is included for building using
the visual studio code remote conatiners add in (highly recommended)

**For Linux**

Expand Down Expand Up @@ -47,16 +48,14 @@ The generated library and executables will be in the bin folder.

The library can now be compiled to javascript/wasm. For this purpose, a small wrapper file (ojph_wrapper.cpp) has been written to interface between javascript and C++; the wrapper currently supports decoding only. A small demo page demonstrating the script can be accessed [here](https://openjph.org/javascript/demo.html).

Compilation needs the [emscripten](https://emscripten.org/) tools. The tools are activated using
```bash
emsdk_env.sh
```
Then, the javascript decoder can be compiled using
Compilation needs the [emscripten](https://emscripten.org/) tools. The script subprojects/js/emscripten-docker.sh will create a shell in a docker image
with emscripten already installed if you don't want to install it locally. The javascript decoder can be compiled using
```bash
cd subprojects/js/build
emmake cmake ..
make
```

This creates libopenjph.js and libopenjph.wasm in subprojects/js/html folder. That html folder also has the demo webpage index.html and a compressed image test.j2c which the script in index.html decodes. To run the demo webpage on your machine, you need a webserver running on the machine -- Due to security reasons, javascript engines running in a browser cannot access local files on the machine. A simple python webserver can be run
```python
python -m SimpleHTTPServer 8000
Expand Down
2 changes: 2 additions & 0 deletions subprojects/js/emscripten-docker.sh
@@ -0,0 +1,2 @@
#!/bin/bash
docker run -it --user $(id -u):$(id -g) -v "$(cd ../.. && pwd)":/src trzeci/emscripten /bin/bash

0 comments on commit e349eba

Please sign in to comment.