Commit 890d9eec authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

Implemented the ability to read input files from a file in makefilegen and compiler (artf785040)



Change-Id: Iff6a4be89bc5f0a92f2ec8fc8a687e482760258f
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent 9e26131c
...@@ -78,6 +78,7 @@ using namespace Common; ...@@ -78,6 +78,7 @@ using namespace Common;
const char *output_dir = NULL; const char *output_dir = NULL;
const char *tcov_file_name = NULL; const char *tcov_file_name = NULL;
const char *profiler_file_name = NULL; const char *profiler_file_name = NULL;
const char *file_list_file_name = NULL;
tcov_file_list *tcov_files = NULL; tcov_file_list *tcov_files = NULL;
expstring_t effective_module_lines = NULL; expstring_t effective_module_lines = NULL;
expstring_t effective_module_functions = NULL; expstring_t effective_module_functions = NULL;
...@@ -384,7 +385,7 @@ static boolean is_valid_asn1_filename(const char* file_name) ...@@ -384,7 +385,7 @@ static boolean is_valid_asn1_filename(const char* file_name)
static void usage() static void usage()
{ {
fprintf(stderr, "\n" 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" " [-o dir] [-U none|type|'number'] [-P modulename.top_level_pdu_name] [-Q number] ...\n"
" [-T] module.ttcn [-A] module.asn ...\n" " [-T] module.ttcn [-A] module.asn ...\n"
" or %s -v\n" " or %s -v\n"
...@@ -401,6 +402,7 @@ static void usage() ...@@ -401,6 +402,7 @@ static void usage()
" -g: emulate GCC error/warning message format\n" " -g: emulate GCC error/warning message format\n"
" -i: use only line numbers in error/warning messages\n" " -i: use only line numbers in error/warning messages\n"
" -j: disable JSON encoder/decoder functions\n" " -j: disable JSON encoder/decoder functions\n"
" -J file: read input files from file\n"
" -K file: enable selective code coverage\n" " -K file: enable selective code coverage\n"
" -l: include source line info in C++ code\n" " -l: include source line info in C++ code\n"
" -L: add source line info for logging\n" " -L: add source line info for logging\n"
...@@ -494,6 +496,8 @@ int main(int argc, char *argv[]) ...@@ -494,6 +496,8 @@ int main(int argc, char *argv[])
size_t n_modules = 0; size_t n_modules = 0;
module_struct *module_list = NULL; module_struct *module_list = NULL;
char* json_schema_name = NULL; char* json_schema_name = NULL;
size_t n_files_from_file = 0;
char ** files_from_file = NULL;
if (0 == strcmp(argv[1], "--ttcn2json")) { if (0 == strcmp(argv[1], "--ttcn2json")) {
ttcn2json = true; ttcn2json = true;
...@@ -575,7 +579,7 @@ int main(int argc, char *argv[]) ...@@ -575,7 +579,7 @@ int main(int argc, char *argv[])
if (!ttcn2json) { if (!ttcn2json) {
for ( ; ; ) { 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; if (c == -1) break;
switch (c) { switch (c) {
case 'a': case 'a':
...@@ -645,6 +649,9 @@ int main(int argc, char *argv[]) ...@@ -645,6 +649,9 @@ int main(int argc, char *argv[])
SET_FLAG(i); SET_FLAG(i);
output_only_linenum = TRUE; output_only_linenum = TRUE;
break; break;
case 'J':
file_list_file_name = optarg;
break;
case 'K': case 'K':
SET_FLAG(K); SET_FLAG(K);
tcov_file_name = optarg; tcov_file_name = optarg;
...@@ -832,7 +839,70 @@ int main(int argc, char *argv[]) ...@@ -832,7 +839,70 @@ int main(int argc, char *argv[])
output_dir); output_dir);
errflag = true; 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."); ERROR("No input TTCN-3 or ASN.1 module was given.");
errflag = true; errflag = true;
} }
...@@ -1156,6 +1226,10 @@ int main(int argc, char *argv[]) ...@@ -1156,6 +1226,10 @@ int main(int argc, char *argv[])
if (zflag) { if (zflag) {
free_profiler_data(); 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]); // dbgnew.hh already does it: check_mem_leak(argv[0]);
......
...@@ -4590,7 +4590,7 @@ static void usage(void) ...@@ -4590,7 +4590,7 @@ static void usage(void)
{ {
fprintf(stderr, "\n" fprintf(stderr, "\n"
"usage: %s [-abc" C_flag "dDEfFglLmMnprRsStTVwWXZ] [-K file] [-z file ] [-P dir]" "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" " [-t project_descriptor.tpd [-b buildconfig]]\n"
" [-O file] ... module_name ... testport_name ...\n" " [-O file] ... module_name ... testport_name ...\n"
" or %s -v\n" " or %s -v\n"
...@@ -4607,7 +4607,7 @@ static void usage(void) ...@@ -4607,7 +4607,7 @@ static void usage(void)
" -f: force overwriting of the output Makefile\n" " -f: force overwriting of the output Makefile\n"
" -g: generate Makefile for use with GNU make\n" " -g: generate Makefile for use with GNU make\n"
" -I path: Add path to the search paths when using TPD files\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" " -K file: enable selective code coverage\n"
" -l: use dynamic linking\n" " -l: use dynamic linking\n"
" -L: create makefile with library archive as the default target\n" " -L: create makefile with library archive as the default target\n"
...@@ -4720,7 +4720,7 @@ int main(int argc, char *argv[]) ...@@ -4720,7 +4720,7 @@ int main(int argc, char *argv[])
} }
for ( ; ; ) { 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; if (c == -1) break;
switch (c) { switch (c) {
case 'O': case 'O':
...@@ -4779,7 +4779,7 @@ int main(int argc, char *argv[]) ...@@ -4779,7 +4779,7 @@ int main(int argc, char *argv[])
case 'H': case 'H':
SET_FLAG(H); SET_FLAG(H);
break; break;
case 'j': case 'J':
file_list_file_name = optarg; file_list_file_name = optarg;
break; break;
case 'o': case 'o':
......
...@@ -116,9 +116,9 @@ close FILE; ...@@ -116,9 +116,9 @@ close FILE;
# Generate the makefile # Generate the makefile
print("LD_LIBRARY_PATH is $ENV{LD_LIBRARY_PATH}\n");#temporary debug printout 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; unlink $outfile;
......
...@@ -17,7 +17,9 @@ COVERAGE_FLAG := -C ...@@ -17,7 +17,9 @@ COVERAGE_FLAG := -C
endif endif
MFGEN := $(TTCN3_DIR)/bin/ttcn3_makefilegen 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}, # ${MAKEPROG} has the same content as the built-in ${MAKE},
# except the special handling of ${MAKE} does not apply. # except the special handling of ${MAKE} does not apply.
...@@ -25,8 +27,24 @@ MFGEN_FLAGS := -f $(RT2_FLAG) $(SPLIT_FLAG) ...@@ -25,8 +27,24 @@ MFGEN_FLAGS := -f $(RT2_FLAG) $(SPLIT_FLAG)
# then fail on every subsequent invocation until a 'make clean' is done. # then fail on every subsequent invocation until a 'make clean' is done.
MAKEPROG := ${MAKE} MAKEPROG := ${MAKE}
all: all: compiler makefile
mkdir -p bin && cp files.txt bin/files.txt && cd bin && $(MFGEN) $(MFGEN_FLAGS) -j files.txt \
&& $(MAKEPROG) && make clean && cd .. && rm -rf bin
.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 @@ ...@@ -9,25 +9,6 @@
* Szabo, Bence Janos * Szabo, Bence Janos
* *
******************************************************************************/ ******************************************************************************/
module MainNormal { module Module1{
const integer module1 := 1;
}
type component EmptyCT {} \ No newline at end of file
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());
}
}
...@@ -9,32 +9,6 @@ ...@@ -9,32 +9,6 @@
* Szabo, Bence Janos * Szabo, Bence Janos
* *
******************************************************************************/ ******************************************************************************/
module MainExtNormal { module Module2{
const integer module2 := 2;
import from MainNormal all; }
\ No newline at end of file
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());
}
}
/******************************************************************************
* 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