Kaydet (Commit) 0a97ece9 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

merge srvdepy functions into xml2cmp and simplify xml2cmp gbuild

üst 8578e3c8
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#************************************************************************* #*************************************************************************
# #
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# Copyright 2009 by Sun Microsystems, Inc. # Copyright 2009 by Sun Microsystems, Inc.
# #
# OpenOffice.org - a multi-platform office productivity suite # OpenOffice.org - a multi-platform office productivity suite
...@@ -36,7 +36,6 @@ $(eval $(call gb_Helper_register_executables,NONE, \ ...@@ -36,7 +36,6 @@ $(eval $(call gb_Helper_register_executables,NONE, \
mkunroll \ mkunroll \
rscdep \ rscdep \
so_checksum \ so_checksum \
srvdepy \
xml2cmp \ xml2cmp \
)) ))
...@@ -257,8 +256,6 @@ $(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \ ...@@ -257,8 +256,6 @@ $(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
salcpprt \ salcpprt \
vclmain \ vclmain \
writerperfect \ writerperfect \
x2c_support \
x2c_xcd \
)) ))
ifeq ($(OS),WNT) ifeq ($(OS),WNT)
......
#
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Peter Foley <pefoley2@verizon.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
#
$(eval $(call gb_Executable_Executable,srvdepy))
$(eval $(call gb_Executable_add_exception_objects,srvdepy,\
xml2cmp/source/finder/dependy \
xml2cmp/source/finder/dep_main \
))
$(eval $(call gb_Executable_add_linked_static_libs,srvdepy,\
x2c_support \
x2c_xcd \
))
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
# #
# Version: MPL 1.1 / GPLv3+ / LGPLv3+ # Version: MPL 1.1 / GPLv3+ / LGPLv3+
# #
...@@ -31,9 +32,21 @@ $(eval $(call gb_Executable_Executable,xml2cmp)) ...@@ -31,9 +32,21 @@ $(eval $(call gb_Executable_Executable,xml2cmp))
$(eval $(call gb_Executable_add_exception_objects,xml2cmp,\ $(eval $(call gb_Executable_add_exception_objects,xml2cmp,\
xml2cmp/source/xcd/main \ xml2cmp/source/xcd/main \
xml2cmp/source/support/cmdline \
xml2cmp/source/support/heap \
xml2cmp/source/support/sistr \
xml2cmp/source/support/syshelp \
xml2cmp/source/support/badcast \
xml2cmp/source/xcd/cr_html \
xml2cmp/source/xcd/cr_index \
xml2cmp/source/xcd/cr_metho \
xml2cmp/source/xcd/filebuff \
xml2cmp/source/xcd/parse \
xml2cmp/source/xcd/xmlelem \
xml2cmp/source/xcd/xmltree \
xml2cmp/source/xcd/dependy \
)) ))
$(eval $(call gb_Executable_add_linked_static_libs,xml2cmp,\ $(eval $(call gb_Executable_add_linked_libs,xml2cmp,\
x2c_support \ $(gb_STDLIBS) \
x2c_xcd \
)) ))
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
# #
# Version: MPL 1.1 / GPLv3+ / LGPLv3+ # Version: MPL 1.1 / GPLv3+ / LGPLv3+
# #
...@@ -31,9 +32,6 @@ $(eval $(call gb_Module_Module,xml2cmp)) ...@@ -31,9 +32,6 @@ $(eval $(call gb_Module_Module,xml2cmp))
ifneq ($(CROSS_COMPILING),YES) ifneq ($(CROSS_COMPILING),YES)
$(eval $(call gb_Module_add_targets,xml2cmp,\ $(eval $(call gb_Module_add_targets,xml2cmp,\
StaticLibrary_x2c_support \
StaticLibrary_x2c_xcd \
Executable_srvdepy \
Executable_xml2cmp \ Executable_xml2cmp \
)) ))
endif endif
......
#
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Peter Foley <pefoley2@verizon.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
#
$(eval $(call gb_StaticLibrary_StaticLibrary,x2c_support))
$(eval $(call gb_StaticLibrary_add_exception_objects,x2c_support,\
xml2cmp/source/support/cmdline \
xml2cmp/source/support/heap \
xml2cmp/source/support/sistr \
xml2cmp/source/support/syshelp \
xml2cmp/source/support/badcast \
))
#
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Peter Foley <pefoley2@verizon.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
#
$(eval $(call gb_StaticLibrary_StaticLibrary,x2c_xcd))
$(eval $(call gb_StaticLibrary_add_exception_objects,x2c_xcd,\
xml2cmp/source/xcd/cr_html \
xml2cmp/source/xcd/cr_index \
xml2cmp/source/xcd/cr_metho \
xml2cmp/source/xcd/filebuff \
xml2cmp/source/xcd/parse \
xml2cmp/source/xcd/xmlelem \
xml2cmp/source/xcd/xmltree \
))
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
char C_sUseText[] = "Use: xml2cmp.exe \n" char C_sUseText[] = "Use: xml2cmp.exe \n"
" [-dep <xml-component-descriptions-root-directory> \n"
" [-func funcFile] \n" " [-func funcFile] \n"
" [-html htmlFile] \n" " [-html htmlFile] \n"
" [-types typeFile] \n" " [-types typeFile] \n"
...@@ -49,6 +50,7 @@ char C_sUseText[] = "Use: xml2cmp.exe \n" ...@@ -49,6 +50,7 @@ char C_sUseText[] = "Use: xml2cmp.exe \n"
char C_sCmdFunc[] = "-func"; char C_sCmdFunc[] = "-func";
char C_sCmdDep[] = "-dep";
char C_sCmdHtml[] = "-html"; char C_sCmdHtml[] = "-html";
char C_sCmdType[] = "-types"; char C_sCmdType[] = "-types";
char C_sCmdIndex[] = "-ix"; char C_sCmdIndex[] = "-ix";
...@@ -215,6 +217,14 @@ CommandLine::ParseSingleFileCommand( int argc, ...@@ -215,6 +217,14 @@ CommandLine::ParseSingleFileCommand( int argc,
argc, argc,
argv ); argv );
} }
else if ( strcmp( argv[nCountArg], C_sCmdDep ) == 0 )
{
bIsOk = GetParameter(
sDepPath,
nCountArg,
argc,
argv );
}
else else
{ {
sXmlSourceFile = argv[nCountArg]; sXmlSourceFile = argv[nCountArg];
......
...@@ -48,8 +48,10 @@ class CommandLine ...@@ -48,8 +48,10 @@ class CommandLine
const char * FuncFile() const { return sFuncFile.str(); } const char * FuncFile() const { return sFuncFile.str(); }
const char * HtmlFile() const { return sHtmlFile.str(); } const char * HtmlFile() const { return sHtmlFile.str(); }
const char * TypeInfoFile() const { return sTypeInfoFile.str(); } const char * TypeInfoFile() const { return sTypeInfoFile.str(); }
const char * DepPath() const { return sDepPath.str(); }
bool IsIndexCommand() const { return sIndexFile.l() > 0; } bool IsIndexCommand() const { return sIndexFile.l() > 0; }
bool IsDepCommand() const { return sDepPath.l() > 0; }
const char * XmlSrcDirectory() const { return sXmlSourceDirectory.str(); } const char * XmlSrcDirectory() const { return sXmlSourceDirectory.str(); }
const char * IndexOutputFile() const { return sIndexFile.str(); } const char * IndexOutputFile() const { return sIndexFile.str(); }
const char * OutputDirectory() const { return sOutputDirectory.str(); } const char * OutputDirectory() const { return sOutputDirectory.str(); }
...@@ -76,6 +78,7 @@ class CommandLine ...@@ -76,6 +78,7 @@ class CommandLine
List<Simstr> aTagsInIndex; List<Simstr> aTagsInIndex;
Simstr sIdlRootPath; Simstr sIdlRootPath;
Simstr sDepPath;
bool bIsOk; bool bIsOk;
}; };
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#include <iostream> #include <iostream>
#include "../support/syshelp.hxx" #include "../support/syshelp.hxx"
#include "../support/list.hxx" #include "../support/list.hxx"
#include "../xcd/xmltree.hxx" #include "xmltree.hxx"
#include "../xcd/parse.hxx" #include "parse.hxx"
......
...@@ -41,46 +41,151 @@ ...@@ -41,46 +41,151 @@
#include "parse.hxx" #include "parse.hxx"
#include "../support/syshelp.hxx" #include "../support/syshelp.hxx"
#include "../support/heap.hxx" #include "../support/heap.hxx"
#include "dependy.hxx"
int Do_IndexCommandLine( void StreamOut_TypeInfo( std::ostream& o_rOut, ModuleDescription& i_rData,
const CommandLine & i_rCommandLine ); const char* i_sSeparator )
int Do_SingleFileCommandLine( {
const CommandLine & i_rCommandLine ); Heap aTypesHeap(12);
void Create_TypeInfo(
const char * o_sOutputFile,
ModuleDescription & i_rData );
// Gather types:
List< const MultipleTextElement * > aTypes;
i_rData.Get_Types(aTypes);
int for ( unsigned t = 0; t < aTypes.size(); ++t )
#ifdef WNT {
_cdecl unsigned i_max = aTypes[t]->Size();
#endif for ( unsigned i = 0; i < i_max; ++i )
main( int argc, {
char * argv[] ) aTypesHeap.InsertValue( aTypes[t]->Data(i), "" );
} // end for
}
// Write types:
HeapItem * pLastHeapTop = 0;
for ( HeapItem * pHeapTop = aTypesHeap.ReleaseTop(); pHeapTop != 0; pHeapTop = aTypesHeap.ReleaseTop() )
{
if (pLastHeapTop != 0)
{
if ( 0 == strcmp(pHeapTop->Key(), pLastHeapTop->Key()) )
continue;
delete pLastHeapTop;
}
pLastHeapTop = pHeapTop;
WriteStr( o_rOut, i_sSeparator );
const char * sEnd = strchr( pHeapTop->Key(), ' ' );
if (sEnd != 0)
{
const char * sQuali = strrchr( pHeapTop->Key(), ' ' ) + 1;
WriteStr( o_rOut, sQuali );
WriteStr( o_rOut, "." );
o_rOut.write( pHeapTop->Key(), sEnd - pHeapTop->Key() );
}
else
{
WriteStr( o_rOut, pHeapTop->Key() );
}
} // end for
if (pLastHeapTop != 0)
{
delete pLastHeapTop;
pLastHeapTop = 0;
}
}
void Put2StdOut_TypeInfo( ModuleDescription& i_rData )
{ {
// Variables StreamOut_TypeInfo(std::cout, i_rData, " ");
CommandLine aCommandLine(argc, argv); }
int ret = 0;
if (! aCommandLine.IsOk()) void Put2File_TypeInfo( const char* i_sOutputFile, ModuleDescription& i_rData )
{
std::ofstream aOut(i_sOutputFile, std::ios::out
#if defined(WNT)
| std::ios::binary
#endif
);
if ( !aOut )
{ {
std::cerr << aCommandLine.ErrorText() << std::endl ; std::cerr << "Error: " << i_sOutputFile << " could not be created." << std::endl;
return 1; return;
} }
if ( aCommandLine.IsIndexCommand() ) Simstr sLibPrefix = i_rData.ModuleName();
ret = Do_IndexCommandLine(aCommandLine); WriteStr( aOut, sLibPrefix );
else WriteStr( aOut, "_XML2CMPTYPES= ");
ret = Do_SingleFileCommandLine(aCommandLine);
return ret; StreamOut_TypeInfo(aOut, i_rData, "\t\\\n\t\t");
aOut.close();
} }
void Create_TypeInfo( const char* o_sOutputFile, ModuleDescription& i_rData )
{
if ( strcmp(o_sOutputFile, "stdout") == 0 )
{
Put2StdOut_TypeInfo(i_rData);
}
else
{
Put2File_TypeInfo(o_sOutputFile,i_rData);
}
}
int int Do_DepCommandLine(const CommandLine & i_rCommandLine)
Do_SingleFileCommandLine(const CommandLine & i_rCommandLine) {
DependencyFinder aDependencies;
aDependencies.GatherData(i_rCommandLine.DepPath());
char sInput[500] = "";
std::vector<Simstr> aLibs;
std::vector<Simstr> aServs;
std::cout
<< "\nNow you can start to put in Service names.\n"
<< "Please use correct case, but don't use namespaces.\n"
<< "Just the Service's own name.\n\n"
<< "To stop the program, put in a hashmark \"#\" + ENTER.\n"
<< std::endl;
do
{
sInput[0] = 0;
std::cin >> sInput;
Simstr sImplService(sInput);
if (*sInput != '#')
{
aLibs.erase( aLibs.begin(), aLibs.end() );
aServs.erase( aServs.begin(), aServs.end() );
aDependencies.FindNeededServices( aLibs, aServs, sImplService );
std::cout << "\n\n\nNeeded libraries: " << std::endl;
for ( unsigned i = 0; i < aLibs.size(); ++i )
{
std::cout << " " << aLibs[i].str() << std::endl;
}
std::cout << "\nNeeded services: " << std::endl;
for ( unsigned s= 0; s < aServs.size(); ++s )
{
std::cout << " " << aServs[s].str() << std::endl;
}
std::cout << "\n\n" << std::endl;
}
}
while (*sInput != '#');
return 0;
}
int Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
{ {
ModuleDescription aDescr; ModuleDescription aDescr;
X2CParser aParser(aDescr); X2CParser aParser(aDescr);
...@@ -95,8 +200,7 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine) ...@@ -95,8 +200,7 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
if ( strlen(i_rCommandLine.FuncFile()) > 0 ) if ( strlen(i_rCommandLine.FuncFile()) > 0 )
{ {
Create_AccessMethod( i_rCommandLine.FuncFile(), Create_AccessMethod( i_rCommandLine.FuncFile(), aParser.PureText() );
aParser.PureText() );
std::cout << "File " std::cout << "File "
<< i_rCommandLine.FuncFile() << i_rCommandLine.FuncFile()
...@@ -118,15 +222,13 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine) ...@@ -118,15 +222,13 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
if (strlen(i_rCommandLine.TypeInfoFile()) > 0) if (strlen(i_rCommandLine.TypeInfoFile()) > 0)
{ {
Create_TypeInfo( i_rCommandLine.TypeInfoFile(), Create_TypeInfo( i_rCommandLine.TypeInfoFile(), aDescr );
aDescr );
} }
return 0; return 0;
}; };
int int Do_IndexCommandLine(const CommandLine & i_rCommandLine)
Do_IndexCommandLine(const CommandLine & i_rCommandLine)
{ {
// Parse files: // Parse files:
List<Simstr> aFiles; List<Simstr> aFiles;
...@@ -148,113 +250,36 @@ Do_IndexCommandLine(const CommandLine & i_rCommandLine) ...@@ -148,113 +250,36 @@ Do_IndexCommandLine(const CommandLine & i_rCommandLine)
//******************** Creating of typeinfo ********************//
void Put2StdOut_TypeInfo(
ModuleDescription & i_rData );
void Put2File_TypeInfo(
const char * i_sOutputFile,
ModuleDescription & i_rData );
void StreamOut_TypeInfo(
std::ostream & o_rOut,
ModuleDescription & i_rData,
const char * i_sSeparator );
void int
Create_TypeInfo( const char * o_sOutputFile, #ifdef WNT
ModuleDescription & i_rData ) _cdecl
{ #endif
if ( strcmp(o_sOutputFile, "stdout") == 0 ) main( int argc, char* argv[] )
Put2StdOut_TypeInfo(i_rData);
else
Put2File_TypeInfo(o_sOutputFile,i_rData);
}
void
Put2StdOut_TypeInfo( ModuleDescription & i_rData )
{ {
StreamOut_TypeInfo(std::cout, i_rData, " "); // Variables
} CommandLine aCommandLine(argc, argv);
int ret = 0;
void if (! aCommandLine.IsOk())
Put2File_TypeInfo( const char * i_sOutputFile,
ModuleDescription & i_rData )
{
std::ofstream aOut(i_sOutputFile, std::ios::out
#if defined(WNT)
| std::ios::binary
#endif
);
if ( !aOut )
{ {
std::cerr << "Error: " << i_sOutputFile << " could not be created." << std::endl; std::cerr << aCommandLine.ErrorText() << std::endl ;
return; return 1;
} }
Simstr sLibPrefix = i_rData.ModuleName(); if ( aCommandLine.IsIndexCommand() )
WriteStr( aOut, sLibPrefix );
WriteStr( aOut, "_XML2CMPTYPES= ");
StreamOut_TypeInfo(aOut, i_rData, "\t\\\n\t\t");
aOut.close();
}
void
StreamOut_TypeInfo( std::ostream & o_rOut,
ModuleDescription & i_rData,
const char * i_sSeparator )
{
Heap aTypesHeap(12);
// Gather types:
List< const MultipleTextElement * > aTypes;
i_rData.Get_Types(aTypes);
for ( unsigned t = 0; t < aTypes.size(); ++t )
{ {
unsigned i_max = aTypes[t]->Size(); ret = Do_IndexCommandLine(aCommandLine);
for ( unsigned i = 0; i < i_max; ++i )
{
aTypesHeap.InsertValue( aTypes[t]->Data(i), "" );
} // end for
} }
else if ( aCommandLine.IsDepCommand() )
// Write types:
HeapItem * pLastHeapTop = 0;
for ( HeapItem * pHeapTop = aTypesHeap.ReleaseTop(); pHeapTop != 0; pHeapTop = aTypesHeap.ReleaseTop() )
{ {
if (pLastHeapTop != 0) ret = Do_DepCommandLine(aCommandLine);
{ }
if ( 0 == strcmp(pHeapTop->Key(), pLastHeapTop->Key()) ) else
continue;
delete pLastHeapTop;
}
pLastHeapTop = pHeapTop;
WriteStr( o_rOut, i_sSeparator );
const char * sEnd = strchr( pHeapTop->Key(), ' ' );
if (sEnd != 0)
{
const char * sQuali = strrchr( pHeapTop->Key(), ' ' ) + 1;
WriteStr( o_rOut, sQuali );
WriteStr( o_rOut, "." );
o_rOut.write( pHeapTop->Key(), sEnd - pHeapTop->Key() );
}
else
WriteStr( o_rOut, pHeapTop->Key() );
} // end for
if (pLastHeapTop != 0)
{ {
delete pLastHeapTop; ret = Do_SingleFileCommandLine(aCommandLine);
pLastHeapTop = 0;
} }
return ret;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment