February 28, 2023
On Tuesday, 28 February 2023 at 16:15:44 UTC, Bradley Chatha wrote:
> Unlikely: In your example they can still use imports by doing something like `mixin("impor"~"t std.file;");`

I'm a numpty, I didn't read your post carefully enough :D
February 28, 2023
On Tuesday, 28 February 2023 at 16:10:19 UTC, Steven Schveighoffer wrote:
> On 2/28/23 10:15 AM, Adam D Ruppe wrote:
>> On Tuesday, 28 February 2023 at 14:29:28 UTC, Mathias LANG wrote:
>>> Obviously such a change would not happen overnight, and would need broad support from the community. Opinions ?
>> 
>> Here's a wild idea: use the D language. Most the things dub.json defines are already available in D anyway.
>
> Is there a way to do this and prevent mischief? Like maybe:
>
> ```d
> module buildfile;
>
> import safe.modules.only;
>
> static immutable buildcode = import("build.d");
>
> shared static this() {
>    import dparser;
>    parseEnsuringNoImportsOrMixins(buildcode);
> }
>
> void build() {
>    mixin(buildcode);
> }
> ```
>
> -Steve

whats preventing some buildfile from including some malicious cmd line in dub?
if you want to restrict buildfiles, they become pretty useless for a lot of cases
February 28, 2023

On Tuesday, 28 February 2023 at 16:04:42 UTC, H. S. Teoh wrote:

>

On Tue, Feb 28, 2023 at 03:15:33PM +0000, Adam D Ruppe via Digitalmars-d wrote:

>

On Tuesday, 28 February 2023 at 14:29:28 UTC, Mathias LANG wrote:

>

Obviously such a change would not happen overnight, and would need broad support from the community. Opinions ?

Here's a wild idea: use the D language. Most the things dub.json defines are already available in D anyway.

Yes!! This is the way to go.

At least, use a reasonable subset of D if being Turing-complete is not necessarily a good thing. :-P Why make the user learn a different syntax? We're already writing D. Just reuse D syntax.

T

There's a whole world between "imperative" recipes (à la Makefile) and declarative ones. I didn't come up with the declarative decision for dub, but I don't think it makes sense to pivot at this point. And such a pivot would be a much more complex discussion than just the format.

Unless you decide to go with D-style, declarative only DSL, but is there really a point to that ? Also it means writting yet another custom parser, and building something that is inherently not easy to interface with. We want more tooling, not less!

February 28, 2023

On 2/28/23 11:18 AM, Commander Zot wrote:

>

whats preventing some buildfile from including some malicious cmd line in dub?
if you want to restrict buildfiles, they become pretty useless for a lot of cases

You need to at least restrict them to things they should be doing. Opening up the entire world of compiled programs to building means you can make extremely brittle build files.

Note also that with such a mechanism, we can have more control over building than current dub has. For instance, you could configure a global "security" import that validates the build file, so it can e.g. only run approved external programs.

I would also like to draw attention to the dmd build.d setup:

https://github.com/dlang/dmd/blob/master/compiler/src/build.d

It's a complex mess that's nigh unreadable/unmaintainable.

Keeping build files simple should be a goal.

That being said, there are plenty of languages (I know swift is one of them) that use the language to configure/direct builds and package management. I think it's a reasonable and promising idea. We should also be looking at the precedents and see how they tackled it.

-Steve

February 28, 2023
On Tuesday, 28 February 2023 at 16:10:19 UTC, Steven Schveighoffer wrote:
> module buildfile;

This isn't what I'm talking about at all.

I don't want to run D to build, I want to *introspect* D for build info. You can read module names, dependencies (including platform-specific and configuration-specific ones) right out of D code. Author, description, license, etc., have standard ddoc sections in D code.

Other things dub.json define like flags could easily be a UDA on the module declaration and be pulled out pretty easily by compilers or even relatively basic parsers.

Even subconfigurations can... kinda be pulled out of D code by looking for version blocks though that's probably another thing I'd put on a UDA.
February 28, 2023
On Tue, Feb 28, 2023 at 04:32:42PM +0000, Adam D Ruppe via Digitalmars-d wrote:
> On Tuesday, 28 February 2023 at 16:10:19 UTC, Steven Schveighoffer wrote:
> > module buildfile;
> 
> This isn't what I'm talking about at all.
> 
> I don't want to run D to build, I want to *introspect* D for build info. You can read module names, dependencies (including platform-specific and configuration-specific ones) right out of D code. Author, description, license, etc., have standard ddoc sections in D code.
> 
> Other things dub.json define like flags could easily be a UDA on the module declaration and be pulled out pretty easily by compilers or even relatively basic parsers.
> 
> Even subconfigurations can... kinda be pulled out of D code by looking for version blocks though that's probably another thing I'd put on a UDA.

Hmm.  Now THIS is an awesome idea.  Instead of having a separate build description apart from the code, inspect the code itself to figure out how to build it.  With the help of UDAs and other such annotations to help things along.  This is definitely a direction worth exploring!


T

-- 
When you breathe, you inspire. When you don't, you expire. -- The Weekly Reader
February 28, 2023

On Tuesday, 28 February 2023 at 14:29:28 UTC, Mathias LANG wrote:

>

[...]

Is obscurity SDL's biggest downside? When I was a D and DUB initiate, I had no issues acclimating to its usage, especially compared to SBT's DSL. Instead, the source of the friction was due to DUB's documentation, and there's already an effort to improve this.

February 28, 2023
On Tuesday, 28 February 2023 at 16:32:42 UTC, Adam D Ruppe wrote:
> On Tuesday, 28 February 2023 at 16:10:19 UTC, Steven Schveighoffer wrote:
>> module buildfile;
>
> This isn't what I'm talking about at all.
>
> I don't want to run D to build, I want to *introspect* D for build info. You can read module names, dependencies (including platform-specific and configuration-specific ones) right out of D code. Author, description, license, etc., have standard ddoc sections in D code.
>
> Other things dub.json define like flags could easily be a UDA on the module declaration and be pulled out pretty easily by compilers or even relatively basic parsers.
>
> Even subconfigurations can... kinda be pulled out of D code by looking for version blocks though that's probably another thing I'd put on a UDA.

Oh wow, that's definitely an interesting idea.

Have you written down a more refined version of these thoughts?
March 01, 2023

On Tuesday, 28 February 2023 at 15:15:33 UTC, Adam D Ruppe wrote:

>

On Tuesday, 28 February 2023 at 14:29:28 UTC, Mathias LANG wrote:

>

Obviously such a change would not happen overnight, and would need broad support from the community. Opinions ?

Here's a wild idea: use the D language. Most the things dub.json defines are already available in D anyway.

Using D to build D would be great. This reminds me of Ziglang. We can learn from it. I really enjoyed the fact that Zig builds Zig.

Here is a simple template.

I also like the fact that Zig understands and can seamlessly import C.


On the other hand, I'd like the SDL format. It's simple. I was able to understand it and modify the file on the second read.

I don't think adding a new config format is the way to go. It will only add more ambience complexity and confuse users what to choose.

There should be one way to do something and it should good and exhaustive.

March 01, 2023

On Tuesday, 28 February 2023 at 14:29:28 UTC, Mathias LANG wrote:

>

Currently, Dub uses two formats: JSON and SDL.

JSON was there from the beginning, I assume due to Dub's npm inspiration.
In fact, we still very much depend on JSON internally: until recently, JSON object were passed around in quite a few places. When we download a package, regardless of the format the package recipe is in, we store it as dub.json.

[...]

It is safer to just go with whatever is used and accepted as a reliable format for configs. I like the idea to use plain D tbo.

JSON lacks comments, but it's fine for minimal default projects. We try to use TOML everywhere in a company, although I cannot say how well it works as a config for building projects. YAML is the most risky, since it has a high chance to alienate a sizeable amount of potential users.