Re: Module Info error

2017-08-19 Thread Mike Wey via Digitalmars-d-learn

On 19-08-17 04:07, Johnson Jones wrote:

Still getting this!

What I don't understand is why I can import certain libraries and they 
compile fine while others don't!


So, moduleInfo is a "function" per module that is created at 
compilation, right?


If one doesn't compile the module then the error results, just like 
standard extern functions. When I don't include the file in the project, 
it doesn't get compiled, even though it gets "imported"? Why? Why can't 
D just know, hey, module X imports module Y, module Y needs to be 
compiled to add moduleInfo?




For example, I am trying to get ffmpeg to work. I downloaded from

https://github.com/complistic-gaff/ffmpeg-d

extracted, put that path in my includes(sc.ini). created a module to 
import the standard modules, tried to compile my project and I get a 
bunch of ModuleInfo errors relating to the imports I added.


I use GtkD exactly the same, yet no errors.

Now, the only difference is that I import the gtkD.lib. I'm assuming 
that all the moduleInfo's of the 1000+ gtk files are in that lib and so 
That is the reason I don't have the compile them all, is that correct?


If so, how can I generate such a lib of moduleInfo's recursively for a 
directory so I can pick up all the files and just import it once?


ffmpeg doesn't require compiling but I don't wanna have to include ever 
file in to my project just to be able to get it to work because of the 
moduleInfo's are missing.


Looking at the build.d for gtkD, it looks like it builds a list of all 
the files to compile and does it recursively.


I imagine it can be modified for ffmpeg too to create a utility to solve 
this problem. Dmd should have a mode to do this automatically, it's 
quite an annoying problem ;/


You need to either compile ffmpeg-d in to a library and include it when 
you are building your application, or pass all the ffmpeg-d source files 
to the compiler.


It looks like ffmpeg-d only has a dub.json file for building so you will 
need to use dub to build it eg: `dub build` from the root of the project.


--
Mike Wey


Re: Module Info error

2017-08-18 Thread Johnson Jones via Digitalmars-d-learn

On Saturday, 19 August 2017 at 02:07:25 UTC, Johnson Jones wrote:

Still getting this!

What I don't understand is why I can import certain libraries 
and they compile fine while others don't!


So, moduleInfo is a "function" per module that is created at 
compilation, right?


If one doesn't compile the module then the error results, just 
like standard extern functions. When I don't include the file 
in the project, it doesn't get compiled, even though it gets 
"imported"? Why? Why can't D just know, hey, module X imports 
module Y, module Y needs to be compiled to add moduleInfo?




For example, I am trying to get ffmpeg to work. I downloaded 
from


https://github.com/complistic-gaff/ffmpeg-d

extracted, put that path in my includes(sc.ini). created a 
module to import the standard modules, tried to compile my 
project and I get a bunch of ModuleInfo errors relating to the 
imports I added.


I use GtkD exactly the same, yet no errors.

Now, the only difference is that I import the gtkD.lib. I'm 
assuming that all the moduleInfo's of the 1000+ gtk files are 
in that lib and so That is the reason I don't have the compile 
them all, is that correct?


If so, how can I generate such a lib of moduleInfo's 
recursively for a directory so I can pick up all the files and 
just import it once?


ffmpeg doesn't require compiling but I don't wanna have to 
include ever file in to my project just to be able to get it to 
work because of the moduleInfo's are missing.


Looking at the build.d for gtkD, it looks like it builds a list 
of all the files to compile and does it recursively.


I imagine it can be modified for ffmpeg too to create a utility 
to solve this problem. Dmd should have a mode to do this 
automatically, it's quite an annoying problem ;/


So, I was able to hack the build script and solve my problem. I 
simply replaced the dir entries and such for ffmpeg instead.




module Build;

import core.stdc.stdlib: exit;

import std.algorithm;
import std.array;
import std.file;
import std.getopt;
import std.path;
import std.process;
import std.stdio;
import std.string;

string dcflags;
string ldflags;

int main(string[] args)
{

build("ffmpeg", "ffmpeg");


return(0);
}

void build(string dir, string lib)
{
version(Win64)
{
		std.file.write("build.rf", format("-m64 -c -lib %s %s 
-Igenerated/gtkd -of%s.lib %s", dcflags, ldflags, lib, 
dFiles(dir)));

auto pid = spawnProcess(["dmd", "@build.rf"]);

if ( wait(pid) != 0 )
exit(1);
}
else
{
if (lib == "gtkd")
{
			string[] subDirs = ["libavcodec", "libavdevice", 
"libavfilter", "libavformat", "libavutil", "libswscale"];


foreach(directory; subDirs)
buildObj(dFiles(directory), directory);

string objects;
foreach(directory; subDirs)
objects ~= directory ~".obj ";

			executeShell(format("dmd -lib %s -of%s.lib %s", ldflags, lib, 
objects));


foreach(directory; subDirs)
std.file.remove(directory ~".obj");
}
else
{
buildObj(dFiles(dir), lib);
			executeShell(format("dmd -lib %s -of%s.lib %s.obj", ldflags, 
lib, lib));

std.file.remove(lib ~".obj");
}
}

std.file.remove("build.rf");
}

void buildObj(string files, string objName)
{
	std.file.write("build.rf", format("-c %s -Igenerated/gtkd 
-of%s.obj %s", dcflags, objName, files));

auto pid = spawnProcess(["dmd", "@build.rf"]);
if ( wait(pid) != 0 )
exit(1);
}

string dFiles(string sourceDir)
{
string files;
auto entries = dirEntries(sourceDir, SpanMode.breadth);

foreach ( DirEntry entry; entries )
{
if ( entry.isDir == false && entry.name.extension == ".d" )
{
files ~= entry.name ~ " ";
}
}

return files;
}


So the question is, is there a direct way to do this? e.g., have 
dmd do it recursively for us, or rdmd, or a tool that is designed 
to do stuff like this for the general case? (the above code could 
be made more general, which I might do in the future)


Module Info error

2017-08-18 Thread Johnson Jones via Digitalmars-d-learn

Still getting this!

What I don't understand is why I can import certain libraries and 
they compile fine while others don't!


So, moduleInfo is a "function" per module that is created at 
compilation, right?


If one doesn't compile the module then the error results, just 
like standard extern functions. When I don't include the file in 
the project, it doesn't get compiled, even though it gets 
"imported"? Why? Why can't D just know, hey, module X imports 
module Y, module Y needs to be compiled to add moduleInfo?




For example, I am trying to get ffmpeg to work. I downloaded from

https://github.com/complistic-gaff/ffmpeg-d

extracted, put that path in my includes(sc.ini). created a module 
to import the standard modules, tried to compile my project and I 
get a bunch of ModuleInfo errors relating to the imports I added.


I use GtkD exactly the same, yet no errors.

Now, the only difference is that I import the gtkD.lib. I'm 
assuming that all the moduleInfo's of the 1000+ gtk files are in 
that lib and so That is the reason I don't have the compile them 
all, is that correct?


If so, how can I generate such a lib of moduleInfo's recursively 
for a directory so I can pick up all the files and just import it 
once?


ffmpeg doesn't require compiling but I don't wanna have to 
include ever file in to my project just to be able to get it to 
work because of the moduleInfo's are missing.


Looking at the build.d for gtkD, it looks like it builds a list 
of all the files to compile and does it recursively.


I imagine it can be modified for ffmpeg too to create a utility 
to solve this problem. Dmd should have a mode to do this 
automatically, it's quite an annoying problem ;/