Commit a36c6be1 authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

makefilegen new switch -j file, to read files from file, rewritten xmlworkflow...


makefilegen new switch -j file, to read files from file, rewritten xmlworkflow tests to use the -j switch

Change-Id: Id8ee0cf9ddeaca30dc7347ce1e58ec1bb738c715
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent d6251d7b
......@@ -985,7 +985,6 @@ static void add_xsd_module(struct makefile_struct *makefile,
struct module_struct *module;
char *dir_name = get_dir_name(path_name, makefile->working_dir);
char *file_name = get_file_from_path(path_name);
const char *suffix = get_suffix(file_name);
size_t i;
for (i = 0; i < makefile->nXSDModules; i++) {
if (strcmp(makefile->XSDModules[i].module_name, module_name) == 0) {
......@@ -1236,6 +1235,48 @@ static void add_user_file(struct makefile_struct *makefile,
makefile->working_dir, TRUE);
}
static void add_file_to_makefile(struct makefile_struct *makefile, char *argument) {
char *file_name = get_file_name_for_argument(argument);
if (file_name != NULL) {
FILE *fp = fopen(file_name, "r");
if (fp != NULL) {
char *module_name = NULL;
if (is_ttcn3_module(file_name, fp, &module_name)) {
if (is_asn1_module(file_name, fp, NULL)) {
ERROR("File `%s' looks so strange that it can be both ASN.1 and "
"TTCN-3 module. Add it to the Makefile manually.", file_name);
Free(module_name);
} else {
add_ttcn3_module(makefile, file_name, module_name);
}
} else if (is_asn1_module(file_name, fp, &module_name)) {
if (is_valid_asn1_filename(file_name)) {
add_asn1_module(makefile, file_name, module_name);
} else {
ERROR("The file name `%s' (without suffix) shall be identical to the module name `%s'.\n"
"If the name of the ASN.1 module contains a hyphen, the corresponding "
"file name shall contain an underscore character instead.", file_name, module_name);
Free(module_name);
}
} else if (is_xsd_module(file_name, &module_name)) {
add_xsd_module(makefile, file_name, module_name);
} else {
add_user_file(makefile, file_name);
}
fclose(fp);
} else {
ERROR("Cannot open file `%s' for reading: %s", file_name,
strerror(errno));
errno = 0;
}
Free(file_name);
} else if (get_path_status(argument) == PS_DIRECTORY) {
ERROR("Argument `%s' is a directory.", argument);
} else {
ERROR("Cannot find any source file for argument `%s'.", argument);
}
}
/** Removes the generated C++ header and/or source files of module \a module
* from Makefile descriptor structure \a makefile. A warning is displayed if
* such file is found. */
......@@ -4356,7 +4397,7 @@ static void generate_makefile(size_t n_arguments, char *arguments[],
boolean central_storage, boolean absolute_paths, boolean preprocess,
boolean dump_makefile_data, boolean force_overwrite, boolean use_runtime_2,
boolean dynamic, boolean makedepend, boolean coverage,
const char *code_splitting_mode, const char *tcov_file_name, struct string_list* profiled_file_list,
const char *code_splitting_mode, const char *tcov_file_name, struct string_list* profiled_file_list, const char* file_list_file_name,
boolean Lflag, boolean Zflag, boolean Hflag, struct string_list* sub_project_dirs, struct string_list* ttcn3_prep_includes,
struct string_list* ttcn3_prep_defines, struct string_list* ttcn3_prep_undefines, struct string_list* prep_includes,
struct string_list* prep_defines, struct string_list* prep_undefines, boolean codesplittpd, boolean quietly, boolean disablesubtypecheck,
......@@ -4429,48 +4470,33 @@ static void generate_makefile(size_t n_arguments, char *arguments[],
makefile.linkerlibsearchpath = linkerlibsearchpath;
makefile.generatorCommandOutput = generatorCommandOutput;
makefile.target_placement_list = target_placement_list;
for (i = 0; i < n_arguments; i++) {
char *file_name = get_file_name_for_argument(arguments[i]);
if (file_name != NULL) {
FILE *fp = fopen(file_name, "r");
if (fp != NULL) {
char *module_name = NULL;
if (is_ttcn3_module(file_name, fp, &module_name)) {
if (is_asn1_module(file_name, fp, NULL)) {
ERROR("File `%s' looks so strange that it can be both ASN.1 and "
"TTCN-3 module. Add it to the Makefile manually.", file_name);
Free(module_name);
} else {
add_ttcn3_module(&makefile, file_name, module_name);
}
} else if (is_asn1_module(file_name, fp, &module_name)) {
if (is_valid_asn1_filename(file_name)) {
add_asn1_module(&makefile, file_name, module_name);
} else {
ERROR("The file name `%s' (without suffix) shall be identical to the module name `%s'.\n"
"If the name of the ASN.1 module contains a hyphen, the corresponding "
"file name shall contain an underscore character instead.", file_name, module_name);
Free(module_name);
}
} else if (is_xsd_module(file_name, &module_name)) {
add_xsd_module(&makefile, file_name, module_name);
} else {
add_user_file(&makefile, file_name);
}
fclose(fp);
} else {
ERROR("Cannot open file `%s' for reading: %s", file_name,
strerror(errno));
errno = 0;
}
Free(file_name);
} else if (get_path_status(arguments[i]) == PS_DIRECTORY) {
ERROR("Argument `%s' is a directory.", arguments[i]);
char ** files_from_file = NULL;
size_t n_files_from_file = 0;
if (file_list_file_name != NULL) {
FILE *fp = fopen(file_list_file_name, "r");
if (fp != NULL) {
char buff[1024];
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 find any source file for argument `%s'.", arguments[i]);
ERROR("Cannot open file `%s' for reading: %s", file_list_file_name,
strerror(errno));
errno = 0;
}
}
for (i = 0; i < n_files_from_file; i++) {
add_file_to_makefile(&makefile, files_from_file[i]);
}
for (i = 0; i < n_arguments; i++) {
add_file_to_makefile(&makefile, arguments[i]);
}
for (i = 0; i < n_other_files; i++) {
char *file_name = get_file_name_for_argument(other_files[i]);
if (file_name != NULL) {
......@@ -4546,6 +4572,10 @@ static void generate_makefile(size_t n_arguments, char *arguments[],
if (dump_makefile_data) dump_makefile_struct(&makefile, 0);
if (error_count == 0) print_makefile(&makefile);
for (i = 0; i < n_files_from_file; i++) {
Free(files_from_file[i]);
}
Free(files_from_file);
free_makefile_struct(&makefile);
}
......@@ -4560,7 +4590,7 @@ static void usage(void)
{
fprintf(stderr, "\n"
"usage: %s [-abc" C_flag "dDEfFglLmMnprRsStTVwWXZ] [-K file] [-z file ] [-P dir]"
" [-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"
......@@ -4577,6 +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"
" -K file: enable selective code coverage\n"
" -l: use dynamic linking\n"
" -L: create makefile with library archive as the default target\n"
......@@ -4641,6 +4672,7 @@ int main(int argc, char *argv[])
const char *tpd_file_name = NULL;
const char *tpd_build_config = NULL;
const char *tcov_file_name = NULL;
const char *file_list_file_name = NULL;
size_t n_search_paths = 0;
const char **search_paths = NULL;
struct string_list* profiled_file_list = NULL;
......@@ -4688,7 +4720,7 @@ int main(int argc, char *argv[])
}
for ( ; ; ) {
int c = getopt(argc, argv, "O:ab:c" C_flag "dDe:EfFgI: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':
......@@ -4747,6 +4779,9 @@ int main(int argc, char *argv[])
case 'H':
SET_FLAG(H);
break;
case 'j':
file_list_file_name = optarg;
break;
case 'o':
SET_FLAG(o);
output_file = optarg;
......@@ -5092,7 +5127,7 @@ int main(int argc, char *argv[])
generate_makefile(argc - optind, argv + optind, n_other_files, other_files,
output_file, ets_name, project_name, gflag, sflag, cflag, aflag, pflag, dflag, fflag||Fflag,
Rflag, lflag, mflag, Cflag, code_splitting_mode, tcov_file_name, profiled_file_list,
Lflag, Zflag, Hflag, rflag ? sub_project_dirs : NULL, ttcn3_prep_includes,
file_list_file_name, Lflag, Zflag, Hflag, rflag ? sub_project_dirs : NULL, ttcn3_prep_includes,
ttcn3_prep_defines, ttcn3_prep_undefines, prep_includes, prep_defines, prep_undefines, csflag, quflag, dsflag, cxxcompiler, optlevel, optflags, dbflag,
drflag, dtflag, dxflag, djflag, fxflag, doflag, gfflag, lnflag, isflag, asflag, wflag, Yflag, Mflag, Eflag, nflag, diflag, solspeclibraries,
sol8speclibraries, linuxspeclibraries, freebsdspeclibraries, win32speclibraries, ttcn3prep, linkerlibraries, additionalObjects,
......
......@@ -108,12 +108,19 @@ map { s!.+/!!g } @xsdfiles;
#add the xsd files as other files
my $prefix = "-O ";
my $xsdfiles2 = join " ", map { $prefix . $_ } @xsdfiles;
my $outfile = 'files.txt';
open (FILE, ">> $outfile") || die "problem opening $outfile\n";
my $files_without_xsd_string = join(' ', @files_without_xsd);
print FILE $files_without_xsd_string;
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 @files_without_xsd $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 @files_without_xsd $xsdfiles2");
system( "\$TTCN3_DIR/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -o Makefile.1 -j files.txt $xsdfiles2");
unlink $outfile;
# Post-process the generated makefile
open(MAKEFILE_IN , '<' . 'Makefile.1') or die "open input: $!";
......
......@@ -26,7 +26,7 @@ CODIRS := dynamicTemplate styleGuide topLevelPdu \
openType optionalAssignCompare portConstructor \
isbound namedActualParameters assignmentNotation \
attribQualif HT48786 selectCase openTypeNames \
defaultParamUsageBeforeDecl deterministic
defaultParamUsageBeforeDecl deterministic readFromFile
all dep clean distclean:
for dir in $(CODIRS); do $(MAKE) -C $$dir $@ || exit; done
##############################################################################
# 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
#
##############################################################################
TOPDIR := ../..
include $(TOPDIR)/Makefile.regression
ifdef LCOV
COVERAGE_FLAG := -C
endif
MFGEN := $(TTCN3_DIR)/bin/ttcn3_makefilegen
MFGEN_FLAGS := -f $(RT2_FLAG) $(SPLIT_FLAG)
# ${MAKEPROG} has the same content as the built-in ${MAKE},
# except the special handling of ${MAKE} does not apply.
# If we used ${MAKE} in the rules below, 'make -n' would succeed once,
# 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
.PHONY: all clean distclean run
../src/Definitions.xsd ../src/MainNormal.ttcn
../src/MainExtNormal.ttcn
\ 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 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());
}
}
/******************************************************************************
* 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 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());
}
}
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