-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1912 from actonlang/guide-pkg
Guide: describe pkg dependencies
- Loading branch information
Showing
6 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
# Add Dependency | ||
|
||
Add a dependency to your project by using `acton pkg add` and providing the URL to the project and a local reference name. | ||
|
||
In this case we add the example `foo` package as a dependency. | ||
```console | ||
acton pkg add https://github.com/actonlang/foo/archive/refs/heads/main.zip foo | ||
``` | ||
|
||
This will fetch the dependency and add it to the `build.act.json` file of your local project, resulting in something like: | ||
```json | ||
{ | ||
"dependencies": { | ||
"foo": { | ||
"url": "https://github.com/actonlang/foo/archive/refs/heads/main.zip", | ||
"hash": "1220cd47344f8a1e7fe86741c7b0257a63567b4c17ad583bddf690eedd672032abdd" | ||
} | ||
}, | ||
"zig_dependencies": {} | ||
} | ||
``` | ||
|
||
```admonish | ||
It is possible to edit `build.act.json` by hand, but adding dependencies, which requires filling in the 'hash' field requires computing the hash which is somewhat tricky. | ||
``` | ||
|
||
The `foo` package provides a single `foo` module with a `foo` function (that appropriately returns `foo`). We can now access it from our main actor: | ||
|
||
```python | ||
import foo | ||
|
||
actor main(env): | ||
print(foo.foo()) | ||
env.exit(0) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# Fetch Dependencies | ||
# Fetch Dependencies / Enable Airplane Mode | ||
|
||
You can fetch all the dependencies of a project by using `acton fetch`. It will download the dependencies specified in `build.act.json` to the cache. | ||
|
||
`acton fetch` enables you to work offline or in **airplane mode**. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Local Dependencies | ||
|
||
It is possible to use dependencies available via a local file system path by setting the `path` attribute. Edit `build.act.json` and add or modify an existing dependency. Set the `path` attribute to a relative path on the local file system, e.g.: | ||
|
||
```json | ||
{ | ||
"dependencies": { | ||
"foo": { | ||
"url": "https://github.com/actonlang/foo/archive/refs/heads/main.zip", | ||
"hash": "1220cd47344f8a1e7fe86741c7b0257a63567b4c17ad583bddf690eedd672032abdd", | ||
"path": "../foo" | ||
}, | ||
"local_lib": { | ||
"path": "deps/local_lib" | ||
} | ||
}, | ||
"zig_dependencies": {} | ||
} | ||
``` | ||
|
||
```admonish | ||
Setting a local `path` will take priority over a remote `url`. This can be useful to fork a library and make local modifications to it before submitting them back upstream. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# Remove Dependency | ||
|
||
You can remove a dependency from your project with `acton pkg remove`: | ||
|
||
```console | ||
acton pkg remove foo | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# C / C++ / Zig dependencies | ||
|
||
Much like dependencies on other Acton packages, an Acton project can depend on a Zig package which could be a C / C++ or Zig library, as long as it has a `build.zig` file. | ||
|
||
- `acton zig-pkg add URL NAME --artifact X --artifact` | ||
- list the libraries you want to link with as artifacts | ||
- `acton zig-pkg remove NAME` |