Exemplo n.º 1
0
RelativePath ProjectExporter::getModuleFolderRelativeToProject (const String& moduleID, ProjectSaver& projectSaver) const
{
    if (project.getModules().shouldCopyModuleFilesLocally (moduleID).getValue())
        return RelativePath (project.getRelativePathForFile (projectSaver.getLocalModuleFolder (moduleID)),
                             RelativePath::projectFolder);

    String path (getPathForModuleString (moduleID));

    if (path.isEmpty())
        return getLegacyModulePath (moduleID).getChildFile (moduleID);

    return RelativePath (path, RelativePath::projectFolder).getChildFile (moduleID);
}
Exemplo n.º 2
0
void ProjectExporter::addVST3FolderToPath()
{
    const String vst3Folder (getVST3PathValue().toString());

    if (vst3Folder.isNotEmpty())
        addToExtraSearchPaths (RelativePath (vst3Folder, RelativePath::projectFolder), 0);
}
Exemplo n.º 3
0
void TJerFile::GetRelativePath(const char *BeginDir,const char *Path,char **TheRelativePath)
{
	BPath BeginPath(BeginDir);
	BPath PathPath(Path);
	string Begin(BeginPath.Path());
	string Chemin(PathPath.Path());
	string RelativePathBuffer("");
	string RelativePath("");
	int indSav;
	for (uint32 ind=Begin.length();ind<Chemin.length();ind++)
	{
		RelativePathBuffer = RelativePathBuffer + Chemin[ind];
	}
	for (int ind=RelativePathBuffer.length()-1;ind>=0;ind--)
	{
		if (RelativePathBuffer[ind]=='/')
		{
			indSav = ind;
			break;
		}
	}
	for (int ind=0;ind<indSav;ind++)
	{
		RelativePath = RelativePath + RelativePathBuffer[ind];
	}
	*TheRelativePath = (char *)malloc(sizeof(char)*(RelativePath.length()+1));
	strcpy(*TheRelativePath,RelativePath.c_str());
}
Exemplo n.º 4
0
RelativePath ProjectExporter::getLegacyModulePath (const String& moduleID) const
{
    if (project.getModules().state.getChildWithProperty (Ids::ID, moduleID) ["useLocalCopy"])
        return RelativePath (project.getRelativePathForFile (project.getGeneratedCodeFolder()
                                                                .getChildFile ("modules")
                                                                .getChildFile (moduleID)), RelativePath::projectFolder);

    String oldJucePath (getLegacyModulePath());

    if (oldJucePath.isEmpty())
        return RelativePath();

    RelativePath p (oldJucePath, RelativePath::projectFolder);
    if (p.getFileName() != "modules")
        p = p.getChildFile ("modules");

    return p.getChildFile (moduleID);
}
Exemplo n.º 5
0
void ProjectExporter::addProjectPathToBuildPathList (StringArray& pathList, const RelativePath& pathFromProjectFolder, int index) const
{
    const auto localPath = RelativePath (rebaseFromProjectFolderToBuildTarget (pathFromProjectFolder));

    const auto path = isVisualStudio() ? localPath.toWindowsStyle() : localPath.toUnixStyle();

    if (! pathList.contains (path))
        pathList.insert (index, path);
}
void*
CSimplisticPluginLoadLogic::LoadPlugin( const CString& rootDir        ,
                                        const CString& moduleName     ,
                                        const CString& groupName      ,
                                        const TVersion* pluginVersion )
{GUCEF_TRACE;

    CString fullPluginPath = CombinePath( rootDir, moduleName );
    fullPluginPath = RelativePath( fullPluginPath );
    return LoadModuleDynamicly( fullPluginPath.C_String() );
}
Exemplo n.º 7
0
/// \brief Returns the absolute path of 'File', by prepending it with
/// 'BaseDirectory' if 'File' is not absolute.
///
/// Otherwise returns 'File'.
/// If 'File' starts with "./", the returned path will not contain the "./".
/// Otherwise, the returned path will contain the literal path-concatenation of
/// 'BaseDirectory' and 'File'.
///
/// \param File Either an absolute or relative path.
/// \param BaseDirectory An absolute path.
static std::string getAbsolutePath(
    StringRef File, StringRef BaseDirectory) {
  assert(llvm::sys::path::is_absolute(BaseDirectory));
  if (llvm::sys::path::is_absolute(File)) {
    return File;
  }
  StringRef RelativePath(File);
  if (RelativePath.startswith("./")) {
    RelativePath = RelativePath.substr(strlen("./"));
  }
  llvm::SmallString<1024> AbsolutePath(BaseDirectory);
  llvm::sys::path::append(AbsolutePath, RelativePath);
  return AbsolutePath.str();
}
Exemplo n.º 8
0
std::string getAbsolutePath(StringRef File) {
  StringRef RelativePath(File);
  // FIXME: Should '.\\' be accepted on Win32?
  if (RelativePath.startswith("./")) {
    RelativePath = RelativePath.substr(strlen("./"));
  }

  SmallString<1024> AbsolutePath = RelativePath;
  llvm::error_code EC = llvm::sys::fs::make_absolute(AbsolutePath);
  assert(!EC);
  (void)EC;
  llvm::sys::path::native(AbsolutePath);
  return AbsolutePath.str();
}
Exemplo n.º 9
0
void TJerFile::GetRelativePathAndName(const char *BeginDir,const char *Path,char **TheRelativePathAndName)
{
	BPath BeginPath(BeginDir);
	BPath PathPath(Path);
	string Begin(BeginPath.Path());
	string Chemin(PathPath.Path());
	string RelativePathBuffer("");
	string RelativePath("");
	for (uint32 ind=Begin.length();ind<Chemin.length();ind++)
	{
		RelativePathBuffer = RelativePathBuffer + Chemin[ind];
	}
	*TheRelativePathAndName = (char *)malloc(sizeof(char)*(RelativePathBuffer.length()+1));
	strcpy(*TheRelativePathAndName,RelativePathBuffer.c_str());
}
bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const
{
	bool bRes = CSettingTypeApplication::Load(Index,Value);
	if (bRes)
	{
		if (Value.substr(0,2) == ".\\" || Value.substr(0,2) == "./" ||
			Value.substr(0,3) == "..\\" || Value.substr(0,3) == "../")
		{
			CPath FullFilePath(CPath::MODULE_DIRECTORY), RelativePath(Value);
			FullFilePath.SetNameExtension(RelativePath.GetNameExtension().c_str());
			FullFilePath.AppendDirectory(RelativePath.GetDirectory().c_str());

            Value = (const std::string &)FullFilePath;
		}
	}
	return bRes;
}
Exemplo n.º 11
0
static void
SelectProfile(const TCHAR *path)
{
  if (StringIsEmpty(path))
    return;

  Profile::SetFiles(path);

  if (RelativePath(path) == nullptr) {
    /* When a profile from a secondary data path is used, this path
       becomes the primary data path */
    TCHAR temp[MAX_PATH];
    SetPrimaryDataPath(DirName(path, temp));
  }

  File::Touch(path);
}
Exemplo n.º 12
0
/// \brief Returns the absolute path of 'File', by prepending it with
/// 'BaseDirectory' if 'File' is not absolute.
///
/// Otherwise returns 'File'.
/// If 'File' starts with "./", the returned path will not contain the "./".
/// Otherwise, the returned path will contain the literal path-concatenation of
/// 'BaseDirectory' and 'File'.
///
/// \param File Either an absolute or relative path.
/// \param BaseDirectory An absolute path.
static std::string getAbsolutePath(
    StringRef File, StringRef BaseDirectory) {
  SmallString<1024> PathStorage;
  assert(llvm::sys::path::is_absolute(BaseDirectory));
  if (llvm::sys::path::is_absolute(File)) {
    llvm::sys::path::native(File, PathStorage);
    return PathStorage.str();
  }
  StringRef RelativePath(File);
  // FIXME: Should '.\\' be accepted on Win32?
  if (RelativePath.startswith("./")) {
    RelativePath = RelativePath.substr(strlen("./"));
  }
  llvm::SmallString<1024> AbsolutePath(BaseDirectory);
  llvm::sys::path::append(AbsolutePath, RelativePath);
  llvm::sys::path::native(Twine(AbsolutePath), PathStorage);
  return PathStorage.str();
}
FString FFileManagerGeneric::DefaultConvertToRelativePath( const TCHAR* Filename )
{
	//default to the full absolute path of this file
	FString RelativePath( Filename );
	FPaths::NormalizeFilename(RelativePath);

	// See whether it is a relative path.
	FString RootDirectory( FPlatformMisc::RootDir() );
	FPaths::NormalizeFilename(RootDirectory);

	//the default relative directory it to the app root which is 3 directories up from the starting directory
	int32 NumberOfDirectoriesToGoUp = 3;

	//temp holder for current position of the slash
	int32 CurrentSlashPosition;

	//while we haven't run out of parent directories until we which a drive name
	while( ( CurrentSlashPosition = RootDirectory.Find( TEXT("/"), ESearchCase::CaseSensitive, ESearchDir::FromEnd ) ) != INDEX_NONE )
	{
		if( RelativePath.StartsWith( RootDirectory ) )
		{
			FString BinariesDir = FString(FPlatformProcess::BaseDir());
			FPaths::MakePathRelativeTo( RelativePath, *BinariesDir );
			break;
		}
		int32 PositionOfNextSlash = RootDirectory.Find( TEXT("/"), ESearchCase::CaseSensitive, ESearchDir::FromEnd, CurrentSlashPosition );
		//if there is another slash to find
		if( PositionOfNextSlash != INDEX_NONE )
		{
			//move up a directory and on an extra .. TEXT("/")
			// the +1 from "InStr" moves to include the "\" at the end of the directory name
			NumberOfDirectoriesToGoUp++;
			RootDirectory = RootDirectory.Left( PositionOfNextSlash + 1 );
		}
		else
		{
			RootDirectory.Empty();
		}
	}
	return RelativePath;
}
Exemplo n.º 14
0
static bool
SelectProfile(Path path)
{
  try {
    if (!CheckProfilePasswordResult(CheckProfileFilePassword(path)))
      return false;
  } catch (const std::runtime_error &e) {
    ShowError(e, _("Password"));
    return false;
  }

  Profile::SetFiles(path);

  if (RelativePath(path) == nullptr)
    /* When a profile from a secondary data path is used, this path
       becomes the primary data path */
    SetPrimaryDataPath(path.GetParent());

  File::Touch(path);
  return true;
}
Exemplo n.º 15
0
std::string getAbsolutePath(StringRef File) {
  SmallString<1024> BaseDirectory;
  if (const char *PWD = ::getenv("PWD"))
    BaseDirectory = PWD;
  else
    llvm::sys::fs::current_path(BaseDirectory);
  SmallString<1024> PathStorage;
  if (llvm::sys::path::is_absolute(File)) {
    llvm::sys::path::native(File, PathStorage);
    return PathStorage.str();
  }
  StringRef RelativePath(File);
  // FIXME: Should '.\\' be accepted on Win32?
  if (RelativePath.startswith("./")) {
    RelativePath = RelativePath.substr(strlen("./"));
  }
  SmallString<1024> AbsolutePath(BaseDirectory);
  llvm::sys::path::append(AbsolutePath, RelativePath);
  llvm::sys::path::native(Twine(AbsolutePath), PathStorage);
  return PathStorage.str();
}
Exemplo n.º 16
0
void BuildPackage( const std::string& FolderName, std::string FileName )
{
    if( FileName.empty() )
    {
        fs::path Path( FolderName );
        FileName = Path.filename().string() + ".pkg";
    }
    AutoFile f( new OsFile( FileName, std::ios_base::out | std::ios_base::trunc ) );
    PackageWriter writer( f );
    PathVector Paths;
    fs::path Dir( FolderName );
    BuildFilesList( Dir, Paths );
    fs::path BasePath = Dir.is_absolute() ? Dir : fs::current_path() / FolderName;
    for( PathVector::const_iterator i = Paths.begin(), e = Paths.end(); i != e; ++i )
    {
        const fs::path& RelPath = *i;
        const fs::path PathInPack = RelativePath( BasePath, RelPath );
        LOG( "Adding %s as %s\n", RelPath.string().c_str(), PathInPack.string().c_str() );
        writer.Add( RelPath, PathInPack );
    }
    writer.Save();
    LOG( "All done." );
}
Exemplo n.º 17
0
void Project::Item::setFile (const File& file)
{
    setFile (RelativePath (project.getRelativePathForFile (file), RelativePath::projectFolder));
    jassert (getFile() == file);
}
Exemplo n.º 18
0
void LibraryModule::addSettingsForModuleToExporter (ProjectExporter& exporter, ProjectSaver& projectSaver) const
{
    auto& project = exporter.getProject();

    const auto moduleRelativePath = exporter.getModuleFolderRelativeToProject (getID());

    exporter.addToExtraSearchPaths (moduleRelativePath.getParentDirectory());

    String libDirPlatform;
    if (exporter.isLinux())
        libDirPlatform = "Linux";
    else if (exporter.isCodeBlocks() && exporter.isWindows())
        libDirPlatform = "MinGW";
    else
        libDirPlatform = exporter.getTargetFolder().getFileName();

    const auto libSubdirPath = String (moduleRelativePath.toUnixStyle() + "/libs/") + libDirPlatform;
    const auto moduleLibDir = File (project.getProjectFolder().getFullPathName() + "/" + libSubdirPath);

    if (moduleLibDir.exists())
        exporter.addToModuleLibPaths (RelativePath (libSubdirPath, moduleRelativePath.getRoot()));

    const auto extraInternalSearchPaths = moduleInfo.getExtraSearchPaths().trim();

    if (extraInternalSearchPaths.isNotEmpty())
    {
        StringArray paths;
        paths.addTokens (extraInternalSearchPaths, true);

        for (int i = 0; i < paths.size(); ++i)
            exporter.addToExtraSearchPaths (moduleRelativePath.getChildFile (paths.getReference(i)));
    }

    {
        const String extraDefs (moduleInfo.getPreprocessorDefs().trim());

        if (extraDefs.isNotEmpty())
            exporter.getExporterPreprocessorDefs() = exporter.getExporterPreprocessorDefsString() + "\n" + extraDefs;
    }

    {
        Array<File> compiled;
        auto& modules = project.getModules();
        auto id = getID();

        const File localModuleFolder = modules.shouldCopyModuleFilesLocally (id).getValue()
                                          ? project.getLocalModuleFolder (id)
                                          : moduleInfo.getFolder();

        findAndAddCompiledUnits (exporter, &projectSaver, compiled);

        if (modules.shouldShowAllModuleFilesInProject (id).getValue())
            addBrowseableCode (exporter, compiled, localModuleFolder);
    }

    if (exporter.isXcode())
    {
        auto& xcodeExporter = dynamic_cast<XcodeProjectExporter&> (exporter);

        if (project.isAUPluginHost())
            xcodeExporter.xcodeFrameworks.addTokens (xcodeExporter.isOSX() ? "AudioUnit CoreAudioKit" : "CoreAudioKit", false);

        const String frameworks (moduleInfo.moduleInfo [xcodeExporter.isOSX() ? "OSXFrameworks" : "iOSFrameworks"].toString());
        xcodeExporter.xcodeFrameworks.addTokens (frameworks, ", ", {});

        parseAndAddLibs (xcodeExporter.xcodeLibs, moduleInfo.moduleInfo [exporter.isOSX() ? "OSXLibs" : "iOSLibs"].toString());
    }
    else if (exporter.isLinux())
    {
        parseAndAddLibs (exporter.linuxLibs, moduleInfo.moduleInfo ["linuxLibs"].toString());
        parseAndAddLibs (exporter.linuxPackages, moduleInfo.moduleInfo ["linuxPackages"].toString());
    }
    else if (exporter.isWindows())
    {
        if (exporter.isCodeBlocks())
            parseAndAddLibs (exporter.mingwLibs, moduleInfo.moduleInfo ["mingwLibs"].toString());
        else
            parseAndAddLibs (exporter.windowsLibs, moduleInfo.moduleInfo ["windowsLibs"].toString());
    }
    else if (exporter.isAndroid())
    {
        parseAndAddLibs (exporter.androidLibs, moduleInfo.moduleInfo ["androidLibs"].toString());
    }
}
Exemplo n.º 19
0
RelativePath ProjectExporter::getJucePathFromProjectFolder() const
{
    return RelativePath (getJuceFolderString(), RelativePath::projectFolder);
}
Exemplo n.º 20
0
void ProjectSaver::writeProjects (const OwnedArray<LibraryModule>& modules, const String& specifiedExporterToSave, bool isCommandLineApp)
{
    ThreadPool threadPool;

    // keep a copy of the basic generated files group, as each exporter may modify it.
    auto originalGeneratedGroup = generatedFilesGroup.state.createCopy();

    CLionProjectExporter* clionExporter = nullptr;
    OwnedArray<ProjectExporter> exporters;

    try
    {
        for (Project::ExporterIterator exp (project); exp.next();)
        {
            if (specifiedExporterToSave.isNotEmpty() && exp->getName() != specifiedExporterToSave)
                continue;

            auto* exporter = exporters.add (exp.exporter.release());

            exporter->initialiseDependencyPathValues();

            if (exporter->getTargetFolder().createDirectory())
            {
                if (exporter->isCLion())
                {
                    clionExporter = dynamic_cast<CLionProjectExporter*> (exporter);
                }
                else
                {
                    exporter->copyMainGroupFromProject();
                    exporter->settings = exporter->settings.createCopy();

                    exporter->addToExtraSearchPaths (RelativePath ("JuceLibraryCode", RelativePath::projectFolder));

                    generatedFilesGroup.state = originalGeneratedGroup.createCopy();
                    exporter->addSettingsForProjectType (project.getProjectType());

                    for (auto& module: modules)
                        module->addSettingsForModuleToExporter (*exporter, *this);

                    generatedFilesGroup.sortAlphabetically (true, true);
                    exporter->getAllGroups().add (generatedFilesGroup);
                }

                if (isCommandLineApp)
                    saveExporter (exporter, modules);
                else
                    threadPool.addJob (new ExporterJob (*this, exporter, modules), true);
            }
            else
            {
                addError ("Can't create folder: " + exporter->getTargetFolder().getFullPathName());
            }
        }
    }
    catch (ProjectExporter::SaveError& saveError)
    {
        addError (saveError.message);
    }

    if (! isCommandLineApp)
        while (threadPool.getNumJobs() > 0)
            Thread::sleep (10);

    if (clionExporter != nullptr)
    {
        for (auto* exporter : exporters)
            clionExporter->writeCMakeListsExporterSection (exporter);

        std::cout << "Finished saving: " << clionExporter->getName() << std::endl;
    }
}