janet-lang / jpm

Janet Project Manager
MIT License
68 stars 22 forks source link

Making `:project` dynamic binding visible to task environment #34

Closed pyrmont closed 2 years ago

pyrmont commented 2 years ago

I would like to add a task that uses information in the :project dynamic binding. I can make this binding visible by defining a binding in my project.janet file but this feels duplicative.

Is it possible to expose :project in a similar way to how :rules is exposed to the task environment?

bakpakin commented 2 years ago

This should already be visible, I think under the :meta dynamic binding rather than :project

pyrmont commented 2 years ago

Hmmm, I'm not seeing that. I have a simple project.janet file with the following:

(declare-project
  :name "Example")

(prin "The value of :project is ") (pp (dyn :project))
(prin "The value of :meta is ") (pp (dyn :meta))

(task "test-meta" []
  (prin "The value of :project in this task is ") (pp (dyn :project))
  (prin "The value of :meta in this task is ") (pp (dyn :meta)))

When I run jpm run test-meta it prints:

The value of :project is {:name "Example"}
The value of :meta is nil
The value of :project in this task is nil
The value of :meta in this task is nil
pyrmont commented 2 years ago

Oh, and if I add (prin "The value of :rules in this task is ") (pp (dyn :rules)) to the end of the test-meta task, the output is:

The value of :rules in this task is @{"/usr/local/lib/janet/.manifests/Example.jdn" @{:inputs @["uninstall"] :outputs @["/usr/local/lib/janet/.manifests/Example.jdn"] :recipe @[<function 0x55B09ADE5F60>]} "build" @{ :inputs @[] :outputs @[] :recipe @[<function 0x55B09ADE5A70>] :task "build"} "clean" @{ :inputs @[] :outputs @[] :recipe @[<function 0x55B09ADE6B60>] :task "clean"} "install" @{ :inputs @["uninstall" "build" "/usr/local/lib/janet/.manifests/Example.jdn"] :outputs @[] :recipe @[<function 0x55B09ADE63A0>] :task "install"} "manifest" @{ :inputs @["/usr/local/lib/janet/.manifests/Example.jdn"] :outputs @[] :recipe @[<function 0x55B09ADE5AC0>] :task "manifest"} "test" @{ :inputs @["build"] :outputs @[] :recipe @[<function 0x55B09ADE6DA0>] :task "test"} "test-meta" @{ :inputs @[] :outputs @[] :recipe @[<function 0x55B09ADE8620>] :task "test-meta"} "uninstall" @{ :inputs @[] :outputs @[] :recipe @[<function 0x55B09ADE68A0>] :task "uninstall"}}
pepe commented 2 years ago

I guess this was addressed in d9016087690d5ba83da132d0b70013c4369a3714?

pyrmont commented 2 years ago

Thanks for the head's up, @pepe. The little test example I wrote above does now pass. Cheers @bakpakin!