open-index/open-npm huggingface dataset:
npm package: @konsumer/protoencoder
Description: This is a simple example of compiling a proto def to C. The idea is that I need to make a message that looks like `2.1.1.1:string` (for `getItems` calls.)
Latest version: 0.0.1

This is a simple example of compiling a proto def to C. The idea is that I need to make a message that looks like `2.1.1.1:string` (for `getItems` calls.)

## usage

```
import createMessage from './protoencoder.mjs'

const msg = createMessage('com.jagex.oldscape.android')
```


## building

I have setup some build-targets that require docker:

```
npm run gen   # just generate the C source-code
npm run build # just build the wasm (and gen first)
npm test      # test that the lib encodes stuff (gen/build first)
```

### docker

You can use docker, if you don't want to install things on the host:

```
# generate C bindings
docker run -it --rm -v $(pwd):/src rvolosatovs/protoc --c_out=/src -I/src/ message.proto

# config
docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk emcmake cmake -B build

# build
docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk cmake --build build
```


### bare system

To compile it, you will need emscripten & protoc.

```
# generate C bindings
protoc --c_out=. message.proto

# config
emcmake cmake -GNinja -B build

# build
cmake --build build
```