diff options
Diffstat (limited to 'docs/platform_agnostic_external_dependencies.md')
-rw-r--r-- | docs/platform_agnostic_external_dependencies.md | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/docs/platform_agnostic_external_dependencies.md b/docs/platform_agnostic_external_dependencies.md new file mode 100644 index 00000000..97f983fa --- /dev/null +++ b/docs/platform_agnostic_external_dependencies.md | |||
@@ -0,0 +1,93 @@ | |||
1 | # Platform-agnostic external dependencies | ||
2 | |||
3 | Since 0.6, LuaRocks supports specifying files for external dependency search | ||
4 | in a platform-agnostic way. When filenames given in the | ||
5 | `external_dependencies` section of a [rockspec](rockspec_format.md) don't | ||
6 | have any dot (".") characters, their contents are substituted according to the | ||
7 | patterns given in the `external_deps_patterns` table of the [configuration | ||
8 | file](config_file_format.md). | ||
9 | |||
10 | These patterns will typically not be used in the configuration file, as | ||
11 | LuaRocks provides sensible defaults. The default patterns defined on Unix are: | ||
12 | |||
13 | ``` | ||
14 | bin = {"?"} | ||
15 | lib = {"lib?.a", "lib?.so"} | ||
16 | include = {"?.h"} | ||
17 | ``` | ||
18 | |||
19 | On Windows the defaults are: | ||
20 | |||
21 | ``` | ||
22 | bin = {"?.exe", "?.bat"} | ||
23 | lib = {"?.lib", "?.dll"} | ||
24 | include = {"?.h"} | ||
25 | ``` | ||
26 | |||
27 | For example, a [rockspec](rockspec_format.md) can define an external | ||
28 | dependency like this: | ||
29 | |||
30 | ``` | ||
31 | external_dependencies = { | ||
32 | FOO = { | ||
33 | library = "foo" | ||
34 | } | ||
35 | } | ||
36 | ``` | ||
37 | |||
38 | and this will result in searches for libfoo.a or libfoo.so on Unix systems, | ||
39 | and foo.lib or foo.dll on Windows. For entries that have more than one | ||
40 | pattern, such as lib, only one entry needs to be satisfied. | ||
41 | |||
42 | In other words, the value "foo" you see in the | ||
43 | external_dependencies.FOO.library entry is the same value you would use when | ||
44 | linking the library, for example -lfoo. In addition, once you added FOO in the | ||
45 | external_dependencies, this means you can pass entries such as FOO_DIR and | ||
46 | FOO_LIBDIR to the `luarocks` command-line tool, in case you have these | ||
47 | libraries in non-standard locations. For example, if the user installed the | ||
48 | library in a custom location in their own home directory, it would still be | ||
49 | usable, like this: | ||
50 | |||
51 | ``` | ||
52 | luarocks install my_rockspec_using_foo-1.0-1.rockspec FOO_LIBDIR=/home/joeuser/foo/lib | ||
53 | ``` | ||
54 | |||
55 | When performing external dependency checks during installation (as opposed to | ||
56 | build) of rocks, static libraries and headers are not searched. The | ||
57 | `runtime_external_deps_patterns` table is used instead. | ||
58 | |||
59 | Since 3.4.0, the variable DEPS_DIR which doesn't depend on the name FOO, could | ||
60 | also used, like this: | ||
61 | |||
62 | ``` | ||
63 | luarocks install my_rockspec_using_foo-1.0-1.rockspec DEPS_DIR=/home/joeuser/foo/lib | ||
64 | ``` | ||
65 | |||
66 | # When filenames don't match | ||
67 | |||
68 | If the pattern system is not enough to hide platform differences, you can | ||
69 | always resort to [per-platform overrides](platform_overrides.md). For example: | ||
70 | |||
71 | ``` | ||
72 | external_dependencies = { | ||
73 | FOO = { | ||
74 | library = "foo" | ||
75 | } | ||
76 | platforms = { | ||
77 | win32 = { | ||
78 | FOO = { | ||
79 | library = "winfoo32.dll" | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | ``` | ||
85 | |||
86 | # Statically linked libraries and dependencies | ||
87 | |||
88 | If your rock links a library statically, avoid adding a library search in its | ||
89 | [rockspec](rockspec_format.md)'s `external_dependencies` table. Search for a | ||
90 | header instead, so that the external dependency search does not fail when | ||
91 | users install a binary rock and they don't have the library installed | ||
92 | separately. | ||
93 | |||