mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-12 01:43:14 +01:00
Added ability to generate JSON files. Fixed generating of 'header' files.
This commit is contained in:
@@ -208,7 +208,7 @@ struct Param
|
||||
char *hdrdir; // write 'header' file to docdir directory
|
||||
char *hdrname; // write 'header' file to docname
|
||||
|
||||
char doXGeneration; // write JSON file
|
||||
bool doXGeneration; // write JSON file
|
||||
char *xfilename; // write JSON file to xfilename
|
||||
|
||||
unsigned debuglevel; // debug level
|
||||
|
||||
@@ -116,6 +116,15 @@ cl::opt<std::string> ddocFile("Df",
|
||||
cl::value_desc("filename"),
|
||||
cl::Prefix);
|
||||
|
||||
// Json options
|
||||
static cl::opt<bool, true> doJson("X",
|
||||
cl::desc("generate JSON file"),
|
||||
cl::location(global.params.doXGeneration));
|
||||
|
||||
cl::opt<std::string> jsonFile("Xf",
|
||||
cl::desc("write JSON file to <filename>"),
|
||||
cl::value_desc("filename"),
|
||||
cl::Prefix);
|
||||
|
||||
// Header generation options
|
||||
#ifdef _DH
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace opts {
|
||||
extern cl::opt<cl::boolOrDefault> output_o;
|
||||
extern cl::opt<std::string> ddocDir;
|
||||
extern cl::opt<std::string> ddocFile;
|
||||
extern cl::opt<std::string> jsonFile;
|
||||
#ifdef _DH
|
||||
extern cl::opt<std::string> hdrDir;
|
||||
extern cl::opt<std::string> hdrFile;
|
||||
|
||||
18
gen/main.cpp
18
gen/main.cpp
@@ -33,6 +33,7 @@
|
||||
#include "mtype.h"
|
||||
#include "id.h"
|
||||
#include "cond.h"
|
||||
#include "json.h"
|
||||
|
||||
#include "gen/logger.h"
|
||||
#include "gen/linkage.h"
|
||||
@@ -228,6 +229,10 @@ int main(int argc, char** argv)
|
||||
global.params.doDocComments |=
|
||||
global.params.docdir || global.params.docname;
|
||||
|
||||
initFromString(global.params.xfilename, jsonFile);
|
||||
if (global.params.xfilename)
|
||||
global.params.doXGeneration = true;
|
||||
|
||||
#ifdef _DH
|
||||
initFromString(global.params.hdrdir, hdrDir);
|
||||
initFromString(global.params.hdrname, hdrFile);
|
||||
@@ -724,6 +729,13 @@ LDC_TARGETS
|
||||
continue;
|
||||
}
|
||||
|
||||
if (FileName::equals(ext, global.json_ext))
|
||||
{
|
||||
global.params.doXGeneration = 1;
|
||||
global.params.xfilename = (char *)files.data[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
#if !POSIX
|
||||
if (stricmp(ext, "res") == 0)
|
||||
{
|
||||
@@ -790,9 +802,9 @@ LDC_TARGETS
|
||||
if (!Module::rootModule)
|
||||
Module::rootModule = m;
|
||||
m->importedFrom = m;
|
||||
m->buildTargetFiles(singleObj);
|
||||
m->read(0);
|
||||
m->parse();
|
||||
m->buildTargetFiles(singleObj);
|
||||
m->deleteObjFile();
|
||||
if (m->isDocFile)
|
||||
{
|
||||
@@ -978,6 +990,10 @@ LDC_TARGETS
|
||||
global.params.objfiles->push(filename);
|
||||
}
|
||||
|
||||
// output json file
|
||||
if (global.params.doXGeneration)
|
||||
json_generate(&modules);
|
||||
|
||||
backend_term();
|
||||
if (global.errors)
|
||||
fatal();
|
||||
|
||||
Reference in New Issue
Block a user