Commit 1c6999ed authored by Botond Baranyi's avatar Botond Baranyi Committed by Gerrit Code Review
Browse files

Merge " Implemented the ability to read input files from a file in makefilegen...

Merge " Implemented the ability to read input files from a file in makefilegen and compiler (artf785040)"
parents 8abd72b8 890d9eec
......@@ -78,6 +78,7 @@ using namespace Common;
const char *output_dir = NULL;
const char *tcov_file_name = NULL;
const char *profiler_file_name = NULL;
const char *file_list_file_name = NULL;
tcov_file_list *tcov_files = NULL;
expstring_t effective_module_lines = NULL;
expstring_t effective_module_functions = NULL;
......@@ -384,7 +385,7 @@ static boolean is_valid_asn1_filename(const char* file_name)
static void usage()
{
fprintf(stderr, "\n"
"usage: %s [-abcdEfgijlLMnOpqrRsStuwxXyY] [-K file] [-z file] [-V verb_level]\n"
"usage: %s [-abcdEfgijlLMnOpqrRsStuwxXyY] [-J file] [-K file] [-z file] [-V verb_level]\n"
" [-o dir] [-U none|type|'number'] [-P modulename.top_level_pdu_name] [-Q number] ...\n"
" [-T] module.ttcn [-A] module.asn ...\n"
" or %s -v\n"
......@@ -401,6 +402,7 @@ static void usage()
" -g: emulate GCC error/warning message format\n"
" -i: use only line numbers in error/warning messages\n"
" -j: disable JSON encoder/decoder functions\n"
" -J file: read input files from file\n"
" -K file: enable selective code coverage\n"
" -l: include source line info in C++ code\n"
" -L: add source line info for logging\n"
......@@ -494,6 +496,8 @@ int main(int argc, char *argv[])
size_t n_modules = 0;
module_struct *module_list = NULL;
char* json_schema_name = NULL;
size_t n_files_from_file = 0;
char ** files_from_file = NULL;
if (0 == strcmp(argv[1], "--ttcn2json")) {
ttcn2json = true;
......@@ -575,7 +579,7 @@ int main(int argc, char *argv[])
if (!ttcn2json) {
for ( ; ; ) {
int c = getopt(argc, argv, "aA:bBcC:dEfFgijK:lLMno:pP:qQ:rRsStT:uU:vV:wxXyYz:0-");
int c = getopt(argc, argv, "aA:bBcC:dEfFgijJ:K:lLMno:pP:qQ:rRsStT:uU:vV:wxXyYz:0-");
if (c == -1) break;
switch (c) {
case 'a':
......@@ -645,6 +649,9 @@ int main(int argc, char *argv[])
SET_FLAG(i);
output_only_linenum = TRUE;
break;
case 'J':
file_list_file_name = optarg;
break;
case 'K':
SET_FLAG(K);
tcov_file_name = optarg;
......@@ -832,7 +839,70 @@ int main(int argc, char *argv[])
output_dir);
errflag = true;
}
if (optind == argc && n_modules == 0) {
if (file_list_file_name != NULL) {
FILE *fp = fopen(file_list_file_name, "r");
if (fp != NULL) {
char buff[1024];
// We store the -A and -T here too
while (fscanf(fp, "%s", buff) == 1) {
n_files_from_file++;
files_from_file = (char**)
Realloc(files_from_file, n_files_from_file * sizeof(*files_from_file));
files_from_file[n_files_from_file - 1] = mcopystr(buff);
}
fclose(fp);
} else {
ERROR("Cannot open file `%s' for reading: %s", file_list_file_name,
strerror(errno));
errno = 0;
errflag = true;
}
bool next_is_asn1 = false;
bool next_is_ttcn = false;
for (size_t i = 0; i < n_files_from_file; i++) {
// Check if -A or -T is present and continue to the next word if yes
if (next_is_ttcn == false && next_is_asn1 == false) {
if (strcmp(files_from_file[i], "-A") == 0) {
next_is_asn1 = true;
continue;
} else if (strcmp(files_from_file[i], "-T") == 0) {
next_is_ttcn = true;
continue;
}
}
Module::moduletype_t module_type = Module::MOD_UNKNOWN;
const char* file = files_from_file[i];
if (next_is_asn1) {
module_type = Module::MOD_ASN;
next_is_asn1 = false;
} else if(next_is_ttcn) {
module_type = Module::MOD_TTCN;
next_is_ttcn = false;
} else if (strlen(files_from_file[i]) > 2) {
// The -A or -T can be given as -TMyTtcnfile.ttcn too
if (files_from_file[i][0] == '-') {
if (files_from_file[i][1] == 'A') {
file = files_from_file[i] + 2;
module_type = Module::MOD_ASN;
} else if (files_from_file[i][1] == 'T') {
file = files_from_file[i] + 2;
module_type = Module::MOD_TTCN;
}
}
}
if (module_type == Module::MOD_TTCN) {
#ifdef LICENSE
ttcn3_modules_present = true;
#endif
} else if (module_type == Module::MOD_ASN) {
asn1_modules_present = true;
}
add_module(n_modules, module_list, file, module_type);
}
}
if (optind == argc && n_modules == 0 && n_files_from_file == 0) {
ERROR("No input TTCN-3 or ASN.1 module was given.");
errflag = true;
}
......@@ -1156,6 +1226,10 @@ int main(int argc, char *argv[])
if (zflag) {
free_profiler_data();
}
for (size_t i = 0; i < n_files_from_file; i++) {
Free(files_from_file[i]);
}
Free(files_from_file);
// dbgnew.hh already does it: check_mem_leak(argv[0]);
......
......@@ -4590,7 +4590,7 @@ static void usage(void)
{
fprintf(stderr, "\n"
"usage: %s [-abc" C_flag "dDEfFglLmMnprRsStTVwWXZ] [-K file] [-z file ] [-P dir]"
" [-j file] [-U none|type|'number'] [-e ets_name] [-o dir|file]\n"
" [-J file] [-U none|type|'number'] [-e ets_name] [-o dir|file]\n"
" [-t project_descriptor.tpd [-b buildconfig]]\n"
" [-O file] ... module_name ... testport_name ...\n"
" or %s -v\n"
......@@ -4607,7 +4607,7 @@ static void usage(void)
" -f: force overwriting of the output Makefile\n"
" -g: generate Makefile for use with GNU make\n"
" -I path: Add path to the search paths when using TPD files\n"
" -j file: The names of files taken from file instead of command line"
" -J file: The names of files taken from file instead of command line"
" -K file: enable selective code coverage\n"
" -l: use dynamic linking\n"
" -L: create makefile with library archive as the default target\n"
......@@ -4720,7 +4720,7 @@ int main(int argc, char *argv[])
}
for ( ; ; ) {
int c = getopt(argc, argv, "O:ab:c" C_flag "dDe:EfFgI:j:K:o:lLmMnpP:rRsSt:TU:vVwWXYz:ZH");
int c = getopt(argc, argv, "O:ab:c" C_flag "dDe:EfFgI:J:K:o:lLmMnpP:rRsSt:TU:vVwWXYz:ZH");
if (c == -1) break;
switch (c) {
case 'O':
......@@ -4779,7 +4779,7 @@ int main(int argc, char *argv[])
case 'H':
SET_FLAG(H);
break;
case 'j':
case 'J':
file_list_file_name = optarg;
break;
case 'o':
......
......@@ -116,9 +116,9 @@ close FILE;
# Generate the makefile
print("LD_LIBRARY_PATH is $ENV{LD_LIBRARY_PATH}\n");#temporary debug printout
print("$ENV{TTCN3_DIR}/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -j files.txt $xsdfiles2 \n");
print("$ENV{TTCN3_DIR}/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -J files.txt $xsdfiles2 \n");
system( "\$TTCN3_DIR/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -o Makefile.1 -j files.txt $xsdfiles2");
system( "\$TTCN3_DIR/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -o Makefile.1 -J files.txt $xsdfiles2");
unlink $outfile;
......
......@@ -17,7 +17,9 @@ COVERAGE_FLAG := -C
endif
MFGEN := $(TTCN3_DIR)/bin/ttcn3_makefilegen
MFGEN_FLAGS := -f $(RT2_FLAG) $(SPLIT_FLAG)
MFGEN_FLAGS := -fs $(RT2_FLAG) $(SPLIT_FLAG) -e Main
COMPILER := $(TTCN3_DIR)/bin/ttcn3_compiler
COMPILER_FLAGS := $(RT2_FLAG) $(SPLIT_FLAG)
# ${MAKEPROG} has the same content as the built-in ${MAKE},
# except the special handling of ${MAKE} does not apply.
......@@ -25,8 +27,24 @@ MFGEN_FLAGS := -f $(RT2_FLAG) $(SPLIT_FLAG)
# then fail on every subsequent invocation until a 'make clean' is done.
MAKEPROG := ${MAKE}
all:
mkdir -p bin && cp files.txt bin/files.txt && cd bin && $(MFGEN) $(MFGEN_FLAGS) -j files.txt \
&& $(MAKEPROG) && make clean && cd .. && rm -rf bin
all: compiler makefile
.PHONY: all clean distclean run
compiler:
mkdir -p bin && cp compiler_files1.txt bin/files.txt && cd bin \
&& $(COMPILER) $(COMPILER_FLAGS) -J files.txt ../src/ASN1Module3.asn \
&& cd .. && rm -rf bin
mkdir -p bin && cp compiler_files2.txt bin/files.txt && cd bin \
&& $(COMPILER) $(COMPILER_FLAGS) -J files.txt ../src/ASN1Module3.asn \
&& cd .. && rm -rf bin
makefile:
mkdir -p bin && cp mfgen_files1.txt bin/files.txt && cd bin \
&& $(MFGEN) $(MFGEN_FLAGS) -J files.txt ../src/ASN1Module3.asn \
&& $(MAKEPROG) && ./Main && make clean && cd .. && rm -rf bin
mkdir -p bin && cp mfgen_files2.txt bin/files.txt && cd bin \
&& $(MFGEN) $(MFGEN_FLAGS) -J files.txt ../src/ASN1Module3.asn \
&& $(MAKEPROG) && ./Main && make clean && cd .. && rm -rf bin
.PHONY: all clean distclean run compiler makefile
../src/UsefulTtcn3Types.ttcn ../src/XSD.ttcn ../src/Module1.ttcn ../src/Module2.ttcn ../src/Module3.ttcn ../src/Module4.ttcn ../src/Module5.ttcn ../src/ASN1Module1.asn ../src/ASN1Module2.asn ../src/Main.ttcn
\ No newline at end of file
../src/UsefulTtcn3Types.ttcn
-T ../src/XSD.ttcn
../src/Module1.ttcn -T
../src/Module2.ttcn
../src/Module3.ttcn -T ../src/Module4.ttcn ../src/Module5.ttcn -A
../src/ASN1Module1.asn -A../src/ASN1Module2.asn
-T../src/Main.ttcn
\ No newline at end of file
../src/Definitions.xsd ../src/MainNormal.ttcn
../src/MainExtNormal.ttcn
\ No newline at end of file
../src/UsefulTtcn3Types.ttcn ../src/XSD.ttcn ../src/Module1.ttcn ../src/Module2.ttcn ../src/Module3.ttcn ../src/Module4.ttcn ../src/Module5.ttcn ../src/ASN1Module1.asn ../src/ASN1Module2.asn ../src/Main.ttcn
\ No newline at end of file
../src/UsefulTtcn3Types.ttcn
../src/XSD.ttcn
../src/Module1.ttcn
../src/Module2.ttcn
../src/Module3.ttcn ../src/Module4.ttcn ../src/Module5.ttcn
../src/ASN1Module1.asn ../src/ASN1Module2.asn
../src/Main.ttcn
\ No newline at end of file
--/////////////////////////////////////////////////////////////////////////////
-- Copyright (c) 2000-2016 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
--
-- Contributors:
-- Szabo, Bence Janos
--
--/////////////////////////////////////////////////////////////////////////////
ASN1Module1
DEFINITIONS
AUTOMATIC TAGS
::=
BEGIN
IMPORTS ; -- nothing
asn1module1 INTEGER ::= 1
END
\ No newline at end of file
--/////////////////////////////////////////////////////////////////////////////
-- Copyright (c) 2000-2016 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
--
-- Contributors:
-- Szabo, Bence Janos
--
--/////////////////////////////////////////////////////////////////////////////
ASN1Module2
DEFINITIONS
AUTOMATIC TAGS
::=
BEGIN
IMPORTS ; -- nothing
asn1module2 INTEGER ::= 2
END
\ No newline at end of file
--/////////////////////////////////////////////////////////////////////////////
-- Copyright (c) 2000-2016 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
--
-- Contributors:
-- Szabo, Bence Janos
--
--/////////////////////////////////////////////////////////////////////////////
ASN1Module3
DEFINITIONS
AUTOMATIC TAGS
::=
BEGIN
IMPORTS ; -- nothing
asn1module3 INTEGER ::= 3
END
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2000-2016 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
Contributors:
Szabo, Bence Janos
-->
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:this="www.example.org/Definitions"
targetNamespace="www.example.org/Definitions">
<xsd:element name="MyInt" type="xsd:integer"/>
</xsd:schema>
/******************************************************************************
* Copyright (c) 2000-2016 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
*
* Contributors:
* Szabo, Bence Janos
*
******************************************************************************/
module Main {
import from Module1 all;
import from Module2 all;
import from Module3 all;
import from Module4 all;
import from Module5 all;
import from ASN1Module1 language "ASN.1:2002" all;
import from ASN1Module2 language "ASN.1:2002" all;
import from ASN1Module3 language "ASN.1:2002" all;
import from XSD all;
import from UsefulTtcn3Types all;
type component EmptyCT {}
testcase tc_test() runs on EmptyCT {
var XSD.Integer sum := module1 + module2 + module3 + module4 + module5
+ asn1module1 + asn1module2 + asn1module3;
if (sum == 21) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(tc_test());
}
}
\ No newline at end of file
......@@ -9,25 +9,6 @@
* Szabo, Bence Janos
*
******************************************************************************/
module MainNormal {
type component EmptyCT {}
const integer myInt := 5;
testcase tc_test() runs on EmptyCT {
var integer tempInt := myInt;
if (tempInt == 5) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(tc_test());
}
}
module Module1{
const integer module1 := 1;
}
\ No newline at end of file
......@@ -9,32 +9,6 @@
* Szabo, Bence Janos
*
******************************************************************************/
module MainExtNormal {
import from MainNormal all;
type component EmptyCT {}
const universal charstring myString := "almafa";
testcase tc_test() runs on EmptyCT {
var universal charstring tempString := myString;
if (tempString == "almafa") {
setverdict(pass);
} else {
setverdict(fail);
}
var integer tempInt := 5;
if (tempInt == 5) {
setverdict(pass);
} else {
setverdict(fail);
}
}
control {
execute(tc_test());
}
}
module Module2{
const integer module2 := 2;
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2016 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
*
* Contributors:
* Szabo, Bence Janos
*
******************************************************************************/
module Module3{
const integer module3 := 3;
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2016 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
*
* Contributors:
* Szabo, Bence Janos
*
******************************************************************************/
module Module4{
const integer module4 := 4;
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2016 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
*
* Contributors:
* Szabo, Bence Janos
*
******************************************************************************/
module Module5{
const integer module5 := 5;
}
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2016 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
*
* Contributors:
* Szabo, Bence Janos
*
******************************************************************************/
module UsefulTtcn3Types {
type integer byte (-128 .. 127) with { variant "/* 8 bit */" };
type integer unsignedbyte (0 .. 255) with { variant "/*unsigned 8 bit*/" };
type integer short (-32768 .. 32767) with { variant "/*16 bit*/" };
type integer unsignedshort (0 .. 65535) with { variant "/*unsigned 16 bit*/" };
type integer long (-2147483648 .. 2147483647) with { variant "/*32 bit*/" };
type integer unsignedlong (0 .. 4294967295) with { variant "/*unsigned 32 bit*/" };
type integer longlong /* ( -9223372036854775808 .. 9223372036854775807 ) */ with { variant "/*64 bit*/" };
type integer unsignedlonglong /* ( 0 .. 18446744073709551615 ) */ with { variant "/*unsigned 64 bit*/" };
type float IEEE754float with { variant "/*IEEE754 float*/" };
type float IEEE754double with { variant "/*IEEE754 double*/" };
type float IEEE754extfloat with { variant "/*IEEE754 extended float*/" };
type float IEEE754extdouble with { variant "/*IEEE754 extended double*/" };
type universal charstring utf8string with { variant "/*UTF-8*/" };
type universal charstring bmpstring ( char ( 0,0,0,0 ) .. char ( 0,0,255,255) ) with { variant "/*UCS-2*/" };
type universal charstring utf16string ( char ( 0,0,0,0 ) .. char ( 0,16,255,255) ) with { variant "/*UTF-16*/" };
type universal charstring iso8859string ( char ( 0,0,0,0 ) .. char ( 0,0,0,255) ) with { variant "/*8 bit*/" };
type record IDLfixed
{
unsignedshort digits,
short scale,
charstring value_