org.gradle.internal.os.OperatingSystem Java Examples
The following examples show how to use
org.gradle.internal.os.OperatingSystem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandLineTool.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public WorkResult execute(T spec) { ExecAction compiler = execActionFactory.newExecAction(); compiler.executable(executable); if (workDir != null) { compiler.workingDir(workDir); } List<String> args = specToArgs.transform(specTransformer.transform(spec)); compiler.args(args); if (!path.isEmpty()) { String pathVar = OperatingSystem.current().getPathVar(); String compilerPath = Joiner.on(File.pathSeparator).join(path); compilerPath = compilerPath + File.pathSeparator + System.getenv(pathVar); compiler.environment(pathVar, compilerPath); } compiler.environment(environment); try { compiler.execute(); } catch (ExecException e) { throw new GradleException(String.format("%s failed; see the error output for details.", action), e); } return new SimpleWorkResult(true); }
Example #2
Source File: GccToolSearchPath.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
@Override protected File findExecutable(OperatingSystem operatingSystem, String name) { List<String> candidates; if (operatingSystem.isWindows()) { // Under Cygwin, g++/gcc is a Cygwin symlink to either g++-3 or g++-4. We can't run g++ directly candidates = Arrays.asList(name + "-4", name + "-3", name); } else { candidates = Arrays.asList(name); } for (String candidate : candidates) { File executable = super.findExecutable(operatingSystem, candidate); if (executable != null) { return executable; } } return null; }
Example #3
Source File: OperatingSystemNotationParser.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
protected OperatingSystemInternal parseType(String notation) { if (WINDOWS_ALIASES.contains(notation.toLowerCase())) { return new DefaultOperatingSystem(notation, OperatingSystem.WINDOWS); } if (OSX_ALIASES.contains(notation.toLowerCase())) { return new DefaultOperatingSystem(notation, OperatingSystem.MAC_OS); } if (LINUX_ALIASES.contains(notation.toLowerCase())) { return new DefaultOperatingSystem(notation, OperatingSystem.LINUX); } if (SOLARIS_ALIASES.contains(notation.toLowerCase())) { return new DefaultOperatingSystem(notation, OperatingSystem.SOLARIS); } if (FREEBSD_ALIASES.contains(notation.toLowerCase())) { return new DefaultOperatingSystem(notation, OperatingSystem.FREE_BSD); } return null; }
Example #4
Source File: CyclicBarrierHttpServer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
/** * Sends a response back on the connection. */ public void release() { // TODO(radim): quick socket operation on Windows is not noticed by client // and it re-opens the connection immediately. Need to find a better way here. if (OperatingSystem.current().isWindows()) { try { Thread.sleep(2000L); } catch (InterruptedException e) { e.printStackTrace(); } } synchronized (lock) { released = true; lock.notifyAll(); } }
Example #5
Source File: Jvm.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
/** * @param os the OS * @param suppliedJavaBase initial location to discover from. May be jdk or jre. */ Jvm(OperatingSystem os, File suppliedJavaBase) { this.os = os; if (suppliedJavaBase == null) { //discover based on what's in the sys. property try { this.javaBase = new File(System.getProperty("java.home")).getCanonicalFile(); } catch (IOException e) { throw new UncheckedException(e); } this.javaHome = findJavaHome(javaBase); this.javaVersion = JavaVersion.current(); this.userSupplied = false; } else { //precisely use what the user wants and validate strictly further on this.javaBase = suppliedJavaBase; this.javaHome = suppliedJavaBase; this.userSupplied = true; this.javaVersion = null; } }
Example #6
Source File: MicrosoftVisualCppPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
@Mutate public static void addGccToolChain(NativeToolChainRegistryInternal toolChainRegistry, ServiceRegistry serviceRegistry) { final FileResolver fileResolver = serviceRegistry.get(FileResolver.class); final ExecActionFactory execActionFactory = serviceRegistry.get(ExecActionFactory.class); final Instantiator instantiator = serviceRegistry.get(Instantiator.class); final OperatingSystem operatingSystem = serviceRegistry.get(OperatingSystem.class); final VisualStudioLocator visualStudioLocator = serviceRegistry.get(VisualStudioLocator.class); final WindowsSdkLocator windowsSdkLocator = serviceRegistry.get(WindowsSdkLocator.class); toolChainRegistry.registerFactory(VisualCpp.class, new NamedDomainObjectFactory<VisualCpp>() { public VisualCpp create(String name) { return instantiator.newInstance(VisualCppToolChain.class, name, operatingSystem, fileResolver, execActionFactory, visualStudioLocator, windowsSdkLocator, instantiator); } }); toolChainRegistry.registerDefaultToolChain(VisualCppToolChain.DEFAULT_NAME, VisualCpp.class); }
Example #7
Source File: CommandLineTool.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void execute(CommandLineToolInvocation invocation) { ExecAction compiler = execActionFactory.newExecAction(); compiler.executable(executable); if (invocation.getWorkDirectory() != null) { GFileUtils.mkdirs(invocation.getWorkDirectory()); compiler.workingDir(invocation.getWorkDirectory()); } compiler.args(invocation.getArgs()); if (!invocation.getPath().isEmpty()) { String pathVar = OperatingSystem.current().getPathVar(); String compilerPath = Joiner.on(File.pathSeparator).join(invocation.getPath()); compilerPath = compilerPath + File.pathSeparator + System.getenv(pathVar); compiler.environment(pathVar, compilerPath); } compiler.environment(invocation.getEnvironment()); try { compiler.execute(); } catch (ExecException e) { throw new GradleException(String.format("%s failed; see the error output for details.", action), e); } }
Example #8
Source File: NativeCompiler.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public WorkResult execute(T spec) { boolean didWork = false; boolean windowsPathLimitation = OperatingSystem.current().isWindows(); String objectFileExtension = OperatingSystem.current().isWindows() ? ".obj" : ".o"; for (File sourceFile : spec.getSourceFiles()) { String objectFileName = FilenameUtils.removeExtension(sourceFile.getName()) + objectFileExtension; WorkResult result = commandLineTool.inWorkDirectory(spec.getObjectFileDir()) .withArguments(new SingleSourceCompileArgTransformer<T>(sourceFile, objectFileName, new ShortCircuitArgsTransformer(argsTransfomer), windowsPathLimitation, false)) .execute(spec); didWork = didWork || result.getDidWork(); } return new SimpleWorkResult(didWork); }
Example #9
Source File: NativeServices.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
protected ProcessEnvironment createProcessEnvironment(OperatingSystem operatingSystem) { if (useNativePlatform) { try { io.rubygrapefruit.platform.Process process = io.rubygrapefruit.platform.Native.get(Process.class); return new NativePlatformBackedProcessEnvironment(process); } catch (NativeIntegrationUnavailableException ex) { LOGGER.debug("Native-platform process integration is not available. Continuing with fallback."); } } try { if (operatingSystem.isUnix()) { return new LibCBackedProcessEnvironment(get(LibC.class)); } else { return new UnsupportedEnvironment(); } } catch (LinkageError e) { // Thrown when jna cannot initialize the native stuff LOGGER.debug("Unable to load native library. Continuing with fallback. Failure: {}", format(e)); return new UnsupportedEnvironment(); } }
Example #10
Source File: MicrosoftVisualCppPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
@Mutate public static void addGccToolChain(NativeToolChainRegistryInternal toolChainRegistry, ServiceRegistry serviceRegistry) { final FileResolver fileResolver = serviceRegistry.get(FileResolver.class); final ExecActionFactory execActionFactory = serviceRegistry.get(ExecActionFactory.class); final Instantiator instantiator = serviceRegistry.get(Instantiator.class); final OperatingSystem operatingSystem = serviceRegistry.get(OperatingSystem.class); final VisualStudioLocator visualStudioLocator = serviceRegistry.get(VisualStudioLocator.class); final WindowsSdkLocator windowsSdkLocator = serviceRegistry.get(WindowsSdkLocator.class); toolChainRegistry.registerFactory(VisualCpp.class, new NamedDomainObjectFactory<VisualCpp>() { public VisualCpp create(String name) { return instantiator.newInstance(VisualCppToolChain.class, name, operatingSystem, fileResolver, execActionFactory, visualStudioLocator, windowsSdkLocator, instantiator); } }); toolChainRegistry.registerDefaultToolChain(VisualCppToolChain.DEFAULT_NAME, VisualCpp.class); }
Example #11
Source File: AbstractGccCompatibleToolChain.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public AbstractGccCompatibleToolChain(String name, OperatingSystem operatingSystem, FileResolver fileResolver, ExecActionFactory execActionFactory, ToolSearchPath toolSearchPath) { super(name, operatingSystem, fileResolver); this.execActionFactory = execActionFactory; this.toolSearchPath = toolSearchPath; addPlatformConfiguration(new ToolChainDefaultArchitecture()); addPlatformConfiguration(new Intel32Architecture()); addPlatformConfiguration(new Intel64Architecture()); configInsertLocation = 0; }
Example #12
Source File: ForkingGradleExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private ExecHandleBuilder createExecHandleBuilder() { TestFile gradleHomeDir = getDistribution().getGradleHomeDir(); if (!gradleHomeDir.isDirectory()) { fail(gradleHomeDir + " is not a directory.\n" + "If you are running tests from IDE make sure that gradle tasks that prepare the test image were executed. Last time it was 'intTestImage' task."); } ExecHandleBuilder builder = new ExecHandleBuilder() { @Override public File getWorkingDir() { // Override this, so that the working directory is not canonicalised. Some int tests require that // the working directory is not canonicalised return ForkingGradleExecuter.this.getWorkingDir(); } }; // Clear the user's environment builder.environment("GRADLE_HOME", ""); builder.environment("JAVA_HOME", ""); builder.environment("GRADLE_OPTS", ""); builder.environment("JAVA_OPTS", ""); builder.environment(getMergedEnvironmentVars()); builder.workingDir(getWorkingDir()); builder.setStandardInput(getStdin()); builder.args(getAllArgs()); ExecHandlerConfigurer configurer = OperatingSystem.current().isWindows() ? new WindowsConfigurer() : new UnixConfigurer(); configurer.configure(builder); getLogger().info(String.format("Execute in %s with: %s %s", builder.getWorkingDir(), builder.getExecutable(), builder.getArgs())); return builder; }
Example #13
Source File: ReflectiveEnvironment.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void unsetenv(String name) { Map<String, String> map = getEnv(); map.remove(name); if (OperatingSystem.current().isWindows()) { Map<String, String> env2 = getWindowsEnv(); env2.remove(name); } }
Example #14
Source File: ClangCompilerPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Mutate public static void addToolChain(NativeToolChainRegistryInternal toolChainRegistry, ServiceRegistry serviceRegistry) { final FileResolver fileResolver = serviceRegistry.get(FileResolver.class); final ExecActionFactory execActionFactory = serviceRegistry.get(ExecActionFactory.class); final Instantiator instantiator = serviceRegistry.get(Instantiator.class); final CompilerMetaDataProviderFactory metaDataProviderFactory = serviceRegistry.get(CompilerMetaDataProviderFactory.class); toolChainRegistry.registerFactory(Clang.class, new NamedDomainObjectFactory<Clang>() { public Clang create(String name) { return instantiator.newInstance(ClangToolChain.class, name, OperatingSystem.current(), fileResolver, execActionFactory, metaDataProviderFactory, instantiator); } }); toolChainRegistry.registerDefaultToolChain(ClangToolChain.DEFAULT_NAME, Clang.class); }
Example #15
Source File: WindowsResourceCompiler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult execute(WindowsResourceCompileSpec spec) { boolean windowsPathLimitation = OperatingSystem.current().isWindows(); MutableCommandLineToolInvocation invocation = baseInvocation.copy(); spec = specTransformer.transform(spec); for (File sourceFile : spec.getSourceFiles()) { RcCompilerArgsTransformer argsTransformer = new RcCompilerArgsTransformer(sourceFile, windowsPathLimitation); invocation.setArgs(argsTransformer.transform(spec)); invocation.setWorkDirectory(spec.getObjectFileDir()); commandLineTool.execute(invocation); } return new SimpleWorkResult(!spec.getSourceFiles().isEmpty()); }
Example #16
Source File: VisualCppToolChain.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public VisualCppToolChain(String name, OperatingSystem operatingSystem, FileResolver fileResolver, ExecActionFactory execActionFactory, VisualStudioLocator visualStudioLocator, WindowsSdkLocator windowsSdkLocator, Instantiator instantiator) { super(name, operatingSystem, fileResolver); this.name = name; this.operatingSystem = operatingSystem; this.fileResolver = fileResolver; this.execActionFactory = execActionFactory; this.visualStudioLocator = visualStudioLocator; this.windowsSdkLocator = windowsSdkLocator; this.instantiator = instantiator; }
Example #17
Source File: ReflectiveEnvironment.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void unsetenv(String name) { Map<String, String> map = getEnv(); map.remove(name); if (OperatingSystem.current().isWindows()) { Map<String, String> env2 = getWindowsEnv(); env2.remove(name); } }
Example #18
Source File: DefaultGradleDistribution.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean worksWith(OperatingSystem os) { // 1.0-milestone-5 was broken where jna was not available //noinspection SimplifiableIfStatement if (isVersion("1.0-milestone-5")) { return os.isWindows() || os.isMacOsX() || os.isLinux(); } else { return true; } }
Example #19
Source File: NativeServices.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
protected ProcessEnvironment createProcessEnvironment(OperatingSystem operatingSystem) { if (useNativePlatform) { try { io.rubygrapefruit.platform.Process process = io.rubygrapefruit.platform.Native.get(Process.class); return new NativePlatformBackedProcessEnvironment(process); } catch (NativeIntegrationUnavailableException ex) { LOGGER.debug("Native-platform process integration is not available. Continuing with fallback."); } } return new UnsupportedEnvironment(); }
Example #20
Source File: DefaultGradleDistribution.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean isDaemonSupported() { // Milestone 7 was broken on the IBM jvm if (Jvm.current().isIbmJvm() && isVersion("1.0-milestone-7")) { return false; } if (OperatingSystem.current().isWindows()) { // On windows, daemon is ok for anything > 1.0-milestone-3 return isSameOrNewer("1.0-milestone-4"); } else { // Daemon is ok for anything >= 0.9 return isSameOrNewer("0.9"); } }
Example #21
Source File: JnaBootPathConfigurer.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * Attempts to find the jna library and copies it to a specified folder. * The copy operation happens only once. Sets the jna-related system property. * * This hackery is to prevent JNA from creating a shared lib in the tmp dir, as it does not clean things up. * * @param storageDir - where to store the jna library */ public void configure(File storageDir) { String nativePrefix = OperatingSystem.current().getNativePrefix(); File tmpDir = new File(storageDir, String.format("jna/%s", nativePrefix)); tmpDir.mkdirs(); String jnaLibName = OperatingSystem.current().isMacOsX() ? "libjnidispatch.jnilib" : System.mapLibraryName("jnidispatch"); File libFile = new File(tmpDir, jnaLibName); if (!libFile.exists()) { String resourceName = "/com/sun/jna/" + nativePrefix + "/" + jnaLibName; try { InputStream lib = getClass().getResourceAsStream(resourceName); if (lib == null) { return; } try { FileOutputStream outputStream = new FileOutputStream(libFile); try { IOUtils.copy(lib, outputStream); } finally { outputStream.close(); } } finally { lib.close(); } } catch (IOException e) { throw new NativeIntegrationException(String.format("Could not create JNA native library '%s'.", libFile), e); } } System.setProperty("jna.boot.library.path", tmpDir.getAbsolutePath()); }
Example #22
Source File: Jvm.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
static Jvm create(File javaBase) { String vendor = System.getProperty("java.vm.vendor"); if (vendor.toLowerCase().startsWith("apple inc.")) { return new AppleJvm(OperatingSystem.current(), javaBase); } if (vendor.toLowerCase().startsWith("ibm corporation")) { return new IbmJvm(OperatingSystem.current(), javaBase); } return new Jvm(OperatingSystem.current(), javaBase); }
Example #23
Source File: GccLinker.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void maybeSetInstallName(SharedLibraryLinkerSpec spec, List<String> args) { String installName = spec.getInstallName(); if (installName == null || OperatingSystem.current().isWindows()) { return; } if (OperatingSystem.current().isMacOsX()) { args.add("-Wl,-install_name," + installName); } else { args.add("-Wl,-soname," + installName); } }
Example #24
Source File: GccToolChain.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public GccToolChain(String name, OperatingSystem operatingSystem, FileResolver fileResolver, ExecActionFactory execActionFactory) { super(name, operatingSystem, fileResolver, execActionFactory, new GccToolSearchPath(operatingSystem)); this.versionDeterminer = new GccVersionDeterminer(execActionFactory); registerTool(ToolType.CPP_COMPILER, "g++"); registerTool(ToolType.C_COMPILER, "gcc"); registerTool(ToolType.OBJECTIVECPP_COMPILER, "g++"); registerTool(ToolType.OBJECTIVEC_COMPILER, "gcc"); registerTool(ToolType.ASSEMBLER, "as"); registerTool(ToolType.LINKER, "g++"); registerTool(ToolType.STATIC_LIB_ARCHIVER, "ar"); }
Example #25
Source File: DefaultGradleDistribution.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean isDaemonSupported() { // Milestone 7 was broken on the IBM jvm if (Jvm.current().isIbmJvm() && isVersion("1.0-milestone-7")) { return false; } if (OperatingSystem.current().isWindows()) { // On windows, daemon is ok for anything > 1.0-milestone-3 return isSameOrNewer("1.0-milestone-4"); } else { // Daemon is ok for anything >= 0.9 return isSameOrNewer("0.9"); } }
Example #26
Source File: AbstractGccCompatibleToolChain.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public List<String> getAssemblerArgs() { if (OperatingSystem.current().isMacOsX()) { return asList("-arch", "x86_64"); } else { return asList("--64"); } }
Example #27
Source File: AbstractGccCompatibleToolChain.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
AbstractGccCompatibleToolChain(String name, OperatingSystem operatingSystem, FileResolver fileResolver, ExecActionFactory execActionFactory, ToolSearchPath tools, CompilerMetaDataProvider metaDataProvider, Instantiator instantiator) { super(name, operatingSystem, fileResolver); this.execActionFactory = execActionFactory; this.toolSearchPath = tools; this.metaDataProvider = metaDataProvider; this.instantiator = instantiator; target(new ToolChainDefaultArchitecture()); target(new Intel32Architecture()); target(new Intel64Architecture()); configInsertLocation = 0; }
Example #28
Source File: DefaultGradleDistribution.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean worksWith(OperatingSystem os) { // 1.0-milestone-5 was broken where jna was not available //noinspection SimplifiableIfStatement if (isVersion("1.0-milestone-5")) { return os.isWindows() || os.isMacOsX() || os.isLinux(); } else { return true; } }
Example #29
Source File: WindowsResourceCompiler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult execute(WindowsResourceCompileSpec spec) { boolean didWork = false; boolean windowsPathLimitation = OperatingSystem.current().isWindows(); CommandLineTool<WindowsResourceCompileSpec> commandLineAssembler = commandLineTool.inWorkDirectory(spec.getObjectFileDir()); for (File sourceFile : spec.getSourceFiles()) { WorkResult result = commandLineAssembler.withArguments(new RcCompilerArgsTransformer(sourceFile, windowsPathLimitation)).execute(spec); didWork |= result.getDidWork(); } return new SimpleWorkResult(didWork); }
Example #30
Source File: WindowsResourceCompiler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult execute(WindowsResourceCompileSpec spec) { boolean windowsPathLimitation = OperatingSystem.current().isWindows(); MutableCommandLineToolInvocation invocation = baseInvocation.copy(); spec = specTransformer.transform(spec); for (File sourceFile : spec.getSourceFiles()) { RcCompilerArgsTransformer argsTransformer = new RcCompilerArgsTransformer(sourceFile, windowsPathLimitation); invocation.setArgs(argsTransformer.transform(spec)); invocation.setWorkDirectory(spec.getObjectFileDir()); commandLineTool.execute(invocation); } return new SimpleWorkResult(!spec.getSourceFiles().isEmpty()); }