25 import com.nokia.carbide.cpp.epoc.engine.model.makefile.IMakefileViewConfiguration; |
25 import com.nokia.carbide.cpp.epoc.engine.model.makefile.IMakefileViewConfiguration; |
26 import com.nokia.carbide.cpp.epoc.engine.preprocessor.AcceptedNodesViewFilter; |
26 import com.nokia.carbide.cpp.epoc.engine.preprocessor.AcceptedNodesViewFilter; |
27 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine; |
27 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine; |
28 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IViewFilter; |
28 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IViewFilter; |
29 import com.nokia.carbide.cpp.epoc.engine.tests.BaseTest; |
29 import com.nokia.carbide.cpp.epoc.engine.tests.BaseTest; |
|
30 import com.nokia.cpp.internal.api.utils.core.HostOS; |
30 import com.nokia.cpp.internal.api.utils.core.IMessage; |
31 import com.nokia.cpp.internal.api.utils.core.IMessage; |
31 |
32 |
32 import org.eclipse.cdt.make.core.makefile.ICommand; |
33 import org.eclipse.cdt.make.core.makefile.ICommand; |
33 import org.eclipse.cdt.make.core.makefile.IMacroDefinition; |
34 import org.eclipse.cdt.make.core.makefile.IMacroDefinition; |
34 import org.eclipse.cdt.make.core.makefile.IMakefile; |
35 import org.eclipse.cdt.make.core.makefile.IMakefile; |
180 |
187 |
181 ICommand[] commands = view.findCommandsInvoking("ld"); |
188 ICommand[] commands = view.findCommandsInvoking("ld"); |
182 assertEquals(1, commands.length); |
189 assertEquals(1, commands.length); |
183 assertNotNull(commands[0].getParent()); |
190 assertNotNull(commands[0].getParent()); |
184 |
191 |
|
192 String mifconvEXELine = "MIFCONV=$(TOOLDIR)\\mifconv"+ (HostOS.IS_WIN32 ? ".exe" : "") + "\n"; |
185 makeModel("TOOLSDIR=c:\\my\\tools\n"+ |
193 makeModel("TOOLSDIR=c:\\my\\tools\n"+ |
186 "MIFCONV=$(TOOLDIR)\\mifconv.exe\n"+ |
194 mifconvEXELine + |
187 "\n"+ |
195 "\n"+ |
188 "all: mytool\n"+ |
196 "all: mytool\n"+ |
189 "\n"+ |
197 "\n"+ |
190 "foo.mif: foo.svg\n"+ |
198 "foo.mif: foo.svg\n"+ |
191 "\t$(MIFCONV) -o $@ $^\n"+ |
199 "\t$(MIFCONV) -o $@ $^\n"+ |
363 |
371 |
364 commitTest(view, TEST_2_a); |
372 commitTest(view, TEST_2_a); |
365 |
373 |
366 } |
374 } |
367 |
375 |
368 public void testUnexpand() { |
376 public void testUnexpand1() { |
369 makeModel("ZDIR=$(EPOCROOT)\\release\\winscw\n"+ |
377 makeModel("ZDIR=$(EPOCROOT)\\release\\winscw\n"+ |
370 "TARGETDIR=$(ZDIR)\\data\n"+ |
378 "TARGETDIR=$(ZDIR)\\data\n"+ |
371 "ICONTARGETFILENAME=$(TARGETDIR)\\foo.mif\n"); |
379 "ICONTARGETFILENAME=$(TARGETDIR)\\foo.mif\n"); |
372 IMakefileView view = getView(viewConfig); |
380 IMakefileView view = getView(viewConfig); |
373 |
381 |
374 String repl = view.unexpandMacros("$(EPOCROOT)\\release\\winscw\\data\\more.mif", |
382 doUnexpandTest(view, "$(EPOCROOT)\\release\\winscw\\data\\more.mif", |
375 new String[] { "TARGETDIR", "ZDIR" }); |
383 "$(TARGETDIR)\\more.mif"); |
376 assertEquals("$(TARGETDIR)\\more.mif", repl); |
384 |
377 |
385 doUnexpandTest(view, "1 2 $(EPOCROOT)\\release\\winscw\\data\\more.mif 3 4", |
378 String repl1 = view.unexpandMacros("1 2 $(EPOCROOT)\\release\\winscw\\data\\more.mif 3 4", |
386 "1 2 $(TARGETDIR)\\more.mif 3 4"); |
379 new String[] { "TARGETDIR", "ZDIR" }); |
387 |
380 assertEquals("1 2 $(TARGETDIR)\\more.mif 3 4", repl1); |
388 doUnexpandTest(view, "$(EPOCROOT)\\release\\winscw\\more.mif", |
381 |
389 "$(ZDIR)\\more.mif"); |
382 String repl2 = view.unexpandMacros("$(EPOCROOT)\\release\\winscw\\more.mif", |
390 |
383 new String[] { "TARGETDIR", "ZDIR" }); |
391 doUnexpandTest(view, "$(EPOCROOT)\\release\\foo\\data\\more.mif", |
384 assertEquals("$(ZDIR)\\more.mif", repl2); |
392 "$(EPOCROOT)\\release\\foo\\data\\more.mif"); |
385 |
393 |
386 String repl3 = view.unexpandMacros("$(EPOCROOT)\\release\\foo\\data\\more.mif", |
394 doUnexpandTest(view, "\\release\\winscw\\data\\more.mif", |
387 new String[] { "TARGETDIR", "ZDIR" }); |
395 "\\release\\winscw\\data\\more.mif"); |
388 assertEquals("$(EPOCROOT)\\release\\foo\\data\\more.mif", repl3); |
396 |
389 |
397 } |
390 String repl4 = view.unexpandMacros("\\release\\winscw\\data\\more.mif", |
398 |
391 new String[] { "TARGETDIR", "ZDIR" }); |
399 |
392 assertEquals("\\release\\winscw\\data\\more.mif", repl4); |
400 private void doUnexpandTest(IMakefileView view, String expanded, |
393 |
401 String unexpanded) { |
394 } |
402 |
395 |
403 // TODO: tests should ideally work with both slash directions on both OSes |
|
404 if (HostOS.IS_WIN32) { |
|
405 String repl = view.unexpandMacros(expanded, |
|
406 new String[] { "TARGETDIR", "ZDIR" }); |
|
407 assertEquals(unexpanded, repl); |
|
408 } else { |
|
409 expanded = HostOS.convertPathToUnix(expanded); |
|
410 unexpanded = HostOS.convertPathToUnix(unexpanded); |
|
411 String repl = view.unexpandMacros(expanded, |
|
412 new String[] { "TARGETDIR", "ZDIR" }); |
|
413 assertEquals(unexpanded, repl); |
|
414 } |
|
415 |
|
416 } |
|
417 |
396 public void testProblems() { |
418 public void testProblems() { |
397 makeModel("\n\n)ZDIR@foo{\n"+ |
419 makeModel("\n\n)ZDIR@foo{\n"+ |
398 "^^ placate ^^\n"); |
420 "^^ placate ^^\n"); |
399 IMakefileView view = getView(viewConfig); |
421 IMakefileView view = getView(viewConfig); |
400 IMessage[] messages = view.getMessages(); |
422 IMessage[] messages = view.getMessages(); |