Template setup fixes for #10290
authorEd Swartz <ed.swartz@nokia.com>
Wed, 16 Dec 2009 15:32:46 -0600
changeset 694 d42018b25fba
parent 693 2d475d296af4
child 695 56780cf045d5
Template setup fixes for #10290
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/processes/CheckS60CustKitSupport.java
project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/project/ui/processes/ProjectCreatedTasks.java
templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-PlatsecApp/group/bld.inf
templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-PlatsecApp/sis/baseName.pkg
templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-TouchUIApplication/group/bld.inf
templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-TouchUIApplication/sis/baseName.pkg
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/processes/CheckS60CustKitSupport.java	Wed Dec 16 15:27:05 2009 -0600
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/processes/CheckS60CustKitSupport.java	Wed Dec 16 15:32:46 2009 -0600
@@ -19,6 +19,7 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.QualifiedName;
 
 import com.nokia.carbide.cpp.internal.api.sdk.SBSv2Utils;
 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
@@ -33,8 +34,12 @@
  * Process used to fill in S60 specific include symbols for INF/MMP files 
  */
 public class CheckS60CustKitSupport extends AbstractProjectProcess {
-	
+
+	// copied from ProjectCreatedTasks (YUCK)
 	private static final String SELECTED_BUILD_CONFIGS_VALUE_KEY = "selectedBuildConfigs"; //$NON-NLS-1$
+	// copied from ProjectCreatedTasks (YUCK)
+	private static final String SBSV2_BUILDER_ATTRIBUTE = "useSBSv2Builder"; //$NON-NLS-1$
+
 	private static final String S60_50_BUILD_MACROS = "S60_50_CustomBuildIncludes";
 	
 	private static final String S60_INC_MACROS = "#include <data_caging_paths.hrh>\n#include <domain/osextensions/platform_paths.hrh>\nMW_LAYER_SYSTEMINCLUDE";
@@ -46,6 +51,8 @@
 	private static final String S60_SF_FOLDER =  "sf";
 	private static final String S60_INC_MACROS_SF = "#include <platform_paths.hrh>\n#include <data_caging_paths.hrh>\nAPP_LAYER_SYSTEMINCLUDE";
 
+	private static final String USE_PRJ_EXTENSIONS_VALUE = "usePrjExtensionsValue";
+
 	private static final String BUILD_HELP_PREFIX = "buildHelpPrefix";
 	private static final String BUILD_HELP_SIS_PREFIX = "buildHelpSISPrefix";
 	private static final String DISABLE_HELP_STRING = "//";
@@ -83,6 +90,9 @@
 		template.getTemplateValues().put(BUILD_HELP_PREFIX, enableHelpString);
 		template.getTemplateValues().put(BUILD_HELP_SIS_PREFIX, enableHelpSISString);
 		template.getTemplateValues().put(HELP_SUPPORT_MACRO, helpSupportString);
+		
+		String usePrjExtensionsValue = usePrjExtensionsRequired(template) ? "1" : "0";
+		template.getTemplateValues().put(USE_PRJ_EXTENSIONS_VALUE, usePrjExtensionsValue);
 	}
 
 	@Override
@@ -116,7 +126,7 @@
 			// TODO: the infrastructure for the techview/bldhelp.mk is a total mess 
 			// currently, and it also appears that help is obsolete in recent devkits,
 			// so just drop this
-			if (!SBSv2Utils.enableSBSv1Support())
+			if (!SBSv2Utils.enableSBSv1Support() && isSBSv2Project(template))
 				return null;
 			
 			helpCompilerNames = new String[] { HELP_COMPILER_PERL };
@@ -182,4 +192,57 @@
 		return S60_50_Macros_String;
 	}
 	
+	/**
+	 * Tell whether we should use PRJ_EXTENSIONS in bld.inf.  Raptor doesn't
+	 * officially support [n|gnu]makefile statements in PRJ_MMPFILES anymore,
+	 * and actively ignores them on Linux.
+	 * @param template
+	 * @return
+	 */
+	private boolean usePrjExtensionsRequired(ITemplate template) {
+		
+		// look for the directory housing the extension templates;
+		// if this doesn't exist, then PRJ_EXTENSIONS won't work
+		boolean makefileTemplatesAlwaysAvailable = true;
+		
+		for (ISymbianBuildContext symbianBuildContext : getBuildContexts(template)) {
+			ISymbianSDK sdk = symbianBuildContext.getSDK();
+			if (sdk != null) {
+				File makefileTemplateDir = new File(sdk.getEPOCROOT(), "epoc32/tools/makefile_templates"); //$NON-NLS-1$
+				if (!makefileTemplateDir.exists()) {
+					// old location
+					makefileTemplateDir = new File(sdk.getEPOCROOT(), "s60/tools/makefile_templates"); //$NON-NLS-1$
+					if (!makefileTemplateDir.exists()) {
+						makefileTemplatesAlwaysAvailable = false;
+						break;
+					}
+				}				
+			}
+		}
+		
+		if (!makefileTemplatesAlwaysAvailable)
+			return false;
+		
+		// Ok, now, even if we DO find the templates, they may be suboptimal.
+		// PRJ_EXTENSIONS mifconv builds causes really messy output 
+		// (tons of spurious warnings), and we don't want to use it unless it's
+		// absolutely necessary.
+		//
+		// If it seems at all likely that gnumakefiles will still work, just use them. 
+		if (!isSBSv2Project(template))
+			return false;
+		
+		return true;
+	}
+
+	/**
+	 * Tell whether the project was created for SBSv2.
+	 * @param template
+	 * @return
+	 */
+	private boolean isSBSv2Project(ITemplate template) {
+		Object value = template.getTemplateValues().get(SBSV2_BUILDER_ATTRIBUTE);
+		return value != null && value == Boolean.TRUE;
+	}
+
 }
--- a/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/project/ui/processes/ProjectCreatedTasks.java	Wed Dec 16 15:27:05 2009 -0600
+++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/project/ui/processes/ProjectCreatedTasks.java	Wed Dec 16 15:32:46 2009 -0600
@@ -85,7 +85,7 @@
 			}
 			
 			project.setSessionProperty(CarbideBuilderPlugin.SBSV2_PROJECT, Boolean.valueOf(useSBSv2Builder));
-			
+		
 			ProjectCorePlugin.postProjectCreatedActions(project, bldInfPath, buildConfigs, new ArrayList<String>(), targetMMPFileName, pkgMappings, monitor);
 		}
 	}
--- a/templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-PlatsecApp/group/bld.inf	Wed Dec 16 15:27:05 2009 -0600
+++ b/templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-PlatsecApp/group/bld.inf	Wed Dec 16 15:32:46 2009 -0600
@@ -8,15 +8,44 @@
 ============================================================================
 */
 
+// When building with Raptor, "gnumakefile" builds are no longer recommended.
+// But, the extensions referenced here are not available in SDKs, only devkits.
+#define USE_PRJ_EXTENSIONS $(usePrjExtensionsValue)
 
 PRJ_PLATFORMS
 WINSCW ARMV5 GCCE
 
 PRJ_MMPFILES
 
-gnumakefile icons_scalable_dc.mk
+#if !USE_PRJ_EXTENSIONS
+
+	gnumakefile icons_scalable_dc.mk
 
-$(buildHelpPrefix)gnumakefile ../$(helpDir)/build_help.mk
+	// help compiler is not always available; see similar comment in *.pkg file
+	$(buildHelpPrefix)gnumakefile ../$(helpDir)/build_help.mk
+
+#endif
 
 $(baseName).mmp
 
+
+#if USE_PRJ_EXTENSIONS
+
+	PRJ_EXTENSIONS
+	
+	START EXTENSION s60/mifconv
+	OPTION TARGETFILE $(baseName$lower)_$(uid3).mif
+	OPTION HEADERFILE $(baseName$lower)_$(uid3).mbg
+	OPTION SOURCEDIR ../gfx
+	OPTION SOURCES -c32 qgn_menu_$(baseName)
+	END
+	
+	// help compiler is not always available; see similar comment in *.pkg file
+	$(buildHelpPrefix)START EXTENSION techview/bldhelp
+	$(buildHelpPrefix)OPTION HELPPROJECTFILE $(baseName).cshlp
+	$(buildHelpPrefix)OPTION HELPTOOLTARGETNAME $(baseName$lower)_$(uid3).hlp
+	$(buildHelpPrefix)END
+
+#endif
+
+
--- a/templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-PlatsecApp/sis/baseName.pkg	Wed Dec 16 15:27:05 2009 -0600
+++ b/templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-PlatsecApp/sis/baseName.pkg	Wed Dec 16 15:32:46 2009 -0600
@@ -27,8 +27,8 @@
 "$(EPOCROOT)epoc32\release\$(PLATFORM)\$(TARGET)\$(baseName)_$(uid3).exe"		-"!:\sys\bin\$(baseName)_$(uid3).exe"
 "$(EPOCROOT)epoc32\data\z\resource\apps\$(baseName$lower)_$(uid3).rsc"		-"!:\resource\apps\$(baseName)_$(uid3).rsc"
 "$(EPOCROOT)epoc32\data\z\private\10003a3f\apps\$(baseName$lower)_$(uid3)_reg.rsc"	-"!:\private\10003a3f\import\apps\$(baseName)_$(uid3)_reg.rsc"
-"$(EPOCROOT)epoc32\data\z\resource\apps\$(baseName)_$(uid3).mif" -"!:\resource\apps\$(baseName)_$(uid3).mif"
-$(buildHelpSISPrefix)"..\$(helpDir)\$(baseName)_$(uid3).hlp"							 -"!:\resource\help\$(baseName)_$(uid3).hlp"
+"$(EPOCROOT)epoc32\data\z\resource\apps\$(baseName$lower)_$(uid3).mif" -"!:\resource\apps\$(baseName)_$(uid3).mif"
+$(buildHelpSISPrefix)"..\$(helpDir)\$(baseName$lower)_$(uid3).hlp"							 -"!:\resource\help\$(baseName)_$(uid3).hlp"
 
 ; Add any installation notes if applicable
 ;"$(baseName).txt"		-"!:\private\$(uid3-WITHOUT_0X)\$(baseName).txt"
--- a/templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-TouchUIApplication/group/bld.inf	Wed Dec 16 15:27:05 2009 -0600
+++ b/templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-TouchUIApplication/group/bld.inf	Wed Dec 16 15:32:46 2009 -0600
@@ -8,15 +8,43 @@
 ============================================================================
 */
 
+// When building with Raptor, "gnumakefile" builds are no longer recommended.
+// But, the extensions referenced here are not available in SDKs, only devkits.
+#define USE_PRJ_EXTENSIONS $(usePrjExtensionsValue)
+
 
 PRJ_PLATFORMS
 WINSCW ARMV5 GCCE
 
 PRJ_MMPFILES
 
-gnumakefile icons_scalable_dc.mk
+#if !USE_PRJ_EXTENSIONS
+
+	gnumakefile icons_scalable_dc.mk
 
-$(buildHelpPrefix)gnumakefile ../$(helpDir)/build_help.mk
+	// help compiler is not always available; see similar comment in *.pkg file
+	$(buildHelpPrefix)gnumakefile ../$(helpDir)/build_help.mk
+
+#endif
 
 $(baseName).mmp
 
+
+#if USE_PRJ_EXTENSIONS
+
+	PRJ_EXTENSIONS
+	
+	START EXTENSION s60/mifconv
+	OPTION TARGETFILE $(baseName$lower)_$(uid3).mif
+	OPTION HEADERFILE $(baseName$lower)_$(uid3).mbg
+	OPTION SOURCEDIR ../gfx
+	OPTION SOURCES -c32 qgn_menu_$(baseName)
+	END
+	
+	// help compiler is not always available; see similar comment in *.pkg file
+	$(buildHelpPrefix)START EXTENSION techview/bldhelp
+	$(buildHelpPrefix)OPTION HELPPROJECTFILE $(baseName).cshlp
+	$(buildHelpPrefix)OPTION HELPTOOLTARGETNAME $(baseName$lower)_$(uid3).hlp
+	$(buildHelpPrefix)END
+
+#endif
--- a/templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-TouchUIApplication/sis/baseName.pkg	Wed Dec 16 15:27:05 2009 -0600
+++ b/templates/com.nokia.carbide.cpp.templates/templates/projecttemplates/S60-TouchUIApplication/sis/baseName.pkg	Wed Dec 16 15:32:46 2009 -0600
@@ -27,8 +27,8 @@
 "$(EPOCROOT)epoc32\release\$(PLATFORM)\$(TARGET)\$(baseName)_$(uid3).exe"		-"!:\sys\bin\$(baseName)_$(uid3).exe"
 "$(EPOCROOT)epoc32\data\z\resource\apps\$(baseName$lower)_$(uid3).rsc"		-"!:\resource\apps\$(baseName)_$(uid3).rsc"
 "$(EPOCROOT)epoc32\data\z\private\10003a3f\apps\$(baseName$lower)_$(uid3)_reg.rsc"	-"!:\private\10003a3f\import\apps\$(baseName)_$(uid3)_reg.rsc"
-"$(EPOCROOT)epoc32\data\z\resource\apps\$(baseName)_$(uid3).mif" -"!:\resource\apps\$(baseName)_$(uid3).mif"
-$(buildHelpSISPrefix)"..\$(helpDir)\$(baseName)_$(uid3).hlp"							 -"!:\resource\help\$(baseName)_$(uid3).hlp"
+"$(EPOCROOT)epoc32\data\z\resource\apps\$(baseName$lower)_$(uid3).mif" -"!:\resource\apps\$(baseName)_$(uid3).mif"
+$(buildHelpSISPrefix)"..\$(helpDir)\$(baseName$lower)_$(uid3).hlp"							 -"!:\resource\help\$(baseName)_$(uid3).hlp"
 
 ; Add any installation notes if applicable
 ;"$(baseName).txt"		-"!:\private\$(uid3-WITHOUT_0X)\$(baseName).txt"