Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Issue 3541 - Add -oq to dmd (use fully qualified module name as object filename) #563

Merged
merged 2 commits into from

4 participants

@jacob-carlborg

Issue 3541 - Add -oq to dmd (use fully qualified module name as object filename).

Trying this again, I've just updated my fork. I have tested this on Mac OS X by running the Phobos unit tests and they all DO PASS. The command line I used to run the unit tests was "make unittest".

http://d.puremagic.com/issues/show_bug.cgi?id=3541

@jacob-carlborg jacob-carlborg Revert "revert pull 169"
This reverts commit 9d664ad3a00d2a09be3aa67cdebb4d4641cdb42f.
44265f9
src/mars.c
@@ -207,7 +207,7 @@ void verror(Loc loc, const char *format, va_list ap)
#endif
fprintf(stdmsg, "\n");
fflush(stdmsg);
-//halt();
+halt();
@yebblies Collaborator

Could you please get rid of this?

I wonder where that came from but it's restored now.

@yebblies Collaborator

Walter adds it in for debugging and it accidentally ended up getting left in the master branch for a couple of weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@WalterBright

It would be nice to also include a pull request for the documentation to add documentation for -oq

@WalterBright WalterBright merged commit cf8c00b into D-Programming-Language:master
@WalterBright

Sigh. Windows still fails to build the phobos unittests with this patch. I'm going to have to revert it again. I want to emphasize that existing behavior must not change if -oq is not used - we cannot break peoples' existing build processes.


..\dmd -O -nofloat -w -d -property -L/co -unittest unittest.d std\variant.d std
\stream.d std\socket.d std\socketstream.d std\perf.d std\container.d std\conv.d
std\zip.d std\cstream.d std\loader.d std__fileinit.d std\datebase.d std\re
gex.d std\stdarg.d std\stdint.d std\json.d std\parallelism.d std\gregorian.
d std\mathspecial.d std\internal\math\biguintcore.d std\internal\math\biguint
noasm.d std\internal\math\biguintx86.d std\internal\math\gammafunction.d std\in
ternal\math\errorfunction.d std\internal\windows\advapi32.d crc32.d std\c\pro
cess.d std\c\stdarg.d std\c\stddef.d std\c\stdlib.d std\c\string.d std\c\ti
me.d std\c\math.d std\c\windows\com.d std\c\windows\stat.d std\c\windows\win
dows.d std\c\windows\winsock.d std\windows\charset.d std\windows\iunknown.d
std\windows\registry.d std\windows\syserror.d unittest11.obj unittest12.obj uni
ttest2.obj etc\c\zlib\zlib.lib ..\druntime\lib\druntime.lib
std.contracts has been scheduled for deprecation. Please use std.exception inste
ad.
Notice: As of Phobos 2.055, std.date and std.dateparse have been deprecated. The
y will be removed in February 2012. Please use std.datetime instead.
std.perf has been scheduled for deprecation. Please use std.datetime instead.
Notice: As of Phobos 2.055, std.regexp has been deprecated. It will be removed i
n February 2012. Please use std.regex instead.
std.stdarg is deprecated. You should import core.vararg instead.
Notice: As of Phobos 2.055, std.gregorian has been deprecated. It will be remove
d in February 2012. Please use std.datetime instead.

unittest
Error: 'unittest' not found

--- errorlevel 1

@WalterBright

Also, please do not use tabs in source files.

@jacob-carlborg

I guess I have to try and test this on Windows. I apologize for the problems this has caused. I'll fix the tabs and documentation in a, hopefully, upcoming pull request.

@braddr braddr referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@timotheecour timotheecour commented on the diff
src/module.c
@@ -646,6 +662,9 @@ void Module::parse()
*/
if (!Lexer::isValidIdentifier(this->ident->toChars()))
error("has non-identifier characters in filename, use module declaration instead");
+
+ if (global.params.packagePaths)
+ error("has no module declaration; this is not allowed when using option -oq");

this is unusually restrictive. AndrejMitrovic/dmd@6d9f4e9 doesn't have this restriction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 16, 2011
  1. @jacob-carlborg

    Revert "revert pull 169"

    jacob-carlborg authored
    This reverts commit 9d664ad3a00d2a09be3aa67cdebb4d4641cdb42f.
  2. @jacob-carlborg

    Remove call to "halt".

    jacob-carlborg authored
This page is out of date. Refresh to see the latest.
Showing with 53 additions and 20 deletions.
  1. +17 −7 src/mars.c
  2. +1 −0  src/mars.h
  3. +32 −13 src/module.c
  4. +3 −0  src/module.h
View
24 src/mars.c
@@ -345,6 +345,7 @@ Usage:\n\
-odobjdir write object & library files to directory objdir\n\
-offilename name output file to filename\n\
-op do not strip paths from source file\n\
+ -oq use fully qualified module name for object filenames\n\
-profile profile runtime performance of generated code\n\
-property enforce property syntax\n\
-quiet suppress unnecessary messages\n\
@@ -591,6 +592,12 @@ int main(int argc, char *argv[])
global.params.preservePaths = 1;
break;
+ case 'q':
+ if (p[3])
+ goto Lerror;
+ global.params.packagePaths = 1;
+ break;
+
case 0:
error("-o no longer supported, use -of or -od");
break;
@@ -1025,6 +1032,7 @@ int main(int argc, char *argv[])
// Create Modules
Modules modules;
modules.reserve(files.dim);
+
int firstmodule = 1;
for (size_t i = 0; i < files.dim; i++)
{
@@ -1142,11 +1150,6 @@ int main(int argc, char *argv[])
Identifier *id = Lexer::idPool(name);
m = new Module(files[i], id, global.params.doDocComments, global.params.doHdrGeneration);
modules.push(m);
-
- if (firstmodule)
- { global.params.objfiles->push(m->objfile->name->str);
- firstmodule = 0;
- }
}
#if WINDOWS_SEH
@@ -1184,8 +1187,7 @@ int main(int argc, char *argv[])
if (!Module::rootModule)
Module::rootModule = m;
m->importedFrom = m;
- if (!global.params.oneobj || modi == 0 || m->isDocFile)
- m->deleteObjFile();
+
#if ASYNCREAD
if (aw->read(filei))
{
@@ -1193,6 +1195,9 @@ int main(int argc, char *argv[])
}
#endif
m->parse();
+ m->prepareObjfile();
+ if (!global.params.oneobj || modi == 0 || m->isDocFile)
+ m->deleteObjFile();
if (m->isDocFile)
{
anydocfiles = true;
@@ -1215,6 +1220,11 @@ int main(int argc, char *argv[])
if (global.params.objfiles->dim == 0)
global.params.link = 0;
}
+
+ if (firstmodule)
+ { global.params.objfiles->push(m->objfile->name->str);
+ firstmodule = 0;
+ }
}
#if ASYNCREAD
AsyncRead::dispose(aw);
View
1  src/mars.h
@@ -170,6 +170,7 @@ struct Param
char useInline; // inline expand functions
char release; // build release version
char preservePaths; // !=0 means don't strip path from source file
+ char packagePaths; // !=0 means use the fully qualified module name as object file output filename
char warnings; // 0: enable warnings
// 1: warnings as errors
// 2: informational warnings (no errors)
View
45 src/module.c
@@ -67,6 +67,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
// printf("Module::Module(filename = '%s', ident = '%s')\n", filename, ident->toChars());
this->arg = filename;
+ orig_filename = filename;
md = NULL;
errors = 0;
numlines = 0;
@@ -136,6 +137,21 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
}
}
+ srcfile = new File(srcfilename);
+
+ if (doDocComment)
+ setDocfile();
+
+ if (doHdrGen)
+ setHdrfile();
+}
+
+void Module::prepareObjfile()
+{
+ char *filename = orig_filename;
+ FileName *objfilename;
+ FileName *symfilename;
+
char *argobj;
if (global.params.objname)
argobj = global.params.objname;
@@ -153,6 +169,18 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
{
if (global.params.preservePaths)
argobj = filename;
+
+ else if (global.params.packagePaths) {
+ argobj = (char*)toPrettyChars();
+ //FileName::forceExt will think the last part of the package path is an extension
+ //argobj = argobj ~ '.' ~ global.obj_ext;
+ char* tmp = (char*)calloc(1, strlen(argobj) + strlen(global.obj_ext) + 2);
+ memcpy(tmp, argobj, strlen(argobj));
+ tmp[strlen(argobj)] = '.';
+ memcpy(tmp + strlen(argobj) + 1, global.obj_ext, strlen(global.obj_ext));
+ argobj = tmp;
+ }
+
else
argobj = FileName::name(filename);
if (!FileName::absolute(argobj))
@@ -169,18 +197,6 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
symfilename = FileName::forceExt(filename, global.sym_ext);
- srcfile = new File(srcfilename);
-
- if (doDocComment)
- {
- setDocfile();
- }
-
- if (doHdrGen)
- {
- setHdrfile();
- }
-
objfile = new File(objfilename);
symfile = new File(symfilename);
}
@@ -243,7 +259,7 @@ void Module::setHdrfile()
void Module::deleteObjFile()
{
- if (global.params.obj)
+ if (global.params.obj && objfile)
objfile->remove();
if (docfile)
docfile->remove();
@@ -646,6 +662,9 @@ void Module::parse()
*/
if (!Lexer::isValidIdentifier(this->ident->toChars()))
error("has non-identifier characters in filename, use module declaration instead");
+
+ if (global.params.packagePaths)
+ error("has no module declaration; this is not allowed when using option -oq");

this is unusually restrictive. AndrejMitrovic/dmd@6d9f4e9 doesn't have this restriction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
// Update global list of modules
View
3  src/module.h
@@ -58,6 +58,7 @@ struct Module : Package
const char *arg; // original argument name
+ char *orig_filename; //original filename (passed to Module ctor)
ModuleDeclaration *md; // if !NULL, the contents of the ModuleDeclaration declaration
File *srcfile; // input source file
File *objfile; // output .obj file
@@ -114,6 +115,8 @@ struct Module : Package
Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen);
~Module();
+ void prepareObjfile();
+
static Module *load(Loc loc, Identifiers *packages, Identifier *ident);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Something went wrong with that request. Please try again.