Skip to content

Commit da49ef6

Browse files
committed
docs: Add documentation on how to fetch packages from other sources, add build instructions, cleanup Readme.
1 parent a550b9a commit da49ef6

File tree

3 files changed

+121
-62
lines changed

3 files changed

+121
-62
lines changed

Building.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Building clib from source
2+
3+
## OSx
4+
5+
```sh
6+
$ git clone https://github.com/clibs/clib.git /tmp/clib
7+
$ cd /tmp/clib
8+
$ make install
9+
```
10+
11+
## Ubuntu or debian
12+
13+
```sh
14+
# install libcurl
15+
$ sudo apt install libcurl4-gnutls-dev -qq
16+
# clone
17+
$ git clone https://github.com/clibs/clib.git /tmp/clib && cd /tmp/clib
18+
# build
19+
$ make
20+
# put on path
21+
$ sudo make install
22+
```
23+
24+
## Windows (crosscompiling from linux)
25+
The docker image contains the mingw toolchain which is used to compile for windows.
26+
Curl needs to be built from source.
27+
```shell
28+
# Download and compile curl
29+
$ docker run --rm dockcross/windows-static-64-posix > dockcross-windows-x64
30+
$ cat dockcross-windows-x64
31+
$ chmod +x dockcross-windows-x64
32+
$ wget https://curl.haxx.se/download/curl-7.76.0.tar.gz
33+
$ tar xzf curl-*
34+
$ CURL_SRC=curl-*
35+
$ ./dockcross-windows-x64 bash -c 'cd '"$CURL_SRC"' && ./configure --prefix="/work/deps/curl" --host=x86_64-w64-mingw32.static --with-winssl --disable-dependency-tracking --disable-pthreads --enable-threaded-resolver --disable-imap --disable-pop3 --disable-smpt --disable-ldap --disable-mqtt --disable-smb'
36+
$ ./dockcross-windows-x64 bash -c 'cd '"$CURL_SRC"' && make'
37+
$ ./dockcross-windows-x64 bash -c 'cd '"$CURL_SRC"' && make install'
38+
$ git clone https://github.com/clibs/clib.git && cd clib
39+
$ ./dockcross-windows-x64 make all NO_PTHREADS=1 EXE=true
40+
```

Readme.md

+36-54
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,28 @@
77

88
![c package manager screenshot](https://i.cloudup.com/GwqOU2hh9Y.png)
99

10-
## Installation
11-
12-
Expects [libcurl](http://curl.haxx.se/libcurl/) to be installed and linkable.
13-
14-
With [homebrew](https://github.com/Homebrew/homebrew):
15-
16-
```sh
17-
$ brew install clib
18-
```
19-
20-
Or [MacPorts](https://www.macports.org):
21-
22-
```sh
23-
$ sudo port selfupdate
24-
$ sudo port install clib
25-
```
26-
27-
With git:
28-
29-
```sh
30-
$ git clone https://github.com/clibs/clib.git /tmp/clib
31-
$ cd /tmp/clib
32-
$ make install
33-
```
10+
## About
3411

35-
Ubuntu:
12+
Basically the lazy-man's copy/paste promoting smaller C utilities, also
13+
serving as a nice way to discover these sort of libraries. From my experience
14+
C libraries are scattered all over the web and discovery is relatively poor. The footprint of these libraries is usually quite large and unfocused. The goal of `clibs` is to provide
15+
stand-alone "micro" C libraries for developers to quickly install without coupling
16+
to large frameworks.
3617

37-
```sh
38-
# install libcurl
39-
$ sudo apt-get install libcurl4-gnutls-dev -qq
40-
# clone
41-
$ git clone https://github.com/clibs/clib.git /tmp/clib && cd /tmp/clib
42-
# build
43-
$ make
44-
# put on path
45-
$ sudo make install
46-
```
18+
You should use `clib(1)` to fetch these files for you and check them into your repository, the end-user and contributors should not require having `clib(1)` installed. This allows `clib(1)` to fit into any new or existing C workflow without friction.
4719

48-
## About
20+
The [listing of packages](https://github.com/clibs/clib/wiki/Packages) acts as the "registry". The registry is used by `clib(1)` when searching for packages.
4921

50-
Basically the lazy-man's copy/paste promoting smaller C utilities, also
51-
serving as a nice way to discover these sort of libraries. From my experience
52-
C libraries are scattered all over the web and discovery is relatively poor. The footprint of these libraries is usually quite large and unfocused. The goal of `clibs` is to provide
53-
stand-alone "micro" C libraries for developers to quickly install without coupling
54-
to large frameworks.
22+
## Installation and building
23+
Binaries for `clib(1)` releases can be found at [releases](https://github.com/clibs/clib/releases/).
24+
For OSx and linux [libcurl](http://curl.haxx.se/libcurl/) should be installed and linkable.
25+
The windows binaries do not require any libraries to be installed.
5526

56-
You should use `clib(1)` to fetch these files for you and check them into your repository, the end-user and contributors should not require having `clib(1)` installed. This allows `clib(1)` to fit into any new or existing C workflow without friction.
27+
See [Building](Building.md) for instructions on how to build clib.
5728

58-
The wiki [listing of packages](https://github.com/clibs/clib/wiki/Packages) acts as the "registry" and populates the `clib-search(1)` results.
5929

6030
## Usage
61-
31+
More detailed information on how to use `clib` can be found in [Usage](Usage.md).
6232
```
6333
clib <command> [options]
6434
@@ -78,13 +48,9 @@ $ sudo make install
7848
search [query] Search for packages
7949
help <cmd> Display help for cmd
8050
```
51+
More information about the Command Line Interface can be found [here](https://github.com/clibs/clib/wiki/Command-Line-Interface).
8152

82-
More about the Command Line Interface [here](https://github.com/clibs/clib/wiki/Command-Line-Interface).
83-
84-
## Examples
85-
86-
More examples and best practices at [BEST_PRACTICE.md](https://github.com/clibs/clib/blob/master/BEST_PRACTICE.md).
87-
53+
### Example usage
8854
Install a few dependencies to `./deps`:
8955

9056
```sh
@@ -109,10 +75,26 @@ $ clib install ms file hash
10975
$ clib install visionmedia/mon visionmedia/every visionmedia/watch
11076
```
11177

112-
## clib.json
113-
114-
Example of a clib.json explicitly listing the source:
78+
## Clib.json
79+
Information about a clib project or a package is stored in `clib.json`.
80+
In a project that uses `clib` to install dependencies a typical `clib.json` will only contain the required dependencies.
81+
It may look something like:
82+
```json
83+
{
84+
"name": "Copy and Paste-Inator",
85+
"version": "0.4.2",
86+
"description": "Creates copies of yourself to do all of his waiting in lines for you.",
87+
"dependencies": {
88+
"clibs/buffer": "0.0.1",
89+
"clibs/term": "0.0.1",
90+
"jwerle/throw.h": "0.0.0"
91+
}
92+
}
93+
```
11594

95+
Packages that can be installed by `clib` should also provide a `clib.json`.
96+
It contains the files that should be installed by `clib` in `"src"`
97+
An example of a clib.json for a package may look like:
11698
```json
11799
{
118100
"name": "term",
@@ -125,7 +107,7 @@ $ clib install visionmedia/mon visionmedia/every visionmedia/watch
125107
}
126108
```
127109

128-
Example of a clib.json for an executable:
110+
Example of a clib.json for an executable:
129111

130112
```json
131113
{

BEST_PRACTICE.md renamed to Usage.md

+45-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
This page will cover:
44

55
- [How to use libraries](#how-to-use-installed-libraries-for-your-project).
6-
- [Example Makefile](#example-makefile).
7-
- [Example `clib.json` for executables](#example-clibjson-for-executable-project).
6+
- [Example Makefile](#example-makefile).
7+
- [Example `clib.json` for executables](#example-packagejson-for-executable-project).
88
- [Making your own library package](#making-your-own-libraries).
9-
- [Example `clib.json` for libraries](#example-clibjson-for-libraries).
9+
- [Example `clib.json` for libraries](#example-packagejson-for-libraries).
1010
- [How to install/uninstall executables](#install-and-uninstall-executables-packages).
11-
12-
For instructions on installation, check out the [README](https://github.com/clibs/clib#installation).
11+
- [How to fetch packages from other sources](#how-to-fetch-packages-from-other-sources).
1312

1413
## How to use installed libraries for your project
1514

@@ -116,7 +115,7 @@ at a example `clib.json` file for your project: (executable package)
116115
"dependencies": {
117116
"stephenmathieson/trim.c": "0.0.2",
118117
"clibs/commander": "1.3.2",
119-
"clibs/logger": "0.0.1",
118+
"clibs/logger": "0.0.1"
120119
},
121120
"install": "make install",
122121
"uninstall": "make uninstall"
@@ -129,9 +128,9 @@ _**NOTE:** Make sure you have a release as the same version in your `clib.json`
129128

130129
## Making your own libraries
131130

132-
Now that you know how to use libraries, heres how to make your own:
131+
Now that you know how to use libraries, here is how to make your own:
133132

134-
Like before, heres a typical project directory tree:
133+
Like before, a typical project directory tree:
135134

136135
```
137136
your-library-c/
@@ -230,3 +229,41 @@ $ sudo clib-uninstall visionmedia/mon
230229
```
231230

232231
<br>
232+
233+
## How to fetch packages from other sources
234+
By default `clib` uses the [listing of packages](https://github.com/clibs/clib/wiki/Packages) as the place to look for packages, the registry, and [github.com](https://github.com) for downloading packages.
235+
You can specify additional registries and download from other repositories than github.
236+
This might be useful when using `clib` to install a mix of private and public packages.
237+
238+
### Adding additional registries
239+
Additional registries can be provided in the `clib.json` of a project.
240+
Currently github wiki's and gitlab &mdash; both [gitlab.com](https://www.gitlab.com) and self hosted &mdash; are supported.
241+
For gitlab the format is a bit complicated as it has to conform to the gitlab api.
242+
You should use the same format as the default registry but in a file in a repository instead of in a wiki.
243+
```json
244+
{
245+
// other definitions
246+
"registries": [
247+
"https://gitlab.com/api/v4/projects/25447829/repository/files/README.md/raw?ref=master",
248+
"https://github.com/awesome-org/clib/wiki/Packages"
249+
]
250+
}
251+
```
252+
253+
_**CAUTION:** For gitlab, the url should be of the form `/project/<id>` and not `/group/repo` check [my-gitlab-registry](https://gitlab.com/nouwaarom/my-clib-registry) for an example._
254+
255+
### Downloading from gitlab or private sources
256+
To download from some sources, authentication might be required.
257+
To facilitate this `clib_secrets.json` is used to store the credentials.
258+
259+
```json
260+
{
261+
"github.com": "GITHUB_API_TOKEN",
262+
"github.example.com": "GITLAB_USER_TOKEN"
263+
}
264+
```
265+
266+
Gitlab always requires a secret in order to use the API.
267+
The secret can be obtained by clicking your profile and then (Preferences -> Access Tokens) and create a token with only `read_repository` rights.
268+
269+
_**TIP:** To prevent accidentally commiting your secrets add `clib_secrets.json` to `.gitignore` and use `clib_secrets.json.dist` to specify for which domains a secret is required._

0 commit comments

Comments
 (0)