Author Topic: relative paths for working files (not project files)  (Read 6531 times)

tcolgan001

  • Community Member
  • Posts: 21
  • Hero Points: 0
relative paths for working files (not project files)
« on: December 04, 2014, 03:55:20 PM »
Is there a way to define the working files for a project using relative paths and keep the slickedit files (vpw/vpj) in a separate place?

For example.  I'd like to keep my slickedit project files in C:\slickedit\proj1, etc.  and my working files in D:\work\proj1.  This way, in the vpj files, files could be defined relative to "D:\work\proj1".  Then when proj1 is copied to proj2 it would be only necessary to redefine the base path.

Any way to do this?  Anyone else have a problem attempting to do this?

Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: relative paths for working files (not project files)
« Reply #1 on: December 04, 2014, 06:56:50 PM »
Since the workspace (.vpw) file simply points to the project file, your best bet is to store the project file (.vpj) with your project and then point the workspace at it.  The files will be stored in the project file relative to its location, so when you move d:\work\proj1, all you will need to do is update the path in your workspace file.

Also, the supplementary files (tag file and history file) are stored relative to the workspace file, so using this technique, they will not litter your project directory.

dfechser

  • Senior Community Member
  • Posts: 123
  • Hero Points: 0
Re: relative paths for working files (not project files)
« Reply #2 on: December 04, 2014, 07:11:01 PM »
I routinely do this.

I keep my Slickedit project files (.vpw, .vpj, etc.) in a local directory on my C-disk but my project files exist on several different networks.

I honestly don't know how I originally set this up, I tend to create new projects and workspaces by copying old .vpw and .vpj files and then editing them manually.

I know that's not much help but, at least, you can be sure that it is possible. :-)

I've attached a vpw and vpj file from one of my projects so you can see what I've done. When I create a new code file it is default-created in the workspace directory which is on the network.
« Last Edit: December 04, 2014, 07:16:13 PM by dfechser »

tcolgan001

  • Community Member
  • Posts: 21
  • Hero Points: 0
Re: relative paths for working files (not project files)
« Reply #3 on: December 05, 2014, 03:45:32 PM »
@dfecher - That's what I've always done, copied my vpj file and then manually edited (find and replace paths).  A real nuisance and disappointing that this is necessary in a programmer's editor.

@Dennis - Your technique would be fine if I could check my vpj file into source  control, but unfortunately, I can't.  People here (and every other place I have worked) tend to use a variety of editors, so checking editor-specific files in is a no-no.  I can understand how this might work for the programmers at Slickedit, but in the real-world this is impractical.

Does anyone else have this problem?  If so, chime in so the people at Slickedit get the message.

Thanks,
Tim

mwb1100

  • Senior Community Member
  • Posts: 156
  • Hero Points: 13
Re: relative paths for working files (not project files)
« Reply #4 on: December 05, 2014, 05:12:01 PM »
@Dennis - Your technique would be fine if I could check my vpj file into source  control, but unfortunately, I can't.  People here (and every other place I have worked) tend to use a variety of editors, so checking editor-specific files in is a no-no.  I can understand how this might work for the programmers at Slickedit, but in the real-world this is impractical.

*.vpj should be in the version control's ignore configuration. Then the problem becomes keeping the .vpj file backed up for when you blow away a working directory then checkout the project again and want to get the SlickEdit project settings back.  That's a bit of a pain, but can usually be managed without too much trouble.

On another note: if the .vpj file uses relative paths for the file locations but isn't in the actual project directory, how would SE know what the paths should be relative to?

tcolgan001

  • Community Member
  • Posts: 21
  • Hero Points: 0
Re: relative paths for working files (not project files)
« Reply #5 on: December 05, 2014, 05:22:41 PM »
On another note: if the .vpj file uses relative paths for the file locations but isn't in the actual project directory, how would SE know what the paths should be relative to?

In the same way that a project has an associated "working directory" it should have a "project directory" to point to the base of the files.

In the vpj file there is currently a line like this:

WorkingDir="."

Another line, would solve the problem:

ProjectDir="D:\work\proj1"


Am I the only one that views projects this way?


Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: relative paths for working files (not project files)
« Reply #6 on: December 05, 2014, 05:24:51 PM »
If clutter is an issue, put the project file in a subdirectory.  For example:

Code: [Select]
project_dir/src/...
                /3rdparty/...
                /docs/...
                /config/...
                /install/...
                /editors/project.vpj
                /editors/... (vim, emacs, Visual Studio, etc)

Then the only clutter you have is the "editors" subdirectory, where all the different programmers can put their different project files needed by their editor, and nobody suffers.  Even the editors that support projects with files relative to another location will be better off (no adjusting paths at all) if they can keep their project information near the source code, and more importantly, in version control.

@mwb1100:  the files are relative to the location of the project file.  That way, if you move the whole directory including the project file, everything just works.  As I said above, I would argue that the .vpj files should be in version control.  It's much easier to have one subdirectory or a few files for your installer to ignore than to make things more difficult for every programmer to work in the tool of their choice.  In this day, space should not be an issue.

@tcolgan001:  we certain *can* add a "project directory" option as you describe, but since you will have to adjust paths anyway, I am not convinced that it is the best solution.
« Last Edit: December 05, 2014, 05:28:35 PM by Dennis »

Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: relative paths for working files (not project files)
« Reply #7 on: December 05, 2014, 05:34:49 PM »
Another solution you might want to consider.  This does involve some one-time manual editing of the project file and workspace file, but it would work.

Change the <F> entries in the project file to use an environment variable %(MYSOURCE_DIR).  Example:
Code: [Select]
   <F N="%(MYSOURCE_DIR)/src/bells/liberty.cpp"/>

Then define MYSOURCE_DIR in your workspace file.
Code: [Select]
<Environment>
<Set Name="MYSOURCE_DIR" Value="D:\work\proj1\" />
        </Environment>

Then when you move the source files, all you have to change is the environment variable in the .vpw file.

tcolgan001

  • Community Member
  • Posts: 21
  • Hero Points: 0
Re: relative paths for working files (not project files)
« Reply #8 on: December 05, 2014, 06:46:39 PM »
Dennis;

Would be nice if that worked.  What I get for a file path is:

C:\tmc\mirror\slickproj\projects\temp\%(SRCDIR)\UCS\Common\Card\Makefile_BAM

I.e. no expansion of %(SRCDIR),  see attached.

Any ideas?


Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: relative paths for working files (not project files)
« Reply #9 on: December 05, 2014, 07:20:24 PM »
Close the workspace and reopen it.  If you edited those things in place while you had the workspace open, it may have not picked up the environment variable yet.

tcolgan001

  • Community Member
  • Posts: 21
  • Hero Points: 0
Re: relative paths for working files (not project files)
« Reply #10 on: December 08, 2014, 05:06:08 PM »
Still doesn't work.

Any idea what I might be doing wrong?

Below are the files:

=====================
workspace.vpw:
=====================
<!DOCTYPE Workspace SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpw.dtd">
<Workspace Version="10.0" VendorName="SlickEdit">
   <Projects>
      <Project File="post.vpj"/>
   </Projects>
   <Environment>
      <Set Name="SRCDIR" Value="D:\BLD_3.3.0.45"/>
   </Environment>
</Workspace>

=================
post.vpj
=================
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project
  Version="10.0"
  VendorName="SlickEdit"
  WorkingDir=".">
  <Config
    Name="Release"
    Type="Makefile"
    OutputFile=""
    CompilerConfigName="">
    <Menu>
      <Target
        Name="Echo"
        MenuCaption="Ech&o"
        CaptureOutputWith="ProcessBuffer"
        SaveOption="SaveCurrent"
        RunFromDir="%rw">
        <Exec CmdLine="echo %(SRCDIR)"/>
      </Target>
      <Target
        Name="Compile"
        MenuCaption="&amp;Compile"
        CaptureOutputWith="ProcessBuffer"
        SaveOption="SaveCurrent"
        RunFromDir="%rw">
        <Exec/>
      </Target>
      <Target
        Name="Build"
        MenuCaption="&amp;Build"
        CaptureOutputWith="ProcessBuffer"
        SaveOption="SaveWorkspaceFiles"
        RunFromDir="%rw">
        <Exec CmdLine='plink onpath@10.88.36.212 -pw onpath "cd /mnt/d/p100sl/UCS/BootRom &amp;&amp; sudo ./build_bootrom.sh pblade"'/>
      </Target>
      <Target
        Name="Rebuild"
        MenuCaption="&amp;Rebuild"
        CaptureOutputWith="ProcessBuffer"
        SaveOption="SaveWorkspaceFiles"
        RunFromDir="%rw">
        <Exec/>
      </Target>
      <Target
        Name="Debug"
        MenuCaption="&amp;Debug"
        SaveOption="SaveNone"
        RunFromDir="%rw">
        <Exec/>
      </Target>
      <Target
        Name="Execute"
        MenuCaption="E&amp;xecute"
        SaveOption="SaveNone"
        RunFromDir="%rw">
        <Exec CmdLine='".exe"'/>
      </Target>
    </Menu>
  </Config>
  <Files>
    <F N="%(SRCDIR)\UCS\Common\Card\Makefile_BAM"/>
    <F N="D:\p100sl\UCS\BootRom\post\Makefile_BAM"/>
  </Files>
</Project>