Re: How to organize a project with local scripts in subdirectories using dub?

2019-12-11 Thread Pavel Shkadzko via Digitalmars-d-learn

On Wednesday, 11 December 2019 at 16:06:30 UTC, drug wrote:


Add to dub.json:
"targetType": "executable"

and it will build executable. Or rename evaluator.d to app.d
It is confused that there is no app.d so it thinks that you 
build a library.


I added "targetType" and now everything works without renaming to 
the script to "app.d". Thank you!


Re: How to organize a project with local scripts in subdirectories using dub?

2019-12-11 Thread drug via Digitalmars-d-learn

On 12/11/19 6:52 PM, Pavel Shkadzko wrote:


It works like this, yes. However, by default it builds a "library" while 
I want to run "evaluator" as a script which uses other scripts by 
calling their functions.


Doing:
dub --compiler=ldc2 --single evaluator.d // throws an error

source\evaluator.d(93,12): Error: module runme_1 is in file 'runme_1.d' 
which cannot be read



Add to dub.json:
"targetType": "executable"

and it will build executable. Or rename evaluator.d to app.d
It is confused that there is no app.d so it thinks that you build a 
library.





Re: How to organize a project with local scripts in subdirectories using dub?

2019-12-11 Thread Pavel Shkadzko via Digitalmars-d-learn

On Wednesday, 11 December 2019 at 13:00:32 UTC, drug wrote:


I would restructure your
folders this way:
my_proj/
source/
script_1/runme_1.d
script_2/runme_2.d
evaluator.d

then using `dub --compiler=ldc2`


It works like this, yes. However, by default it builds a 
"library" while I want to run "evaluator" as a script which uses 
other scripts by calling their functions.


Doing:
dub --compiler=ldc2 --single evaluator.d // throws an error

source\evaluator.d(93,12): Error: module runme_1 is in file 
'runme_1.d' which cannot be read





Re: How to organize a project with local scripts in subdirectories using dub?

2019-12-11 Thread drug via Digitalmars-d-learn

On 12/11/19 2:18 PM, Pavel Shkadzko wrote:

I have the following project structure.

my_proj/
     script_1/runme_1.d
     script_2/runme_2.d
     evaluator.d

The project has a library dependency:

"dependencies": {
     "mir": "~>3.2.0",
},

The "evaluator.d" script contains some general functions that convert 
dataset and pass it to "runme_1.d" and "runme_2.d" scripts the following 
way:


import mir.ndslice;

void main() {
     import script_1.runme_1 : runTask1;
     import script_2.runme_2 : runTask2;

     mir_slice!(real*, 1LU, cast(mir_slice_kind)2)[]) dataset = 
convertDataset("data.txt");

     runTask1(dataset);
     //runTask2(dataset); //disable for now
}

So, basically what I need is to be able to run "./evaluator" and get the 
results by running the corresponding scripts.


I am trying to build the project the following way:

dub build --compiler=ldc2 --single evaluator.d

I get the following error:

Performing "debug" build using ldc2 for x86_64.
mir-core 1.0.2: target for configuration "library" is up to date.
mir-algorithm 3.7.2: target for configuration "default" is up to date.
mir-linux-kernel 1.0.1: target for configuration "library" is up to date.
mir-random 2.2.8: target for configuration "extended" is up to date.
survey ~master: building configuration "application"...
lld-link: error: undefined symbol: 
_D5runme_114runTask1FS3mir7ndslice5slice__T9mir_sliceTPeVmi2VEQBoQBnQBi14mir_slice_kindi2ZQBvZv 


referenced by C:\Users\user\my_proj\evaluator.d:89
  .dub\obj\evaluator.obj:(_Dmain)

Error: linking with LLD failed
ldc2 failed with exit code 1.

How should I organize my project for this kind of setup?

(I am sorry for the absence of code formatting. I could not find any 
quick howto here)





I would restructure your
folders this way:
my_proj/
source/
script_1/runme_1.d
script_2/runme_2.d
evaluator.d

then using `dub --compiler=ldc2`