コード例 #1
1
ファイル: NativeLibrary.java プロジェクト: starkingpku/jna
  /**
   * Similar to {@link System#mapLibraryName}, except that it maps to standard shared library
   * formats rather than specifically JNI formats.
   *
   * @param libName base (undecorated) name of library
   */
  static String mapSharedLibraryName(String libName) {
    if (Platform.isMac()) {
      if (libName.startsWith("lib")
          && (libName.endsWith(".dylib") || libName.endsWith(".jnilib"))) {
        return libName;
      }
      String name = System.mapLibraryName(libName);
      // On MacOSX, System.mapLibraryName() returns the .jnilib extension
      // (the suffix for JNI libraries); ordinarily shared libraries have
      // a .dylib suffix
      if (name.endsWith(".jnilib")) {
        return name.substring(0, name.lastIndexOf(".jnilib")) + ".dylib";
      }
      return name;
    } else if (Platform.isLinux()) {
      if (isVersionedName(libName) || libName.endsWith(".so")) {
        // A specific version was requested - use as is for search
        return libName;
      }
    } else if (Platform.isAIX()) { // can be libx.a, libx.a(shr.o), libx.so
      if (libName.startsWith("lib")) {
        return libName;
      }
    } else if (Platform.isWindows()) {
      if (libName.endsWith(".drv") || libName.endsWith(".dll")) {
        return libName;
      }
    }

    return System.mapLibraryName(libName);
  }
コード例 #2
0
  @Override
  public String toString() {
    StringBuffer strb = new StringBuffer();
    strb.append("Test " + getName());
    strb.append("\n Description of the platform :" + plateforme.getName());
    strb.append("\n Os Name :" + plateforme.getOsName());
    strb.append("\n---------------------------------------");
    if (isCompileTime) {
      strb.append("\nCompile Time : " + compileTime.getMeasure() + " " + compileTime.getUnit());
    }
    if (isExecutionTime) {
      strb.append(
          "\nExecution Time : " + executionTime.getMeasure() + " " + executionTime.getUnit());
    }
    if (isPerformance) {
      strb.append("\nPerformance : " + performance.getMeasure() + " " + performance.getUnit());
    }
    if (isSuccess) {
      strb.append("\nSuccess State : " + success.getState() + " %");
    }
    if (metrics.size() > 0) {
      strb.append("\nYour metrics : ");
      for (String metric_name : this.metrics.keySet()) {
        strb.append("\n" + metric_name + " : " + this.metrics.get(metric_name));
      }
    }

    return strb.toString();
  }
コード例 #3
0
 public int runDirectorToInstall(
     String message, File installFolder, String sourceRepo, String iuToInstall) {
   String[] command =
       new String[] { //
         "-application",
         "org.eclipse.equinox.p2.director", //
         "-repository",
         sourceRepo,
         "-installIU",
         iuToInstall, //
         "-destination",
         installFolder.getAbsolutePath(), //
         "-bundlepool",
         installFolder.getAbsolutePath(), //
         "-roaming",
         "-profile",
         "PlatformProfile",
         "-profileProperties",
         "org.eclipse.update.install.features=true", //
         "-p2.os",
         Platform.getOS(),
         "-p2.ws",
         Platform.getWS(),
         "-p2.arch",
         Platform.getOSArch()
       };
   return runEclipse(message, command);
 }
コード例 #4
0
 /**
  * Reads and returns the VM arguments specified in the running platform's .ini file, or am empty
  * string if none.
  *
  * @return VM arguments specified in the running platform's .ini file
  */
 public static String getIniVMArgs() {
   File installDirectory = new File(Platform.getInstallLocation().getURL().getFile());
   if (Platform.getOS().equals(Platform.OS_MACOSX))
     installDirectory = new File(installDirectory, "Eclipse.app/Contents/MacOS"); // $NON-NLS-1$
   File eclipseIniFile = new File(installDirectory, "eclipse.ini"); // $NON-NLS-1$
   BufferedReader in = null;
   StringBuffer result = new StringBuffer();
   if (eclipseIniFile.exists()) {
     try {
       in = new BufferedReader(new FileReader(eclipseIniFile));
       String str;
       boolean vmargs = false;
       while ((str = in.readLine()) != null) {
         if (vmargs) {
           if (result.length() > 0) result.append(" "); // $NON-NLS-1$
           result.append(str);
         }
         // start concat'ng if we have vmargs
         if (vmargs == false && str.equals("-vmargs")) // $NON-NLS-1$
         vmargs = true;
       }
     } catch (IOException e) {
       MDECore.log(e);
     } finally {
       if (in != null)
         try {
           in.close();
         } catch (IOException e) {
           MDECore.log(e);
         }
     }
   }
   return result.toString();
 }
コード例 #5
0
  public void setCallingConvention(Convention.Style style) {
    if (style == null) return;

    if (!Platform.isWindows() || Platform.is64Bits()) return;

    switch (style) {
      case FastCall:
        this.direct = false;
        setDcCallingConvention(
            Platform.isWindows()
                ? DC_CALL_C_X86_WIN32_FAST_MS
                : DC_CALL_C_DEFAULT); // TODO allow GCC-compiled C++ libs on windows
        break;
      case Pascal:
      case StdCall:
        this.direct = false;
        setDcCallingConvention(DC_CALL_C_X86_WIN32_STD);
        break;
      case ThisCall:
        this.direct = false;
        setDcCallingConvention(
            Platform.isWindows() ? DC_CALL_C_X86_WIN32_THIS_MS : DC_CALL_C_DEFAULT);
    }
    if (BridJ.veryVerbose)
      BridJ.info("Setting CC " + style + " (-> " + dcCallingConvention + ") for " + methodName);
  }
コード例 #6
0
 @Override
 public int compareTo(Object o) {
   Platform t = (Platform) o;
   if (getPlatformId() < t.getPlatformId()) return -1;
   if (getPlatformId() > t.getPlatformId()) return 1;
   return 0;
 }
コード例 #7
0
ファイル: NativeLibrary.java プロジェクト: starkingpku/jna
  /**
   * Returns an instance of NativeLibrary for the specified name. The library is loaded if not
   * already loaded. If already loaded, the existing instance is returned.
   *
   * <p>More than one name may map to the same NativeLibrary instance; only a single instance will
   * be provided for any given unique file path.
   *
   * @param libraryName The library name to load. This can be short form (e.g. "c"), an explicit
   *     version (e.g. "libc.so.6" or "QuickTime.framework/Versions/Current/QuickTime"), or the full
   *     (absolute) path to the library (e.g. "/lib/libc.so.6").
   * @param options native library options for the given library (see {@link Library}).
   */
  public static final NativeLibrary getInstance(String libraryName, Map options) {
    options = new HashMap(options);
    if (options.get(Library.OPTION_CALLING_CONVENTION) == null) {
      options.put(Library.OPTION_CALLING_CONVENTION, new Integer(Function.C_CONVENTION));
    }

    // Use current process to load libraries we know are already
    // loaded by the VM to ensure we get the correct version
    if ((Platform.isLinux() || Platform.isAIX()) && Platform.C_LIBRARY_NAME.equals(libraryName)) {
      libraryName = null;
    }
    synchronized (libraries) {
      WeakReference ref = (WeakReference) libraries.get(libraryName + options);
      NativeLibrary library = ref != null ? (NativeLibrary) ref.get() : null;

      if (library == null) {
        if (libraryName == null) {
          library =
              new NativeLibrary("<process>", null, Native.open(null, openFlags(options)), options);
        } else {
          library = loadLibrary(libraryName, options);
        }
        ref = new WeakReference(library);
        libraries.put(library.getName() + options, ref);
        File file = library.getFile();
        if (file != null) {
          libraries.put(file.getAbsolutePath() + options, ref);
          libraries.put(file.getName() + options, ref);
        }
      }
      return library;
    }
  }
コード例 #8
0
ファイル: Scene8.java プロジェクト: timendez/Starduck
  /** Constructor for objects of class Scene8. */
  public Scene8(StarDuck starduck) {
    // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
    super(600, 400, 1);
    setBackground("background.png");
    this.starduck = starduck;
    starduck.setAdvance(false);

    Platform platform = new Platform();
    addObject(platform, 300, 400);

    Platform botPlatform = new Platform();
    botPlatform.getImage().scale(500, 25);
    addObject(botPlatform, 250, 250);

    Platform topPlatform = new Platform();
    topPlatform.getImage().scale(500, 25);
    addObject(topPlatform, 350, 100);

    addObject(starduck, 25, 338);

    // Start Zombies
    addZombie();
    addObject(new Zombie(this, false), 600, 338);
    addObject(new Zombie(this, false), 300, 200);
    addObject(new Zombie(this, false), 400, 338);
    addObject(new Zombie(this, false), 4, 200);
    addObject(new Zombie(this, false), 350, 338);
    addObject(new Zombie(this, false), 125, 200);

    healthHUD(starduck.getHealth());
    addObject(healthText, 75, 20);
  }
コード例 #9
0
ファイル: Retrofit.java プロジェクト: kimiscircle/retrofit
 private void eagerlyValidateMethods(Class<?> service) {
   Platform platform = Platform.get();
   for (Method method : service.getDeclaredMethods()) {
     if (!platform.isDefaultMethod(method)) {
       loadMethodHandler(method);
     }
   }
 }
コード例 #10
0
ファイル: PlatformTest.java プロジェクト: santiycr/selenium
 private void assertAllAre(Platform platform, String... osNames) {
   for (String osName : osNames) {
     Platform seen = Platform.extractFromSysProperty(osName);
     assertTrue(
         String.format("Expected %s, but got %s from %s", platform, seen, osName),
         seen.is(platform));
   }
 }
コード例 #11
0
ファイル: Level.java プロジェクト: stango12/Mario
  public void render(SpriteBatch batch) {
    batch.begin();
    for (Platform p : platforms) p.render(batch);
    for (QBlock q : qBlocks) q.render(batch);
    for (Goomba g : goombas) g.render(batch);
    for (Pipe p : pipes) p.render(batch);

    mario.render(batch);
    batch.end();
  }
コード例 #12
0
ファイル: Browser.java プロジェクト: srihariinnamuri/trunk
  public boolean isMobileDevice() {
    Capabilities browserCapabilities = ((RemoteWebDriver) se.driver()).getCapabilities();
    String browserName = browserCapabilities.getBrowserName();
    Platform platform = browserCapabilities.getPlatform();

    if (browserName.equals("android") && platform.equals(Platform.ANDROID)) return true;
    else if ((browserName.equals("iOS") || browserName.equals("iPhone"))
        && platform.equals(Platform.MAC)) return true;
    else return false;
  }
コード例 #13
0
 static String machineNameFromID(String s) {
   if (Platform.isNTRemote(s)) {
     return Machine.getMachineFromMachineID(s);
   }
   if (Platform.isCommandLineRemote(s)) {
     return Machine.getMachineName(s);
   } else {
     return Machine.getMachineFromMachineID(s);
   }
 }
コード例 #14
0
ファイル: TimeT.java プロジェクト: Jsalim/nativelibs4java
    @Override
    public void beforeLayout(
        StructDescription desc, List<StructFieldDescription> aggregatedFields) {
      StructFieldDescription secondsField = aggregatedFields.get(0);
      if (Platform.isWindows() || !Platform.is64Bits()) {
        secondsField.byteLength = 4;
      } else {
        secondsField.byteLength = 8;
      }

      secondsField.alignment = secondsField.byteLength;
    }
コード例 #15
0
ファイル: StartupManager.java プロジェクト: RickKohrs/mcidasv
  /**
   * Applies the command line arguments to the startup preferences. This function is mostly useful
   * because it allows us to supply an arbitrary {@code args} array, link in {@link
   * edu.wisc.ssec.mcidasv.McIDASV#main(String[])}.
   *
   * @param ignoreUnknown If {@code true} ignore any parameters that do not apply to the startup
   *     manager. If {@code false} the non-applicable parameters should signify an error.
   * @param fromStartupManager Whether or not this call originated from the startup manager (rather
   *     than preferences).
   * @param args Incoming command line arguments. Cannot be {@code null}.
   * @throws NullPointerException if {@code args} is null.
   * @see #getArgs(boolean, boolean, String[], Properties)
   */
  public static void applyArgs(
      final boolean ignoreUnknown, final boolean fromStartupManager, final String[] args) {
    if (args == null) {
      throw new NullPointerException("Arguments list cannot be null");
    }
    StartupManager sm = StartupManager.getInstance();
    Platform platform = sm.getPlatform();

    Properties props = getArgs(ignoreUnknown, fromStartupManager, args, getDefaultProperties());
    platform.setUserDirectory(props.getProperty("userpath"));
    platform.setAvailableMemory(props.getProperty(Constants.PROP_SYSMEM));
  }
コード例 #16
0
ファイル: TestRunner.java プロジェクト: tiennv90/SVN
  /**
   * Excutes the selected test run.
   *
   * @param testRunName name of the test run to execute
   */
  private void executeTestRun(String testRunName) {

    log.log(Level.INFO, "Executing Test Run '" + testRunName + "'");

    // get the selected test run
    TestRun testRun = config.getTestRun(testRunName);

    // check if the application under test is available
    BaseTestCase.testAUTHTTPConnection(testRun.getBaseURL());

    // check if all configured servers for this test run are responding
    BaseTestCase.testSeleniumHTTPConnection(config, testRun.getTestRunServerIterator());

    // set the Application-under-Test parameters in the JUnit Base Class
    BaseTestCase.setBaseURL(testRun.getBaseURL());

    String msg = "Application under Test:\n" + "BaseURL=" + testRun.getBaseURL();

    System.out.println(msg);
    log.log(Level.INFO, msg);

    // go through all servers defined in the test run and execute the tests
    Iterator<TestRun.TestRunServer> selServerIt = testRun.getTestRunServerIterator();
    while (selServerIt.hasNext()) {

      // get the next server entry from the test run
      TestRun.TestRunServer selServerConfig = selServerIt.next();
      // set the speed for this server/browser combination
      BaseTestCase.setSpeed(selServerConfig.getSpeed());

      // get the test server settings
      Map<String, String> testServer = config.getTestServers().get(selServerConfig.getName());

      // set the host,port and browser used for the next tests
      BaseTestCase.isExternallySetup = true;
      BaseTestCase.setSeleniumServerHost(testServer.get("host"));
      BaseTestCase.setSeleniumServerPort(testServer.get("port"));

      msg = "Platform is: " + System.getProperty("os.name");
      System.out.println(msg);
      log.log(Level.INFO, msg);

      Map<String, Platform> platforms = config.getPlatforms();
      for (Platform platformToCheck : platforms.values()) {
        if (platformToCheck.isValid()) {
          executeForPlatform(selServerConfig, testServer, platformToCheck);
        }
      }
    }
  }
コード例 #17
0
 protected static String getLineDelimiterPreference(IFile file) {
   IScopeContext[] scopeContext;
   if (file != null && file.getProject() != null) {
     // project preference
     scopeContext = new IScopeContext[] {new ProjectScope(file.getProject())};
     String lineDelimiter =
         Platform.getPreferencesService()
             .getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
     if (lineDelimiter != null) return lineDelimiter;
   }
   // workspace preference
   scopeContext = new IScopeContext[] {InstanceScope.INSTANCE};
   return Platform.getPreferencesService()
       .getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
 }
コード例 #18
0
  static {
    {
      OpenCLProbeLibrary probe = new OpenCLProbeLibrary();
      try {
        if (!probe.isValid()) {
          String alt;
          if (Platform.is64Bits() && BridJ.getNativeLibraryFile(alt = "atiocl64") != null
              || BridJ.getNativeLibraryFile(alt = "atiocl32") != null
              || BridJ.getNativeLibraryFile(alt = "atiocl") != null) {
            log(
                Level.INFO,
                "Hacking around ATI's weird driver bugs (using atiocl library instead of OpenCL)",
                null);
            BridJ.setNativeLibraryActualName("OpenCL", alt);
          }
        }
      } finally {
        probe = null;
        BridJ.unregister(OpenCLProbeLibrary.class);
      }
    }

    if (debug) {
      String debugArgs = System.getenv(JAVACL_DEBUG_COMPILER_FLAGS_PROP);
      if (debugArgs != null) DEBUG_COMPILER_FLAGS = Arrays.asList(debugArgs.split(" "));
      else if (Platform.isMacOSX()) DEBUG_COMPILER_FLAGS = Arrays.asList("-g");
      else DEBUG_COMPILER_FLAGS = Arrays.asList("-O0", "-g");

      int pid = ProcessUtils.getCurrentProcessId();
      log(
          Level.INFO,
          "Debug mode enabled with compiler flags \""
              + StringUtils.implode(DEBUG_COMPILER_FLAGS, " ")
              + "\" (can be overridden with env. var. JAVACL_DEBUG_COMPILER_FLAGS_PROP)");
      log(
          Level.INFO,
          "You can debug your kernels with GDB using one of the following commands :\n"
              + "\tsudo gdb --tui --pid="
              + pid
              + "\n"
              + "\tsudo ddd --debugger \"gdb --pid="
              + pid
              + "\"\n"
              + "More info here :\n"
              + "\thttp://code.google.com/p/javacl/wiki/DebuggingKernels");
    }
    CL = new OpenCLLibrary();
  }
 public void testIsAssociatedWith() {
   IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
   final SingleNodeScope scope = new SingleNodeScope();
   IContentType textContentType =
       contentTypeManager.getContentType(Platform.PI_RUNTIME + '.' + "text");
   IContentTypeSettings localSettings = null;
   try {
     localSettings = textContentType.getSettings(scope);
   } catch (CoreException e) {
     fail("0.1", e);
   }
   // haven't added association yet
   assertTrue("1.0", !textContentType.isAssociatedWith("hello.foo", scope));
   assertTrue("1.1", !textContentType.isAssociatedWith("hello.foo"));
   try {
     // associate at the scope level
     localSettings.addFileSpec("foo", IContentType.FILE_EXTENSION_SPEC);
   } catch (CoreException e) {
     fail("1.5", e);
   }
   try {
     localSettings = textContentType.getSettings(scope);
   } catch (CoreException e) {
     fail("2.1", e);
   }
   // scope-specific settings should contain the filespec we just added
   String[] fileSpecs = localSettings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
   assertEquals("2.2", 1, fileSpecs.length);
   assertEquals("2.3", "foo", fileSpecs[0]);
   // now it is associated at the scope level...
   assertTrue("2.5", textContentType.isAssociatedWith("hello.foo", scope));
   // ...but not at the global level
   assertTrue("2.6", !textContentType.isAssociatedWith("hello.foo"));
 }
コード例 #20
0
 private boolean isDerivedEncodingStoredSeparately(IProject project) {
   // be careful looking up for our node so not to create any nodes as side effect
   Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE);
   try {
     // TODO once bug 90500 is fixed, should be as simple as this:
     //			String path = project.getName() + IPath.SEPARATOR + ResourcesPlugin.PI_RESOURCES;
     //			return node.nodeExists(path) ?
     // node.node(path).getBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, false) : false;
     // for now, take the long way
     if (!node.nodeExists(project.getName()))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(project.getName());
     if (!node.nodeExists(ResourcesPlugin.PI_RESOURCES))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(ResourcesPlugin.PI_RESOURCES);
     return node.getBoolean(
         ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS,
         ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS);
   } catch (BackingStoreException e) {
     // nodeExists failed
     String message = Messages.resources_readingEncoding;
     Policy.log(
         new ResourceStatus(
             IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e));
     return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
   }
 }
コード例 #21
0
ファイル: Health.java プロジェクト: SiteView/ECC8.13
 public static Array createHealthGroup() throws SiteViewParameterException {
   String s = Platform.getRoot() + File.separator + "groups" + File.separator + "__Health__.mg";
   File file = new File(s);
   Array array = null;
   if (!file.exists()) {
     array = new Array();
     HashMap hashmap = new HashMap();
     hashmap.put("_encoding", I18N.getDefaultEncoding());
     hashmap.put("_health", "true");
     hashmap.put("_dependsCondition", "good");
     hashmap.put("_fileEncoding", I18N.getDefaultEncoding());
     hashmap.put("_name", "Health");
     hashmap.put("_nextID", "1");
     array.add(hashmap);
     try {
       FrameFile.writeToFile(s, array);
     } catch (IOException ioexception1) {
       String as[] = {"__Health__.mg", ioexception1.getMessage()};
       throw new SiteViewParameterException(SiteViewErrorCodes.ERR_OP_SS_HEALTH_CANNOT_WRITE, as);
     }
   } else {
     try {
       array = FrameFile.readFromFile(s);
     } catch (IOException ioexception) {
       LogManager.log(
           "error", "Couldn't read the Health group. Got Error: " + ioexception.getMessage());
     }
   }
   return array;
 }
コード例 #22
0
 public static void estimateKeyDerivationTime() {
   // This is run in the background after startup. If we haven't recorded it before, do a key
   // derivation to see
   // how long it takes. This helps us produce better progress feedback, as on Windows we don't
   // currently have a
   // native Scrypt impl and the Java version is ~3 times slower, plus it depends a lot on CPU
   // speed.
   checkGuiThread();
   estimatedKeyDerivationTime = Main.instance.prefs.getExpectedKeyDerivationTime();
   if (estimatedKeyDerivationTime == null) {
     new Thread(
             () -> {
               log.info("Doing background test key derivation");
               KeyCrypterScrypt scrypt = new KeyCrypterScrypt(SCRYPT_PARAMETERS);
               long start = System.currentTimeMillis();
               scrypt.deriveKey("test password");
               long msec = System.currentTimeMillis() - start;
               log.info("Background test key derivation took {}msec", msec);
               Platform.runLater(
                   () -> {
                     estimatedKeyDerivationTime = Duration.ofMillis(msec);
                     Main.instance.prefs.setExpectedKeyDerivationTime(estimatedKeyDerivationTime);
                   });
             })
         .start();
   }
 }
コード例 #23
0
 /**
  * Returns whether monitoring of a given performance event is enabled.
  *
  * <p>For frequent performance events, the result of this method call should be cached by the
  * caller to minimize overhead when performance monitoring is turned off. It is not possible for
  * enablement to change during the life of this invocation of the platform.
  *
  * @param eventName The name of the event to determine enablement for
  * @return <code>true</code>If the performance event with the given name is enabled, and <code>
  *     false</code> otherwise.
  */
 public static boolean isEnabled(String eventName) {
   if (!ENABLED) return false;
   String option = Platform.getDebugOption(eventName);
   return option != null
       && !option.equalsIgnoreCase("false")
       && !option.equalsIgnoreCase("-1"); // $NON-NLS-1$ //$NON-NLS-2$
 }
コード例 #24
0
  public void update(UpdateMemo memo) throws Exception {

    ArtifactData target = put(memo.best.urls.iterator().next());

    memo.current.version = new Version(memo.best.version);
    target.sync();
    memo.current.sha = target.sha;
    // memo.current.dependencies = target.dependencies;
    // memo.current.dependencies.add((new File(repoDir,
    // Hex.toHexString(target.sha))).getCanonicalPath());
    // memo.current.runbundles = target.runbundles;
    // memo.current.description = target.description;
    memo.current.time = target.time;

    if (memo.current instanceof ServiceData) {
      Service service = getService((ServiceData) memo.current);
      service.remove();
      createService((ServiceData) memo.current);
      IO.delete(new File(IO.getFile(serviceDir, memo.current.name), "data"));
      storeData(new File(IO.getFile(serviceDir, memo.current.name), "data"), memo.current);
    } else {
      platform.deleteCommand(memo.current);
      createCommand(memo.current, false);
      IO.delete(IO.getFile(commandDir, memo.current.name));
      storeData(IO.getFile(commandDir, memo.current.name), memo.current);
    }
  }
コード例 #25
0
 public void testMapSharedLibraryName() {
   final Object[][] MAPPINGS = {
     {Platform.MAC, "lib", ".dylib"},
     {Platform.LINUX, "lib", ".so"},
     {Platform.WINDOWS, "", ".dll"},
     {Platform.SOLARIS, "lib", ".so"},
     {Platform.FREEBSD, "lib", ".so"},
     {Platform.OPENBSD, "lib", ".so"},
     {Platform.WINDOWSCE, "", ".dll"},
     {Platform.AIX, "lib", ".a"},
     {Platform.ANDROID, "lib", ".so"},
     {Platform.GNU, "lib", ".so"},
     {Platform.KFREEBSD, "lib", ".so"},
     {Platform.NETBSD, "lib", ".so"},
   };
   for (int i = 0; i < MAPPINGS.length; i++) {
     int osType = ((Integer) MAPPINGS[i][0]).intValue();
     if (osType == Platform.getOSType()) {
       assertEquals(
           "Wrong shared library name mapping",
           MAPPINGS[i][1] + "testlib" + MAPPINGS[i][2],
           NativeLibrary.mapSharedLibraryName("testlib"));
     }
   }
 }
コード例 #26
0
ファイル: IosSdkCommands.java プロジェクト: nkhuyu/bazel
  public static List<String> commonLinkAndCompileFlagsForClang(
      ObjcProvider provider, ObjcConfiguration configuration) {
    ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
    if (Platform.forArch(configuration.getIosCpu()) == Platform.SIMULATOR) {
      builder.add("-mios-simulator-version-min=" + configuration.getMinimumOs());
    } else {
      builder.add("-miphoneos-version-min=" + configuration.getMinimumOs());
    }

    if (configuration.generateDebugSymbols()) {
      builder.add("-g");
    }

    return builder
        .add("-arch", configuration.getIosCpu())
        .add("-isysroot", sdkDir(configuration))
        // TODO(bazel-team): Pass framework search paths to Xcodegen.
        .add("-F", sdkDir(configuration) + "/Developer/Library/Frameworks")
        // As of sdk8.1, XCTest is in a base Framework dir
        .add("-F", frameworkDir(configuration))
        // Add custom (non-SDK) framework search paths. For each framework foo/bar.framework,
        // include "foo" as a search path.
        .addAll(
            Interspersing.beforeEach(
                "-F",
                PathFragment.safePathStrings(uniqueParentDirectories(provider.get(FRAMEWORK_DIR)))))
        .build();
  }
コード例 #27
0
ファイル: TerminalPlugin.java プロジェクト: smoczek/elt
 public static boolean isOptionEnabled(String option) {
   String enabled = Platform.getDebugOption(option);
   if (enabled == null) {
     return false;
   }
   return Boolean.parseBoolean(enabled);
 }
コード例 #28
0
  /**
   * Tests a JDT source feature bundle container contains the appropriate bundles
   *
   * @throws Exception
   */
  public void testSourceFeatureBundleContainer() throws Exception {
    // extract the feature
    IPath location = extractModifiedFeatures();

    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService()
            .newFeatureLocation(location.toOSString(), "org.eclipse.jdt.source", null);
    container.resolve(definition, null);
    TargetBundle[] bundles = container.getBundles();

    List expected = new ArrayList();
    expected.add("org.eclipse.jdt.source");
    expected.add("org.eclipse.jdt.launching.source");
    // There are two versions of junit available, each with source
    expected.add("org.junit.source");
    expected.add("org.junit.source");
    if (Platform.getOS().equals(Platform.OS_MACOSX)) {
      expected.add("org.eclipse.jdt.launching.macosx.source");
    }

    assertEquals("Wrong number of bundles", expected.size(), bundles.length);
    for (int i = 0; i < bundles.length; i++) {
      if (bundles[i].getBundleInfo().getSymbolicName().equals("org.eclipse.jdt.doc.isv")) {
        assertFalse("Should not be a source bundle", bundles[i].isSourceBundle());
      } else {
        assertTrue(expected.remove(bundles[i].getBundleInfo().getSymbolicName()));
        assertTrue("Should be a source bundle", bundles[i].isSourceBundle());
      }
    }
    assertTrue("Wrong bundles in JDT feature", expected.isEmpty());
  }
コード例 #29
0
ファイル: Portal.java プロジェクト: SiteView/eclipse3.7
 public static void readExtraItems(String s, ArrayList array) throws IOException {
   File file = new File(Platform.getRoot() + File.separator + "templates.view");
   if (!file.exists()) {
     return;
   }
   String as[] = file.list();
   if (as == null) {
     return;
   }
   for (int i = 0; i < as.length; i++) {
     File file1 = new File(file, as[i]);
     if (!file1.isDirectory()) {
       continue;
     }
     File file2 = new File(file1, s);
     if (!file2.exists()) {
       continue;
     }
     ArrayList array1 = FrameFile.readFromFile(file2.getAbsolutePath());
     for (int j = 0; j < array1.size(); j++) {
       HashMap hashmap = (HashMap) array1.get(j);
       String s1 = TextUtils.getValue(hashmap, "_id");
       s1 = file1.getName() + "-" + s1;
       hashmap.put("_id", s1);
       hashmap.put("_package", as[i]);
       array.add(hashmap);
     }
   }
 }
  public void testContentTypeLookup() {
    IContentTypeManager global = Platform.getContentTypeManager();
    final SingleNodeScope scope = new SingleNodeScope();
    IContentTypeMatcher local = global.getMatcher(new LocalSelectionPolicy(), scope);
    IContentType textContentType = global.getContentType(Platform.PI_RUNTIME + '.' + "text");
    try {
      // added "<test case name>.global" to the text content type as a global file spec
      textContentType.addFileSpec(getName() + ".global", IContentType.FILE_NAME_SPEC);
    } catch (CoreException e) {
      fail("0.1", e);
    }
    try {
      // added "<test case name>.local" to the text content type as a local (scope-specific) file
      // spec
      textContentType
          .getSettings(scope)
          .addFileSpec(getName() + ".local", IContentType.FILE_NAME_SPEC);
    } catch (CoreException e) {
      fail("0.2", e);
    }
    // make ensure associations are properly recognized when doing content type lookup
    assertEquals("1.0", textContentType, global.findContentTypeFor(getName() + ".global"));
    assertEquals("1.1", null, local.findContentTypeFor(getName() + ".global"));
    assertEquals("2.0", textContentType, local.findContentTypeFor(getName() + ".local"));
    assertEquals("2.1", null, global.findContentTypeFor(getName() + ".local"));

    try {
      textContentType.removeFileSpec(getName() + ".global", IContentType.FILE_NAME_SPEC);
    } catch (CoreException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }