Commit af710487 authored by Elemer Lelik's avatar Elemer Lelik
Browse files

Sync with 5.2.0

parent 4567b25b
******************************************************************************
* Copyright (c) 2000-2015 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************
Cygwin setup
- If Cygwin is installed already, refresh your Cygwin installation
Titan is always build for the newest Cygwin version available.
......
******************************************************************************
* Copyright (c) 2000-2015 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************
Build and install Titan on Linux
1.Install required libraries:
......@@ -108,6 +116,3 @@ These tests might run for half an hour (regr.tests) to two hours (func.tests)
6. Optionally , copy Titan into its' final directory.
From here on, you can continue with the Titan installation guide, see /Install/docs, to set environment variables etc.
......@@ -20,26 +20,26 @@ http://polarsys.org/sites/default/files/custom_uploads/TITAN%20Datasheet%20A4%20
##Binaries and SHA512 checksums for a number of Linux platforms can be downloaded from:
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.1.0-sles10.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.1.0-sles10.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.1.2-sled10.2.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.1.2-sled10.2.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.3-SLED11.1.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.3-SLED11.1.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.1.2-rhel5.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.1.2-rhel5.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-SLED11.1.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-SLED11.1.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-sled11.0.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-sled11.0.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-sles11.1.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-sles11.1.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.4.5-rhel6.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.4.5-rhel6.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.6-ubuntu12.04.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.6-ubuntu12.04.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.8-ubuntu14.04.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.8-ubuntu14.04.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux32-gcc4.1.0-sles10.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux32-gcc4.1.0-sles10.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux32-gcc4.1.2-sled10.2.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux32-gcc4.1.2-sled10.2.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux32-gcc4.3-SLED11.1.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux32-gcc4.3-SLED11.1.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.1.2-rhel5.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.1.2-rhel5.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.3-SLED11.1.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.3-SLED11.1.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.3-sled11.0.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.3-sled11.0.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.3-sles11.1.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.3-sles11.1.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.4.5-rhel6.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.4.5-rhel6.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.6-ubuntu12.04.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.6-ubuntu12.04.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.8-ubuntu14.04.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.2.pl0-linux64-gcc4.8-ubuntu14.04.tgz.sha512
# Related products:
......
# titan.core
TTCN-3 is a standardized, modular language specifically designed for testing.
Eclipse Titan offers a free and open source (FOSS) compiler both for TTCN-3 and for
ASN.1 (Abstract Syntax Notation One).
# Standards page (also including downloadable code):
* http://www.ttcn-3.org/
# Main project page:
* https://projects.eclipse.org/projects/tools.titan
##Introductory video of a presentation about Titan held at EclipseCon 2014:
* https://www.youtube.com/watch?v=2knzZuwzn-Y.
##Titan Datasheet on polarsys.org:
http://polarsys.org/sites/default/files/custom_uploads/TITAN%20Datasheet%20A4%202.1.pdf
##Binaries and SHA512 checksums for a number of Linux platforms can be downloaded from:
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.1.0-sles10.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.1.0-sles10.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.1.2-sled10.2.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.1.2-sled10.2.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.3-SLED11.1.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux32-gcc4.3-SLED11.1.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.1.2-rhel5.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.1.2-rhel5.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-SLED11.1.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-SLED11.1.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-sled11.0.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-sled11.0.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-sles11.1.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.3-sles11.1.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.4.5-rhel6.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.4.5-rhel6.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.6-ubuntu12.04.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.6-ubuntu12.04.tgz.sha512
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.8-ubuntu14.04.tgz
* https://www.eclipse.org/downloads/download.php?file=/titan/ttcn3-5.1.pl0-linux64-gcc4.8-ubuntu14.04.tgz.sha512
# Related products:
## Test Ports:
* https://github.com/eclipse/titan.TestPorts.Common_Components.Abstract_Socket
* https://github.com/eclipse/titan.TestPorts.HTTPmsg
* https://github.com/eclipse/titan.TestPorts.LANL2asp
* https://github.com/eclipse/titan.TestPorts.PCAPasp
* https://github.com/eclipse/titan.TestPorts.PIPEasp
* https://github.com/eclipse/titan.TestPorts.SCTPasp
* https://github.com/eclipse/titan.TestPorts.SIPmsg
* https://github.com/eclipse/titan.TestPorts.SQLasp
* https://github.com/eclipse/titan.TestPorts.TCPasp
* https://github.com/eclipse/titan.TestPorts.TELNETasp
* https://github.com/eclipse/titan.TestPorts.UDPasp
## Protocol Modules:
* https://github.com/eclipse/titan.ProtocolModules.COMMON
* https://github.com/eclipse/titan.ProtocolModules.DHCP
* https://github.com/eclipse/titan.ProtocolModules.DHCPv6
* https://github.com/eclipse/titan.ProtocolModules.DIAMETER_ProtocolModule_Generator
* https://github.com/eclipse/titan.ProtocolModules.DNS
* https://github.com/eclipse/titan.ProtocolModules.ICMP
* https://github.com/eclipse/titan.ProtocolModules.ICMPv6
* https://github.com/eclipse/titan.ProtocolModules.IP
* https://github.com/eclipse/titan.ProtocolModules.RTP
* https://github.com/eclipse/titan.ProtocolModules.RTSP
* https://github.com/eclipse/titan.ProtocolModules.SMPP
* https://github.com/eclipse/titan.ProtocolModules.SMTP
* https://github.com/eclipse/titan.ProtocolModules.SNMP
* https://github.com/eclipse/titan.ProtocolModules.TCP
* https://github.com/eclipse/titan.ProtocolModules.UDP
* https://github.com/eclipse/titan.ProtocolModules.XMPP
******************************************************************************
* Copyright (c) 2000-2015 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************
MinGW setup
(A) Download the MinGW installer from the MinGW site:
http://www.mingw.org/
(B) Follow the install steps found on the MinGW getting started page:
http://www.mingw.org/wiki/getting_started
Select the mingw-gcc-v3 packages because Titan only compiles
with older gcc. If you select the gcc4 packages, then the make process
stops immediately with some error messages. Select the msys packages too.
(C) Check the PATH system variable:
System -> Advanced system settings -> Environment Variables -> Path
The MinGW installation path must be present to use the installed
executables and files. For example:
echo %PATH%
C:\MinGW\bin;C:\MinGW\usr\bin...
(D) Working environment:
Use the <Install folder>\msys\<version>\msys.bat file to start a shell.
Download and extract the Titan source files and folders to a directory,
and create a Makefile.personal in the top directory. Please check the
installation guide and set all the needed variables like TTCN3_DIR. The
MinGW compilation needs a few extra changes in the Makefile.cfg also. Set
the PLATFORM and MINGW values:
PLATFORM := WIN32
MINGW := -DMINGW -mno-cygwin
(E) Compile Titan:
cd titan
make -j
make install
The compiled files will be placed into the ./Install directory.
(F) If the build process stops with a Windows error message saying that some files
are missing, search for the indicated Cygwin package and download it from the Cygwin page.
You can search fast and easily with the Cygwin Package Search tool:
https://cygwin.com/cgi-bin2/package-grep.cgi
Extract the downloaded package into the MinGW installation directory, and
restart the build process.
......@@ -142,6 +142,7 @@ MACRO_REFERENCE_INT \$"{"{WS}{TTCN3IDENTIFIER}{WS}(","{WS}integer{WS})?"}"
}
"["{WS}LOGGING{WS}"]" BEGIN(INITIAL);
"["{WS}PROFILER{WS}"]" BEGIN(INITIAL);
"["{WS}EXECUTE{WS}"]" BEGIN(INITIAL);
"["{WS}EXTERNAL_COMMANDS{WS}"]" BEGIN(INITIAL);
"["{WS}GROUPS{WS}"]" BEGIN(INITIAL);
......
......@@ -10,7 +10,7 @@
/* Version numbers */
#define TTCN3_MAJOR 5
#define TTCN3_MINOR 1
#define TTCN3_MINOR 2
#define TTCN3_PATCHLEVEL 0
//#define TTCN3_BUILDNUMBER 0
......@@ -22,7 +22,7 @@
* TTCN3_VERSION = TTCN3_MAJOR * 1000000 + TTCN3_MINOR * 10000 +
* TTCN3_PATCHLEVEL * 100 + TTCN3_BUILDNUMBER
*/
#define TTCN3_VERSION 50100
#define TTCN3_VERSION 50200
/* A monotonically increasing version number.
* An official release is deemed to have the highest possible build number (99)
......
......@@ -263,17 +263,10 @@ namespace Common {
return versions;
}
void Modules::add_types_to_json_schema(JSON_Tokenizer& json)
void Modules::generate_json_schema(JSON_Tokenizer& json, map<Type*, JSON_Tokenizer>& json_refs)
{
for(size_t i = 0; i < mods_v.size(); ++i) {
mods_v[i]->add_types_to_json_schema(json);
}
}
void Modules::add_func_to_json_schema(map<Type*, JSON_Tokenizer>& json_refs)
{
for(size_t i = 0; i < mods_v.size(); ++i) {
mods_v[i]->add_func_to_json_schema(json_refs);
mods_v[i]->generate_json_schema(json, json_refs);
}
}
......@@ -807,6 +800,12 @@ namespace Common {
mputprintf(effective_module_functions, "%s\"%s\"",
(effective_module_functions ? ", " : ""), get_modid().get_dispname().c_str());
}
if (profiler_enabled && MOD_TTCN == get_moduletype()) {
output->source.static_function_bodies = mputprintf(output->source.static_function_bodies,
"TTCN3_Stack_Depth stack_depth;\n"
"ttcn3_prof.enter_function(\"%s\", 0, \"%s\");\n",
get_filename(), get_modid().get_dispname().c_str());
}
}
output->source.static_function_bodies =
mputstr(output->source.static_function_bodies, output->functions.pre_init);
......@@ -844,6 +843,12 @@ namespace Common {
mputprintf(effective_module_functions, "%s\"%s\"",
(effective_module_functions ? ", " : ""), get_modid().get_dispname().c_str());
}
if (profiler_enabled && MOD_TTCN == get_moduletype()) {
output->source.static_function_bodies = mputprintf(output->source.static_function_bodies,
"TTCN3_Stack_Depth stack_depth;\n"
"ttcn3_prof.enter_function(\"%s\", 0, \"%s\");\n",
get_filename(), get_modid().get_dispname().c_str());
}
}
output->source.static_function_bodies =
mputstr(output->source.static_function_bodies, output->functions.post_init);
......
......@@ -116,14 +116,15 @@ namespace Common {
void generate_code(CodeGenHelper& cgh);
void dump(unsigned level=1) const;
/** Generates JSON schema segments for the types defined in the modules
* and adds them to the JSON schema parameter. */
void add_types_to_json_schema(JSON_Tokenizer& json);
/** Generates JSON schemas containing references to the types defined in the
* modules. Information related to the types' JSON encoding and decoding
* functions is also inserted after the references. */
void add_func_to_json_schema(map<Type*, JSON_Tokenizer>& json_refs);
/** Generates JSON schema segments for the types defined in the modules,
* and references to these types. Information related to the types'
* JSON encoding and decoding functions is also inserted after the references.
*
* @param json JSON document containing the main schema, schema segments for
* the types will be inserted here
* @param json_refs map of JSON documents containing the references and function
* info related to each type */
void generate_json_schema(JSON_Tokenizer& json, map<Type*, JSON_Tokenizer>& json_refs);
};
/**
......@@ -391,15 +392,15 @@ namespace Common {
void generate_code(CodeGenHelper& cgh);
virtual void dump(unsigned level) const;
/** Generates JSON schema segments for the types defined in the module
* and adds them to the JSON schema parameter. */
virtual void add_types_to_json_schema(JSON_Tokenizer&) = 0;
/** Generates JSON schemas containing references to the types that have JSON
* encoding and/or decoding functions declared in the module. Information
* related to these functions is also inserted after the references
* (only for TTCN-3 modules). */
virtual void add_func_to_json_schema(map<Type*, JSON_Tokenizer>&) = 0;
/** Generates JSON schema segments for the types defined in the modules,
* and references to these types. Information related to the types'
* JSON encoding and decoding functions is also inserted after the references.
*
* @param json JSON document containing the main schema, schema segments for
* the types will be inserted here
* @param json_refs map of JSON documents containing the references and function
* info related to each type */
virtual void generate_json_schema(JSON_Tokenizer& json, map<Type*, JSON_Tokenizer>& json_refs) = 0;
};
/**
......
......@@ -298,7 +298,7 @@ namespace Common {
if (++error_count >= max_errors) {
fputs("Maximum number of errors reached, aborting.\n", stderr);
fflush(stderr);
abort();
exit(EXIT_FAILURE);
}
}
......
......@@ -68,7 +68,7 @@ main.cc Real.cc Setting.cc SigParam.cc string.cc subtype.cc Stopwatch.cc \
Type.cc Type_chk.cc Type_codegen.cc TypeCompat.cc \
Typestuff.cc ustring.cc Value.cc Valuestuff.cc XerAttributes.cc subtypestuff.cc CodeGenHelper.cc
MFGEN_SOURCES := makefile.c xpather.cc
MFGEN_SOURCES := makefile.c xpather.cc ProjectGenHelper.cc
TCOV2LCOV_SOURCES := tcov2lcov.cc
......
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2000-2014 Ericsson Telecom AB
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
///////////////////////////////////////////////////////////////////////////////
#include "ProjectGenHelper.hh"
#include "../common/memory.h"
#include "error.h"
#include <limits>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const std::string ProjectDescriptor::emptyString = std::string();
ProjectDescriptor::ProjectDescriptor(const char * name) :
projectName(std::string(name)),
tpdFileName(),
targetExecutableName(),
projectAbsTpdDir(),
projectAbsWorkingDir(),
projectWorkingDir(),
library(false),
dynamicLinked(false),
referencedProjects(),
refProjWorkingDirs(),
libSearchPaths(),
linkerLibraries(),
ttcn3ModuleNames(),
asn1ModuleNames(),
userSources(),
userHeaders(),
ttcnPP(),
initialized(false)
{}
void ProjectDescriptor::cleanUp()
{
referencedProjects.clear();
refProjWorkingDirs.clear(),
libSearchPaths.clear();
linkerLibraries.clear();
ttcn3ModuleNames.clear();
asn1ModuleNames.clear();
userSources.clear();
userHeaders.clear();
ttcnPP.clear();
}
bool ProjectDescriptor::isInitialized()
{
if (!projectName.empty() &&
!targetExecutableName.empty() &&
!projectAbsTpdDir.empty() &&
!projectAbsWorkingDir.empty() &&
!projectWorkingDir.empty())
initialized = true;
return initialized;
}
void ProjectDescriptor::setTPDFileName(const char* name)
{
const char SEPARATOR = '/';
std::string fileName(name);
size_t refProjPos = fileName.find_last_of(SEPARATOR);
if (std::string::npos == refProjPos) {
tpdFileName = fileName;
}
else {
tpdFileName = fileName.substr(refProjPos + 1);
}
}
void ProjectDescriptor::setProjectAbsWorkingDir(const char* name)
{
if (!name) {
ERROR("No path was given to the working directory. Check if 'r' flag is set ");
return;
}
projectAbsWorkingDir = std::string(name);
ProjectGenHelper::Instance().setRootDirOS(name);
}
void ProjectDescriptor::addToReferencedProjects(const char* refProjName)
{
std::vector<std::string>::iterator it;
for (it = referencedProjects.begin(); it != referencedProjects.end(); ++it) {
if (*it == std::string(refProjName)) return;
}
referencedProjects.push_back(std::string(refProjName));
}
void ProjectDescriptor::addToRefProjWorkingDirs(const std::string& subProjDir)
{
std::vector<std::string>::iterator it;
for (it = refProjWorkingDirs.begin(); it != refProjWorkingDirs.end(); ++it) {
if (*it == subProjDir) return;
}
refProjWorkingDirs.push_back(subProjDir);
}
bool ProjectDescriptor::hasLinkerLibTo(const std::string& refProjName) const
{
ProjectDescriptor* refProj = ProjectGenHelper::Instance().getTargetOfProject(refProjName.c_str());
for (size_t i = 0; i < referencedProjects.size(); ++i){
if (refProj && refProj->library) return true;
}
return false;
}
bool ProjectDescriptor::hasLinkerLib(const char* libName) const
{
std::string linkerLibName(libName);
std::vector<std::string>::const_iterator it;
for (it = linkerLibraries.begin(); it != linkerLibraries.end(); ++it) {
if (*it == linkerLibName) return true;
}
return false;
}
void ProjectDescriptor::addToLibSearchPaths(const char* libSearchPath)
{
std::string searchPath(libSearchPath);
std::vector<std::string>::iterator it;
for (it = libSearchPaths.begin(); it != libSearchPaths.end(); ++it) {
if (*it == searchPath) return;
}
libSearchPaths.push_back(libSearchPath);
}
void ProjectDescriptor::addToLinkerLibs(const char* linkerLibs)
{
std::string llibs(linkerLibs);
std::vector<std::string>::iterator it;
for (it = linkerLibraries.begin(); it != linkerLibraries.end(); ++it) {
if (*it == llibs) return;
}
linkerLibraries.push_back(linkerLibs);
}
size_t ProjectDescriptor::getLibSearchPathIndex(const std::string& subProjName) const
{
for (size_t i = 0; i < libSearchPaths.size(); ++i) {
if (std::string::npos != libSearchPaths[i].find(subProjName))
return i;
}
return std::numeric_limits<unsigned int>::max();
}
const char* ProjectDescriptor::getLibSearchPath(const std::string& subProjName) const
{
for (size_t i = 0; i < libSearchPaths.size(); ++i) {
if (std::string::npos != libSearchPaths[i].find(subProjName))
return libSearchPaths[i].c_str();
}
return NULL;
}
bool ProjectDescriptor::hasTtcn3ModuleName(const char* moduleName) const
{
std::string modName(moduleName);
std::vector<std::string>::const_iterator it;
for (it = ttcn3ModuleNames.begin(); it != ttcn3ModuleNames.end(); ++it) {
if (*it == modName) return true;
}
return false;
}
bool ProjectDescriptor::hasAsn1ModuleName(const char* moduleName) const
{
std::string modName(moduleName);
std::vector<std::string>::const_iterator it;
for (it = asn1ModuleNames.begin(); it != asn1ModuleNames.end(); ++it) {
if (*it == modName) return true;
}
return false;
}
bool ProjectDescriptor::hasUserSource(const char* userSourceName) const
{
std::string sourceName(userSourceName);
std::vector<std::string>::const_iterator it;
for (it = userSources.begin(); it != userSources.end(); ++it) {
if (*it == sourceName) return true;
}
return false;
}
bool ProjectDescriptor::hasUserHeader(const char* userHeaderName) const
{
std::string headerName(userHeaderName);
std::vector<std::string>::const_iterator it;
for (it = userHeaders.begin(); it != userHeaders.end(); ++it) {
if (*it == headerName) return true;
}
return false;
}
bool ProjectDescriptor::hasTtcn3PP(const char* ttcnPPName) const
{
std::string ttcnPPFile(ttcnPPName);
std::vector<std::string>::const_iterator it;
for (it = ttcnPP.begin(); it != ttcnPP.end(); ++it) {
if (*it == ttcnPPFile) return true;
}
return false;
}
std::string ProjectDescriptor::setRelativePathTo(const std::string& absPathTo)
{
if (projectAbsWorkingDir.empty()) return std::string();
const char SEPARATOR = '/';
if (projectAbsWorkingDir.at(0) != SEPARATOR || absPathTo.at(0) != SEPARATOR)
ERROR("Expecting absolute path to generate LinkerLibSearchPath ");
size_t length = projectAbsWorkingDir.size() > absPathTo.size() ? absPathTo.size() : projectAbsWorkingDir.size();
size_t lastSlash = 0;
size_t i;
for(i = 0; i < length && projectAbsWorkingDir.at(i) == absPathTo.at(i); ++i) {
if (projectAbsWorkingDir.at(i) == SEPARATOR && absPathTo.at(i) == SEPARATOR) {
lastSlash = i; // the same path until now...
}
}
if (length == i) { // got subdirectory
if (projectAbsWorkingDir == absPathTo) {
return std::string("."); // the same pathes were given
}
else if ((projectAbsWorkingDir.size() > absPathTo.size() && projectAbsWorkingDir.at(length) == SEPARATOR) ||
(projectAbsWorkingDir.size() < absPathTo.size() && absPathTo.at(length) == SEPARATOR))
lastSlash = length;
}
size_t slashCount = 0;
for (size_t i = lastSlash; i < projectAbsWorkingDir.size(); ++i) {
if (projectAbsWorkingDir.at(i) == SEPARATOR)
++slashCount;
}
std::string relPath;
const std::string upDir("../");
for (size_t i = 0; i < slashCount; ++i)
relPath.append(upDir);
std::string pathTo = absPathTo.substr(lastSlash+1); // we left the heading slash
relPath.append(pathTo);
return std::string(relPath);
}
void ProjectDescriptor::print()
{
fprintf( stderr, "project name %s and it is %s initialized\n", projectName.c_str(), isInitialized() ? "" : "not");
fprintf( stderr, " target executable name %s\n",targetExecutableName.c_str());
fprintf( stderr, " project abs TPD dir %s\n", projectAbsTpdDir.c_str());
fprintf( stderr, " project abs working dir %s\n", projectAbsWorkingDir.c_str());
fprintf( stderr, " project working dir %s\n", projectWorkingDir.c_str());
fprintf( stderr, " project is %s\n", library ? "Library" : "Executable");
fprintf( stderr, " project linking is %s\n", dynamicLinked ? "dynamic" : "static");
std::vector<std::string>::iterator it;
for (it = referencedProjects.begin(); it != referencedProjects.end(); ++it) {
fprintf( stderr, " Referenced project %s\n",(*it).c_str());
}