Thread overview
How do I create a package?
Mar 02, 2022
M
Mar 02, 2022
Anonymouse
Mar 02, 2022
Mike Parker
Mar 05, 2022
M
Mar 05, 2022
M
Mar 05, 2022
Anonymouse
March 02, 2022

There doesn't seem to be any docs on how to actually create packages.

Is there a description anywhere?

March 02, 2022

On Wednesday, 2 March 2022 at 16:38:58 UTC, M wrote:

>

There doesn't seem to be any docs on how to actually create packages.

Is there a description anywhere?

https://dub.pm/getting_started.html is it, I think. It should get you started on creating a package, and then you have https://dub.pm/publish.html on how to register it.

March 02, 2022

On Wednesday, 2 March 2022 at 16:38:58 UTC, M wrote:

>

There doesn't seem to be any docs on how to actually create packages.

Is there a description anywhere?

In case you're talking about a language-level package and not a dub package, just create a directory in your source tree with the name of your package, stick your source files in it and add a module statement to the top of each source file like so:

module packagename.modulename;

For subpackages, add subdirectories and throw those names into the module statement:

module packagename.subpackagename.modulename;
March 05, 2022

On Wednesday, 2 March 2022 at 16:38:58 UTC, M wrote:

>

There doesn't seem to be any docs on how to actually create packages.

THE DOCS ARE INADEQUATE TO THE TASK.

dub app-path ..

dub build

It says "module bcm2835 is in file bcm2835.d' which cannot be read."

I want to make bcm2835.d common to a few projects. How do I do it?

Is there something I can add to dub.json to tell it where to look?

I tried to do

import ../bcm2835;

but that doesn't work either.

What am I supposed to do?

March 05, 2022

On Saturday, 5 March 2022 at 15:12:35 UTC, M wrote:

>

THE DOCS ARE INADEQUATE TO THE TASK.

I've created a directory bcm2835. Then within source/bcm2835 I have bcm2835.d.

I run dub build, and file called libbcm2835.a gets built.

I type
dub list

and it reports

Packages present in the system and known to dub:
...
bcm2835 ~master: /home/pi/repos/cerbo/dsp/dlang/bcm2835/

So, some kind of success, presumably.

So then, in the app I want to build, I type

  dub add bcm2835

but it says

 Could not find package 'bcm2835'.

So, dunno, any ideas?

March 05, 2022

On 3/5/22 10:30 AM, M wrote:

>

On Saturday, 5 March 2022 at 15:12:35 UTC, M wrote:

>

THE DOCS ARE INADEQUATE TO THE TASK.

I've created a directory bcm2835. Then within source/bcm2835 I have bcm2835.d.

I run dub build, and file called libbcm2835.a gets built.

I type
        dub list

and  it reports

    Packages present in the system and known to dub:
    ...
    bcm2835 ~master: /home/pi/repos/cerbo/dsp/dlang/bcm2835/

So, some kind of success, presumably.

So then, in the app I want to build, I type

      dub add bcm2835

but it says

     Could not find package 'bcm2835'.

So, dunno, any ideas?

dub add requires the package to be hosted on the dub online repository. dub add is like "lookup the latest version of package X and add the dependency for that into my build". I agree it would be nice for dub to glance at your locally-added packages.

You can dub add-local the package (as it appears you have done), and then edit the dub.json or dub.sdl file directly to add the dependency yourself. Then it will find the package when building.

I use this for private packages I'm not ready to publish.

-Steve

March 05, 2022

On Saturday, 5 March 2022 at 15:30:19 UTC, M wrote:

>

On Saturday, 5 March 2022 at 15:12:35 UTC, M wrote:

>

THE DOCS ARE INADEQUATE TO THE TASK.

I've created a directory bcm2835. Then within source/bcm2835 I have bcm2835.d.

I run dub build, and file called libbcm2835.a gets built.

I type
dub list

and it reports

Packages present in the system and known to dub:
...
bcm2835 ~master: /home/pi/repos/cerbo/dsp/dlang/bcm2835/

So, some kind of success, presumably.

So then, in the app I want to build, I type

  dub add bcm2835

but it says

 Could not find package 'bcm2835'.

So, dunno, any ideas?

So I tried and I agree it's not intuitive.

Once you've created a package bcm2835 with dub init, you can add it to the local registry with dub add-local /path/to/bcm2835.

Registered package: bcm2835 (version: ~master)

This you already did, presumably, or something to the same effect.

Packages present in the system and known to dub:
[...]
  bcm2835 ~master: /home/wob/src/test/bcm2835/

Then you can add it to your dub.sdl/dub.json as a dependency with dub add if and only if you also specify a version. Else it will look it up in the online registry, find nothing, and fail. The help text in dub add --help briefly mentions it.

$ dub add bcm2835@"*"
Adding dependency bcm2835 >=0.0.0

$ dub build
Performing "debug" build using /usr/bin/dmd for x86_64.
bcm2835 ~master: target for configuration "library" is up to date.
test ~master: building configuration "application"...
Linking...
To force a rebuild of up-to-date targets, run again with --force.