mapbox / mapbox/cpp

Docs on publishing of header-only C++ libs (include in node c++ modules)

未关闭
#20 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
没有语言数据
星标
110
派生
17
PR 合并指标
30 天内没有已合并 PR

描述

## rational

We are increasingly working on small node C++ modules that depend on header-only C++ libs.
Node.js's [`Nan` module](https://github.com/nodejs/nan) has pioneered a best practice for how to include header only C++ libs in node C++ addons by simply adding a `package.json` and `include_dirs.js` file to the root of the project. I think we should follow the lead of how`Nan` does this and package all our C++ header only libs in npm as well as mason. I think publishing in two places is worth it because it makes including the libraries from node modules very easy and consistent with how JS modules work.

## method

Add:

- package.json
- include_dirs.js
- `files` parameter to `package.json` so that only the `include/` directory is included

Example:

```
{
"name": "@mapbox/geometry-hpp",
"version": "0.9.0",
"description": "A C++ header only geometry type library",
"main": "./include_dirs.js",
"repository" : {
"type" : "git",
"url" : "git://github.com/mapbox/geometry.hpp.git"
},
"files": [
"include"
]
}
```

Then test that only the right files are going to be packaged:

```
npm pack
tar -ztvf *tgz
```

^^ that should list just the headers and the default files npm includes like `README.md` and `package.json` etc

Examples:

- https://github.com/mapbox/protozero/pull/59
- https://github.com/osmcode/libosmium/pull/186

Example use case:

- https://github.com/springmeyer/node-osmium-count/blob/master/package.json#L17

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

Locate the header-only C++ libraries in this repository and compare Nan's package.json and include_dirs.js pattern with the linked examples. Add the requested package metadata for each library, then run npm pack and inspect the tarball to confirm it contains the headers and npm's default files only.

由索引模型根据 Issue 内容生成。

评估

技术栈
cpp, nodejs
领域
release, tooling
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。