# HG changeset patch # User Ed Swartz # Date 1259787725 21600 # Node ID bfb3ab3f70f26c08250f0aa88fa00fcb7f35fb69 # Parent bf7dbec89c47de37c749d3946ea44f05a0c0b28a Initial round of Unix portability fixes (using HostOS class), and fixes to EPOC engine unit tests. diff -r bf7dbec89c47 -r bfb3ab3f70f2 builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultViewParserConfiguration.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultViewParserConfiguration.java Wed Dec 02 14:40:51 2009 -0600 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/DefaultViewParserConfiguration.java Wed Dec 02 15:02:05 2009 -0600 @@ -27,6 +27,7 @@ import com.nokia.carbide.cpp.epoc.engine.preprocessor.IIncludeFileLocator; import com.nokia.carbide.cpp.epoc.engine.preprocessor.ITranslationUnitProvider; import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; +import com.nokia.cpp.internal.api.utils.core.HostOS; public class DefaultViewParserConfiguration implements IViewParserConfiguration { @@ -144,6 +145,9 @@ // when there's no project and it's local, we just return the drive letter. for network // paths, I assume we just return the machine name? return bldInfPath.removeLastSegments(bldInfPath.segmentCount()-1); + } else if (HostOS.IS_UNIX) { + // won't be a base drive + return Path.ROOT; } } } diff -r bf7dbec89c47 -r bfb3ab3f70f2 builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/EnvironmentVarsInfo2.java --- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/EnvironmentVarsInfo2.java Wed Dec 02 14:40:51 2009 -0600 +++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/EnvironmentVarsInfo2.java Wed Dec 02 15:02:05 2009 -0600 @@ -24,6 +24,7 @@ import com.nokia.carbide.cpp.internal.x86build.X86BuildPlugin; import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; +import com.nokia.cpp.internal.api.utils.core.HostOS; import com.nokia.cpp.internal.api.utils.core.TrackedResource; import org.eclipse.cdt.core.settings.model.ICStorageElement; @@ -36,6 +37,9 @@ import java.util.*; public class EnvironmentVarsInfo2 implements IEnvironmentVarsInfo { + + // NOTE: all the paths below use Win32 paths. We convert these to Unix format at the end of the + // #getResolved...() and #getModified...() methods. private static final String X86_COMP_LINK_FOLDER = "Symbian_Tools\\Command_Line_Tools"; @@ -43,11 +47,12 @@ private static final String X86_WIN32SDK_FOLDER = "Symbian_Support\\Win32-x86 Support\\Libraries\\Win32 SDK"; private static final String X86_LINK_LIB_LIST = "MSL_All_MSE_Symbian_D.lib;gdi32.lib;user32.lib;kernel32.lib;"; - - private static final String MWCSYM2INCLUDES = "MWCSYM2INCLUDES"; - private static final String MWSYM2LIBRARIES = "MWSYM2LIBRARIES"; - private static final String MWSYM2LIBRARYFILES = "MWSYM2LIBRARYFILES"; - private static final String MWCINCLUDES = "MWCINCLUDES"; + + // use host-independent case + private static final String MWCSYM2INCLUDES = "MWCSym2Includes"; + private static final String MWSYM2LIBRARIES = "MWSym2Libraries"; + private static final String MWSYM2LIBRARYFILES = "MWSym2LibraryFiles"; + private static final String MWCINCLUDES = "MWCIncludes"; private static final String PATH = "PATH"; private static final String EPOCROOT = "EPOCROOT"; @@ -123,7 +128,7 @@ public IEnvironmentVariable getEnvVarFromConfiguration(String varName) { for (IEnvironmentVariable currVar : envVarsList) { - if (currVar.getName().toUpperCase().equals(varName.toUpperCase())) { + if (currVar.getName().equalsIgnoreCase(varName)) { return currVar; } } @@ -229,13 +234,13 @@ prependValue += currEnvVar.substring(PATH.length() + 1); returnEnvArray[i] = prependValue; - } else if ((currEnvVar.toUpperCase() + EQUALS).startsWith(MWCSYM2INCLUDES + EQUALS)) { + } else if ((currEnvVar.toUpperCase() + EQUALS).startsWith(MWCSYM2INCLUDES.toUpperCase() + EQUALS)) { returnEnvArray[i] = MWCSYM2INCLUDES + EQUALS + getMWIncludesEnvString(); //} - } else if ((currEnvVar.toUpperCase() + EQUALS).startsWith(MWSYM2LIBRARIES + EQUALS)) { + } else if ((currEnvVar.toUpperCase() + EQUALS).startsWith(MWSYM2LIBRARIES.toUpperCase() + EQUALS)) { returnEnvArray[i] = MWSYM2LIBRARIES + EQUALS + getMWLibraryIncludesEnvString(); - } else if ((currEnvVar.toUpperCase() + EQUALS).startsWith(MWSYM2LIBRARYFILES + EQUALS)) { + } else if ((currEnvVar.toUpperCase() + EQUALS).startsWith(MWSYM2LIBRARYFILES.toUpperCase() + EQUALS)) { returnEnvArray[i] = MWSYM2LIBRARYFILES + EQUALS + getMWLibraryFilesEnvString(); } @@ -352,6 +357,13 @@ returnEnvArray = mapToStringArray(varsMap); } } + + // Fix up the notation in the environment (convert Win32-type variables to Unix-type) + if (HostOS.IS_UNIX) { + for (int i = 0; i < returnEnvArray.length; i++) { + returnEnvArray[i] = HostOS.convertPathListToUnix(returnEnvArray[i]); + } + } return returnEnvArray; } @@ -372,6 +384,13 @@ } } + // Fix up the notation in the environment (convert Win32-type variables to Unix-type) + if (HostOS.IS_UNIX) { + for (int i = 0; i < modifiedVars.length; i++) { + modifiedVars[i] = HostOS.convertPathListToUnix(modifiedVars[i]); + } + } + return modifiedVars; } diff -r bf7dbec89c47 -r bfb3ab3f70f2 core/com.nokia.carbide.bugreport/src/com/nokia/carbide/internal/bugreport/resources/ImageResourceManager.java --- a/core/com.nokia.carbide.bugreport/src/com/nokia/carbide/internal/bugreport/resources/ImageResourceManager.java Wed Dec 02 14:40:51 2009 -0600 +++ b/core/com.nokia.carbide.bugreport/src/com/nokia/carbide/internal/bugreport/resources/ImageResourceManager.java Wed Dec 02 15:02:05 2009 -0600 @@ -41,7 +41,7 @@ ImageRegistry imgReg = JFaceResources.getImageRegistry(); - Image img = new Image( disp, imagesPath + "\\bug_report_with_banner_75x66.png" ); //$NON-NLS-1$ + Image img = new Image( disp, imagesPath + "/bug_report_with_banner_75x66.png" ); //$NON-NLS-1$ imgReg.put( ImageKeys.WIZARD_BANNER, img ); } diff -r bf7dbec89c47 -r bfb3ab3f70f2 core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java --- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java Wed Dec 02 14:40:51 2009 -0600 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java Wed Dec 02 15:02:05 2009 -0600 @@ -20,6 +20,7 @@ import com.nokia.carbide.cpp.sdk.core.*; import com.nokia.carbide.internal.api.cpp.epoc.engine.preprocessor.BasicIncludeFileLocator; import com.nokia.carbide.internal.api.cpp.epoc.engine.preprocessor.MacroScanner; +import com.nokia.cpp.internal.api.utils.core.HostOS; import com.sun.org.apache.xpath.internal.XPathAPI; import org.eclipse.core.resources.ResourcesPlugin; @@ -68,7 +69,7 @@ private static final String BUILD_INFO_TXT_FILE = "epoc32/data/buildinfo.txt"; //$NON-NLS-1$ private static final String BUILD_INFO_KEYWORD = "ManufacturerSoftwareBuild"; - private static final String WINSCW_UREL_DIR = "epoc32\\release\\winscw\\urel"; + private static final String WINSCW_UREL_DIR = "epoc32/release/winscw/urel"; protected DeviceType deviceEntry = null; private boolean enabled = true; @@ -350,7 +351,7 @@ public IPath getIncludePath() { String epocRoot = getEPOCROOT(); if (epocRoot.length() > 0) { - IPath epoc32IncPath = new Path(epocRoot).append("epoc32\\include"); + IPath epoc32IncPath = new Path(epocRoot).append("epoc32/include"); // try to canonicalize it so it matches actual file system case try { epoc32IncPath = new Path(epoc32IncPath.toFile().getCanonicalPath()); @@ -414,7 +415,7 @@ public IPath getReleaseRoot() { String epocRoot = getEPOCROOT(); if (epocRoot.length() > 0) { - IPath epoc32RelPath = new Path(epocRoot).append("epoc32\\release"); + IPath epoc32RelPath = new Path(epocRoot).append("epoc32/release"); // try to canonicalize it so it matches actual file system case try { epoc32RelPath = new Path(epoc32RelPath.toFile().getCanonicalPath()); @@ -443,7 +444,7 @@ public IPath getToolsPath() { String epocRoot = getEPOCROOT(); if (epocRoot.length() > 0) { - IPath epoc32ToolsPath = new Path(epocRoot).append("epoc32\\tools"); + IPath epoc32ToolsPath = new Path(epocRoot).append("epoc32/tools"); // try to canonicalize it so it matches actual file system case try { epoc32ToolsPath = new Path(epoc32ToolsPath.toFile().getCanonicalPath()); @@ -1102,7 +1103,7 @@ variantDir = matcher.group(1); variantFile = matcher.group(3); File variantFullPathFile = new File(epocRoot, variantDir + File.separator + variantFile); - IPath variantFilePath = new Path(variantFullPathFile.getAbsolutePath()); + IPath variantFilePath = new Path(HostOS.convertPathToUnix(variantFullPathFile.getAbsolutePath())); return variantFilePath; } } diff -r bf7dbec89c47 -r bfb3ab3f70f2 core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetsPage.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetsPage.java Wed Dec 02 14:40:51 2009 -0600 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetsPage.java Wed Dec 02 15:02:05 2009 -0600 @@ -45,6 +45,7 @@ import com.nokia.carbide.internal.api.templatewizard.ui.IWizardDataPage; import com.nokia.carbide.template.engine.ITemplate; import com.nokia.cpp.internal.api.utils.core.Check; +import com.nokia.cpp.internal.api.utils.core.HostOS; /** * Wizard page used to select a list of Carbide.c++ build configurations. Currently used @@ -274,6 +275,11 @@ protected void checkPathWithSDKs(IPath path) { setMessage(null); + + // drives are relevant in Windows only + if (!HostOS.IS_WIN32) + return; + for (ISymbianBuildContext context : getSelectedBuildConfigs()) { Path sdkPath = new Path(context.getSDK().getEPOCROOT()); if (sdkPath.getDevice() != null) { diff -r bf7dbec89c47 -r bfb3ab3f70f2 core/com.nokia.cpp.utils.core/src/com/nokia/cpp/internal/api/utils/core/FileUtils.java --- a/core/com.nokia.cpp.utils.core/src/com/nokia/cpp/internal/api/utils/core/FileUtils.java Wed Dec 02 14:40:51 2009 -0600 +++ b/core/com.nokia.cpp.utils.core/src/com/nokia/cpp/internal/api/utils/core/FileUtils.java Wed Dec 02 15:02:05 2009 -0600 @@ -847,7 +847,7 @@ if (path == null) return null; - if (Platform.getOS().equals(Platform.OS_WIN32)) { + if (HostOS.IS_WIN32) { return new Path(path.toOSString().toLowerCase()); } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/BaseTest.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/BaseTest.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/BaseTest.java Wed Dec 02 15:02:05 2009 -0600 @@ -39,6 +39,7 @@ import com.nokia.carbide.internal.cpp.epoc.engine.preprocessor.ASTPreprocessor; import com.nokia.carbide.internal.cpp.epoc.engine.preprocessor.IConditionalBlock; import com.nokia.cpp.internal.api.utils.core.FileUtils; +import com.nokia.cpp.internal.api.utils.core.HostOS; import com.nokia.cpp.internal.api.utils.core.IMessage; import com.nokia.cpp.internal.api.utils.core.TextUtils; @@ -153,6 +154,18 @@ private HashMap refMap; protected IPath modelPath; + protected String getTokenAbsolutePath() { + return HostOS.IS_WIN32 + ? "c:\\tests\\" : "/tmp/"; + } + + protected String toDosPath(IPath path) { + return path.toPortableString().replaceAll("/", "\\\\"); + } + protected String toDosPath(String path) { + return path.replaceAll("/", "\\\\"); + } + /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ @@ -160,7 +173,7 @@ protected void setUp() throws Exception { super.setUp(); if (projectPath == null) - projectPath = new Path("c:/tests/project"); + projectPath = new Path(getTokenAbsolutePath()).append("project"); parserConfig = new ParserConfigurationBase(projectPath) { @Override diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/ParserConfigurationBase.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/ParserConfigurationBase.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/ParserConfigurationBase.java Wed Dec 02 15:02:05 2009 -0600 @@ -26,6 +26,7 @@ import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTTranslationUnit; import com.nokia.carbide.internal.cpp.epoc.engine.parser.IDocumentParser; import com.nokia.carbide.internal.cpp.epoc.engine.parser.ParserFactory; +import com.nokia.cpp.internal.api.utils.core.HostOS; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -105,6 +106,10 @@ fileLocator = new IIncludeFileLocator() { public File findIncludeFile(String file, boolean isUser, File currentDir) { + if (HostOS.IS_UNIX) { + file = HostOS.convertPathToUnix(file); + } + if (fs.containsKey(file)) return new File(file); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/conversion/TestAifdefFileConversion.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/conversion/TestAifdefFileConversion.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/conversion/TestAifdefFileConversion.java Wed Dec 02 15:02:05 2009 -0600 @@ -32,11 +32,13 @@ import com.nokia.carbide.internal.api.cpp.epoc.engine.image.IPathResolver; import com.nokia.carbide.internal.api.cpp.epoc.engine.image.LegacyImageFileConverterFactory; import com.nokia.cpp.internal.api.utils.core.FileUtils; +import com.nokia.cpp.internal.api.utils.core.HostOS; public class TestAifdefFileConversion extends BaseTest { - private static final String BAD_PROJECT_ROOT = "c:/workspace/CarbideTest/FormTime/"; + private static final String BAD_PROJECT_ROOT = + HostOS.IS_WIN32 ? "c:/workspace/CarbideTest/FormTime/" : "/home/me/workspace/CarbideTest/FormTime/"; private File tmpdir; private File tmpMbmdef; private IPathResolver resolver; @@ -88,7 +90,7 @@ static final String AIFDEF_1 = - BAD_PROJECT_ROOT + "|aif/formtimeaif.rss|c4,1|aif/context_pane_icon.bmp|aif/context_pane_icon_mask.bmp|aif/list_icon.bmp|aif/list_icon_mask.bmp\r\n" + + BAD_PROJECT_ROOT + "|aif/FormTimeAif.rss|c4,1|aif/context_pane_icon.bmp|aif/context_pane_icon_mask.bmp|aif/list_icon.bmp|aif/list_icon_mask.bmp\r\n" + ""; public void testAifdef1() throws CoreException { diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBSFView.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBSFView.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBSFView.java Wed Dec 02 15:02:05 2009 -0600 @@ -43,7 +43,7 @@ @Override protected void setUp() throws Exception { super.setUp(); - this.path = new Path("c:\\symbian\\9.5\\epoc32\\tools\\Test.bsf"); + this.path = new Path("c:/symbian/9.5/epoc32/tools/Test.bsf"); config = new IViewConfiguration() { diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBldInfView.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBldInfView.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBldInfView.java Wed Dec 02 15:02:05 2009 -0600 @@ -22,8 +22,10 @@ import com.nokia.carbide.cpp.epoc.engine.preprocessor.DefineFactory; import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine; import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTProblemNode; +import com.nokia.cpp.internal.api.utils.core.HostOS; import com.nokia.cpp.internal.api.utils.core.IMessage; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import java.util.ArrayList; @@ -446,13 +448,13 @@ exp = view.createExport(); exp.setSourcePath(new Path("gfx/myfile.mbm")); - exp.setTargetPath(new Path("\\sys\\resources\\MyApp\\myfile.mbm")); - assertEquals(new Path("\\sys\\resources\\MyApp\\myfile.mbm"), exp.getTargetPath()); + exp.setTargetPath(new Path("/sys/resources/MyApp/myfile.mbm")); + assertEquals(new Path("/sys/resources/MyApp/myfile.mbm"), exp.getTargetPath()); view.getExports().add(exp); exp = view.createExport(); exp.setSourcePath(new Path("inc/header2.h")); - exp.setTargetPath(new Path("\\epoc32\\include\\header2.h")); + exp.setTargetPath(new Path("/epoc32/include/header2.h")); view.getExports().add(exp); exp = view.createExport(); @@ -509,7 +511,7 @@ IBldInfView view = getView(config); assertNotNull(view); - view.getExports().get(1).setTargetPath(new Path("\\sys\\resources\\MyApp\\myfile.mbm")); + view.getExports().get(1).setTargetPath(new Path("/sys/resources/MyApp/myfile.mbm")); commitTest(view, "PRJ_EXPORTS\n"+ @@ -565,11 +567,19 @@ assertEquals(2, view.getMessages().length); } + private static IPath insideSDKPath; + static { + if (HostOS.IS_WIN32) { + insideSDKPath = new Path("c:\\symbian\\9.1\\S60_3rd\\S60Ex\\Hello\\group\\bld.inf"); + } else { + insideSDKPath = new Path("/home/user/symbian/9.1/S60_3rd/S60Ex/Hello/group/bld.inf"); + } + } public void testRootProject() { // make sure we handle project root correctly when it's the root directory for (int i = 0; i < 2; i++){ parserConfig.projectPath = i == 0 ? new Path("c:\\") : new Path("c:"); - this.path = new Path("c:\\symbian\\9.1\\S60_3rd\\S60Ex\\Hello\\group\\bld.inf"); + this.path = insideSDKPath; makeModel("PRJ_MMPFILES\n"+ "test.mmp\n"); @@ -581,16 +591,24 @@ private void _testRootProject(IBldInfData bldInfData) { IMMPReference mmp = bldInfData.getAllMMPReferences()[0]; - // important to be relative - assertEquals(new Path("symbian/9.1/S60_3rd/S60Ex/Hello/group/test.mmp"), mmp.getPath()); + // important to be relative and with no drive + if (HostOS.IS_WIN32) + assertEquals(insideSDKPath.makeRelative().setDevice(null).removeLastSegments(1).append("test.mmp"), mmp.getPath()); + else + assertEquals(insideSDKPath.removeLastSegments(1).append("test.mmp"), mmp.getPath()); } /** * The base directory changes as files are #included * */ + private static IPath basePath; public void testBaseDirectory() { - parserConfig.getFilesystem().put(new Path("c:/test/bld.inf").toOSString(), + if (HostOS.IS_WIN32) + basePath = new Path("c:/test/"); + else + basePath = new Path("/tmp/test/"); + parserConfig.getFilesystem().put(basePath.append("bld.inf").toOSString(), "PRJ_MMPFILES\n"+ "base.mmp\n"+ "gnumakefile sub\\base.mk\n"+ @@ -607,7 +625,7 @@ makeModel( "PRJ_MMPFILES\n"+ "first.mmp\n"+ - "#include \"c:\\test\\bld.inf\"\n"+ + "#include \"" + basePath.toOSString() + "bld.inf\"\n"+ "#include \"../utils/bld.inf\"\n"+ "PRJ_MMPFILES\n"+ "last.mmp\n" + @@ -626,8 +644,8 @@ assertEquals(new Path("group/first.mmp"), bldInfData.getMakMakeReferences().get(0).getPath()); // note: should not be relative path when outside the project - assertEquals(new Path("c:/test/base.mmp"), bldInfData.getMakMakeReferences().get(1).getPath()); - assertEquals(new Path("c:/test/sub/base.mk"), bldInfData.getMakMakeReferences().get(2).getPath()); + assertEquals(basePath.append("base.mmp"), bldInfData.getMakMakeReferences().get(1).getPath()); + assertEquals(basePath.append("sub/base.mk"), bldInfData.getMakMakeReferences().get(2).getPath()); assertEquals(new Path("utils/utils.mmp"), bldInfData.getMakMakeReferences().get(3).getPath()); assertEquals(new Path("utils.mk"), bldInfData.getMakMakeReferences().get(4).getPath()); @@ -635,7 +653,7 @@ assertEquals(new Path("group/last.mmp"), bldInfData.getMakMakeReferences().get(5).getPath()); assertEquals(3, bldInfData.getExports().size()); - assertEquals(new Path("c:/test/base.txt"), bldInfData.getExports().get(0).getSourcePath()); + assertEquals(basePath.append("base.txt"), bldInfData.getExports().get(0).getSourcePath()); assertEquals(new Path("utils/utils.txt"), bldInfData.getExports().get(1).getSourcePath()); assertEquals(new Path("group/last.txt"), bldInfData.getExports().get(2).getSourcePath()); } @@ -978,7 +996,7 @@ "// End of File \r\n"; Map originalFiles = new HashMap(); - originalFiles.put("..\\Speeddial\\group\\bld.inf", spdiaText); + originalFiles.put(new Path("../Speeddial/group/bld.inf").toOSString(), spdiaText); // this fails originalFiles.put("platform_paths.hrh", "\n"+"#ifndef MACRO\n"+"#define MACRO\n"+"\n"+"#endif\n"+"\n"); // this passes @@ -1270,7 +1288,7 @@ "* Description : \r\n" + "* Version : \r\n" + "*\r\n" + - "* Copyright © 2006 Nokia. All rights reserved.\r\n" + + "* Copyright (c) 2006 Nokia. All rights reserved.\r\n" + "* This material, including documentation and any related\r\n" + "* computer programs, is protected by copyright controlled by\r\n" + "* Nokia Corporation. All rights are reserved. Copying,\r\n" + @@ -1329,7 +1347,7 @@ "* whole MusicPlayer application including all related libraries.\r\n" + "* Version : \r\n" + "*\r\n" + - "* Copyright © 2002-2006 Nokia Corporation.\r\n" + + "* Copyright (c) 2002-2006 Nokia Corporation.\r\n" + "* This material, including documentation and any related \r\n" + "* computer programs, is protected by copyright controlled by \r\n" + "* Nokia Corporation. All rights are reserved. Copying, \r\n" + @@ -1430,7 +1448,7 @@ "* that make up the MusicShopEmbed, MusicShopApp and MusicShopLib\r\n" + "* Version : %version: da1mmcf#15 %\r\n" + "*\r\n" + - "* Copyright © 2006 Nokia. All rights reserved.\r\n" + + "* Copyright (c) 2006 Nokia. All rights reserved.\r\n" + "* This material, including documentation and any related\r\n" + "* computer programs, is protected by copyright controlled by\r\n" + "* Nokia Corporation. All rights are reserved. Copying,\r\n" + @@ -1477,7 +1495,7 @@ "* all MusicVisualization projects including plugins.\r\n" + "* Version : \r\n" + "*\r\n" + - "* Copyright © 2005 Nokia Corporation.\r\n" + + "* Copyright (c) 2005 Nokia Corporation.\r\n" + "* This material, including documentation and any related \r\n" + "* computer programs, is protected by copyright controlled by \r\n" + "* Nokia Corporation. All rights are reserved. Copying, \r\n" + @@ -1508,9 +1526,9 @@ "\r\n" + "// End of File\r\n" ; - parserConfig.getFilesystem().put("..\\MusicPlayer\\group\\bld.inf", musicPlayerBldInf); - parserConfig.getFilesystem().put("..\\MusicShop\\group\\bld.inf", musicShopBldInf); - parserConfig.getFilesystem().put("..\\MusicVisualization\\group\\bld.inf", musicVisualizationBldInf); + parserConfig.getFilesystem().put("../MusicPlayer/group/bld.inf", musicPlayerBldInf); + parserConfig.getFilesystem().put("../MusicShop/group/bld.inf", musicShopBldInf); + parserConfig.getFilesystem().put("../MusicVisualization/group/bld.inf", musicVisualizationBldInf); makeModel(origFile); @@ -1518,13 +1536,13 @@ assertNotNull(view); IMMPReference ref = view.createMMPReference(); - ref.setPath(new Path("group\\FMRadio.mmp")); + ref.setPath(new Path("group/FMRadio.mmp")); view.getMakMakeReferences().add(ref); commitTest(view, updatedFile); - assertEquals(parserConfig.getFilesystem().get("..\\MusicPlayer\\group\\bld.inf"), musicPlayerBldInf); - assertEquals(parserConfig.getFilesystem().get("..\\MusicShop\\group\\bld.inf"), musicShopBldInf); - assertEquals(parserConfig.getFilesystem().get("..\\MusicVisualization\\group\\bld.inf"), musicVisualizationBldInf); + assertEquals(parserConfig.getFilesystem().get("../MusicPlayer/group/bld.inf"), musicPlayerBldInf); + assertEquals(parserConfig.getFilesystem().get("../MusicShop/group/bld.inf"), musicShopBldInf); + assertEquals(parserConfig.getFilesystem().get("../MusicVisualization/group/bld.inf"), musicVisualizationBldInf); } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBldInfView4.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBldInfView4.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestBldInfView4.java Wed Dec 02 15:02:05 2009 -0600 @@ -244,7 +244,7 @@ assertEquals(new Path("base/config"), ext.getTemplatePath()); assertEquals("armcc", ext.getToolName()); - assertEquals(new Path("zap_ma_ma\\"), ext.getTargetPath()); + assertEquals(new Path("zap_ma_ma/"), ext.getTargetPath()); assertNotNull(ext.getSources()); assertEquals(2, ext.getSources().size()); assertEquals(new Path("src/file1.cpp"), ext.getSources().get(0)); @@ -725,9 +725,9 @@ view = getView(config); assertEquals(1, view.getMakMakeReferences().size()); IMakMakeReference mak = view.getMakMakeReferences().get(0); - assertEquals(new Path("\\test\\drivers\\cpa_log_kernel.mmp"), mak.getPath()); + assertEquals(new Path("/test/drivers/cpa_log_kernel.mmp"), mak.getPath()); - mak.setPath(new Path("\\test\\drivers\\kernel.mmp")); + mak.setPath(new Path("/test/drivers/kernel.mmp")); commitTest(view, text2); } public void testBug3696() { diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestImageMakefileView.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestImageMakefileView.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestImageMakefileView.java Wed Dec 02 15:02:05 2009 -0600 @@ -26,6 +26,7 @@ import com.nokia.carbide.internal.api.cpp.epoc.engine.preprocessor.BasicIncludeFileLocator; import com.nokia.carbide.internal.cpp.epoc.engine.model.StandaloneModelProvider; import com.nokia.cpp.internal.api.utils.core.FileUtils; +import com.nokia.cpp.internal.api.utils.core.HostOS; import org.eclipse.cdt.make.core.makefile.IDirective; import org.eclipse.cdt.make.core.makefile.gnu.IInclude; @@ -99,11 +100,22 @@ } protected void makeModel(String text) { + text = convertForOS(text); IDocument document = DocumentFactory.createDocument(text); model = new ImageMakefileModelFactory().createModel(path, document); model.parse(); } + + private String convertForOS(String text) { + // TODO: tests should work with both slash directions on both OSes + if (HostOS.IS_UNIX) { + text = text.replaceAll("\\\\(?!\r|\n)", "/"); + text = text.replaceAll("(?<=\\s|^)/([A-Z])", "-$1"); + text = text.replaceAll("(?<=\\s|^)/(c?(\\d|,)+)", "-$1"); + } + return text; + } protected IImageMakefileView getView(IImageMakefileViewConfiguration config) { IImageMakefileView view = (IImageMakefileView) model.createView(config); @@ -112,9 +124,26 @@ } protected void commitTest(IImageMakefileView view, String refText) { + refText = convertForOS(refText); commitTest(model, view, refText); } + private static IPath stockRootedProjectPath; + private static IPath stockRootedImgPath; + private static IPath stockRootedSvgPath; + + static { + if (HostOS.IS_WIN32) { + stockRootedProjectPath = new Path("c:\\symbian\\9.1\\S60_3rd\\S60Ex\\Hello"); + stockRootedImgPath = new Path("c:\\imgs\\"); + stockRootedSvgPath = new Path("c:\\svgs\\"); + } else { + stockRootedProjectPath = new Path("/home/me/Hello"); + stockRootedImgPath = new Path("/tmp/imgs/"); + stockRootedSvgPath = new Path("/tmp/svgs/"); + } + } + final String TEST_1 = "# ============================================================================\r\n" + "# Name : Icons_aif_scalable_dc.mk\r\n" + @@ -570,7 +599,7 @@ "ICONDIR=..\\aif\r\n" + "\r\n" + "$(ICONTARGETFILENAME): $(ICONDIR)\\icon1.svg $(ICONDIR)\\icon2.svg\r\n" + - " mifconv $< /E /Bbmconv.exe /h$(HEADERDIR)/Birthdays_aif.mbg /c16 $@\r\n" + + " mifconv $< /E /Bbmconv.exe /H$(HEADERDIR)/Birthdays_aif.mbg /c16 $@\r\n" + " mifconv extra.mif /c8,8 /Fbitmaps.txt\r\n" + "FREEZE : do_nothing\r\n" + "\r\n" + @@ -583,13 +612,13 @@ "\r\n"; final String TEST_2_inc = - "\t../pix/bitmap1.bmp\t\nbitmap2.bmp\\\n/1,1\nc:\\test\\dot.bmp\t\n"; + "\t../pix/bitmap1.bmp\t\nbitmap2.bmp\\\n/1,1\n"+stockRootedImgPath.append("dot.bmp")+"\t\n"; public void testImageContainerParsing2()throws Exception { File incFile = new File(projectPath.toFile(), "group/bitmaps.txt"); incFile.getParentFile().mkdir(); incFile.delete(); - FileUtils.writeFileContents(incFile, TEST_2_inc.toCharArray(), null); + FileUtils.writeFileContents(incFile, convertForOS(TEST_2_inc).toCharArray(), null); makeModel(TEST_2); IImageMakefileView view = (IImageMakefileView) model.createView(viewConfig); @@ -608,7 +637,7 @@ assertEquals(EGeneratedHeaderFlags.Header, c.getHeaderFlags()); // default value not represented assertNull(c.getGeneratedHeaderFilePath()); - assertEquals(new Path("epoc32\\include\\Birthdays_aif.mbg"), c.getDefaultGeneratedHeaderFilePath()); + assertEquals(new Path("epoc32/include/Birthdays_aif.mbg"), c.getDefaultGeneratedHeaderFilePath()); assertEquals("Birthdays_aif.mif", c.getTargetFile()); assertEquals(new Path("resource/apps"), c.getTargetPath()); @@ -663,12 +692,12 @@ assertFalse(b.isColor()); assertEquals(1, b.getDepth()); assertEquals(1, b.getMaskDepth()); - assertEquals(new Path("c:/test/dot.bmp"), b.getPath()); + assertEquals(stockRootedImgPath.append("dot.bmp"), b.getPath()); assertNull(b.getMaskPath()); - assertEquals(new Path("c:/test/dot_mask.bmp"), b.getDefaultMaskPath()); + assertEquals(stockRootedImgPath.append("dot_mask.bmp"), b.getDefaultMaskPath()); } - // alternate style uses \\epoc32 directly + // alternate style uses /epoc32 directly final String TEST_3 = "# ============================================================================\r\n" + "# Name : Icons_aif_scalable_dc.mk\r\n" + @@ -712,7 +741,7 @@ "CLEANLIB : do_nothing\r\n" + "\r\n" + "RESOURCE : \r\n" + - " mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \\\r\n" + + " mifconv $(ICONTARGETFILENAME) /H$(HEADERFILENAME) \\\r\n" + " /c32 $(ICONDIR)\\qgn_menu_Birthdays.svg\r\n" + " \r\n" + "FREEZE : do_nothing\r\n" + @@ -742,7 +771,7 @@ /////// IMultiImageSource c = mis.get(0); assertEquals(EGeneratedHeaderFlags.Header, c.getHeaderFlags()); - assertEquals(new Path("\\epoc32\\include\\Birthdays_aif.mbg"), c.getGeneratedHeaderFilePath()); + assertEquals(new Path("/epoc32/include/Birthdays_aif.mbg"), c.getGeneratedHeaderFilePath()); assertEquals("Birthdays_aif.mif", c.getTargetFile()); assertEquals(new Path("/epoc32/data/z/resource/apps"), c.getTargetPath()); @@ -760,7 +789,7 @@ // no extension --> svg final String TEST_4 = "ifeq (WINS,$(findstring WINS, $(PLATFORM)))\r\n" + - "ZDIR=\\epoc32\\release\\$(PLATFORM)\\$(CFG)\\Z\r\n" + + "ZDIR=/epoc32\\release\\$(PLATFORM)\\$(CFG)\\Z\r\n" + "else\r\n" + "ZDIR=\\epoc32\\data\\z\r\n" + "endif\r\n" + @@ -773,7 +802,7 @@ "\r\n" + "ICONDIR=..\\gfx\r\n" + "RESOURCE : \r\n" + - " mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \\\r\n" + + " mifconv $(ICONTARGETFILENAME) /H$(HEADERFILENAME) \\\r\n" + " /c32 $(ICONDIR)\\qgn_menu_Birthdays\r\n" + " \r\n" + ""; @@ -868,7 +897,7 @@ IMultiImageSource mis = view.createMultiImageSource(); mis.setHeaderFlags(EGeneratedHeaderFlags.Header); - mis.setTargetPath(new Path("epoc32\\release\\winscw\\udeb\\sys\\bin")); + mis.setTargetPath(new Path("epoc32/release/winscw/udeb/sys/bin")); mis.setTargetFile("miffile.mif"); view.getMultiImageSources().add(mis); @@ -900,7 +929,7 @@ assertEquals(0, view.getMultiImageSources().size()); IMultiImageSource mis = view.createMultiImageSource(); - mis.setTargetPath(new Path("epoc32\\release\\winscw\\udeb\\sys\\bin")); + mis.setTargetPath(new Path("epoc32/release/winscw/udeb/sys/bin")); mis.setTargetFile("miffile.mif"); view.getMultiImageSources().add(mis); @@ -929,8 +958,11 @@ public void testRootProject() { // make sure we handle project root correctly when it's the root directory for (int i = 0; i < 2; i++){ - parserConfig.projectPath = i == 0 ? new Path("c:\\") : new Path("c:"); - this.path = new Path("c:\\symbian\\9.1\\S60_3rd\\S60Ex\\Hello\\group\\Icons.mk"); + if (HostOS.IS_WIN32) + parserConfig.projectPath = i == 0 ? new Path("c:\\") : new Path("c:"); + else + parserConfig.projectPath = new Path("/"); + this.path = stockRootedProjectPath.append("/group/Icons.mk"); makeModel("RESOURCE:\n"+ "\tmifconv hello.mif /c8,8 ../gfx/file.svg\n"); @@ -943,26 +975,33 @@ private void _testRootProject(IImageMakefileData imageMakefileData) { IImageSource source = imageMakefileData.getMultiImageSources().get(0).getSources().get(0); // important to be relative - assertEquals(new Path("symbian/9.1/S60_3rd/S60Ex/Hello/gfx/file.svg"), source.getPath()); + IPath relBase; + relBase = stockRootedProjectPath.makeRelative(); + assertEquals(relBase.append("/gfx/file.svg"), source.getPath()); } public void testMifconvBugs() { makeModel("RESOURCE:\n"+ - "\tmifconv hello.mif /c8,8 c:\\imgs\\foo.bmp /c32 c:\\svgs\\foo.svg\n"); + "\tmifconv hello.mif /c8,8 "+stockRootedImgPath.append("foo.bmp").toOSString() + +" /c32 "+stockRootedSvgPath.append("foo.svg") + "\n"); IImageMakefileView view =model.createView(this.viewConfig); IImageSource source = view.getMultiImageSources().get(0).getSources().get(0); // BMPs can have drive letter on input... - assertEquals(new Path("c:/imgs/foo.bmp"), source.getPath()); + assertEquals(stockRootedImgPath.append("foo.bmp"), source.getPath()); source.setMaskDepth(1); source = view.getMultiImageSources().get(0).getSources().get(1); // SVGs can have drive letter on input... - assertEquals(new Path("c:/svgs/foo.svg"), source.getPath()); + assertEquals(stockRootedSvgPath.append("foo.svg"), source.getPath()); // drop drive letters on output for bmps - commitTest(view, "RESOURCE:\n"+ - "\tmifconv hello.mif \\\n\t/c8,1 \\imgs\\foo.bmp \\\n\t/c32 c:\\svgs\\foo.svg\n"); + IPath outBmpPath = stockRootedImgPath.append("foo.bmp").setDevice(null); + IPath outSvgPath = stockRootedSvgPath.append("foo.svg"); + String refText = "RESOURCE:\n"+ + "\tmifconv hello.mif \\\n\t/c8,1 "+HostOS.convertPathToWindows(outBmpPath) + " " + + "\\\n\t/c32 " + HostOS.convertPathToWindows(outSvgPath) + "\n"; + commitTest(view, refText); } @@ -1260,7 +1299,7 @@ File incFile = new File(projectPath.toFile(), "group/bitmaps.txt"); incFile.getParentFile().mkdir(); incFile.delete(); - FileUtils.writeFileContents(incFile, bitmapFile.toCharArray(), null); + FileUtils.writeFileContents(incFile, convertForOS(bitmapFile).toCharArray(), null); makeModel("target:\n"+ "\tmifconv foo.mif /X /GOO /B /Smyencode.exe /H\\noob.h /Fbitmaps.txt"); @@ -1323,12 +1362,12 @@ File incFile = new File(projectPath.toFile(), "inc/Icons_generic.mk"); incFile.getParentFile().mkdir(); incFile.delete(); - FileUtils.writeFileContents(incFile, incl.toCharArray(), null); + FileUtils.writeFileContents(incFile, convertForOS(incl).toCharArray(), null); File normFile = new File(projectPath.toFile(), "group/Icons_scalable.mk"); normFile.getParentFile().mkdir(); normFile.delete(); - FileUtils.writeFileContents(normFile, text.toCharArray(), null); + FileUtils.writeFileContents(normFile, convertForOS(text).toCharArray(), null); parserConfig.fileLocator = new BasicIncludeFileLocator( new File[] { projectPath.append("inc").toFile() }, @@ -1362,12 +1401,12 @@ File incFile = new File(projectPath.toFile(), "inc/Icons_generic.mk"); incFile.getParentFile().mkdir(); incFile.delete(); - FileUtils.writeFileContents(incFile, incl.toCharArray(), null); + FileUtils.writeFileContents(incFile, convertForOS(incl).toCharArray(), null); File normFile = new File(projectPath.toFile(), "group/Icons_scalable.mk"); normFile.getParentFile().mkdir(); normFile.delete(); - FileUtils.writeFileContents(normFile, text.toCharArray(), null); + FileUtils.writeFileContents(normFile, convertForOS(text).toCharArray(), null); parserConfig.fileLocator = new BasicIncludeFileLocator( new File[] { projectPath.append("inc").toFile() }, @@ -1417,7 +1456,7 @@ File normFile = new File(projectPath.toFile(), "group/Icons_scalable.mk"); normFile.getParentFile().mkdir(); normFile.delete(); - FileUtils.writeFileContents(normFile, text.toCharArray(), null); + FileUtils.writeFileContents(normFile, convertForOS(text).toCharArray(), null); parserConfig.fileLocator = new BasicIncludeFileLocator( new File[] { projectPath.append("inc").toFile() }, @@ -1450,7 +1489,7 @@ File incFile = new File(projectPath.toFile(), "inc/Icons_generic.mk"); incFile.getParentFile().mkdir(); incFile.delete(); - FileUtils.writeFileContents(incFile, incl.toCharArray(), null); + FileUtils.writeFileContents(incFile, convertForOS(incl).toCharArray(), null); // revert the view and be sure we can get the file now @@ -1488,7 +1527,7 @@ File normFile = new File(projectPath.toFile(), "group/Icons_scalable.mk"); normFile.getParentFile().mkdir(); normFile.delete(); - FileUtils.writeFileContents(normFile, text.toCharArray(), null); + FileUtils.writeFileContents(normFile, convertForOS(text).toCharArray(), null); parserConfig.fileLocator = new BasicIncludeFileLocator( new File[] { projectPath.append("inc").toFile() }, @@ -1524,7 +1563,7 @@ // the model should go into the main file, and the include removed String newText = new String(FileUtils.readFileContents(normFile, null)); - assertEquals("\r\n" + + assertEquals(convertForOS("\r\n" + "SECURITY_FLAG=on\r\n" + "SCALABLE_FLAG=on\r\n" + "\r\n" + @@ -1532,11 +1571,11 @@ " qgn_prop_nrtyp_date\r\n" + " mifc$(SECURITY_FLAG)v foo.mif \\\r\n" + " /c8,1 qgn_prop_nrtyp_date\r\n" + - "", newText); + ""), convertForOS(newText)); // the include is unchanged String newIncl = new String(FileUtils.readFileContents(incFile, null)); - assertEquals(incl, newIncl); + assertEquals(convertForOS(incl), convertForOS(newIncl)); referencedFiles = view.getReferencedFiles(); assertEquals(1, referencedFiles.length); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView.java Wed Dec 02 15:02:05 2009 -0600 @@ -26,6 +26,7 @@ import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTTopLevelNode; import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.mmp.IASTMMPListArgumentStatement; import com.nokia.carbide.internal.cpp.epoc.engine.model.ViewASTBase; +import com.nokia.cpp.internal.api.utils.core.HostOS; import com.nokia.cpp.internal.api.utils.core.IMessage; import org.eclipse.core.runtime.IPath; @@ -1049,7 +1050,7 @@ assertEquals(2, resource.getDependsFiles().size()); assertEquals("foo1.rsg", resource.getDependsFiles().get(0)); assertEquals("foo2.rsg", resource.getDependsFiles().get(1)); - assertEquals(new Path("\\sys\\bin"), resource.getTargetPath()); + assertEquals(new Path("/sys/bin"), resource.getTargetPath()); assertEquals("foo.rsc", resource.getTargetFile()); assertEquals(2, resource.getLanguages().size()); assertEquals(EGeneratedHeaderFlags.Header, resource.getHeaderFlags()); @@ -1101,7 +1102,7 @@ } private void _testNewResourcesParsing2a(IMMPData data) { - assertEquals(new Path("\\sys\\target\\foo"), data.getTargetFilePath()); + assertEquals(new Path("/sys/target/foo"), data.getTargetFilePath()); assertEquals("0x1", data.getUid2()); assertEquals("0x2", data.getUid3()); @@ -1111,7 +1112,7 @@ assertEquals("foo1.rsg", resource.getDependsFiles().get(0)); assertEquals("foo2.rsg", resource.getDependsFiles().get(1)); - assertEquals(new Path("\\sys\\bin"), resource.getTargetPath()); + assertEquals(new Path("/sys/bin"), resource.getTargetPath()); assertEquals("0x3", resource.getUid2()); assertEquals("0x4", resource.getUid3()); } @@ -1142,7 +1143,7 @@ assertEquals("foo1.rsg", resource.getDependsFiles().get(0)); assertEquals("foo2.rsg", resource.getDependsFiles().get(1)); - assertEquals(new Path("\\sys\\bin"), resource.getTargetPath()); + assertEquals(new Path("/sys/bin"), resource.getTargetPath()); assertEquals("0x3", resource.getUid2()); assertEquals("0x4", resource.getUid3()); } @@ -1202,7 +1203,7 @@ assertEquals(1, resources.size()); IMMPResource resource = resources.get(0); - resource.setTargetPath(new Path("\\sys\\data\\myapp")); + resource.setTargetPath(new Path("/sys/data/myapp")); resource.getLanguages().add(EMMPLanguage.American); commitTest(view, @@ -1221,7 +1222,7 @@ assertNotNull(view); IMMPResource resource = view.createMMPResource(); - resource.setTargetPath(new Path("\\where")); + resource.setTargetPath(new Path("/where")); resource.setTargetFile("targ.rsc"); assertFalse(resource.isValid()); resource.setSource(new Path("/foo/bar/data/uidesign.rss")); @@ -1379,10 +1380,10 @@ makeModel("TARGETPATH \\foo\\bar\n"+ "TARGET file.exe\n"); IMMPView view = getView(mmpConfig); - assertEquals(new Path("\\foo\\bar\\file.exe"), view.getTargetFilePath()); + assertEquals(new Path("/foo/bar/file.exe"), view.getTargetFilePath()); // keep predom slash fmt - view.setTargetFilePath(new Path("\\sys\\bin\\nasty.exe")); + view.setTargetFilePath(new Path("/sys/bin/nasty.exe")); commitTest(view, "TARGETPATH \\sys\\bin\n"+ "TARGET nasty.exe\n"); @@ -1408,7 +1409,7 @@ private void _testAIFParsing0(IMMPData data) { assertEquals(1, data.getAifs().size()); IMMPAIFInfo info = data.getAifs().get(0); - assertEquals(new Path("data\\aiffile.rss"), info.getResource()); + assertEquals(new Path("data/aiffile.rss"), info.getResource()); // TARGETPATH not represented assertEquals(new Path("targetfile.aif"), info.getTarget()); @@ -1432,7 +1433,7 @@ private void _testAIFParsing1(IMMPData data) { assertEquals(1, data.getAifs().size()); IMMPAIFInfo info = data.getAifs().get(0); - assertEquals(new Path("data\\aiffile.rss"), info.getResource()); + assertEquals(new Path("data/aiffile.rss"), info.getResource()); // TARGETPATH not represented assertEquals(new Path("targetfile.aif"), info.getTarget()); @@ -1638,7 +1639,7 @@ IMMPBitmap bitmap = bitmaps.get(0); assertEquals("foo.mbm", bitmap.getTargetFile()); - assertEquals(new Path("\\sys\\pix"), bitmap.getTargetPath()); + assertEquals(new Path("/sys/pix"), bitmap.getTargetPath()); assertEquals(EGeneratedHeaderFlags.Header, bitmap.getHeaderFlags()); assertEquals(3, bitmap.getSources().size()); @@ -1673,7 +1674,10 @@ IMMPBitmap bitmap = view.createMMPBitmap(); bitmap.setTargetFile("target.mbm"); - bitmap.setTargetPath(new Path("e:\\foo\\bar")); + if (HostOS.IS_WIN32) + bitmap.setTargetPath(new Path("e:\\foo\\bar")); + else + bitmap.setTargetPath(new Path("e:/foo/bar")); bitmap.setHeaderFlags(EGeneratedHeaderFlags.Header); IBitmapSource source = bitmap.createBitmapSource(); @@ -1701,10 +1705,15 @@ } public void testBitmapChanging1() { + String nativePath; + if (HostOS.IS_WIN32) + nativePath = "e:\\foo\\bar"; + else + nativePath = "e:/foo/bar"; makeModel( "START BITMAP target.mbm\n"+ "// comment 1\n"+ - "\tTARGETPATH e:\\foo\\bar\n"+ + "\tTARGETPATH "+ nativePath + "\n"+ "// comment 2\n"+ "\tHEADER\n"+ "// comment 3\n"+ @@ -1719,7 +1728,7 @@ IMMPBitmap bitmap = view.getBitmaps().get(0); bitmap.setTargetFile("target.mbm"); - bitmap.setTargetPath(new Path("e:\\foo\\bar")); + bitmap.setTargetPath(new Path(nativePath)); bitmap.setHeaderFlags(EGeneratedHeaderFlags.Header); IBitmapSource source = (IBitmapSource) bitmap.getSources().get(0); @@ -1733,7 +1742,7 @@ commitTest(view, "START BITMAP target.mbm\n"+ "// comment 1\n"+ - "\tTARGETPATH e:\\foo\\bar\n"+ + "\tTARGETPATH " + nativePath + "\n"+ "// comment 2\n"+ "\tHEADER\n"+ "// comment 3\n"+ @@ -1746,11 +1755,16 @@ bitmap = view.getBitmaps().get(0); bitmap.setHeaderFlags(EGeneratedHeaderFlags.HeaderOnly); - // unfortunately we have to rewrite and lose comments here + // unfortunately we have to rewrite, reslash, and lose comments here + String nativePix; + if (HostOS.IS_WIN32) + nativePix = "..\\data\\pix"; + else + nativePix = "../data/pix"; commitTest(view, "START BITMAP target.mbm\n"+ - "\tTARGETPATH e:\\foo\\bar\n"+ - "\tSOURCEPATH ..\\data\\pix\n"+ + "\tTARGETPATH " + nativePath + "\n"+ + "\tSOURCEPATH " + nativePix + "\n"+ "\tSOURCE 8,8 icon.bmp icon_mask_soft.bmp\n"+ "\tHEADERONLY\n"+ "END\n"); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView2.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView2.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView2.java Wed Dec 02 15:02:05 2009 -0600 @@ -32,12 +32,14 @@ import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.IASTTranslationUnit; import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.mmp.IASTMMPStartBlockStatement; import com.nokia.carbide.internal.cpp.epoc.engine.model.ViewASTBase; +import com.nokia.cpp.internal.api.utils.core.HostOS; import com.nokia.cpp.internal.api.utils.core.IMessage; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jface.text.IDocument; +import java.io.File; import java.util.List; /** @@ -92,44 +94,49 @@ public void testAbsolutePaths() { // don't convert absolute or absolute-like paths final String MMP = - "USERINCLUDE +\\include\\oem \\epoc32\\foo c:\\foo\\bar\n"; + "USERINCLUDE +\\include\\oem \\epoc32\\foo " + getTokenAbsolutePath() + "foo\\bar\n"; makeModel(MMP); IMMPView view = model.createView(mmpConfig); IPath path = view.getUserIncludes().get(0); - assertEquals(new Path("+\\include\\oem"), path); + assertEquals(new Path("+/include/oem"), path); path = view.getUserIncludes().get(1); - assertEquals(new Path("\\epoc32\\foo"), path); + assertEquals(new Path("/epoc32/foo"), path); path = view.getUserIncludes().get(2); - assertEquals(new Path("c:\\foo\\bar"), path); + assertEquals(new Path(getTokenAbsolutePath()).append("/foo/bar"), path); - view.getSystemIncludes().add(new Path("+\\epoc32\\data")); - view.getSystemIncludes().add(new Path("\\epoc32\\user")); + view.getSystemIncludes().add(new Path("+/epoc32/data")); + view.getSystemIncludes().add(new Path("/epoc32/user")); // NOTE: absolute paths with drive letters not allowed, so c:\ is dropped // if a normal API using MMPViewPathHelper constructs the path. // We don't strip anything inside MMPView because we don't know // what future enhancements may need the letter. - view.getSystemIncludes().add(new Path("c:\\system\\files")); + view.getSystemIncludes().add(new Path(getTokenAbsolutePath()).append("system/files")); + + // since the other paths are backslash, we keep this in this forward-slash path + String expected = toDosPath(new Path(getTokenAbsolutePath()).append("system\\files")); commitTest(view, MMP + - "SYSTEMINCLUDE +\\epoc32\\data \\epoc32\\user c:\\system\\files\n"); + "SYSTEMINCLUDE +\\epoc32\\data \\epoc32\\user " + expected + "\n"); } public void testRootProject() { // make sure we handle project root correctly when it's the root directory + String root = HostOS.IS_WIN32 ? "C:" : "/"; for (int i = 0; i < 2; i++){ - parserConfig.projectPath = i == 0 ? new Path("c:\\") : new Path("c:"); - this.path = new Path("c:\\symbian\\9.1\\S60_3rd\\S60Ex\\Hello\\group\\hello.mmp"); + parserConfig.projectPath = new Path(i == 0 ? root : root + File.separator); + IPath base = new Path(getTokenAbsolutePath()); + this.path = base.append("symbian/9.1/S60_3rd/S60Ex/Hello/group/hello.mmp"); makeModel("SOURCEPATH ..\\src\n"+ "SOURCE foo.cpp\n"); IMMPView view = model.createView(mmpConfig); IPath[] srcPaths = view.getEffectiveSourcePaths(); // important to be relative - assertEquals(new Path("symbian/9.1/S60_3rd/S60Ex/Hello/src"), srcPaths[0]); + assertEquals(base.makeRelative().append("symbian/9.1/S60_3rd/S60Ex/Hello/src"), srcPaths[0]); IPath src = view.getSources().get(0); // important to be relative - assertEquals(new Path("symbian/9.1/S60_3rd/S60Ex/Hello/src/foo.cpp"), src); + assertEquals(base.makeRelative().append("symbian/9.1/S60_3rd/S60Ex/Hello/src/foo.cpp"), src); } } @@ -303,7 +310,8 @@ * */ public void testBaseDirectory() { - parserConfig.getFilesystem().put(new Path("c:/test/basefile.mmp").toOSString(), + IPath base = new Path(getTokenAbsolutePath()).append("test/basefile.mmp"); + parserConfig.getFilesystem().put(base.toOSString(), "SOURCEPATH .\n"+ "SOURCE base.cpp\n"); @@ -314,7 +322,7 @@ makeModel( "SOURCEPATH .\n"+ "SOURCE first.cpp\n"+ - "#include \"c:\\test\\basefile.mmp\"\n"+ + "#include \"" + base.toOSString() + "\"\n"+ "#include \"../utils/helper.mmh\"\n"+ "SOURCEPATH ../src\n"+ "SOURCE last.cpp\n"); @@ -325,7 +333,7 @@ assertEquals(new Path("group/first.cpp"), view.getSources().get(0)); // note: should not be relative path when outside the project - assertEquals(new Path("c:/test/base.cpp"), view.getSources().get(1)); + assertEquals(base.removeLastSegments(1).append("base.cpp"), view.getSources().get(1)); assertEquals(new Path("utils/helper.cpp"), view.getSources().get(2)); assertEquals(new Path("src/last.cpp"), view.getSources().get(3)); @@ -730,7 +738,7 @@ "* Description : Music Collection Common project specification\r\n" + "* Version : 1.0\r\n" + "*\r\n" + - "* Copyright © 2004 Nokia. All rights reserved.\r\n" + + "* Copyright (c) 2004 Nokia. All rights reserved.\r\n" + "* This material, including documentation and any related \r\n" + "* computer programs, is protected by copyright controlled by \r\n" + "* Nokia. All rights are reserved. Copying, including \r\n" + @@ -844,7 +852,7 @@ "* Description : Music Collection project specification\r\n" + "* Version : \r\n" + "*\r\n" + - "* Copyright © 2004 Nokia. All rights reserved.\r\n" + + "* Copyright (c) 2004 Nokia. All rights reserved.\r\n" + "* This material, including documentation and any related \r\n" + "* computer programs, is protected by copyright controlled by \r\n" + "* Nokia. All rights are reserved. Copying, including \r\n" + @@ -1183,20 +1191,25 @@ public void testNoDriveLettersAppear() { makeModel("USERINCLUDE ..\\group\n"); IMMPView view = model.createView(mmpConfig); - view.getUserIncludes().add(new Path("c:\\temp")); + IPath fullpath = new Path(getTokenAbsolutePath()).append("temp"); + view.getUserIncludes().add(fullpath); // We don't strip drive letters inside the MMPView, only through the // canonicalization API MMPViewPathHelper. commitTest(view, - "USERINCLUDE ..\\group c:\\temp\n"); + "USERINCLUDE ..\\group " + toDosPath(fullpath) + "\n"); } public void testNoDriveLettersAppear2() { + // not going to have a drivey path here + if (HostOS.IS_UNIX) + return; + makeModel("USERINCLUDE ..\\group\n"); IMMPView view = model.createView(mmpConfig); MMPViewPathHelper helper = new MMPViewPathHelper(view, (IPath)null); try { // no SDK active here, so all full paths throw helper.convertProjectOrFullPathToMMP( - EMMPPathContext.USERINCLUDE, new Path("c:\\temp")); + EMMPPathContext.USERINCLUDE, new Path(getTokenAbsolutePath()).append("temp")); fail(); } catch (InvalidDriveInMMPPathException e) { view.getUserIncludes().add(e.getPathNoDevice()); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView3.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView3.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView3.java Wed Dec 02 15:02:05 2009 -0600 @@ -28,6 +28,7 @@ import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; import com.nokia.carbide.cpp.sdk.core.SymbianSDKFactory; +import com.nokia.cpp.internal.api.utils.core.HostOS; import org.eclipse.core.runtime.*; import org.osgi.framework.Version; @@ -115,7 +116,7 @@ // if we got here, now try converting back boolean isFixedDirectory = false; String origDefFile = mmpView.getSingleArgumentSettings().get(EMMPStatement.DEFFILE); - if (origDefFile != null && new Path(origDefFile).segmentCount() > 1) + if (origDefFile != null && new Path(HostOS.convertPathToUnix(origDefFile)).segmentCount() > 1) isFixedDirectory = true; mmpView.setDefFile(realPath, isFixedDirectory); IPath convPath = mmpView.getDefFile(); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView4.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView4.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMMPView4.java Wed Dec 02 15:02:05 2009 -0600 @@ -1009,7 +1009,7 @@ makeModel(text); view = getView(mmpConfig); - view.getSystemIncludes().set(1, new Path("\\epoc32\\foo")); + view.getSystemIncludes().set(1, new Path("/epoc32/foo")); commitTest(view, text5); } @@ -1065,7 +1065,7 @@ makeModel(text); view = getView(mmpConfig); - view.getSystemIncludes().set(1, new Path("\\epoc32\\arglebargle")); + view.getSystemIncludes().set(1, new Path("/epoc32/arglebargle")); commitTest(view, text4); } @@ -1122,7 +1122,7 @@ makeModel(text); view = getView(mmpConfig); - view.getSystemIncludes().set(1, new Path("\\epoc32\\arglebargle")); + view.getSystemIncludes().set(1, new Path("/epoc32/arglebargle")); commitTest(view, text4); } @@ -1181,7 +1181,7 @@ checkNoProblems(view); IPath path = view.getSystemIncludes().get(0); - assertEquals(new Path("\\src\\cedar\\generic\\base\\e32\\drivers\\pbus\\mmc\\sdcard\\sdcard3c"), + assertEquals(new Path("/src/cedar/generic/base/e32/drivers/pbus/mmc/sdcard/sdcard3c"), path); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMakefileView.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMakefileView.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestMakefileView.java Wed Dec 02 15:02:05 2009 -0600 @@ -27,6 +27,7 @@ import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine; import com.nokia.carbide.cpp.epoc.engine.preprocessor.IViewFilter; import com.nokia.carbide.cpp.epoc.engine.tests.BaseTest; +import com.nokia.cpp.internal.api.utils.core.HostOS; import com.nokia.cpp.internal.api.utils.core.IMessage; import org.eclipse.cdt.make.core.makefile.ICommand; @@ -86,6 +87,9 @@ } protected void makeModel(String text) { + // TODO: tests should work with both slash directions on both OSes + if (HostOS.IS_UNIX) + text = text.replaceAll("\\\\(?!\r|\n)", "/"); IDocument document = DocumentFactory.createDocument(text); model = new MakefileModelFactory().createModel(path, document); @@ -99,6 +103,9 @@ } protected void commitTest(IMakefileView view, String refText) { + // TODO: tests should work with both slash directions on both OSes + if (HostOS.IS_UNIX) + refText = refText.replaceAll("\\\\(?!\r|\n)", "/"); commitTest(model, view, refText); } @@ -182,8 +189,9 @@ assertEquals(1, commands.length); assertNotNull(commands[0].getParent()); + String mifconvEXELine = "MIFCONV=$(TOOLDIR)\\mifconv"+ (HostOS.IS_WIN32 ? ".exe" : "") + "\n"; makeModel("TOOLSDIR=c:\\my\\tools\n"+ - "MIFCONV=$(TOOLDIR)\\mifconv.exe\n"+ + mifconvEXELine + "\n"+ "all: mytool\n"+ "\n"+ @@ -206,7 +214,7 @@ view.replaceDirective(oldRule, newRule); commitTest(view, "TOOLSDIR=c:\\my\\tools\n"+ - "MIFCONV=$(TOOLDIR)\\mifconv.exe\n"+ + mifconvEXELine + "\n"+ "all: mytool\n"+ "\n"+ @@ -365,34 +373,48 @@ } - public void testUnexpand() { + public void testUnexpand1() { makeModel("ZDIR=$(EPOCROOT)\\release\\winscw\n"+ "TARGETDIR=$(ZDIR)\\data\n"+ "ICONTARGETFILENAME=$(TARGETDIR)\\foo.mif\n"); IMakefileView view = getView(viewConfig); - String repl = view.unexpandMacros("$(EPOCROOT)\\release\\winscw\\data\\more.mif", - new String[] { "TARGETDIR", "ZDIR" }); - assertEquals("$(TARGETDIR)\\more.mif", repl); + doUnexpandTest(view, "$(EPOCROOT)\\release\\winscw\\data\\more.mif", + "$(TARGETDIR)\\more.mif"); - String repl1 = view.unexpandMacros("1 2 $(EPOCROOT)\\release\\winscw\\data\\more.mif 3 4", - new String[] { "TARGETDIR", "ZDIR" }); - assertEquals("1 2 $(TARGETDIR)\\more.mif 3 4", repl1); + doUnexpandTest(view, "1 2 $(EPOCROOT)\\release\\winscw\\data\\more.mif 3 4", + "1 2 $(TARGETDIR)\\more.mif 3 4"); - String repl2 = view.unexpandMacros("$(EPOCROOT)\\release\\winscw\\more.mif", - new String[] { "TARGETDIR", "ZDIR" }); - assertEquals("$(ZDIR)\\more.mif", repl2); + doUnexpandTest(view, "$(EPOCROOT)\\release\\winscw\\more.mif", + "$(ZDIR)\\more.mif"); - String repl3 = view.unexpandMacros("$(EPOCROOT)\\release\\foo\\data\\more.mif", - new String[] { "TARGETDIR", "ZDIR" }); - assertEquals("$(EPOCROOT)\\release\\foo\\data\\more.mif", repl3); + doUnexpandTest(view, "$(EPOCROOT)\\release\\foo\\data\\more.mif", + "$(EPOCROOT)\\release\\foo\\data\\more.mif"); - String repl4 = view.unexpandMacros("\\release\\winscw\\data\\more.mif", - new String[] { "TARGETDIR", "ZDIR" }); - assertEquals("\\release\\winscw\\data\\more.mif", repl4); + doUnexpandTest(view, "\\release\\winscw\\data\\more.mif", + "\\release\\winscw\\data\\more.mif"); } + + private void doUnexpandTest(IMakefileView view, String expanded, + String unexpanded) { + + // TODO: tests should ideally work with both slash directions on both OSes + if (HostOS.IS_WIN32) { + String repl = view.unexpandMacros(expanded, + new String[] { "TARGETDIR", "ZDIR" }); + assertEquals(unexpanded, repl); + } else { + expanded = HostOS.convertPathToUnix(expanded); + unexpanded = HostOS.convertPathToUnix(unexpanded); + String repl = view.unexpandMacros(expanded, + new String[] { "TARGETDIR", "ZDIR" }); + assertEquals(unexpanded, repl); + } + + } + public void testProblems() { makeModel("\n\n)ZDIR@foo{\n"+ "^^ placate ^^\n"); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestViewDataCache.java --- a/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestViewDataCache.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine.tests/src/com/nokia/carbide/cpp/epoc/engine/tests/model/TestViewDataCache.java Wed Dec 02 15:02:05 2009 -0600 @@ -60,9 +60,13 @@ private File tmpDir; private File projectDir; + // Try to wait long enough to ensure the timestamp-based check will detect a change + private static final long FS_TIME_RESOLUTION = ViewDataCache.ModelFileTimestampCollection.MIN_TIMESTAMP_RESOLUTION; + /* (non-Javadoc) * @see com.nokia.carbide.cpp.epoc.engine.tests.BaseTest#setUp() */ + @SuppressWarnings("unchecked") protected void setUp() throws Exception { super.setUp(); modelProvider = ModelProviderFactory.createModelProvider(new MMPModelFactory()); @@ -123,12 +127,12 @@ assertEquals(new Path("group/foo.cpp"), data.getSources().get(0)); // change foo.mmp on disk - Thread.sleep(50); + Thread.sleep(FS_TIME_RESOLUTION); makeFile("group/foo.mmp", "SOURCEPATH .\n"+ - "SOURCE foo.cpp bar.cpp\n"); + "SOURCE foo.cpp bar.cpp\n"); // note: size changes too // cache throttles file timestamp checks - Thread.sleep(55); + Thread.sleep(FS_TIME_RESOLUTION); IMMPData data2 = viewDataCache.getData(mmpPath, new DefaultMMPViewConfiguration(projectPath)); assertNotNull(data2); @@ -154,12 +158,12 @@ assertEquals("0x6000", data.getSingleArgumentSettings().get(EMMPStatement.BASEADDRESS)); // change foo.mmh on disk - Thread.sleep(5); + Thread.sleep(FS_TIME_RESOLUTION); makeFile("group/header.mmh", - "BASEADDRESS 0x1111"); + "BASEADDRESS 0x1111"); // note: size does not change // cache throttles disk time checks - Thread.sleep(55); + Thread.sleep(FS_TIME_RESOLUTION); IMMPData data2 = viewDataCache.getData(mmpPath, new DefaultMMPViewConfiguration(projectPath)); assertNotNull(data2); @@ -354,6 +358,7 @@ data = viewDataCache.getData(path, config); data = viewDataCache.getData(path, config); data = viewDataCache.getData(path, config); + if (data != null) ; // read to squash warning } catch (CoreException e) { throw new RuntimeException(e); } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/image/ImageFormat.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/image/ImageFormat.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/image/ImageFormat.java Wed Dec 02 15:02:05 2009 -0600 @@ -27,7 +27,7 @@ */ public class ImageFormat { // tolerate but ignore extra 'c' - private static final Pattern FORMAT_PATTERN = Pattern.compile("/?(c?)(\\d+)(,c?(\\d+))?", //$NON-NLS-1$ + private static final Pattern FORMAT_PATTERN = Pattern.compile("[/-]?(c?)(\\d+)(,c?(\\d+))?", //$NON-NLS-1$ Pattern.CASE_INSENSITIVE); public boolean isColor; public int depth; diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/makefile/ArgList.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/makefile/ArgList.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/cpp/epoc/engine/model/makefile/ArgList.java Wed Dec 02 15:02:05 2009 -0600 @@ -38,7 +38,7 @@ public ArgList(String text) { String trimmed = text.trim(); this.initial = text.substring(0, text.indexOf(trimmed)); - this.terminal = text.substring(text.length() - this.initial.length() - trimmed.length()); + this.terminal = text.substring(text.length() - this.initial.length()); this.argv = splitArguments(trimmed); } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/preprocessor/BasicIncludeFileLocator.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/preprocessor/BasicIncludeFileLocator.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/api/cpp/epoc/engine/preprocessor/BasicIncludeFileLocator.java Wed Dec 02 15:02:05 2009 -0600 @@ -26,6 +26,7 @@ import java.io.IOException; import com.nokia.carbide.cpp.epoc.engine.preprocessor.IIncludeFileLocator; +import com.nokia.cpp.internal.api.utils.core.HostOS; public class BasicIncludeFileLocator implements IIncludeFileLocator { private static final File[] NO_DIRS = new File[0]; @@ -43,6 +44,10 @@ } public File findIncludeFile(String file, boolean isUser, File currentDir) { + if (HostOS.IS_UNIX) { + file = HostOS.convertPathToUnix(file); + } + // see if the file exists as an absolute file File theFile = new File(file); if (theFile.exists() && theFile.isFile() && theFile.isAbsolute()) diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/image/AifdefFileConverter.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/image/AifdefFileConverter.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/image/AifdefFileConverter.java Wed Dec 02 15:02:05 2009 -0600 @@ -98,7 +98,7 @@ // but only .mbmdef available in Carbide UI String mbmdefFile = matcher.group(3); IPath mbmdefPath = resolver.resolvePath(projectPath.append(mbmdefFile).toOSString()); - if (mbmdefPath.getDevice() == null) + if (mbmdefPath.getDevice() == null && (!HostOS.IS_WIN32 && !mbmdefPath.isAbsolute())) mbmdefPath = new Path(projectPath.removeTrailingSeparator().lastSegment()).append(mbmdefPath); String mbmdefText = readFileText(mbmdefPath); IMultiImageSource multiImageSource = new MbmdefFileConverter().convert(targetPath, mbmdefFile, mbmdefText, resolver); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/image/MultiImageSource.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/image/MultiImageSource.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/image/MultiImageSource.java Wed Dec 02 15:02:05 2009 -0600 @@ -102,7 +102,7 @@ public IPath getDefaultGeneratedHeaderFilePath() { String fileName = targetFile != null && targetFile.length() > 0 ? targetFile : ""; //$NON-NLS-1$ - return new Path("epoc32\\include").append(fileName).removeFileExtension().addFileExtension("mbg"); //$NON-NLS-1$ //$NON-NLS-2$ + return new Path("epoc32/include").append(fileName).removeFileExtension().addFileExtension("mbg"); //$NON-NLS-1$ //$NON-NLS-2$ } /* (non-Javadoc) diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewBase.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewBase.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewBase.java Wed Dec 02 15:02:05 2009 -0600 @@ -447,13 +447,13 @@ } public IPath convertModelToProjectPath(IPath modelPath) { - if (modelPath == null || modelPath.isAbsolute()) + if (modelPath == null || isAbsolutePath(modelPath)) return modelPath; return fromProjectToRelativePath(getProjectPath(), model.getPath().removeLastSegments(1).append(modelPath), true); } public IPath convertProjectToModelPath(IPath prjPath) { - if (prjPath == null || prjPath.isAbsolute()) + if (prjPath == null || isAbsolutePath(prjPath)) return prjPath; return fromProjectToRelativePath(model.getPath().removeLastSegments(1), getProjectPath().append(prjPath)); } @@ -560,4 +560,25 @@ else return '\\'; } + + /** + * Tell if the path is a Win32 path with drive letter or UNC. + * @param path + */ + public static boolean isWin32DrivePath(IPath path) { + return path.getDevice() != null + || (!HostOS.IS_WIN32 && path.segmentCount() > 0 && path.segment(0).matches("[A-Za-z]:")); + } + + /** + * Tell if the path is absolute -- e.g., according to the host or to Windows conventions. + * @param path + */ + public static boolean isAbsolutePath(IPath path) { + if (path.isAbsolute()) + return true; + if (isWin32DrivePath(path)) + return true; + return false; + } } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewDataCache.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewDataCache.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/ViewDataCache.java Wed Dec 02 15:02:05 2009 -0600 @@ -164,49 +164,72 @@ } - static class FileTimestampCollection { - private static FileTimestampCollection instance; + static class FileTimestampSizeCollection { + static FileTimestampSizeCollection INSTANCE = new FileTimestampSizeCollection(); /** Check timestamps only once in this number of milliseconds */ final int QUANTUM = 0; - /** map of file to last queried timestamp + time of last query */ - private Map> timestamps; - public static FileTimestampCollection getInstance() { - if (instance == null) { - instance = new FileTimestampCollection(); + static class FileInfo extends Tuple { + public FileInfo(long lastModified, long lastQueried, long size) { + super(lastModified, lastQueried, size); + } + public long getLastModified() { + return (Long) get(0); } - return instance; + public long getLastQueried() { + return (Long) get(0); + } + public long getLength() { + return (Long) get(2); + } } + /** map of file to file size + last queried timestamp + time of last query + * (use File, not IPath, so we canonicalize for the OS) */ + private Map info = new HashMap(); - private FileTimestampCollection() { - timestamps = new HashMap>(); - } - + /** Tell if the file's timestamp changed in the past quantum * and update the record */ public boolean changed(File file) { long now = System.currentTimeMillis(); - Pair stamp = timestamps.get(file); - if (stamp == null) { - stamp = new Pair(file.lastModified(), now); - timestamps.put(file, stamp); + FileInfo finfo = info.get(file); + if (finfo == null) { + finfo = new FileInfo(file.lastModified(), now, file.length()); + info.put(file, finfo); + if (DEBUG) System.out.println("First info for " + file + ": " + finfo); return true; - } else if (stamp.second + QUANTUM < now) { + } else if (finfo.getLastQueried() + QUANTUM < now) { // don't check times more than QUANTUM - long origTime = stamp.first; - stamp = new Pair(file.lastModified(), now); - timestamps.put(file, stamp); - return origTime != stamp.first; + long origTime = finfo.getLastModified(); + long origSize = finfo.getLength(); + finfo = new FileInfo(file.lastModified(), now, file.length()); + info.put(file, finfo); + if (DEBUG) System.out.println("Updated info for " + file + ": " + origTime + "/" + origSize + " <=> " + + finfo.getLastModified() + "/" + finfo.getLength()); + return origTime != finfo.getLastModified() || finfo.getLastModified() == 0 // 0 if deleted + || origSize != finfo.getLength(); } else { - // not changed + // not changed, as far as we assume + if (DEBUG) System.out.println("Assuming no change for " + file); return false; } } } - static class ModelFileTimestampCollection { - - private static final long QUANTUM = 50; + public static class ModelFileTimestampCollection { + /** + * The minimum timestamp resolution for a file in ms (based on heuristics for the OS). + * VFAT on Win32 uses 2 second increments. Linux ext2/3 uses 1 second resolution, + * until ext4, where it becomes nanoseconds. + * Assume the worst format in all cases. + */ + public static final long MIN_TIMESTAMP_RESOLUTION = HostOS.IS_WIN32 ? 2000 : 1000; + /** + * Delay in ms between successive checks of the filesystem, to avoid wasting time + * when such checks are slow, and in cases where it's unlikely the human will edit files + * fast enough to care. + */ + public static final long QUANTUM = HostOS.IS_WIN32 ? 50 : 10; private File[] files; private long lastQuery; @@ -217,7 +240,7 @@ for (IPath path : paths) { files[idx] = path.toFile(); // prime the cache - FileTimestampCollection.getInstance().changed(files[idx]); + FileTimestampSizeCollection.INSTANCE.changed(files[idx]); idx++; } this.lastQuery = System.currentTimeMillis(); @@ -230,11 +253,15 @@ public boolean changed() { long prevQuery = lastQuery; lastQuery = System.currentTimeMillis(); - if (prevQuery + QUANTUM > lastQuery) + + // don't check more often than the resolution of the file allows + if (prevQuery + QUANTUM > lastQuery) { + if (DEBUG) System.out.println("Skipping fileinfo check"); return false; + } for (File file : files) { - if (FileTimestampCollection.getInstance().changed(file)) { + if (FileTimestampSizeCollection.INSTANCE.changed(file)) { return true; } } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/bldinf/BldInfView.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/bldinf/BldInfView.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/bldinf/BldInfView.java Wed Dec 02 15:02:05 2009 -0600 @@ -41,7 +41,7 @@ /** * */ - public static final String EPOC32_INCLUDE = "\\epoc32\\include"; //$NON-NLS-1$ + public static final String EPOC32_INCLUDE = "/epoc32/include"; //$NON-NLS-1$ public static final String ZIP_MODIFIER = ":zip"; //$NON-NLS-1$ public static final String PRJ_EXPORTS_KEYWORD = "PRJ_EXPORTS"; //$NON-NLS-1$ public static final String PRJ_TESTEXPORTS_KEYWORD = "PRJ_TESTEXPORTS"; //$NON-NLS-1$ @@ -105,7 +105,11 @@ * @return */ private IPath fromBldInfToProjectPath(IPath bldinfPath) { - IPath path = currentDirectory != null && !bldinfPath.isAbsolute() ? currentDirectory.append(bldinfPath) : bldinfPath; + IPath path; + if (currentDirectory != null && !isAbsolutePath(bldinfPath)) + path = currentDirectory.append(bldinfPath); + else + path = bldinfPath; if (FileUtils.isPathInParent(path)) { path = getProjectPath().append(path); } @@ -136,7 +140,7 @@ * @return BldInf-relative directory */ IPath fromProjectToBldInfPath(IPath projectPath) { - if (projectPath.isAbsolute()) + if (isAbsolutePath(projectPath)) return projectPath; return fromProjectToRelativePath(currentDirectory, projectPath); } @@ -277,7 +281,7 @@ path = fromBldInfToProjectPath(pathName.substring(1)); } else { path = FileUtils.createPossiblyRelativePath(pathName); - if (!path.isAbsolute()) + if (!isAbsolutePath(path)) path = new Path(EPOC32_INCLUDE).append(path); } } @@ -311,7 +315,7 @@ } else { return epocIncludeRelPath; } - } else if (!projectPath.isAbsolute()) { + } else if (!isAbsolutePath(projectPath)) { // project-relative return new Path("|" + fromProjectToBldInfPath(projectPath).toString()); } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/bldinf/ExportListConverter.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/bldinf/ExportListConverter.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/bldinf/ExportListConverter.java Wed Dec 02 15:02:05 2009 -0600 @@ -25,6 +25,7 @@ import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.bldinf.ASTBldInfFactory; import com.nokia.carbide.internal.api.cpp.epoc.engine.dom.bldinf.IASTBldInfExportStatement; import com.nokia.carbide.internal.cpp.epoc.engine.model.StructuredItemStatementListConverter; +import com.nokia.carbide.internal.cpp.epoc.engine.model.ViewBase; import com.nokia.cpp.internal.api.utils.core.*; import org.eclipse.core.runtime.IPath; @@ -90,9 +91,9 @@ if (targetPath != null) { // need the backslashes for an export to a drive, else the build rules are broken // (they use 'copy' in DOS which doesn't like forward slashes) - if (targetPath.getDevice() != null) { - target = targetPath.toOSString(); - source = sourcePath.toOSString(); + if (ViewBase.isWin32DrivePath(targetPath)) { + target = HostOS.convertPathToWindows(targetPath.toOSString()); + source = HostOS.convertPathToWindows(sourcePath.toOSString()); } else target = bldInfView.pathString(targetPath); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/makefile/MakefileViewBase.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/makefile/MakefileViewBase.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/makefile/MakefileViewBase.java Wed Dec 02 15:02:05 2009 -0600 @@ -51,6 +51,8 @@ private String eol; private HashMap directiveFilenameToPathMap; private Set referencedFiles; + private VariableSubstitutionEngine engine; + private IVariableLookupCallback engineSubstitutor; /** * @param model @@ -351,7 +353,7 @@ protected String getProgramMatcherPattern(String program) { String ext = ""; //$NON-NLS-1$ program = makefile.expandString(program, true); - if (!Platform.isRunning() || Platform.getOS().equals(Platform.OS_WIN32)) { + if (HostOS.IS_WIN32) { ext = ".exe"; //$NON-NLS-1$ if (program.length() > 4 && program.substring(program.length() - 4).equalsIgnoreCase(ext)) { program = program.substring(0, program.length() - 4); @@ -577,11 +579,25 @@ return vars; } - private String substituteMacros(Map vars, String text) { - VariableSubstitutionEngine engine = new VariableSubstitutionEngine(null, null); - engine.allowRecursion(true); - engine.setVariableToken('('); - return engine.substitute(vars, text); + private String substituteMacros(final Map vars, String text) { + if (engine == null) { + engine = new VariableSubstitutionEngine(null, null); + engine.allowRecursion(true); + engine.setVariableToken('('); + + engineSubstitutor = new IVariableLookupCallback() { + + public Object getValue(String var) { + String value = vars.get(var); + if (value == null) + return null; + if (HostOS.IS_UNIX) + value = HostOS.convertPathToUnix(value); + return value; + } + }; + } + return engine.substitute(engineSubstitutor, text); } /* (non-Javadoc) @@ -702,7 +718,7 @@ */ @Override public IPath convertModelToProjectPath(IPath modelPath) { - if (modelPath.isAbsolute() || modelPath.toString().startsWith("$")) //$NON-NLS-1$ + if (isAbsolutePath(modelPath) || modelPath.toString().startsWith("$")) //$NON-NLS-1$ return modelPath; return super.convertModelToProjectPath(modelPath); @@ -713,7 +729,7 @@ */ @Override public IPath convertProjectToModelPath(IPath prjPath) { - if (prjPath.isAbsolute() || prjPath.toString().startsWith("$")) //$NON-NLS-1$ + if (isAbsolutePath(prjPath) || prjPath.toString().startsWith("$")) //$NON-NLS-1$ return prjPath; return super.convertProjectToModelPath(prjPath); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/makefile/image/MifConvCommandLineConverter.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/makefile/image/MifConvCommandLineConverter.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/makefile/image/MifConvCommandLineConverter.java Wed Dec 02 15:02:05 2009 -0600 @@ -22,6 +22,7 @@ import com.nokia.carbide.cpp.epoc.engine.model.EGeneratedHeaderFlags; import com.nokia.carbide.cpp.epoc.engine.model.makefile.ArgList; import com.nokia.carbide.cpp.epoc.engine.model.makefile.image.*; +import com.nokia.carbide.internal.cpp.epoc.engine.model.ViewBase; import com.nokia.cpp.internal.api.utils.core.*; import org.eclipse.core.runtime.*; @@ -38,11 +39,19 @@ public class MifConvCommandLineConverter implements IImageBuilderCommandLineConverter { - static final Pattern HEADER_PATTERN = Pattern.compile("/H(.*)", //$NON-NLS-1$ + // The original syntax used slash options, but these look like paths in Unix, + // so mifconv changed to use dash options. We originally generated slash options + // so we need to support both, but generate dash options now. + static final String OPTION_CHARS = HostOS.IS_WIN32 ? "[/-]" : "-"; + + // TODO: still prefer '/' in Win32 until we fix unit tests and templates + static final char OUT_OPTION_CHAR = HostOS.IS_WIN32 ? '/' : '-'; + + static final Pattern HEADER_PATTERN = Pattern.compile(OPTION_CHARS + "H(.*)", //$NON-NLS-1$ Pattern.CASE_INSENSITIVE); - static final Pattern PARAM_FILE_PATTERN = Pattern.compile("/F(.*)", //$NON-NLS-1$ + static final Pattern PARAM_FILE_PATTERN = Pattern.compile(OPTION_CHARS + "F(.*)", //$NON-NLS-1$ Pattern.CASE_INSENSITIVE); - static final Pattern EXTENSIONS_PATTERN = Pattern.compile("/E", //$NON-NLS-1$ + static final Pattern EXTENSIONS_PATTERN = Pattern.compile(OPTION_CHARS + "E", //$NON-NLS-1$ Pattern.CASE_INSENSITIVE); private static final Pattern SVG_EXTENSION_PATTERN = Pattern.compile("svgt?", //$NON-NLS-1$ Pattern.CASE_INSENSITIVE); @@ -50,7 +59,7 @@ Pattern.CASE_INSENSITIVE); private static final String EPOCROOT_SUBSTITUTION = "$(EPOCROOT)"; //$NON-NLS-1$ private static final String ZDIR_SUBSTITUTION = "$(ZDIR)"; //$NON-NLS-1$ - private static final String ZDIR_CONTENTS = "epoc32\\data\\z"; //$NON-NLS-1$ + private static final String ZDIR_CONTENTS = HostOS.IS_WIN32 ? "epoc32\\data\\z" : "epoc32/data/z"; //$NON-NLS-1$ //$NON-NLS-2$ // tracked during parsing (non-reentrant!) private ImageFormat imageFormat; @@ -161,8 +170,8 @@ continue; } - // unused option - if (arg.startsWith("/")) //$NON-NLS-1$ + // unused option (or filename) + if (arg.matches(OPTION_CHARS + ".*") && !arg.toLowerCase().matches(".*\\.(bmp|svg).*")) //$NON-NLS-1$ //$NON-NLS-2$ continue; // if image format not set, unknown garbage @@ -209,7 +218,7 @@ */ private List readParamFile(IImageMakefileView view, String filename) { IPath filePath = FileUtils.createPossiblyRelativePath(filename); - if (!filePath.isAbsolute() && !filePath.toString().startsWith("$")) { + if (!ViewBase.isAbsolutePath(filePath) && !filePath.toString().startsWith("$")) { filePath = view.getModelPath().removeLastSegments(1).append(filePath); } File file = filePath.toFile(); @@ -222,7 +231,7 @@ ArgList list = new ArgList(text); return list.getArgv(); } catch (CoreException e) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } } @@ -277,30 +286,30 @@ if (generatedHeaderFilePath == null) { generatedHeaderFilePath = multiImageSource.getDefaultGeneratedHeaderFilePath(); } - if (!generatedHeaderFilePath.isAbsolute() && !generatedHeaderFilePath.toString().startsWith(EPOCROOT_SUBSTITUTION)) { + if (!ViewBase.isAbsolutePath(generatedHeaderFilePath) && !generatedHeaderFilePath.toString().startsWith(EPOCROOT_SUBSTITUTION)) { generatedHeaderFilePath = new Path(EPOCROOT_SUBSTITUTION + generatedHeaderFilePath.toOSString()); } file = fromProjectToMakefilePath(view, generatedHeaderFilePath); - arg = "/H" + view.unexpandMacros(file.toOSString(), //$NON-NLS-1$ + arg = OUT_OPTION_CHAR + "H" + view.unexpandMacros(file.toOSString(), //$NON-NLS-1$ true); if (needNewLine) addNewLine(view, args); args.add(arg); needNewLine = true; } - + if (origArgv != null) { // remove existing header arg if present - removeArgMatching(origArgv, "(?i)/H.*"); //$NON-NLS-1$ + removeArgMatching(origArgv, "(?i)" + OPTION_CHARS + "H.*"); //$NON-NLS-1$ // remove any /F entries: we don't update parameter files - removeArgMatching(origArgv, "(?i)/F.*"); //$NON-NLS-1$ + removeArgMatching(origArgv, "(?i)" + OPTION_CHARS + "F.*"); //$NON-NLS-1$ - // keep remaining arguments, except for files + // keep remaining arguments, except for files for (Iterator iter = origArgv.iterator(); iter.hasNext();) { String origArg = iter.next(); - if (origArg.matches("(?i)/[a-bd-z].*")) { //$NON-NLS-1$ + if (origArg.matches("(?i)" + OPTION_CHARS + "[a-bd-z].*")) { //$NON-NLS-1$ args.add(origArg); iter.remove(); } @@ -339,7 +348,7 @@ explicitMaskPath ? 0 : maskDepth); if (imageFormat == null || !format.equals(imageFormat)) { imageFormat = format; - args.add("/" + format.toString()); //$NON-NLS-1$ + args.add(OUT_OPTION_CHAR + format.toString()); //$NON-NLS-1$ } // emit source file @@ -354,7 +363,7 @@ // emit explicit mask path if needed if (explicitMaskPath) { file = fromProjectToMakefilePath(view, maskPath); - args.add("/" + maskDepth); //$NON-NLS-1$ + args.add(OUT_OPTION_CHAR + "" + maskDepth); //$NON-NLS-1$ args.add(view.unexpandMacros(file.setDevice(null).toOSString(), false)); } } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/mmp/MMPView.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/mmp/MMPView.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/mmp/MMPView.java Wed Dec 02 15:02:05 2009 -0600 @@ -147,7 +147,7 @@ * @return */ static boolean isAbsoluteLikePath(IPath mmpPath) { - return (mmpPath.isAbsolute() + return (isAbsolutePath(mmpPath) || (mmpPath.segmentCount() > 0 && mmpPath.segment(0).equals("+"))); //$NON-NLS-1$ } @@ -1143,7 +1143,7 @@ IPath basePath = mmpPath.removeFileExtension(); baseName = basePath.lastSegment(); - if (basePath.isAbsolute()) { + if (isAbsolutePath(basePath)) { dirPath = basePath.removeLastSegments(1); } else { dirPath = defFileBase.append(basePath.removeLastSegments(1)); @@ -1176,7 +1176,8 @@ } else { // replace any "/~/" sequences if (dirPath.segmentCount() > 0) - dirPath = new Path(dirPath.addTrailingSeparator().toString().replace("/~/", "/"+implDirectory+"/")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + dirPath = new Path(dirPath.addTrailingSeparator().toPortableString() + .replace("/~/", "/"+implDirectory+"/")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } // version identifier overrides unicode @@ -1191,9 +1192,9 @@ IPath prjPath = null; IPath tempPath = dirPath.append(baseName + "." + ext); //$NON-NLS-1$ - if (!tempPath.isAbsolute()) { + if (!isAbsolutePath(tempPath)) { prjPath = tempPath; //convertMMPToProject(EMMPPathContext.DEFFILE, tempPath); - } else if (mmpPath == null || !mmpPath.isAbsolute()) { + } else if (mmpPath == null || !isAbsolutePath(mmpPath)) { /* IPath wsPath = epocHelper.convertFilesystemToWorkspace(tempPath); if (wsPath != null) @@ -1249,7 +1250,7 @@ if (realPath == null) return null; - if (!realPath.isAbsolute()) { + if (!isAbsolutePath(realPath)) { //realPath = ((IModel)mmpView.getModel()).getPath().removeLastSegments(1).append(realPath); realPath = convertProjectToModelPath(realPath); } @@ -1280,7 +1281,7 @@ // return string value, containing literal .\ if not generic name String mmpPath = pathString(dirPath.append(baseName + "." + ext)); //$NON-NLS-1$ - if (isFixedDirectory && !dirPath.isAbsolute() && dirPath.segmentCount() == 0) + if (isFixedDirectory && !isAbsolutePath(dirPath) && dirPath.segmentCount() == 0) mmpPath = "." + pathSeparator() + mmpPath; //$NON-NLS-1$ return mmpPath; } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/mmp/ResourceBlockListConverter.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/mmp/ResourceBlockListConverter.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/mmp/ResourceBlockListConverter.java Wed Dec 02 15:02:05 2009 -0600 @@ -109,7 +109,8 @@ resource.setTargetFile(((IASTMMPSingleArgumentStatement) stmt).getArgument().getValue()); } else if (EMMPStatement.TARGETPATH.matches(stmt)) { - resource.setTargetPath(new Path(((IASTMMPSingleArgumentStatement) stmt).getArgument().getValue())); + resource.setTargetPath(new Path( + HostOS.convertPathToUnix(((IASTMMPSingleArgumentStatement) stmt).getArgument().getValue()))); } else if (EMMPStatement.HEADER.matches(stmt)) { resource.setHeaderFlags(EGeneratedHeaderFlags.Header); diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/preprocessor/ASTPreprocessor.java --- a/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/preprocessor/ASTPreprocessor.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/preprocessor/ASTPreprocessor.java Wed Dec 02 15:02:05 2009 -0600 @@ -690,7 +690,7 @@ */ return null; } - return new Pair(isUser, fileName); + return new Pair(isUser, fileName); } diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.project.core/src/com/nokia/carbide/cpp/internal/project/core/updater/ProjectUpdater.java --- a/project/com.nokia.carbide.cpp.project.core/src/com/nokia/carbide/cpp/internal/project/core/updater/ProjectUpdater.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.project.core/src/com/nokia/carbide/cpp/internal/project/core/updater/ProjectUpdater.java Wed Dec 02 15:02:05 2009 -0600 @@ -285,7 +285,7 @@ private static final String DEFAULT_PRJ_PLATFORM_COMMENT = Messages.getString("ProjectUpdater.PlatformsNotAvailableWithAllSDKsComment"); //$NON-NLS-1$ private static final String CUR_DIR = "."; //$NON-NLS-1$ - private static final String EPOC32_INC = "\\epoc32\\include"; //$NON-NLS-1$ + private static final String EPOC32_INC = File.separator +"epoc32" + File.separator + "include"; //$NON-NLS-1$ //$NON-NLS-2$ private static final String[] IMPLICIT_LIB_PREFIXES = { "dfpaeabi", //$NON-NLS-1$ @@ -1665,15 +1665,15 @@ "\r\n" + //$NON-NLS-1$ "\r\n" + //$NON-NLS-1$ "ifeq (WINS,$(findstring WINS, $(PLATFORM)))\r\n" + //$NON-NLS-1$ - "ZDIR=$(EPOCROOT)epoc32\\release\\$(PLATFORM)\\$(CFG)\\Z\r\n" + //$NON-NLS-1$ + "ZDIR=$(EPOCROOT)epoc32/release/$(PLATFORM)/$(CFG)/Z\r\n" + //$NON-NLS-1$ "else\r\n" + //$NON-NLS-1$ - "ZDIR=$(EPOCROOT)epoc32\\data\\z\r\n" + //$NON-NLS-1$ + "ZDIR=$(EPOCROOT)epoc32/data/z\r\n" + //$NON-NLS-1$ "endif\r\n" + //$NON-NLS-1$ "\r\n" + //$NON-NLS-1$ "\r\n" + //$NON-NLS-1$ - "TARGETDIR=$(ZDIR)\\resource\\apps\r\n" + //$NON-NLS-1$ + "TARGETDIR=$(ZDIR)/resource/apps\r\n" + //$NON-NLS-1$ "\r\n" + //$NON-NLS-1$ - "ICONDIR=..\\gfx\r\n" + //$NON-NLS-1$ + "ICONDIR=../gfx\r\n" + //$NON-NLS-1$ "\r\n" + //$NON-NLS-1$ "do_nothing :\r\n" + //$NON-NLS-1$ "\t@rem do_nothing\r\n" + //$NON-NLS-1$ @@ -1696,8 +1696,8 @@ "#\r\n" + //$NON-NLS-1$ "# NOTE 2: Usually, source paths should not be included in the bitmap\r\n" + //$NON-NLS-1$ "# definitions. MifConv searches for the icons in all icon directories in a\r\n" + //$NON-NLS-1$ - "# predefined order, which is currently \\s60\\icons, \\s60\\bitmaps2.\r\n" + //$NON-NLS-1$ - "# The directory \\s60\\icons is included in the search only if the feature flag\r\n" + //$NON-NLS-1$ + "# predefined order, which is currently /s60/icons, /s60/bitmaps2.\r\n" + //$NON-NLS-1$ + "# The directory /s60/icons is included in the search only if the feature flag\r\n" + //$NON-NLS-1$ "# __SCALABLE_ICONS is defined.\r\n" + //$NON-NLS-1$ "# ----------------------------------------------------------------------------\r\n" + //$NON-NLS-1$ "# NOTE: if you have JUSTINTIME enabled for your S60 3rd FP1 or newer SDK\r\n"+ //$NON-NLS-1$ diff -r bf7dbec89c47 -r bfb3ab3f70f2 project/com.nokia.carbide.cpp.project.core/src/com/nokia/carbide/cpp/internal/project/core/updater/SymbianBuildParser.java --- a/project/com.nokia.carbide.cpp.project.core/src/com/nokia/carbide/cpp/internal/project/core/updater/SymbianBuildParser.java Wed Dec 02 14:40:51 2009 -0600 +++ b/project/com.nokia.carbide.cpp.project.core/src/com/nokia/carbide/cpp/internal/project/core/updater/SymbianBuildParser.java Wed Dec 02 15:02:05 2009 -0600 @@ -40,7 +40,7 @@ public class SymbianBuildParser { - private static final String RESOURCE_APPS = "resource\\apps"; //$NON-NLS-1$ + private static final String RESOURCE_APPS = "resource" + File.separator + "apps"; //$NON-NLS-1$ private static final String CDTBUILD_FILENAME = ".cdtbuild"; //$NON-NLS-1$ private static final String OPTION = "option"; //$NON-NLS-1$ private static final String TOOL = "tool"; //$NON-NLS-1$ @@ -180,7 +180,7 @@ public String convert(String value) { String pathString = TextUtils.unquote(value, '"'); if (pathString.startsWith(EPOCROOT_VAR)) { - pathString = "\\" + pathString.substring(EPOCROOT_VAR.length()); //$NON-NLS-1$ + pathString = File.separator + pathString.substring(EPOCROOT_VAR.length()); //$NON-NLS-1$ return pathString; } else if (!VARIABLE_PATTERN.matcher(pathString).matches()) // no other variables