{"id":13672823,"url":"https://github.com/charto/autogypi","last_synced_at":"2025-04-06T12:32:01.165Z","repository":{"id":29828759,"uuid":"33373341","full_name":"charto/autogypi","owner":"charto","description":"Autogypi handles dependencies for node-gyp projects.","archived":false,"fork":false,"pushed_at":"2017-05-03T16:35:30.000Z","size":32,"stargazers_count":21,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-21T23:51:15.789Z","etag":null,"topics":["node-addon"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-03T17:02:26.000Z","updated_at":"2023-09-22T08:19:54.000Z","dependencies_parsed_at":"2022-08-30T17:50:21.725Z","dependency_job_id":null,"html_url":"https://github.com/charto/autogypi","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fautogypi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fautogypi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fautogypi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charto%2Fautogypi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charto","download_url":"https://codeload.github.com/charto/autogypi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247484345,"owners_count":20946384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["node-addon"],"created_at":"2024-08-02T09:01:50.061Z","updated_at":"2025-04-06T12:32:00.917Z","avatar_url":"https://github.com/charto.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"autogypi\n========\n\n[![build status](https://travis-ci.org/charto/autogypi.svg?branch=master)](http://travis-ci.org/charto/autogypi)\n[![dependency status](https://david-dm.org/charto/autogypi.svg)](https://david-dm.org/charto/autogypi)\n[![npm version](https://img.shields.io/npm/v/autogypi.svg)](https://www.npmjs.com/package/autogypi)\n\n`autogypi` handles issues with C++ libraries published on npm.\nIt generates required compiler and `node-gyp` options for you and works great\nwith [`nbind`](https://github.com/charto/nbind#readme).\n\n`node-gyp` is very good at fixing relative paths between `.gypi` files\nin different locations, but it cannot automatically find other npm packages,\nwhich may have been installed globally or in a `node_modules` directory\nhigher up in the directory tree or hidden inside another package.\n`autogypi` deals with them.\n\nFeatures\n========\n\n- Initialize configuration for a `node-gyp` -based project.\n- Generate C++ compiler options.\n- Guess include directories to use headers from other packages.\n- Include additional `.gypi` files required by other packages.\n\nUsage\n=====\n\nInstallation\n------------\n\nAdd in the `scripts` section of your `package.json`:\n\n```json\n  \"scripts\": {\n    \"autogypi\": \"autogypi\",\n    \"node-gyp\": \"node-gyp\",\n\n    \"install\": \"autogypi \u0026\u0026 node-gyp configure build\"\n  }\n```\n\nThen run the commands:\n\n```bash\nnpm install --save autogypi\n```\n\nConfiguring `node-gyp`\n----------------------\n\nYou should add `auto-top.gypi` in the in the `includes` section\nat the top level of your `binding.gyp` file and `auto.gypi` in the `includes`\nsection of each target inside.\n\nIf you don't have a `binding.gyp` file yet, you can create one now with the\nrequired changes already made. For example:\n\n```bash\nnpm run -- autogypi --init-gyp -p nbind -s example.cc\n```\n\nReplace `example.cc` with the name of your C++ source file.\nYou can add multiple `-s` options, one for each source file.\n\nThe `-p nbind` option means the C++ code uses a package called\n[`nbind`](https://github.com/charto/nbind#readme).\nMultiple `-p` options can be added to add any other packages\ncompatible with `autogypi`.\n\nThe above command creates two files with contents:\n\n**`binding.gyp`**\n\n```json\n{\n  \"targets\": [\n    {\n      \"includes\": [\n        \"auto.gypi\"\n      ],\n      \"sources\": [\n        \"example.cc\"\n      ]\n    }\n  ],\n  \"includes\": [\n    \"auto-top.gypi\"\n  ]\n}\n```\n\n**`autogypi.json`**\n\n```json\n{\n  \"dependencies\": [\n    \"nbind\"\n  ],\n  \"includes\": []\n}\n```\n\nIt also prints an error if the packages you listed as dependencies are missing.\nFor example you can install `nbind` and run `autogypi` again:\n\n```bash\nnpm install --save nbind\nnpm run autogypi\n```\n\nCompiling your project\n----------------------\n\nCall `autogypi` and `node-gyp` from the install script in your\n`package.json` file, for example like\n`autogypi \u0026\u0026 node-gyp configure build`\nor from the command line:\n`npm run autogypi \u0026\u0026 npm run node-gyp configure build`\n\n`autogypi` generates two `.gypi` files according to its configuration.\nFor example with only `nbind` as a dependency they look like:\n\n**`auto-top.gypi`**\n\n```json\n{\n  \"includes\": [\n    \"node_modules/nbind/src/nbind-common.gypi\"\n  ]\n}\n```\n\n**`auto.gypi`**\n\n```json\n{\n  \"include_dirs\": [\n    \"node_modules/nbind/node_modules/nan\"\n  ],\n  \"includes\": [\n    \"node_modules/nbind/src/nbind.gypi\"\n  ]\n}\n```\n\nPublishing a C++ library on npm\n-------------------------------\n\nPackages should include an `autogypi.json` file in their root directory\nif they require or are intended to be used by other modules.\nThey should list any .gypi files of their own that are required to compile\nor use the module. For example:\n\n```json\n{\n  \"dependencies\": [\n    \"nan\"\n  ],\n  \"includes\": [\n    \"example.gypi\"\n  ]\n}\n```\n\nThe `example.gypi` file would then contain any gyp settings\nrequired to successfully compile and include it in other packages.\n\nModules without any `autogypi.json` file get their root directory\nadded to `include_dirs`. This is enough to successfully use the `nan` module.\nMore heuristics may be added later if needed.\n\nCommand line options\n====================\n\nRun `npm run -- autogypi --help` to see the command line options:\n\n```\n  Usage: autogypi [options]\n\n  Generate node-gyp dependency files.\n\n  Options:\n\n    -h, --help                output usage information\n    -V, --version             output the version number\n    -r, --root \u003cpath\u003e         root path for config files, default is shell working directory\n    -c, --config \u003cpath\u003e       config file, default autogypi.json\n    -o, --output \u003cpath\u003e       per-target gypi file to create, default auto.gypi\n    -t, --output-top \u003cpath\u003e   top-level gypi file to create, default auto-top.gypi\n    -T, --no-output-top       omit top-level gypi file\n    -p, --package \u003cpath\u003e      add dependency on another npm package\n    -I, --include-dir \u003cpath\u003e  add include directory for header files\n    --save [flag]             save changes to config file\n    --init-gyp [path]         create gyp file (default binding.gyp, implies --save) with options:\n    -s, --source \u003cpath\u003e         - add C or C++ source file\n```\n\nRenaming `autogypi.json`, `auto.gypi` and `auto-top.gypi` using the relevant\ncommand line parameters will affect generating the `.gypi` files and also\nthe contents of any `binding.gyp` generated using the `--init-gyp` option.\n\nAPI\n===\nDocs generated using [`docts`](https://github.com/charto/docts)\n\u003e\n\u003e \u003ca name=\"api-AutogypiConfig\"\u003e\u003c/a\u003e\n\u003e ### Interface [`AutogypiConfig`](#api-AutogypiConfig)\n\u003e \u003cem\u003eFormat of autogypi.json files published in Node.js modules.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/autogypi/blob/cc6e9d1/src/autogypi.ts#L36-L47)  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.dependencies**\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring[]\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eList of required Node.js modules.\u003c/em\u003e  \n\u003e \u003e **.includes**\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring[]\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eAdditional gypi files to include inside relevant targets.\u003c/em\u003e  \n\u003e \u003e **.topIncludes**\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring[]\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eAdditional gypi files to include at top level.\u003c/em\u003e  \n\u003e \u003e **.output**\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003ePath to auto.gypi to generate.\u003c/em\u003e  \n\u003e \u003e **.outputTop**\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003ePath to auto-top.gypi to generate.\u003c/em\u003e  \n\u003e\n\u003e \u003ca name=\"api-BindingConfig\"\u003e\u003c/a\u003e\n\u003e ### Interface [`BindingConfig`](#api-BindingConfig)\n\u003e \u003cem\u003eOptions for generating an initial binding.gyp file.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/autogypi/blob/cc6e9d1/src/autogypi.ts#L12-L21)  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.basePath** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eDirectory where the binding.gyp will be stored.\u003c/em\u003e  \n\u003e \u003e **.outputPath** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eAbsolute path to generated auto.gypi to include in default target.\u003c/em\u003e  \n\u003e \u003e **.outputTopPath** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eAbsolute path to generated auto-top.gypi to include at top level.\u003c/em\u003e  \n\u003e \u003e **.sourceList** \u003csup\u003e\u003ccode\u003estring[]\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eList of absolute paths to C/C++ source files to compile.\u003c/em\u003e  \n\u003e\n\u003e \u003ca name=\"api-GenerateOptions\"\u003e\u003c/a\u003e\n\u003e ### Interface [`GenerateOptions`](#api-GenerateOptions)\n\u003e \u003cem\u003eGeneral options for generating gypi files.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/autogypi/blob/cc6e9d1/src/autogypi.ts#L25-L32)  \n\u003e  \n\u003e Properties:  \n\u003e \u003e **.configPath** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eAbsolute path to autogypi.json.\u003c/em\u003e  \n\u003e \u003e **.outputPath** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eAbsolute path to auto.gypi to generate.\u003c/em\u003e  \n\u003e \u003e **.outputTopPath** \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u003cem\u003eAbsolute path to auto-top.gypi to generate.\u003c/em\u003e  \n\u003e\n\u003e \u003ca name=\"api-generate\"\u003e\u003c/a\u003e\n\u003e ### Function [`generate`](#api-generate)\n\u003e \u003cem\u003eWrite auto.gypi and auto-top.gypi files according to config.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/autogypi/blob/cc6e9d1/src/autogypi.ts#L188-L216)  \n\u003e \u003e **generate( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eBluebird\u0026lt;{}[]\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/autogypi/blob/cc6e9d1/src/autogypi.ts#L188-L216)  \n\u003e \u003e \u0026emsp;\u0026#x25aa; opts \u003csup\u003e\u003ccode\u003e[GenerateOptions](#api-GenerateOptions)\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; config \u003csup\u003e\u003ccode\u003e[AutogypiConfig](#api-AutogypiConfig)\u003c/code\u003e\u003c/sup\u003e \u003cem\u003eContents of autogypi.json.\u003c/em\u003e  \n\u003e\n\u003e \u003ca name=\"api-initGyp\"\u003e\u003c/a\u003e\n\u003e ### Function [`initGyp`](#api-initGyp)\n\u003e \u003cem\u003eReturn an object with contents for an initial binding.gyp file.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/autogypi/blob/cc6e9d1/src/autogypi.ts#L220-L241)  \n\u003e \u003e **initGyp( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eany\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/autogypi/blob/cc6e9d1/src/autogypi.ts#L220-L241)  \n\u003e \u003e \u0026emsp;\u0026#x25aa; opts \u003csup\u003e\u003ccode\u003e[BindingConfig](#api-BindingConfig)\u003c/code\u003e\u003c/sup\u003e  \n\u003e\n\u003e \u003ca name=\"api-writeJson\"\u003e\u003c/a\u003e\n\u003e ### Function [`writeJson`](#api-writeJson)\n\u003e \u003cem\u003eSave pretty-printed JSON object to a file or print an appropriate error.\u003c/em\u003e  \n\u003e Source code: [`\u003c\u003e`](http://github.com/charto/autogypi/blob/cc6e9d1/src/autogypi.ts#L62-L84)  \n\u003e \u003e **writeJson( )** \u003csup\u003e\u0026rArr; \u003ccode\u003eBluebird\u0026lt;{}\u0026gt;\u003c/code\u003e\u003c/sup\u003e [`\u003c\u003e`](http://github.com/charto/autogypi/blob/cc6e9d1/src/autogypi.ts#L62-L84)  \n\u003e \u003e \u0026emsp;\u0026#x25aa; outputPath \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25aa; json \u003csup\u003e\u003ccode\u003eany\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25ab; name\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\u003e \u003e \u0026emsp;\u0026#x25ab; header\u003csub\u003e?\u003c/sub\u003e \u003csup\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/sup\u003e  \n\nLicense\n=======\n\n[The MIT License](https://raw.githubusercontent.com/charto/autogypi/master/LICENSE)\nCopyright (c) 2015-2016 BusFaster Ltd\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharto%2Fautogypi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharto%2Fautogypi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharto%2Fautogypi/lists"}