DUB is not working correctly
Hello, I have problems with working in dub environment. If I try to init my project with 'dub init', all needed files will be created successfully. However, when I run 'dub run', the manager gives me an error: 'Configuration 'application' of package application contains no source files. Please add {"targetType": "none"} to its package description to avoid building it. Package with target type "none" must have dependencies to build.' If I set targetType in dub.json to "none", the only message: 'Package with target type "none" must have dependencies to build.' will remain. When I set targetName to "app" or any other name, the problem will appear again with the same message above. I flicked through many forums and videos how to correctly install dub, and nothing helped. I am using dub 1.23.0 built on Sep 25 2020 on Windows 10 x64. Will be very thankful for your help!
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 16:13:48 UTC, Maxim wrote: Hello, I have problems with working in dub environment. If I try to init my project with 'dub init', all needed files will be created successfully. However, when I run 'dub run', the manager gives me an error: 'Configuration 'application' of package application contains no source files. Please add {"targetType": "none"} to its package description to avoid building it. Package with target type "none" must have dependencies to build.' If I set targetType in dub.json to "none", the only message: 'Package with target type "none" must have dependencies to build.' will remain. When I set targetName to "app" or any other name, the problem will appear again with the same message above. I flicked through many forums and videos how to correctly install dub, and nothing helped. I am using dub 1.23.0 built on Sep 25 2020 on Windows 10 x64. Will be very thankful for your help! Doesn't seem like an installation problem. Could you post your dub.json contents and describe what you are trying to achieve? Do you have your source files in 'src' or 'source' folder next to the dub.json file? If not, you need to tell dub to treat any other non conventional folder as source location.
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 16:27:49 UTC, evilrat wrote: On Wednesday, 24 February 2021 at 16:13:48 UTC, Maxim wrote: Hello, I have problems with working in dub environment. If I try to init my project with 'dub init', all needed files will be created successfully. However, when I run 'dub run', the manager gives me an error: 'Configuration 'application' of package application contains no source files. Please add {"targetType": "none"} to its package description to avoid building it. Package with target type "none" must have dependencies to build.' If I set targetType in dub.json to "none", the only message: 'Package with target type "none" must have dependencies to build.' will remain. When I set targetName to "app" or any other name, the problem will appear again with the same message above. I flicked through many forums and videos how to correctly install dub, and nothing helped. I am using dub 1.23.0 built on Sep 25 2020 on Windows 10 x64. Will be very thankful for your help! Doesn't seem like an installation problem. Could you post your dub.json contents and describe what you are trying to achieve? Do you have your source files in 'src' or 'source' folder next to the dub.json file? If not, you need to tell dub to treat any other non conventional folder as source location. Sure, here are dub.json contents: { "authors": [ "Max" ], "copyright": "Copyright © 2021, Max", "description": "A minimal D application.", "license": "proprietary", "dependencies": { "dsfml": "~>2.1.1" }, "targetType": "none", "targetName": "app", "name": "test" } I just want to run it by typing 'dub run'. But the error message says that I need to set targetType to none, add targetName and dependencies for it. I have folder source next to dub.json. I'd better show you my project structure: test | source | app.d | dub.json
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 16:46:20 UTC, Maxim wrote: Sure, here are dub.json contents: { "authors": [ "Max" ], "copyright": "Copyright © 2021, Max", "description": "A minimal D application.", "license": "proprietary", "dependencies": { "dsfml": "~>2.1.1" }, "targetType": "none", "targetName": "app", "name": "test" } I just want to run it by typing 'dub run'. But the error message says that I need to set targetType to none, add targetName and dependencies for it. ok, you don't need targetType in this case, setting it to none means it will do nothing. the original message likely related to dsmfl which haven't been updated since 2016, maybe you can try another package, for example bindbc-smfl (there is older 'derelict' series, and 'bindbc' series which is newer and recommended over derelict) https://code.dlang.org/packages/bindbc-sfml
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 17:27:19 UTC, evilrat wrote: On Wednesday, 24 February 2021 at 16:46:20 UTC, Maxim wrote: Sure, here are dub.json contents: { "authors": [ "Max" ], "copyright": "Copyright © 2021, Max", "description": "A minimal D application.", "license": "proprietary", "dependencies": { "dsfml": "~>2.1.1" }, "targetType": "none", "targetName": "app", "name": "test" } I just want to run it by typing 'dub run'. But the error message says that I need to set targetType to none, add targetName and dependencies for it. ok, you don't need targetType in this case, setting it to none means it will do nothing. the original message likely related to dsmfl which haven't been updated since 2016, maybe you can try another package, for example bindbc-smfl (there is older 'derelict' series, and 'bindbc' series which is newer and recommended over derelict) https://code.dlang.org/packages/bindbc-sfml Unfortunately, I tried bindbc-sfml package but the problem is still existing. I also started a new project and without any changes ran it but the result was the same. Anyway, thank you so much for your help!
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 16:13:48 UTC, Maxim wrote: Hello, I have problems with working in dub environment. If I try to init my project with 'dub init', all needed files will be created successfully. However, when I run 'dub run', the manager gives me an error: [...] Wierd, have never encountered that. I'm also using Win 10 x64.
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 17:45:56 UTC, Maxim wrote: Unfortunately, I tried bindbc-sfml package but the problem is still existing. I also started a new project and without any changes ran it but the result was the same. Anyway, thank you so much for your help! does it works for an empty project created with 'dub init' from terminal?
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 18:21:40 UTC, evilrat wrote: On Wednesday, 24 February 2021 at 17:45:56 UTC, Maxim wrote: Unfortunately, I tried bindbc-sfml package but the problem is still existing. I also started a new project and without any changes ran it but the result was the same. Anyway, thank you so much for your help! does it works for an empty project created with 'dub init' from terminal? No, it doesn't work on an empty project with 'dub init'.
Re: Compile-Time Function Parameters That Aren't Types?
On Wednesday, 24 February 2021 at 06:18:02 UTC, H. S. Teoh wrote: Usually it's when there's a decision that needs to be made at compile-time (or desirable to be made at compile-time for whatever reason). For example, if there are two very different branches of code that should run depending on the value of parameter, and user code is expected to want only one or the other code path, so fixing the code path at compile-time may be advantageous. D's operator overloading is one example of this. It takes a compile-time string containing the operator, which lets the implementor choose whether to implement multiple operator overloads separately, or grouped together in a common implementation. E.g.: Thank you for the additional clarification with a new example. Compile-time parameters are indeed a powerful tool.
Re: DUB is not working correctly
On Wed, Feb 24, 2021 at 06:32:00PM +, Maxim via Digitalmars-d-learn wrote: > On Wednesday, 24 February 2021 at 18:21:40 UTC, evilrat wrote: > > On Wednesday, 24 February 2021 at 17:45:56 UTC, Maxim wrote: > > > > > > Unfortunately, I tried bindbc-sfml package but the problem is > > > still existing. I also started a new project and without any > > > changes ran it but the result was the same. Anyway, thank you so > > > much for your help! > > > > does it works for an empty project created with 'dub init' from > > terminal? > > No, it doesn't work on an empty project with 'dub init'. Sounds like something is wrong with your toolchain installation. An empty project ought to work. Maybe try a fresh reinstall? T -- BREAKFAST.COM halted...Cereal Port Not Responding. -- YHL
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 18:52:12 UTC, H. S. Teoh wrote: On Wed, Feb 24, 2021 at 06:32:00PM +, Maxim via Digitalmars-d-learn wrote: On Wednesday, 24 February 2021 at 18:21:40 UTC, evilrat wrote: > On Wednesday, 24 February 2021 at 17:45:56 UTC, Maxim wrote: > > > > Unfortunately, I tried bindbc-sfml package but the problem > > is still existing. I also started a new project and > > without any changes ran it but the result was the same. > > Anyway, thank you so much for your help! > > does it works for an empty project created with 'dub init' > from terminal? No, it doesn't work on an empty project with 'dub init'. Sounds like something is wrong with your toolchain installation. An empty project ought to work. Maybe try a fresh reinstall? T I recently tried that. Even compiler was reinstalled. It didn't help.
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 19:04:02 UTC, Maxim wrote: On Wednesday, 24 February 2021 at 18:52:12 UTC, H. S. Teoh I recently tried that. Even compiler was reinstalled. It didn't help. Just try remove dsfml and all depencies. My void "dub init"? which works { "authors": [ "zws" ], "copyright": "Copyright © 2021, zws", "description": "A minimal D application.", "license": "proprietary", "name": "d_dub" }
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 19:18:32 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:04:02 UTC, Maxim wrote: On Wednesday, 24 February 2021 at 18:52:12 UTC, H. S. Teoh I recently tried that. Even compiler was reinstalled. It didn't help. Just try remove dsfml and all depencies. My void "dub init"? which works { "authors": [ "zws" ], "copyright": "Copyright © 2021, zws", "description": "A minimal D application.", "license": "proprietary", "name": "d_dub" } Unfortunately, the program is still saying me: 'Configuration 'application' of package d_dub contains no source files. Please add {"targetType": "none"} to its package description to avoid building it. Package with target type "none" must have dependencies to build.'
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 19:35:46 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:18:32 UTC, Siemargl wrote: [...] Yes, i see th error. If in your dub.json change > "targetType": "executable", [...] Tried and everything seems to be okay with underscores but the error message about the targetType appears even when I start my new pure project without any dependencies.
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 19:42:05 UTC, Maxim wrote: On Wednesday, 24 February 2021 at 19:35:46 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:18:32 UTC, Siemargl wrote: [...] Yes, i see th error. If in your dub.json change > "targetType": "executable", [...] Tried and everything seems to be okay with underscores but the error message about the targetType appears even when I start my new pure project without any dependencies. Just downloaded latest dmd 2.095.1, it comes with dub 1.24.1 Works fine on void dub init project, but underscore problem whith dsfml still here
Re: Introspection of exceptions that a function can throw
On Wednesday, 24 February 2021 at 19:38:53 UTC, Mark wrote: Is there a way to obtain a list, at compile-time, of all the exception types that a function might throw (directly or through a call to another function)? Thanks. I don't believe that there's any built-in way, as that'd mean that functions would have to define what they throw as part of their signature (like in Java). But you can semi-emulate it with metaprogramming, it's just that you'll have to manually keep all the information up to date. Here's an example: https://run.dlang.io/is/UUHumO Which supports saying what a function directly throws (`@Throws`), and also saying what functions it calls that may also throw well-defined exceptions (`@ThrowsInclude`), and results in `(Exception, MyExcept)`
Re: Introspection of exceptions that a function can throw
On Wednesday, 24 February 2021 at 19:38:53 UTC, Mark wrote: Is there a way to obtain a list, at compile-time, of all the exception types that a function might throw (directly or through a call to another function)? No, since this is not known at compile-time. See: https://forum.dlang.org/post/qnarroejixxtqxjiw...@forum.dlang.org
Re: Introspection of exceptions that a function can throw
On Wednesday, 24 February 2021 at 19:58:41 UTC, SealabJaster wrote: ... Just realised that can include duplicates, but there's std.meta.NoDuplicates to solve that.
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 19:48:10 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:42:05 UTC, Maxim wrote: On Wednesday, 24 February 2021 at 19:35:46 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:18:32 UTC, Siemargl wrote: [...] Yes, i see th error. If in your dub.json change > "targetType": "executable", [...] Tried and everything seems to be okay with underscores but the error message about the targetType appears even when I start my new pure project without any dependencies. Just downloaded latest dmd 2.095.1, it comes with dub 1.24.1 Works fine on void dub init project, but underscore problem whith dsfml still here I think that dsfml itself causing this problem with underscores. As evilrat said, dsfml haven't been updated since 2016.
Re: Can Metaprogramming Help Here?
On Tuesday, 23 February 2021 at 22:55:53 UTC, H. S. Teoh wrote: On Tue, Feb 23, 2021 at 10:24:50PM +, Mike Brown via Digitalmars-d-learn wrote: Hi all, Im porting some C++ code, which has a mess of a section that implements prime number type id's. I've had to smother it to death with test cases to get it reliable, I think metaprogramming that D provides is the better solution - Id rather not reimplement that C++ mess ideally. Try something like this: -snip- import std; int[] firstNPrimes(int n) { // FIXME: replace this with actual primes computation return [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 ]; } string genEnum(string enumName, idents...)() { string code = "enum " ~ enumName ~ " {"; auto primes = firstNPrimes(idents.length); foreach (i, ident; idents) { code ~= ident ~ " = " ~ primes[i].to!string ~ ", "; } code ~= "}"; return code; } template PrimeEnum(idents...) { mixin(genEnum!("PrimeEnum", idents)); } alias MyEnum = PrimeEnum!( "unknown", "newline", "identifier", "var", "user_defined", ); void main() { writefln("%(%d\n%)", [ MyEnum.unknown, MyEnum.newline, MyEnum.identifier, MyEnum.var, MyEnum.user_defined ]); } -snip- You can substitute the body of firstNPrimes with any standard prime-generation algorithm. As long as it's not too heavyweight, you should be able to get it to compile without the compiler soaking up unreasonable amounts of memory. :-D If you find the compiler using up too much memory, try precomputing the list of primes beforehand and pasting it into firstNPrimes (so that the CTFE engine doesn't have to recompute it every time you compile). Note that PrimeEnum can be used to generate any number of enums you wish to have prime values. Or if you replace the call to firstNPrimes with something else, you can generate enums whose identifiers map to any integer sequence of your choosing. T Hi T, Thank you for the reply. Im struggling extending this to get the nesting working. I'm trying something like: string entry(string i, string[] inherit = []) { return i; } alias token_type2 = PrimeEnum!( entry("unknown"), entry("newline"), entry("identifier"), entry("var", ["identifier"]), entry("userDefined", ["identifier"]) ); Its worth noting that multiple inherited bases are needed too. But I can't get those functions contexts linking, can I pass a function pointer as lazy into the PrimeEnum!() template? Would it be easier to just parse the text at once into a single templating function? Kind regards, Mike Brown
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 19:48:10 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:42:05 UTC, Maxim wrote: On Wednesday, 24 February 2021 at 19:35:46 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:18:32 UTC, Siemargl wrote: [...] Yes, i see th error. If in your dub.json change > "targetType": "executable", [...] Tried and everything seems to be okay with underscores but the error message about the targetType appears even when I start my new pure project without any dependencies. Just downloaded latest dmd 2.095.1, it comes with dub 1.24.1 Works fine on void dub init project, but underscore problem whith dsfml still here I think, its a problem with dsfml project. You can see it in %userprofile%\AppData\Local\dub\packages\dsfml-2.1.1\dsfml There is a build.d build program, i compile it and build.exe -unittest fails, can see source code : Needed depencies dsfmlc-*.lib (note 'c' on tth end!)
Re: Compile-Time Function Parameters That Aren't Types?
On 2/23/21 7:52 PM, Kyle Ingraham wrote: Where would one find information on this There are Point and Polygon struct templates on the following page where one can pick e.g. the dimension (e.g. three dimensional space) by a size_t template parameter. http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.value%20template%20parameter Ali
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 20:10:29 UTC, Siemargl wrote: Works fine on void dub init project, but underscore problem whith dsfml still here I think, its a problem with dsfml project. You can see it in %userprofile%\AppData\Local\dub\packages\dsfml-2.1.1\dsfml There is a build.d build program, i compile it and build.exe -unittest fails, can see source code : Needed depencies dsfmlc-*.lib (note 'c' on tth end!) So its not a dub problem, just needed dsfmlc-*.libs, which is not a part of a dsfml-2.1.1, but maybe external to C-linking libraries.
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 20:10:29 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:48:10 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:42:05 UTC, Maxim wrote: On Wednesday, 24 February 2021 at 19:35:46 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 19:18:32 UTC, Siemargl wrote: [...] Yes, i see th error. If in your dub.json change > "targetType": "executable", [...] Tried and everything seems to be okay with underscores but the error message about the targetType appears even when I start my new pure project without any dependencies. Just downloaded latest dmd 2.095.1, it comes with dub 1.24.1 Works fine on void dub init project, but underscore problem whith dsfml still here I think, its a problem with dsfml project. You can see it in %userprofile%\AppData\Local\dub\packages\dsfml-2.1.1\dsfml There is a build.d build program, i compile it and build.exe -unittest fails, can see source code : Needed depencies dsfmlc-*.lib (note 'c' on tth end!) Thanks for the tip! Anyway, if I understood right, I would add "dsfmlc-*.lib" to dependencies in my dub.json. But it needs a version which I don't know. So, I tried to put '"dependencies": { "dsfmlc-*.lib": "~>2.1.1" }' in the file but it didn't compile because of wrong version. I am sorry if I got you wrong.
Re: DUB is not working correctly
On Wednesday, 24 February 2021 at 20:28:45 UTC, Siemargl wrote: On Wednesday, 24 February 2021 at 20:10:29 UTC, Siemargl wrote: Works fine on void dub init project, but underscore problem whith dsfml still here I think, its a problem with dsfml project. You can see it in %userprofile%\AppData\Local\dub\packages\dsfml-2.1.1\dsfml There is a build.d build program, i compile it and build.exe -unittest fails, can see source code : Needed depencies dsfmlc-*.lib (note 'c' on tth end!) So its not a dub problem, just needed dsfmlc-*.libs, which is not a part of a dsfml-2.1.1, but maybe external to C-linking libraries. I agree with you. Well, dsfml is a very old library. It's a pity that the main problem of this topic was caused not because of dsfml but something else. In any case, thank you very much for your help!
byte array to string
hi all, If i have an array: byte[3] = [1,2,3]; How to get string "123" from it? Thanks in advance.
string to type
Say, please, how to convert string to type ? Is: interface IX { // } mixin template X() { // } // Mixin templates to class. // Scan class interfaces, then mix mixin template Members() { alias T = typeof( this ); static foreach ( IFACE; InterfacesTuple! T ) { pragma( msg, IFACE ); pragma( msg, IFACE.stringof[ 1 .. $ ] ); static if ( IFACE.stringof.length > 1 && IFACE.stringof[ 1 .. $ ] ) { mixin ( IFACE.stringof[ 1 .. $ ] )!(); // <-- HERE TROUBLE } } } class A : IX { mixin Members!(); } Want: // Mixin template mixin IFACE.stringof[ 1 .. $ ] !(); Got: Compilation error: "declaration expected" source: https://run.dlang.io/is/smFaWc Help wanted.
Re: string to type
On Thursday, 25 February 2021 at 06:51:11 UTC, Виталий Фадеев wrote: Say, please, how to convert string to type ? [...] Simple version of this question is: string t = "X"; mixin t!(); // <-- HERE TROUBLE
Re: byte array to string
On Thursday, 25 February 2021 at 06:47:11 UTC, Mike wrote: hi all, If i have an array: byte[3] = [1,2,3]; How to get string "123" from it? Thanks in advance. string str = format!"%(%s)"(array);
Re: byte array to string
On Thursday, 25 February 2021 at 06:57:57 UTC, FeepingCreature wrote: On Thursday, 25 February 2021 at 06:47:11 UTC, Mike wrote: hi all, If i have an array: byte[3] = [1,2,3]; How to get string "123" from it? Thanks in advance. string str = format!"%(%s)"(array); Er sorry, typo, that should be "%(%s%)". "Print the elements of the array, separated by nothing." Compare "%(%s, %)" for a comma separated list.
Re: string to type
On Thursday, 25 February 2021 at 06:53:28 UTC, Виталий Фадеев wrote: On Thursday, 25 February 2021 at 06:51:11 UTC, Виталий Фадеев wrote: Say, please, how to convert string to type ? [...] Simple version of this question is: string t = "X"; mixin t!(); // <-- HERE TROUBLE I was stupid. Solution is: mixin ( "mixin " ~ IFACE.stringof[ 1 .. $ ] ~ "!();" ); Thanks!
Re: byte array to string
On Thursday, 25 February 2021 at 06:58:51 UTC, FeepingCreature wrote: On Thursday, 25 February 2021 at 06:57:57 UTC, FeepingCreature wrote: On Thursday, 25 February 2021 at 06:47:11 UTC, Mike wrote: hi all, If i have an array: byte[3] = [1,2,3]; How to get string "123" from it? Thanks in advance. string str = format!"%(%s)"(array); Er sorry, typo, that should be "%(%s%)". "Print the elements of the array, separated by nothing." Compare "%(%s, %)" for a comma separated list. Thanks a lot. Keep playing.