From a15ceec8fde92557bc968f220a58c49c550afd78 Mon Sep 17 00:00:00 2001 From: BenceJanosSzabo <bence.janos.szabo@ericsson.com> Date: Mon, 27 Feb 2017 10:14:42 +0100 Subject: [PATCH] Fixed incorrect makefile dependency generation (Bug 512688) Change-Id: I7abba40416eb3a307c6b3a5448316f501af94760 Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com> --- compiler2/makefile.c | 7 +++ compiler2/xpather.cc | 2 + .../compileonly/mfgen-tpd/Makefile | 2 +- .../mfgen-tpd/compile_once/Makefile | 53 +++++++++++++++++++ .../mfgen-tpd/compile_once/a/a.tpd | 49 +++++++++++++++++ .../mfgen-tpd/compile_once/a/src/ModuleA.ttcn | 32 +++++++++++ .../compile_once/a/src/ModuleA2.ttcnpp | 14 +++++ .../mfgen-tpd/compile_once/a/src/ModuleA3.asn | 27 ++++++++++ .../mfgen-tpd/compile_once/b/b.tpd | 44 +++++++++++++++ .../mfgen-tpd/compile_once/b/src/ModuleB.ttcn | 18 +++++++ .../compile_once/b/src/ModuleB2.ttcnpp | 14 +++++ .../mfgen-tpd/compile_once/b/src/ModuleB3.asn | 27 ++++++++++ .../mfgen-tpd/compile_once/c/c.tpd | 35 ++++++++++++ .../mfgen-tpd/compile_once/c/src/ModuleC.ttcn | 17 ++++++ .../compile_once/c/src/ModuleC2.ttcnpp | 14 +++++ .../mfgen-tpd/compile_once/c/src/ModuleC3.asn | 27 ++++++++++ 16 files changed, 381 insertions(+), 1 deletion(-) create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/Makefile create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/a/a.tpd create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA.ttcn create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA2.ttcnpp create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA3.asn create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/b/b.tpd create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB.ttcn create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB2.ttcnpp create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB3.asn create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/c/c.tpd create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC.ttcn create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC2.ttcnpp create mode 100644 regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC3.asn diff --git a/compiler2/makefile.c b/compiler2/makefile.c index 762ae90c0..4b3636573 100644 --- a/compiler2/makefile.c +++ b/compiler2/makefile.c @@ -3961,6 +3961,13 @@ static void print_makefile(struct makefile_struct *makefile) } } } + + for (i = 0; i < makefile->nBaseDirs; i++) { + fprintf(fp, "\n\n%s/%%.o: %s/%%.c\n" + "\t$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<\n\n", makefile->BaseDirs[i].dir_name, makefile->BaseDirs[i].dir_name); + fprintf(fp, "%s/%%.o: %s/%%.cc\n" + "\t$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<", makefile->BaseDirs[i].dir_name, makefile->BaseDirs[i].dir_name); + } fputs("\n\n%.o: %.c $(GENERATED_HEADERS)\n" "\t$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<\n\n", fp); fputs("%.o: %.cc $(GENERATED_HEADERS)\n" diff --git a/compiler2/xpather.cc b/compiler2/xpather.cc index 0d5c0a74b..55ac07a2d 100644 --- a/compiler2/xpather.cc +++ b/compiler2/xpather.cc @@ -3038,6 +3038,8 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, co } else { ERROR("Internal error: cannot add command to list"); } + } else { + Free(command); } // add working dir to the end of list if (sub_project_dirs) { diff --git a/regression_test/compileonly/mfgen-tpd/Makefile b/regression_test/compileonly/mfgen-tpd/Makefile index be7d1d3b4..4970bc56a 100644 --- a/regression_test/compileonly/mfgen-tpd/Makefile +++ b/regression_test/compileonly/mfgen-tpd/Makefile @@ -32,7 +32,7 @@ MAKEPROG := ${MAKE} DIRLIST := buildconfig_param invalid_buildconfig_param invalid_buildconfig_tpd \ HP79745 HQ56829 HQ56834 HQ56848 library HR30356 flagTest HR30365 dependency_check \ required_config required_config_v2 required_config_v3 disablePredefinedExternalFolder \ - makefileScript splitting + makefileScript splitting compile_once # The default target. ifeq ($(findstring c,$(MFGEN_FLAGS)),) # no -c diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/Makefile b/regression_test/compileonly/mfgen-tpd/compile_once/Makefile new file mode 100644 index 000000000..91dc96b81 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/Makefile @@ -0,0 +1,53 @@ +############################################################################## +# Copyright (c) 2000-2017 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 + + +MAKEPROG := ${MAKE} + +all: Recursive RecursiveAbsolute + +Recursive: + -rm -rf a/binDefault b/binDefault c/binDefault && \ + cd c && $(TTCN3_DIR)/bin/ttcn3_makefilegen $(MFGEN_FLAGS) $(COVERAGE_FLAG) \ + -t c.tpd -cVfgpl && cd binDefault && make shared_objects && \ + cd ../../b && $(TTCN3_DIR)/bin/ttcn3_makefilegen $(MFGEN_FLAGS) $(COVERAGE_FLAG) \ + -t b.tpd -cVfgpl && cd binDefault && make shared_objects && \ + cd ../../a && $(TTCN3_DIR)/bin/ttcn3_makefilegen $(MFGEN_FLAGS) $(COVERAGE_FLAG) \ + -t a.tpd -FTrcgpl && cd binDefault && make > compile.txt && \ + if [ `grep -c "ModuleB\." compile.txt` -ne 4 ] || [ `grep -c "ModuleC\." compile.txt` -ne 5 ]; \ + then echo "Makefilegen compile once test failed: Overall verdict: fail" && exit 1; fi + +RecursiveAbsolute: + -rm -rf a/binDefault b/binDefault c/binDefault && \ + cd c && $(TTCN3_DIR)/bin/ttcn3_makefilegen $(MFGEN_FLAGS) $(COVERAGE_FLAG) \ + -at c.tpd -cVfgpl && cd binDefault && make shared_objects && \ + cd ../../b && $(TTCN3_DIR)/bin/ttcn3_makefilegen $(MFGEN_FLAGS) $(COVERAGE_FLAG) \ + -at b.tpd -cVfgpl && cd binDefault && make shared_objects && \ + cd ../../a && $(TTCN3_DIR)/bin/ttcn3_makefilegen $(MFGEN_FLAGS) $(COVERAGE_FLAG) \ + -at a.tpd -FTrcgpl && cd binDefault && make > compile.txt && \ + if [ `grep -c "ModuleB\." compile.txt` -ne 4 ] || [ `grep -c "ModuleC\." compile.txt` -ne 5 ]; \ + then echo "Makefilegen compile once test failed: Overall verdict: fail" && exit 1; fi + +clean: + -rm -rf a/binDefault b/binDefault c/binDefault + +distclean: clean + -rm -f *.out + +.PHONY: all clean distclean Normal Recursive RecursiveAbsolute + diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/a/a.tpd b/regression_test/compileonly/mfgen-tpd/compile_once/a/a.tpd new file mode 100644 index 000000000..ca25c0b0a --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/a/a.tpd @@ -0,0 +1,49 @@ +<!-- + Copyright (c) 2000-2017 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 – initial implementation +--> +<TITAN_Project_File_Information version="1.0"> + <ProjectName>a</ProjectName> + <ReferencedProjects> + <ReferencedProject name="b" projectLocationURI="../b/b.tpd"/> + <ReferencedProject name="c" projectLocationURI="../c/c.tpd"/> + </ReferencedProjects> + <Folders> + <FolderResource projectRelativePath="src" relativeURI="src"/> + </Folders> + <Files> + <FileResource projectRelativePath="src/ModuleA.ttcn" relativeURI="src/ModuleA.ttcn"/> + <FileResource projectRelativePath="src/ModuleA2.ttcnpp" relativeURI="src/ModuleA2.ttcnpp"/> + <FileResource projectRelativePath="src/ModuleA3.asn" relativeURI="src/ModuleA3.asn"/> + </Files> + <ActiveConfiguration>None</ActiveConfiguration> + <Configurations> + <Configuration name="None"> + <ProjectProperties> + <MakefileSettings> + <codeSplitting>none</codeSplitting> + <targetExecutable>binDefault/binDefault</targetExecutable> + </MakefileSettings> + <LocalBuildSettings> + <workingDirectory>binDefault</workingDirectory> + </LocalBuildSettings> + <ConfigurationRequirements> + <configurationRequirement> + <projectName>b</projectName> + <requiredConfiguration>None</requiredConfiguration> + </configurationRequirement> + <configurationRequirement> + <projectName>c</projectName> + <requiredConfiguration>None</requiredConfiguration> + </configurationRequirement> + </ConfigurationRequirements> + </ProjectProperties> + </Configuration> + </Configurations> +</TITAN_Project_File_Information> diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA.ttcn b/regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA.ttcn new file mode 100644 index 000000000..3d9c7b13c --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA.ttcn @@ -0,0 +1,32 @@ +/****************************************************************************** + * Copyright (c) 2000-2017 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 ModuleAMain { + import from ModuleB all; + import from ModuleC all; + + import from ModuleA2 all; + import from ModuleA3 all; + + import from ModuleB2 all; + import from ModuleB3 all; + import from ModuleC2 all; + import from ModuleC3 all; + + + const My_Integer_A a := 1; + const My_Integer_B b_1 := 1; + const My_Integer_C c_1 := 1; + + function f() return integer { + return a + b + c + b_1 + c_1 + a2 + b2 + c2; + } +} \ No newline at end of file diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA2.ttcnpp b/regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA2.ttcnpp new file mode 100644 index 000000000..46d893007 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA2.ttcnpp @@ -0,0 +1,14 @@ +/****************************************************************************** + * Copyright (c) 2000-2017 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 ModuleA2 { + const integer a2 := 1; +} \ No newline at end of file diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA3.asn b/regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA3.asn new file mode 100644 index 000000000..d8967f01c --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/a/src/ModuleA3.asn @@ -0,0 +1,27 @@ +--///////////////////////////////////////////////////////////////////////////// +-- Copyright (c) 2000-2017 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 +-- +--///////////////////////////////////////////////////////////////////////////// +ModuleA3 +DEFINITIONS + +AUTOMATIC TAGS + +::= + +BEGIN + +IMPORTS ; -- nothing + +My-Integer ::= INTEGER + +My-Integer-A ::= INTEGER + +END diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/b/b.tpd b/regression_test/compileonly/mfgen-tpd/compile_once/b/b.tpd new file mode 100644 index 000000000..7107d5f6c --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/b/b.tpd @@ -0,0 +1,44 @@ +<!-- + Copyright (c) 2000-2017 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 – initial implementation +--> +<TITAN_Project_File_Information version="1.0"> + <ProjectName>b</ProjectName> + <ReferencedProjects> + <ReferencedProject name="c" projectLocationURI="../c/c.tpd"/> + </ReferencedProjects> + <Folders> + <FolderResource projectRelativePath="src" relativeURI="src"/> + </Folders> + <Files> + <FileResource projectRelativePath="src/ModuleB.ttcn" relativeURI="src/ModuleB.ttcn"/> + <FileResource projectRelativePath="src/ModuleB2.ttcnpp" relativeURI="src/ModuleB2.ttcnpp"/> + <FileResource projectRelativePath="src/ModuleB3.asn" relativeURI="src/ModuleB3.asn"/> + </Files> + <ActiveConfiguration>None</ActiveConfiguration> + <Configurations> + <Configuration name="None"> + <ProjectProperties> + <MakefileSettings> + <codeSplitting>none</codeSplitting> + <targetExecutable>binDefault/binDefault</targetExecutable> + </MakefileSettings> + <LocalBuildSettings> + <workingDirectory>binDefault</workingDirectory> + </LocalBuildSettings> + <ConfigurationRequirements> + <configurationRequirement> + <projectName>c</projectName> + <requiredConfiguration>None</requiredConfiguration> + </configurationRequirement> + </ConfigurationRequirements> + </ProjectProperties> + </Configuration> + </Configurations> +</TITAN_Project_File_Information> diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB.ttcn b/regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB.ttcn new file mode 100644 index 000000000..219f68c00 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB.ttcn @@ -0,0 +1,18 @@ +/****************************************************************************** + * Copyright (c) 2000-2017 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 ModuleB { + import from ModuleC all; + import from ModuleB2 all; + import from ModuleB3 all; + + const integer b := 2; +} \ No newline at end of file diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB2.ttcnpp b/regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB2.ttcnpp new file mode 100644 index 000000000..32a6e43bd --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB2.ttcnpp @@ -0,0 +1,14 @@ +/****************************************************************************** + * Copyright (c) 2000-2017 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 ModuleB2 { + const integer b2 := 1; +} \ No newline at end of file diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB3.asn b/regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB3.asn new file mode 100644 index 000000000..d1087a792 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/b/src/ModuleB3.asn @@ -0,0 +1,27 @@ +--///////////////////////////////////////////////////////////////////////////// +-- Copyright (c) 2000-2017 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 +-- +--///////////////////////////////////////////////////////////////////////////// +ModuleB3 +DEFINITIONS + +AUTOMATIC TAGS + +::= + +BEGIN + +IMPORTS ; -- nothing + +My-Integer ::= INTEGER + +My-Integer-B ::= INTEGER + +END diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/c/c.tpd b/regression_test/compileonly/mfgen-tpd/compile_once/c/c.tpd new file mode 100644 index 000000000..f0e6eac28 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/c/c.tpd @@ -0,0 +1,35 @@ +<!-- + Copyright (c) 2000-2017 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 – initial implementation +--> +<TITAN_Project_File_Information version="1.0"> + <ProjectName>c</ProjectName> + <Folders> + <FolderResource projectRelativePath="src" relativeURI="src"/> + </Folders> + <Files> + <FileResource projectRelativePath="src/ModuleC.ttcn" relativeURI="src/ModuleC.ttcn"/> + <FileResource projectRelativePath="src/ModuleC2.ttcnpp" relativeURI="src/ModuleC2.ttcnpp"/> + <FileResource projectRelativePath="src/ModuleC3.asn" relativeURI="src/ModuleC3.asn"/> + </Files> + <ActiveConfiguration>None</ActiveConfiguration> + <Configurations> + <Configuration name="None"> + <ProjectProperties> + <MakefileSettings> + <codeSplitting>none</codeSplitting> + <targetExecutable>binDefault/binDefault</targetExecutable> + </MakefileSettings> + <LocalBuildSettings> + <workingDirectory>binDefault</workingDirectory> + </LocalBuildSettings> + </ProjectProperties> + </Configuration> + </Configurations> +</TITAN_Project_File_Information> diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC.ttcn b/regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC.ttcn new file mode 100644 index 000000000..f391ab909 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC.ttcn @@ -0,0 +1,17 @@ +/****************************************************************************** + * Copyright (c) 2000-2017 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 ModuleC { + import from ModuleC2 all; + import from ModuleC3 all; + + const integer c := 3; +} \ No newline at end of file diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC2.ttcnpp b/regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC2.ttcnpp new file mode 100644 index 000000000..6c2c2d7a5 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC2.ttcnpp @@ -0,0 +1,14 @@ +/****************************************************************************** + * Copyright (c) 2000-2017 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 ModuleC2 { + const integer c2 := 1; +} \ No newline at end of file diff --git a/regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC3.asn b/regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC3.asn new file mode 100644 index 000000000..ad4090789 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/compile_once/c/src/ModuleC3.asn @@ -0,0 +1,27 @@ +--///////////////////////////////////////////////////////////////////////////// +-- Copyright (c) 2000-2017 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 +-- +--///////////////////////////////////////////////////////////////////////////// +ModuleC3 +DEFINITIONS + +AUTOMATIC TAGS + +::= + +BEGIN + +IMPORTS ; -- nothing + +My-Integer ::= INTEGER + +My-Integer-C ::= INTEGER + +END -- GitLab