Re: Packages and module import
On 2018-03-21 17:06, Russel Winder wrote: No I wasn't. And it works a treat. Cool :). I recommend having a look at the changelog and the usage information (--help). -- /Jacob Carlborg
Re: Packages and module import
On Tue, 2018-03-20 at 22:08 +0100, Jacob Carlborg via Digitalmars-d- learn wrote: > […] > Not sure if this will help, but are you aware that DStep can add a > package to the module declaration using "--package"? No I wasn't. And it works a treat. -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
Re: Packages and module import
On 2018-03-19 18:29, Russel Winder wrote: I had assumed that a directory of modules was a package. So for example: A/a.d A/b.d were two modules in package A. Especially given there is a module statement at the beginning of each module: A/a.d has module A.a; A/b.d has module A.b; Now A.b needs to access something from A.a. I had assumed that the import should be fully qualified. So in A.b.d: import A.a: thing; This all works when building the library. ldc2 -of=Build/Release/libdvbv5_d.so -shared -defaultlib=phobos2-ldc Build/Release/source/libdvbv5_d/linux_dmx.o Build/Release/source/libdvbv5_d/dvb_v5_std.o Build/Release/source/libdvbv5_d/dvb_frontend.o Build/Release/source/libdvbv5_d/dvb_log.o Build/Release/source/libdvbv5_d/dvb_demux.o Build/Release/source/libdvbv5_d/dvb_fe.o Build/Release/source/libdvbv5_d/dvb_file.o Build/Release/source/libdvbv5_d/dvb_scan.o Build/Release/source/libdvbv5_d/dvb_sat.o -L-ldruntime-ldc However when trying to build the unit-tests: ldc2 -I=source -unittest --main -of=Build/Test/libdvbv5_d source/libdvbv5_d/linux_dmx.d source/libdvbv5_d/dvb_v5_std.d source/libdvbv5_d/dvb_frontend.d source/libdvbv5_d/dvb_log.d source/libdvbv5_d/dvb_demux.d source/libdvbv5_d/dvb_fe.d source/libdvbv5_d/dvb_file.d source/libdvbv5_d/dvb_scan.d source/libdvbv5_d/dvb_sat.d source/libdvbv5_d/dvb_demux.d(35): Error: module linux_dmx from file source/libdvbv5_d/linux_dmx.d must be imported with 'import linux_dmx;' Am I just missing something simple? Not sure if this will help, but are you aware that DStep can add a package to the module declaration using "--package"? -- /Jacob Carlborg
Re: Packages and module import
On Mon, 2018-03-19 at 11:56 -0600, Jonathan M Davis via Digitalmars-d- learn wrote: > > […] > Well, what's the module statement in linux_dmx.d look like? > There wasn't one, even though I knew there was one. -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
Re: Packages and module import
On Mon, 2018-03-19 at 17:49 +, Adam D. Ruppe via Digitalmars-d- learn wrote: > […] > > Odds are, linux_dmx.d is missing the `module > libdvbv5_d.linux_dmx;` line. > […] You are right. I was certain I had correct module statements in all the modules, but I hadn't. -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
Re: Packages and module import
On Monday, March 19, 2018 17:29:10 Russel Winder via Digitalmars-d-learn wrote: > I had assumed that a directory of modules was a package. So for > example: > > A/a.d > A/b.d > > were two modules in package A. Especially given there is a module > statement at the beginning of each module: > > A/a.d has module A.a; > A/b.d has module A.b; > > Now A.b needs to access something from A.a. I had assumed that the > import should be fully qualified. So in A.b.d: > > import A.a: thing; > > This all works when building the library. Yes packages are directories and modules are files, but that can be mucked with on some level by explicitly marking the module with a module path that doesn't match its directory structure. If you do that, that tends to cause problems with the compiler finding your module to import, and build tools like rdmd and dub assume that the module's import path matches the file structure, but it's unfortunately not actually required, much as conceptually, that's the idea. > ldc2 -of=Build/Release/libdvbv5_d.so -shared -defaultlib=phobos2-ldc > Build/Release/source/libdvbv5_d/linux_dmx.o > Build/Release/source/libdvbv5_d/dvb_v5_std.o > Build/Release/source/libdvbv5_d/dvb_frontend.o > Build/Release/source/libdvbv5_d/dvb_log.o > Build/Release/source/libdvbv5_d/dvb_demux.o > Build/Release/source/libdvbv5_d/dvb_fe.o > Build/Release/source/libdvbv5_d/dvb_file.o > Build/Release/source/libdvbv5_d/dvb_scan.o > Build/Release/source/libdvbv5_d/dvb_sat.o -L-ldruntime-ldc > > > However when trying to build the unit-tests: > > > ldc2 -I=source -unittest --main -of=Build/Test/libdvbv5_d > source/libdvbv5_d/linux_dmx.d source/libdvbv5_d/dvb_v5_std.d > source/libdvbv5_d/dvb_frontend.d source/libdvbv5_d/dvb_log.d > source/libdvbv5_d/dvb_demux.d source/libdvbv5_d/dvb_fe.d > source/libdvbv5_d/dvb_file.d source/libdvbv5_d/dvb_scan.d > source/libdvbv5_d/dvb_sat.d source/libdvbv5_d/dvb_demux.d(35): Error: > module linux_dmx from file source/libdvbv5_d/linux_dmx.d must be imported > with 'import linux_dmx;' > > > Am I just missing something simple? Well, what's the module statement in linux_dmx.d look like? For better or worse, while the compiler will infer a module's name from the file name if you don't give it one, it won't infer the pcakage name. So, if you have no module declaration in linux_dmx.d, then it's going to be inferred as being the module linux_dmx with no package. So, that may or may not be part of your problem. Based on what you posted, it's not at all clear to me how you're building this stuff. The first example without -unittest is just dealing with .o files and not having to deal with imports at all. To know how that's being dealt with would require the command-line associated with generating the .o files. Also, if the import that's being complained about is in a unit test and isn't imported outside of one, then the problem relating to the import wouldn't be found when building without -unittest. The same would frequently be true if it's a template, since often, templates aren't instantiated outside of unit tests when compiling a library. - Jonathan M Davis
Re: Packages and module import
On Monday, 19 March 2018 at 17:29:10 UTC, Russel Winder wrote: I had assumed that a directory of modules was a package. So for example: [...] On Monday, 19 March 2018 at 17:29:10 UTC, Russel Winder wrote: To my amateur eyes, first command-line build looks like a linking of object files into a .so. The second command-line build looks like compilation is taking place. Seems like the command-line used to compile the library is missing.
Re: Packages and module import
On Monday, 19 March 2018 at 17:29:10 UTC, Russel Winder wrote: Especially given there is a module statement at the beginning of each module: It is not especially, it is ONLY because of the module statement. The directory layout is a convention so tools can find the module file, but only the module declaration line in the code itself defines the authoritative name. source/libdvbv5_d/dvb_demux.d(35): Error: module linux_dmx from file source/libdvbv5_d/linux_dmx.d must be imported with 'import linux_dmx;' Odds are, linux_dmx.d is missing the `module libdvbv5_d.linux_dmx;` line. Any import statements and module statements need to use the same name. The layout in the file system is secondary to this.
Packages and module import
I had assumed that a directory of modules was a package. So for example: A/a.d A/b.d were two modules in package A. Especially given there is a module statement at the beginning of each module: A/a.d has module A.a; A/b.d has module A.b; Now A.b needs to access something from A.a. I had assumed that the import should be fully qualified. So in A.b.d: import A.a: thing; This all works when building the library. ldc2 -of=Build/Release/libdvbv5_d.so -shared -defaultlib=phobos2-ldc Build/Release/source/libdvbv5_d/linux_dmx.o Build/Release/source/libdvbv5_d/dvb_v5_std.o Build/Release/source/libdvbv5_d/dvb_frontend.o Build/Release/source/libdvbv5_d/dvb_log.o Build/Release/source/libdvbv5_d/dvb_demux.o Build/Release/source/libdvbv5_d/dvb_fe.o Build/Release/source/libdvbv5_d/dvb_file.o Build/Release/source/libdvbv5_d/dvb_scan.o Build/Release/source/libdvbv5_d/dvb_sat.o -L-ldruntime-ldc However when trying to build the unit-tests: ldc2 -I=source -unittest --main -of=Build/Test/libdvbv5_d source/libdvbv5_d/linux_dmx.d source/libdvbv5_d/dvb_v5_std.d source/libdvbv5_d/dvb_frontend.d source/libdvbv5_d/dvb_log.d source/libdvbv5_d/dvb_demux.d source/libdvbv5_d/dvb_fe.d source/libdvbv5_d/dvb_file.d source/libdvbv5_d/dvb_scan.d source/libdvbv5_d/dvb_sat.d source/libdvbv5_d/dvb_demux.d(35): Error: module linux_dmx from file source/libdvbv5_d/linux_dmx.d must be imported with 'import linux_dmx;' Am I just missing something simple? -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part