mapbox / mapbox/cpp

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

Aperta
#20 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Nessun dato sulla lingua
Stelle
110
Fork
17
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

rational

We are increasingly working on small node C++ modules that depend on header-only C++ libs.
Node.js's Nan module 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 howNan 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:

Example use case:

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Individua le librerie C++ header-only in questo repository e confronta il pattern di package.json e include_dirs.js di Nan con gli esempi collegati. Aggiungi i metadati del pacchetto richiesti per ogni libreria, quindi esegui npm pack e ispeziona il tarball per confermare che contenga gli header e solo i file predefiniti di npm.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, nodejs
Ambito
release, tooling
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.