Skip to content

Commit

Permalink
Added configuration options to better control the sqlite3 output.
Browse files Browse the repository at this point in the history
Still requires cmake -Duse_sqlite=YES to compile in support (and
libsqlite3)

New configuration options available:
- GENERATE_SQLITE3 enable/disable SQLITE3 output
- SQLITE3_OUTPUT configure directory where output is written to
  (default: sqlite3)
- SQLITE3_RECREATE_DB controls if existing database file is overwritten
  (default: YES)
  • Loading branch information
doxygen committed Jul 30, 2020
1 parent d24fde4 commit 4ae47ae
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
17 changes: 12 additions & 5 deletions src/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3034,28 +3034,35 @@ front of it.
</docs>
</option>
</group>
<!--
<group name='Sqlite3' docs='Configuration options related to Sqlite3 output'>
<option type='bool' id='GENERATE_SQLITE3' defval='0'>
<group name='Sqlite3' setting='USE_SQLITE3' docs='Configuration options related to Sqlite3 output'>
<option type='bool' id='GENERATE_SQLITE3' setting='USE_SQLITE3' defval='0'>
<docs>
<![CDATA[
If the \c GENERATE_SQLITE3 tag is set to \c YES doxygen will generate a
\c Sqlite3 database with symbols found by doxygen stored in tables.
]]>
</docs>
</option>
<option type='string' id='SQLITE3_OUTPUT' format='dir' defval='sqlite3' depends='GENERATE_SQLITE3'>
<option type='string' id='SQLITE3_OUTPUT' format='dir' defval='sqlite3' setting='USE_SQLITE3' depends='GENERATE_SQLITE3'>
<docs>
<![CDATA[
The \c SQLITE3_OUTPUT tag is used to specify where the \c Sqlite3 database will be put.
If a relative path is entered the value of \ref cfg_output_directory "OUTPUT_DIRECTORY" will be
put in front of it.
]]>
</docs>
</option>
<option type='bool' id='SQLITE3_RECREATE_DB' defval='1' setting='USE_SQLITE3' depends='GENERATE_SQLITE3'>
<docs>
<![CDATA[
The \c SQLITE3_OVERWRITE_DB tag is set to \c YES, the existing doxygen_sqlite3.db
database file will be recreated with each doxygen run.
If set to \c NO, doxygen will warn if an a database file is already found and not modify it.
]]>
</docs>
</option>

</group>
-->
<group name='PerlMod' docs='Configuration options related to the Perl module output'>
<option type='bool' id='GENERATE_PERLMOD' defval='0'>
<docs>
Expand Down
5 changes: 5 additions & 0 deletions src/configgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ def parseOption(node):
def parseGroups(node):
name = node.getAttribute('name')
doc = node.getAttribute('docs')
setting = node.getAttribute('setting')
if len(setting) > 0:
print("#if %s" % (setting))
print("%s%s" % (" //-----------------------------------------",
"----------------------------------"))
print(" cfg->addInfo(\"%s\",\"%s\");" % (name, doc))
Expand All @@ -354,6 +357,8 @@ def parseGroups(node):
for n in node.childNodes:
if n.nodeType == Node.ELEMENT_NODE:
parseOption(n)
if len(setting) > 0:
print("#endif")


def parseGroupMapGetter(node):
Expand Down
20 changes: 12 additions & 8 deletions src/doxygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10920,13 +10920,15 @@ void parseInput()
Config_updateString(MAN_OUTPUT,manOutput);
}

//QCString sqlOutput;
//bool &generateSql = Config_getBool(GENERATE_SQLITE3);
//if (generateSql)
//{
// sqlOutput = createOutputDirectory(outputDirectory,Config_getString(SQLITE3_OUTPUT),"/sqlite3");
// Config_update(SQLITE3_OUTPUT,sqlOutput);
//}
#if USE_SQLITE3
QCString sqlOutput;
bool generateSql = Config_getBool(GENERATE_SQLITE3);
if (generateSql)
{
sqlOutput = createOutputDirectory(outputDirectory,Config_getString(SQLITE3_OUTPUT),"/sqlite3");
Config_updateString(SQLITE3_OUTPUT,sqlOutput);
}
#endif

if (Config_getBool(HAVE_DOT))
{
Expand Down Expand Up @@ -11543,12 +11545,14 @@ void generateOutput()
Doxygen::generatingXmlOutput=FALSE;
g_s.end();
}
if (USE_SQLITE3)
#if USE_SQLITE3
if (Config_getBool(GENERATE_SQLITE3))
{
g_s.begin("Generating SQLITE3 output...\n");
generateSqlite3();
g_s.end();
}
#endif

if (Config_getBool(GENERATE_AUTOGEN_DEF))
{
Expand Down
20 changes: 14 additions & 6 deletions src/sqlite3gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2503,11 +2503,10 @@ static void generateSqlite3ForPage(const PageDef *pd,bool isExample)
static sqlite3* openDbConnection()
{

QCString outputDirectory = Config_getString(OUTPUT_DIRECTORY);
QCString outputDirectory = Config_getString(SQLITE3_OUTPUT);
QDir sqlite3Dir(outputDirectory);
sqlite3 *db;
int rc;
struct stat buf;

rc = sqlite3_initialize();
if (rc != SQLITE_OK)
Expand All @@ -2516,15 +2515,24 @@ static sqlite3* openDbConnection()
return NULL;
}

QCString dbFileName = "doxygen_sqlite3.db";
QFileInfo fi(outputDirectory+"/"+dbFileName);

if (stat (outputDirectory+"/doxygen_sqlite3.db", &buf) == 0)
if (fi.exists())
{
err("doxygen_sqlite3.db already exists! Rename, remove, or archive it to regenerate\n");
return NULL;
if (Config_getBool(SQLITE3_RECREATE_DB))
{
QDir().remove(fi.absFilePath());
}
else
{
err("doxygen_sqlite3.db already exists! Rename, remove, or archive it to regenerate\n");
return NULL;
}
}

rc = sqlite3_open_v2(
outputDirectory+"/doxygen_sqlite3.db",
fi.absFilePath().utf8(),
&db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
0
Expand Down

0 comments on commit 4ae47ae

Please sign in to comment.