diff --git a/compiler2/makefile.c b/compiler2/makefile.c index 8f8a0a1bd35631a796a24192c3ce98112b4421c3..34c9176b15fc230357b2831f9b9b9fe0665cf740 100644 --- a/compiler2/makefile.c +++ b/compiler2/makefile.c @@ -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, diff --git a/regression_test/XML/XmlWorkflow/bin/prj2mk.pl b/regression_test/XML/XmlWorkflow/bin/prj2mk.pl index 9469a6f0c57f5af09103bde1f1470cd745046e9c..84021f21b73b20effe15578bcdfc410f25d490e2 100644 --- a/regression_test/XML/XmlWorkflow/bin/prj2mk.pl +++ b/regression_test/XML/XmlWorkflow/bin/prj2mk.pl @@ -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: $!"; diff --git a/regression_test/compileonly/Makefile b/regression_test/compileonly/Makefile index e0b58918f11c6fbb284f59059f73757b0c17785c..f76cf23ffd0a79dfd917044d26a7ab0f2d654802 100644 --- a/regression_test/compileonly/Makefile +++ b/regression_test/compileonly/Makefile @@ -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 diff --git a/regression_test/compileonly/readFromFile/Makefile b/regression_test/compileonly/readFromFile/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..ecd3814cd432e7835dd2ef9aad5e7cd2669d1b91 --- /dev/null +++ b/regression_test/compileonly/readFromFile/Makefile @@ -0,0 +1,32 @@ +############################################################################## +# 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 diff --git a/regression_test/compileonly/readFromFile/files.txt b/regression_test/compileonly/readFromFile/files.txt new file mode 100644 index 0000000000000000000000000000000000000000..836ca8b34956c00dc6d4c0e00f397e3181efc2d6 --- /dev/null +++ b/regression_test/compileonly/readFromFile/files.txt @@ -0,0 +1,5 @@ + ../src/Definitions.xsd ../src/MainNormal.ttcn + + + + ../src/MainExtNormal.ttcn \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/Definitions.xsd b/regression_test/compileonly/readFromFile/src/Definitions.xsd new file mode 100644 index 0000000000000000000000000000000000000000..497f1dc98d0ac8a56d8ee3dfcdbdd5dd879a2847 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/Definitions.xsd @@ -0,0 +1,19 @@ +<?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> diff --git a/regression_test/compileonly/readFromFile/src/MainExtNormal.ttcn b/regression_test/compileonly/readFromFile/src/MainExtNormal.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..5a580d67b24734758f9c8ec04b20d6d17260dc58 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/MainExtNormal.ttcn @@ -0,0 +1,40 @@ +/****************************************************************************** + * 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()); +} + +} + diff --git a/regression_test/compileonly/readFromFile/src/MainNormal.ttcn b/regression_test/compileonly/readFromFile/src/MainNormal.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..64b797c0b89cb2688d6f8792e0b9b6116ad102e5 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/MainNormal.ttcn @@ -0,0 +1,33 @@ +/****************************************************************************** + * 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()); +} + +} + diff --git a/usrguide/referenceguide.doc b/usrguide/referenceguide.doc index d28141366e514788c930b9c6af64c30eb29dccaf..7f8a34c75938f449b9c424b5dcfab066698dc77b 100644 Binary files a/usrguide/referenceguide.doc and b/usrguide/referenceguide.doc differ