Skip to content

Commit e349eba

Browse files
committed
Merge branch 'devcontainer' into development
2 parents 12c6dba + bca3446 commit e349eba

File tree

4 files changed

+88
-6
lines changed

4 files changed

+88
-6
lines changed

.devcontainer/Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
FROM debian:9
7+
8+
# Avoid warnings by switching to noninteractive
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
12+
# this user's GID/UID must match your local user UID/GID to avoid permission issues
13+
# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
14+
# https://aka.ms/vscode-remote/containers/non-root-user for details.
15+
ARG USERNAME=vscode
16+
ARG USER_UID=1000
17+
ARG USER_GID=$USER_UID
18+
19+
# Configure apt and install packages
20+
RUN apt-get update \
21+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
22+
#
23+
# Verify git, process tools, lsb-release (useful for CLI installs) installed
24+
&& apt-get -y install git iproute2 procps lsb-release \
25+
#
26+
# Install C++ tools
27+
&& apt-get -y install build-essential cppcheck valgrind \
28+
#
29+
## Install newer version of CMake (OpenJPH requires 3.10+, debian has older version)
30+
&& apt-get install wget \
31+
&& wget https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz \
32+
&& tar -zxvf cmake-3.15.2.tar.gz \
33+
&& (cd /cmake-3.15.2; ./bootstrap; make -j2 install)\
34+
&& rm -rf /cmake-3.15.2\
35+
#
36+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
37+
&& groupadd --gid $USER_GID $USERNAME \
38+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
39+
# [Optional] Add sudo support for the non-root user
40+
&& apt-get install -y sudo \
41+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
42+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
43+
#
44+
# Clean up
45+
&& apt-get autoremove -y \
46+
&& apt-get clean -y \
47+
&& rm -rf /var/lib/apt/lists/*
48+
49+
# Switch back to dialog for any ad-hoc use of apt-get
50+
ENV DEBIAN_FRONTEND=

.devcontainer/devcontainer.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
2+
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/cpp
3+
{
4+
"name": "C++",
5+
"dockerFile": "Dockerfile",
6+
"runArgs": [
7+
// Uncomment the next line to use a non-root user. On Linux, this will prevent
8+
// new files getting created as root, but you may need to update the USER_UID
9+
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
10+
// "-u", "vscode",
11+
12+
"--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"
13+
],
14+
15+
// Use 'settings' to set *default* container specific settings.json values on container create.
16+
// You can edit these settings after create using File > Preferences > Settings > Remote.
17+
"settings": {
18+
"terminal.integrated.shell.linux": "/bin/bash"
19+
},
20+
21+
// Uncomment the next line if you want to publish any ports.
22+
// "appPort": [],
23+
24+
// Uncomment the next line to run commands after the container is created.
25+
// "postCreateCommand": "gcc -v",
26+
27+
// Add the IDs of extensions you want installed when the container is created in the array below.
28+
"extensions": [
29+
"ms-vscode.cpptools"
30+
]
31+
}

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ The provided command line tools ojph\_compress and ojph\_expand accepts and gene
1616

1717
# Compiling #
1818

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

2122
**For Linux**
2223

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

4849
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).
4950

50-
Compilation needs the [emscripten](https://emscripten.org/) tools. The tools are activated using
51-
```bash
52-
emsdk_env.sh
53-
```
54-
Then, the javascript decoder can be compiled using
51+
Compilation needs the [emscripten](https://emscripten.org/) tools. The script subprojects/js/emscripten-docker.sh will create a shell in a docker image
52+
with emscripten already installed if you don't want to install it locally. The javascript decoder can be compiled using
5553
```bash
5654
cd subprojects/js/build
5755
emmake cmake ..
5856
make
5957
```
58+
6059
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
6160
```python
6261
python -m SimpleHTTPServer 8000
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
docker run -it --user $(id -u):$(id -g) -v "$(cd ../.. && pwd)":/src trzeci/emscripten /bin/bash

0 commit comments

Comments
 (0)