Example #1
0
 private function getTargetDirectory(PackageInterface $package)
 {
     if (!is_dir($this->vendorDirectory)) {
         if (file_exists($this->vendorDirectory)) {
             throw new RuntimeException($this->vendorDirectory . ' exists and is not a directory.');
         }
         if (!@mkdir($this->vendorDirectory, 0777, true)) {
             throw new RuntimeException($this->vendorDirectory . ' does not exist and could not be created.');
         }
     }
     $targetDirectory = $this->vendorDirectory . DIRECTORY_SEPARATOR . $package->getName();
     FileSystem::createDirectory($targetDirectory);
     return $targetDirectory;
 }
Example #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $ide = $input->getArgument('ide');
     $config = $this->getConfig();
     if (!array_key_exists($ide, $this->generators)) {
         throw new InvalidArgumentException(sprintf('The "%s" generator is not supported.', $ide));
     }
     $output->writeln('Generating project files for ' . $this->generators[$ide]['name']);
     $variableParser = new Parser();
     $variableParser->push('config', $config);
     $variableParser->set('ide.type', $ide);
     $outputDirectory = $variableParser->parse('projects/$(ide.type)/');
     FileSystem::createDirectory($outputDirectory, 0777);
     $generatorFqcn = $this->generators[$ide]['fqcn'];
     $generator = new $generatorFqcn($config);
     $generator->setVariableParser($variableParser);
     $generator->generate($outputDirectory);
 }
Example #3
0
 private function extractContent($downloadPath, $path)
 {
     $extractDirectory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('zip-extract');
     FileSystem::createDirectory($extractDirectory, 0777);
     FileSystem::emptyDirectory($path);
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         $this->extractContentWindows($downloadPath, $extractDirectory);
     } else {
         $this->extractContentUnix($downloadPath, $extractDirectory);
     }
     // When there was only one directory in the zip, we extract the content out of it.
     $files = FileSystem::getDirectoryContent($extractDirectory);
     if (count($files) === 1 && is_dir(key($files))) {
         $files = FileSystem::getDirectoryContent(key($files));
     }
     foreach ($files as $file) {
         $file = (string) $file;
         FileSystem::rename($file, $path . '/' . basename($file));
     }
     FileSystem::removeDirectory($extractDirectory);
 }
Example #4
0
 private function buildLinkStaticLibraryCommand(Project $project, Configuration $configuration)
 {
     $outputPath = sprintf('%s\\%s.%s', getcwd(), $this->variableParser->parse($configuration->getOutputPath()), $configuration->getParsedExtension());
     $outputDir = dirname($outputPath);
     FileSystem::createDirectory($outputDir);
     $cmd = ['lib'];
     $cmd[] = '/NOLOGO';
     $cmd[] = '"/OUT:' . $outputPath . '"';
     if (!$configuration->getDebug()) {
         $cmd[] = '/LTCG';
     }
     return $cmd;
 }
 protected function writePropertyGroup(DOMElement $parent, Configuration $configuration)
 {
     $element = XmlDom::createElement($parent, 'PropertyGroup', null, ['Condition' => $this->buildCondition($configuration)]);
     XmlDom::createElement($element, 'LinkIncremental', $configuration->getDebug() ? 'true' : 'false');
     $this->writePathList($element, 'IncludePath', 'include', $configuration);
     $this->writePathList($element, 'LibraryPath', 'library', $configuration);
     $this->writePathList($element, 'ExecutablePath', 'executable', $configuration);
     $this->writePathList($element, 'SourcePath', 'source', $configuration);
     $this->writePathList($element, 'ReferencePath', 'reference', $configuration);
     $this->writePathList($element, 'ExcludePath', 'exclude', $configuration);
     $outputExt = $configuration->getParsedExtension();
     $outputExtWithDot = '.' . $outputExt;
     $outputPath = $this->variableParser->parse($configuration->getOutputPath()) . $outputExt;
     $outputDirectory = dirname($outputPath);
     $intDir = $configuration->getIntermediateDirectory();
     if (!$intDir) {
         $intDir = sprintf('intermediate\\%s', $configuration->getName());
     } else {
         $intDir = $this->variableParser->parse($intDir);
     }
     FileSystem::createDirectory($outputDirectory);
     FileSystem::createDirectory($intDir);
     XmlDom::createElement($element, 'OutDir', FileSystem::getRelativePath($this->config->getProjectsDirectory() . '/vs2010', $outputDirectory . '/bla/bla2/') . '\\');
     XmlDom::createElement($element, 'IntDir', FileSystem::getRelativePath($this->config->getProjectsDirectory(), $intDir) . '\\');
     XmlDom::createElement($element, 'TargetName', basename($outputPath, $outputExtWithDot));
     XmlDom::createElement($element, 'TargetExt', $outputExt);
 }