PreferenceConstants.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. ///////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) 2018 Intel Corporation. //
  3. // //
  4. // All rights reserved. This program and the accompanying materials //
  5. // are made available under the terms of the Eclipse Public License v1.0 //
  6. // which accompanies this distribution, and is available at //
  7. // http://www.eclipse.org/legal/epl-v10.html //
  8. // //
  9. // Contributors: //
  10. // Intel Corporation - initial implementation and documentation //
  11. ///////////////////////////////////////////////////////////////////////////
  12. package com.intel.sgx.preferences;
  13. import java.io.File;
  14. import org.eclipse.jface.preference.IPreferenceStore;
  15. import com.intel.sgx.Activator;
  16. /**
  17. * Constant definitions for plug-in preferences
  18. */
  19. public class PreferenceConstants {
  20. public static final String SDK_PATH = "SDKPathPreference";
  21. public static ISDKDescriptor getSDKDescriptor() {
  22. IPreferenceStore store = Activator.getDefault().getPreferenceStore();
  23. File sdkDir = new File(store.getString(PreferenceConstants.SDK_PATH));
  24. if (System.getProperty("os.arch").contains("64")) {
  25. return new SGXSDK64Descriptor(sdkDir);
  26. } else {
  27. return new SGXSDK32Descriptor(sdkDir);
  28. }
  29. }
  30. static public class SGXSDK32Descriptor implements ISDKDescriptor {
  31. private final File sdkDir;
  32. private final File toolDir;
  33. private final File signerPath;
  34. private final File edger8rPath;
  35. public SGXSDK32Descriptor(File location){
  36. this.sdkDir = location;
  37. this.toolDir = new File(location, "bin/x86");
  38. this.signerPath = new File(toolDir, "sgx_sign");
  39. this.edger8rPath = new File(toolDir, "sgx_edger8r");
  40. }
  41. @Override
  42. public File getSdkDir() {
  43. return sdkDir;
  44. }
  45. @Override
  46. public File getToolsDir() {
  47. return toolDir;
  48. }
  49. @Override
  50. public File getSignerPath() {
  51. return signerPath;
  52. }
  53. @Override
  54. public File getEdger8rPath() {
  55. return edger8rPath;
  56. }
  57. }
  58. static public class SGXSDK64Descriptor implements ISDKDescriptor {
  59. private final File sdkDir;
  60. private final File toolDir;
  61. private final File signerPath;
  62. private final File edger8rPath;
  63. public SGXSDK64Descriptor(File sdkDir){
  64. this.sdkDir = sdkDir;
  65. this.toolDir = new File(sdkDir, "bin/x64");
  66. this.signerPath = new File(toolDir, "sgx_sign");
  67. this.edger8rPath = new File(toolDir, "sgx_edger8r");
  68. }
  69. @Override
  70. public File getSdkDir() {
  71. return sdkDir;
  72. }
  73. @Override
  74. public File getToolsDir() {
  75. return toolDir;
  76. }
  77. @Override
  78. public File getSignerPath() {
  79. return signerPath;
  80. }
  81. @Override
  82. public File getEdger8rPath() {
  83. return edger8rPath;
  84. }
  85. }
  86. }