savi-lang / savi

A fast language for programmers who are passionate about their craft.
BSD 3-Clause "New" or "Revised" License
155 stars 12 forks source link

`savi deps update` should fetch dependencies for all manifests by default #359

Closed mneumann closed 1 year ago

mneumann commented 1 year ago

I have this manifest.savi:

:manifest lib MQTT
  :sources "src/*.savi"

  :dependency ByteStream v0
    :from "github:savi-lang/ByteStream"

  :dependency TCP v0
    :from "github:savi-lang/TCP"
    :depends on ByteStream
    :depends on IO
    :depends on OSError
    :depends on IPAddress

  :dependency IO v0
    :from "github:savi-lang/IO"
    :depends on ByteStream
    :depends on OSError

  :dependency OSError v0
    :from "github:savi-lang/OSError"

  :transitive dependency IPAddress v0
    :from "github:savi-lang/IPAddress"

:manifest bin "example"
  :copies MQTT
  :sources "example/*.savi"

:manifest bin "spec"
  :copies MQTT
  :sources "spec/*.savi"

  :dependency Spec v0
    :from "github:savi-lang/Spec"
    :depends on Map
    :depends on Time
    :depends on Timer

  :transitive dependency Map v0
    :from "github:savi-lang/Map"

  :transitive dependency Time v0
    :from "github:savi-lang/Time"

  :transitive dependency Timer v0
    :from "github:savi-lang/Timer"
    :depends on Time

Running savi deps update gives me:

> savi deps update
Downloading new library versions from GitHub...
Downloaded ByteStream v0.20220422.1
Downloaded TCP v0.20220405.0
Downloaded IO v0.20220405.0
Downloaded OSError v0.20220325.0
Downloaded IPAddress v0.20220404.1

When I run savi build spec, I get the following errors:


Compilation Errors:

---

This dependency needs to be fetched:
from ./manifest.savi:33:
  :dependency Spec v0
              ^~~~

- expected to find a directory named "./deps/github:savi-lang/Spec" with per-version subdirectories:
  from ./manifest.savi:34:
    :from "github:savi-lang/Spec"
          ^~~~~~~~~~~~~~~~~~~~~~~

---

This dependency needs to be fetched:
from ./manifest.savi:39:
  :transitive dependency Map v0
                         ^~~

- expected to find a directory named "./deps/github:savi-lang/Map" with per-version subdirectories:
  from ./manifest.savi:40:
    :from "github:savi-lang/Map"
          ^~~~~~~~~~~~~~~~~~~~~~

---

This dependency needs to be fetched:
from ./manifest.savi:42:
  :transitive dependency Time v0
                         ^~~~

- expected to find a directory named "./deps/github:savi-lang/Time" with per-version subdirectories:
  from ./manifest.savi:43:
    :from "github:savi-lang/Time"
          ^~~~~~~~~~~~~~~~~~~~~~~

---

This dependency needs to be fetched:
from ./manifest.savi:45:
  :transitive dependency Timer v0
                         ^~~~~

- expected to find a directory named "./deps/github:savi-lang/Timer" with per-version subdirectories:
  from ./manifest.savi:46:
    :from "github:savi-lang/Timer"
          ^~~~~~~~~~~~~~~~~~~~~~~~
mneumann commented 1 year ago

savi build spec works when I manually git clone the missing deps.

jemc commented 1 year ago

If you run savi deps update --for spec it will fetch the dependencies for the spec manifest.

If you don't include --for then Savi will try to guess which one is the manifest that you want (if you have exactly one bin it will guess that, but otherwise it will guess the lib if there is exactly one of those).

You can tell Savi that your spec manifest is the "main" binary to use as the default if you declare it as :manifest main spec as :manifest bin spec. This will make it so that it is always selected by default if you don't include a --for MANIFEST_NAME CLI argument.

This is all under-documented at the moment, so it's not surprising that you didn't know this. I definitely need to spend some time writing clear documentation for the packaging and manifests system in general.

mneumann commented 1 year ago

I'd make savi deps update fetch all dependencies, and only if you specify --for then fetch only those.

jemc commented 1 year ago

That seems reasonable. I'll update the ticket title.