commands/variant/variant.cpp
changeset 49 b33ec37addee
parent 43 96bfe2624d23
child 66 2a78c4ff2eab
equal deleted inserted replaced
48:a45c6889feae 49:b33ec37addee
    10 // Accenture - Initial contribution
    10 // Accenture - Initial contribution
    11 //
    11 //
    12 
    12 
    13 #include <hal.h>
    13 #include <hal.h>
    14 #include "variant.h"
    14 #include "variant.h"
       
    15 #include <fshell/common.mmh>
    15 #include <fshell/descriptorutils.h>
    16 #include <fshell/descriptorutils.h>
    16 
    17 
    17 //
    18 //
    18 // CCmdVariant
    19 // CCmdVariant
    19 //
    20 //
    69 	{ 0x20029a73, DESC("n8") }, // Likewise...
    70 	{ 0x20029a73, DESC("n8") }, // Likewise...
    70 	{ 0x102734e3, DESC("qemu") },
    71 	{ 0x102734e3, DESC("qemu") },
    71 	};
    72 	};
    72 const TInt KMachineIdVariantCount = sizeof(KMachineIdVariants) / sizeof(TVariant);
    73 const TInt KMachineIdVariantCount = sizeof(KMachineIdVariants) / sizeof(TVariant);
    73 
    74 
       
    75 // This is a list of things configured in or out at compile time based on the platform.mmh macros and similar
       
    76 const LtkUtils::SLitC KOtherSupportedVariants[] =
       
    77 	{
       
    78 #ifdef __WINS__
       
    79 	DESC("wins"),
       
    80 #else
       
    81 	DESC("target"),
       
    82 #endif
       
    83 #ifdef FSHELL_TRACECORE_SUPPORT
       
    84 	DESC("tracecore-support"),
       
    85 #endif
       
    86 	};
       
    87 const TInt KOtherSupportedVariantsCount = sizeof(KOtherSupportedVariants) / sizeof(LtkUtils::SLitC);
       
    88 
    74 void CCmdVariant::DoRunL()
    89 void CCmdVariant::DoRunL()
    75 	{
    90 	{
    76 	if (iList)
    91 	TInt localMachineUid = GetMachineUidL();
       
    92 
       
    93 	if (iMachineId.Count() == 0 && iVariant.Count() == 0)
    77 		{
    94 		{
    78 		Printf(_L("Supported variants: "));
    95 		Printf(_L("Variant names understood by this command: "));
    79 		for (TInt i = 0; i < KMachineIdVariantCount; i++)
    96 		for (TInt i = 0; i < KMachineIdVariantCount; i++)
    80 			{
    97 			{
    81 			Printf(_L("%S, "), &KMachineIdVariants[i].iName);
    98 			Printf(_L("%S, "), &KMachineIdVariants[i].iName);
    82 			}
    99 			}
    83 		// Finally add the ones which don't appear in KMachineIdVariants
   100 		// Finally add the ones which can appear in KOtherSupportedVariants
    84 		Write(_L("wins, target\r\n"));
   101 		Printf(_L("wins, target, tracecore-support\r\n"));
       
   102 
       
   103 		Printf(_L("Variant names supported by this device: "));
       
   104 		for (TInt i = 0; i < KMachineIdVariantCount; i++)
       
   105 			{
       
   106 			if (localMachineUid == KMachineIdVariants[i].iUid)
       
   107 				{
       
   108 				Printf(_L("%S, "), &KMachineIdVariants[i].iName);
       
   109 				}
       
   110 			}
       
   111 		for (TInt i = 0; i < KOtherSupportedVariantsCount; i++)
       
   112 			{
       
   113 			if (i > 0) Printf(_L(", "));
       
   114 			Printf(KOtherSupportedVariants[i]());
       
   115 			}
       
   116 		Printf(_L("\r\n"));
    85 		Complete(KErrNone);
   117 		Complete(KErrNone);
    86 		return;
   118 		return;
    87 		}
   119 		}
    88 
   120 
    89 	if (iMachineId.Count() == 0 && iVariant.Count() == 0)
       
    90 		{
       
    91 		LeaveIfErr(KErrArgument, _L("You must specify at least one <variantname> argument or --uid option"));
       
    92 		}
       
    93 
       
    94 	TInt localMachineUid = GetMachineUidL();
       
    95 	TBool match = EFalse;
   121 	TBool match = EFalse;
    96 	if (iMachineId.Count())
   122 	if (iMachineId.Count())
    97 		{
   123 		{
    98 		for (TInt i = 0; i < iMachineId.Count(); i++)
   124 		for (TInt i = 0; i < iMachineId.Count(); i++)
    99 			{
   125 			{
   114 				if (iVariant[i]->CompareF(KMachineIdVariants[j].iName) == 0 && localMachineUid == KMachineIdVariants[j].iUid)
   140 				if (iVariant[i]->CompareF(KMachineIdVariants[j].iName) == 0 && localMachineUid == KMachineIdVariants[j].iUid)
   115 					{
   141 					{
   116 					match = ETrue;
   142 					match = ETrue;
   117 					}
   143 					}
   118 				}
   144 				}
   119 #ifdef __WINS__
   145 			
   120 			if (iVariant[i]->CompareF(_L("wins")) == 0) match = ETrue;
   146 			for (TInt j = 0; match == EFalse && j < KOtherSupportedVariantsCount; j++)
   121 #else
   147 				{
   122 			if (iVariant[i]->CompareF(_L("target")) == 0) match = ETrue;
   148 				if (iVariant[i]->CompareF(KOtherSupportedVariants[j]) == 0)
   123 #endif
   149 					{
       
   150 					match = ETrue;
       
   151 					}
       
   152 				}
   124 			}
   153 			}
   125 		}
   154 		}
   126 
   155 
   127 	if (iVerbose)
   156 	if (iVerbose)
   128 		{
   157 		{