diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-09-14 10:10:34 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-09-14 10:10:49 -0500 |
commit | 0a97ece91e8a87724230f39276f0a7537b1566c3 (patch) | |
tree | 7008ee761af3294548978c3a0421608000f60781 /xml2cmp | |
parent | 8578e3c80d99da0b47cd450a9be61cef28f411b0 (diff) |
merge srvdepy functions into xml2cmp and simplify xml2cmp gbuild
Diffstat (limited to 'xml2cmp')
-rw-r--r-- | xml2cmp/Executable_srvdepy.mk | 40 | ||||
-rw-r--r-- | xml2cmp/Executable_xml2cmp.mk | 19 | ||||
-rw-r--r-- | xml2cmp/Module_xml2cmp.mk | 4 | ||||
-rw-r--r-- | xml2cmp/StaticLibrary_x2c_support.mk | 38 | ||||
-rw-r--r-- | xml2cmp/StaticLibrary_x2c_xcd.mk | 40 | ||||
-rw-r--r-- | xml2cmp/source/support/cmdline.cxx | 10 | ||||
-rw-r--r-- | xml2cmp/source/support/cmdline.hxx | 3 | ||||
-rw-r--r-- | xml2cmp/source/xcd/dependy.cxx (renamed from xml2cmp/source/finder/dependy.cxx) | 4 | ||||
-rw-r--r-- | xml2cmp/source/xcd/dependy.hxx (renamed from xml2cmp/source/finder/dependy.hxx) | 0 | ||||
-rw-r--r-- | xml2cmp/source/xcd/main.cxx | 281 |
10 files changed, 185 insertions, 254 deletions
diff --git a/xml2cmp/Executable_srvdepy.mk b/xml2cmp/Executable_srvdepy.mk deleted file mode 100644 index 3bcaa84c0e89..000000000000 --- a/xml2cmp/Executable_srvdepy.mk +++ /dev/null @@ -1,40 +0,0 @@ -# -# 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 \ -)) diff --git a/xml2cmp/Executable_xml2cmp.mk b/xml2cmp/Executable_xml2cmp.mk index 692a043dcc1a..28ed105a1a14 100644 --- a/xml2cmp/Executable_xml2cmp.mk +++ b/xml2cmp/Executable_xml2cmp.mk @@ -1,3 +1,4 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- # # Version: MPL 1.1 / GPLv3+ / LGPLv3+ # @@ -31,9 +32,21 @@ $(eval $(call gb_Executable_Executable,xml2cmp)) $(eval $(call gb_Executable_add_exception_objects,xml2cmp,\ 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,\ - x2c_support \ - x2c_xcd \ +$(eval $(call gb_Executable_add_linked_libs,xml2cmp,\ + $(gb_STDLIBS) \ )) diff --git a/xml2cmp/Module_xml2cmp.mk b/xml2cmp/Module_xml2cmp.mk index dc11c53a971d..c4279fbffb15 100644 --- a/xml2cmp/Module_xml2cmp.mk +++ b/xml2cmp/Module_xml2cmp.mk @@ -1,3 +1,4 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- # # Version: MPL 1.1 / GPLv3+ / LGPLv3+ # @@ -31,9 +32,6 @@ $(eval $(call gb_Module_Module,xml2cmp)) ifneq ($(CROSS_COMPILING),YES) $(eval $(call gb_Module_add_targets,xml2cmp,\ - StaticLibrary_x2c_support \ - StaticLibrary_x2c_xcd \ - Executable_srvdepy \ Executable_xml2cmp \ )) endif diff --git a/xml2cmp/StaticLibrary_x2c_support.mk b/xml2cmp/StaticLibrary_x2c_support.mk deleted file mode 100644 index 0219bbec1ba4..000000000000 --- a/xml2cmp/StaticLibrary_x2c_support.mk +++ /dev/null @@ -1,38 +0,0 @@ -# -# 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 \ -)) diff --git a/xml2cmp/StaticLibrary_x2c_xcd.mk b/xml2cmp/StaticLibrary_x2c_xcd.mk deleted file mode 100644 index b4f8261ec2b2..000000000000 --- a/xml2cmp/StaticLibrary_x2c_xcd.mk +++ /dev/null @@ -1,40 +0,0 @@ -# -# 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 \ -)) diff --git a/xml2cmp/source/support/cmdline.cxx b/xml2cmp/source/support/cmdline.cxx index 2af998cfd922..eb1b867b3805 100644 --- a/xml2cmp/source/support/cmdline.cxx +++ b/xml2cmp/source/support/cmdline.cxx @@ -35,6 +35,7 @@ char C_sUseText[] = "Use: xml2cmp.exe \n" + " [-dep <xml-component-descriptions-root-directory> \n" " [-func funcFile] \n" " [-html htmlFile] \n" " [-types typeFile] \n" @@ -49,6 +50,7 @@ char C_sUseText[] = "Use: xml2cmp.exe \n" char C_sCmdFunc[] = "-func"; +char C_sCmdDep[] = "-dep"; char C_sCmdHtml[] = "-html"; char C_sCmdType[] = "-types"; char C_sCmdIndex[] = "-ix"; @@ -215,6 +217,14 @@ CommandLine::ParseSingleFileCommand( int argc, argc, argv ); } + else if ( strcmp( argv[nCountArg], C_sCmdDep ) == 0 ) + { + bIsOk = GetParameter( + sDepPath, + nCountArg, + argc, + argv ); + } else { sXmlSourceFile = argv[nCountArg]; diff --git a/xml2cmp/source/support/cmdline.hxx b/xml2cmp/source/support/cmdline.hxx index 126cdeae138f..948685ea185e 100644 --- a/xml2cmp/source/support/cmdline.hxx +++ b/xml2cmp/source/support/cmdline.hxx @@ -48,8 +48,10 @@ class CommandLine const char * FuncFile() const { return sFuncFile.str(); } const char * HtmlFile() const { return sHtmlFile.str(); } const char * TypeInfoFile() const { return sTypeInfoFile.str(); } + const char * DepPath() const { return sDepPath.str(); } bool IsIndexCommand() const { return sIndexFile.l() > 0; } + bool IsDepCommand() const { return sDepPath.l() > 0; } const char * XmlSrcDirectory() const { return sXmlSourceDirectory.str(); } const char * IndexOutputFile() const { return sIndexFile.str(); } const char * OutputDirectory() const { return sOutputDirectory.str(); } @@ -76,6 +78,7 @@ class CommandLine List<Simstr> aTagsInIndex; Simstr sIdlRootPath; + Simstr sDepPath; bool bIsOk; }; diff --git a/xml2cmp/source/finder/dependy.cxx b/xml2cmp/source/xcd/dependy.cxx index 8a7ae0a8d94f..6e909d018582 100644 --- a/xml2cmp/source/finder/dependy.cxx +++ b/xml2cmp/source/xcd/dependy.cxx @@ -31,8 +31,8 @@ #include <iostream> #include "../support/syshelp.hxx" #include "../support/list.hxx" -#include "../xcd/xmltree.hxx" -#include "../xcd/parse.hxx" +#include "xmltree.hxx" +#include "parse.hxx" diff --git a/xml2cmp/source/finder/dependy.hxx b/xml2cmp/source/xcd/dependy.hxx index c2c2d7d9233f..c2c2d7d9233f 100644 --- a/xml2cmp/source/finder/dependy.hxx +++ b/xml2cmp/source/xcd/dependy.hxx diff --git a/xml2cmp/source/xcd/main.cxx b/xml2cmp/source/xcd/main.cxx index 5a42d51db90b..ea6b140904ba 100644 --- a/xml2cmp/source/xcd/main.cxx +++ b/xml2cmp/source/xcd/main.cxx @@ -41,46 +41,151 @@ #include "parse.hxx" #include "../support/syshelp.hxx" #include "../support/heap.hxx" +#include "dependy.hxx" -int Do_IndexCommandLine( - const CommandLine & i_rCommandLine ); -int Do_SingleFileCommandLine( - const CommandLine & i_rCommandLine ); -void Create_TypeInfo( - const char * o_sOutputFile, - ModuleDescription & i_rData ); +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); -int -#ifdef WNT -_cdecl -#endif -main( int argc, - char * argv[] ) + for ( unsigned t = 0; t < aTypes.size(); ++t ) + { + unsigned i_max = aTypes[t]->Size(); + for ( unsigned i = 0; i < i_max; ++i ) + { + 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 - CommandLine aCommandLine(argc, argv); - int ret = 0; + StreamOut_TypeInfo(std::cout, i_rData, " "); +} - 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 ; - return 1; + std::cerr << "Error: " << i_sOutputFile << " could not be created." << std::endl; + return; } - if ( aCommandLine.IsIndexCommand() ) - ret = Do_IndexCommandLine(aCommandLine); - else - ret = Do_SingleFileCommandLine(aCommandLine); + Simstr sLibPrefix = i_rData.ModuleName(); + WriteStr( aOut, sLibPrefix ); + WriteStr( aOut, "_XML2CMPTYPES= "); - 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 -Do_SingleFileCommandLine(const CommandLine & i_rCommandLine) +int Do_DepCommandLine(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; X2CParser aParser(aDescr); @@ -95,8 +200,7 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine) if ( strlen(i_rCommandLine.FuncFile()) > 0 ) { - Create_AccessMethod( i_rCommandLine.FuncFile(), - aParser.PureText() ); + Create_AccessMethod( i_rCommandLine.FuncFile(), aParser.PureText() ); std::cout << "File " << i_rCommandLine.FuncFile() @@ -118,15 +222,13 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine) if (strlen(i_rCommandLine.TypeInfoFile()) > 0) { - Create_TypeInfo( i_rCommandLine.TypeInfoFile(), - aDescr ); + Create_TypeInfo( i_rCommandLine.TypeInfoFile(), aDescr ); } return 0; }; -int -Do_IndexCommandLine(const CommandLine & i_rCommandLine) +int Do_IndexCommandLine(const CommandLine & i_rCommandLine) { // Parse files: List<Simstr> aFiles; @@ -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 -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); -} - -void -Put2StdOut_TypeInfo( ModuleDescription & i_rData ) +int +#ifdef WNT +_cdecl +#endif +main( int argc, char* argv[] ) { - StreamOut_TypeInfo(std::cout, i_rData, " "); -} + // Variables + CommandLine aCommandLine(argc, argv); + int ret = 0; -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 ) + if (! aCommandLine.IsOk()) { - std::cerr << "Error: " << i_sOutputFile << " could not be created." << std::endl; - return; + std::cerr << aCommandLine.ErrorText() << std::endl ; + return 1; } - Simstr sLibPrefix = i_rData.ModuleName(); - 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 ) + if ( aCommandLine.IsIndexCommand() ) { - unsigned i_max = aTypes[t]->Size(); - for ( unsigned i = 0; i < i_max; ++i ) - { - aTypesHeap.InsertValue( aTypes[t]->Data(i), "" ); - } // end for + ret = Do_IndexCommandLine(aCommandLine); } - - // Write types: - HeapItem * pLastHeapTop = 0; - for ( HeapItem * pHeapTop = aTypesHeap.ReleaseTop(); pHeapTop != 0; pHeapTop = aTypesHeap.ReleaseTop() ) + else if ( aCommandLine.IsDepCommand() ) { - 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) + ret = Do_DepCommandLine(aCommandLine); + } + else { - delete pLastHeapTop; - pLastHeapTop = 0; + ret = Do_SingleFileCommandLine(aCommandLine); } + return ret; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |