Author Topic: Project Base Path and Soft Links  (Read 6092 times)

Offline Thoth

  • Multiple posting newcomer
  • *
  • Posts: 11
Project Base Path and Soft Links
« on: July 31, 2021, 12:15:19 am »
Hello People,

A long standing issue I have had is the inclusion of the actual full path including mount point for project resources on a separate drive. In my case this is a problem when the project is worked on using a different computer.
I am looking for a way to use the full path without the mount point to reference project resources.

I am using CodeBlocks 16.01 on Debian 10 (Buster), CB 20.03 on FreeBSD 12.2, and older versions on OSX, MacOS, and RHEL 5.10.

I typically use absolute paths to project resources and let CB figure out the relative paths when it needs to.

Most of the computers I use have the project files, source code, and other resources on a separate drive.

The separate drive for each computer has a different mount point name. One is SG2Data, another is PIIData, another is KOSXData, another is FCH016Data, etc.

There are soft links to directories containing various project resources, e.g.
/Code -> /PIIData/Code
/CodeTemp -> /SG2Data/CodeTemp
/SDK -> /SG2Data/SDK
/Source -> /PIIData/Source
etc
(two different computers are reflected above)

The Project Base Path in CodeBlocks uses the mount point as part of the path:
/SG2Data/CodeTemp/ins_LPOCode/LPOCheck/Source/main.cpp
/PIIData/CodeTemp/ins_LPOCode/LPOCheck/Source/main.cpp

Is there a way to have CodeBlocks use the path I tell it as the project base path so that none of the paths include the mount point in this situation?



As a side note, over the years I have made a point of manually editing project files to remove the mount point. However, I have to do this each time the project or workspace is updated on one computer and used on another.


Thanks


=thoth=

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Project Base Path and Soft Links
« Reply #1 on: July 31, 2021, 12:58:43 am »
1. Use a VCS to share projects between computers
2. Try Settings -> Global variables https://wiki.codeblocks.org/index.php/Global_compiler_variables
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Project Base Path and Soft Links
« Reply #2 on: July 31, 2021, 10:44:00 am »
I agree with oBFusCATed about this. I have used Code::Blocks for years with different operating systems and computers, and initially I used some odd techniques for sharing projects and source code between computers in my local network. Later I used Bazaar for version control, and since a number of years I use only git for sharing between computers locally and also externally when appropriate (e.g. Github).  I use a common local LAN network share to store local repositories, and clone from there to each local computer. This way it is very easy to synchronize locally without depending on external services.

I also combine this with extensive use of C::B global variables, references to 3rd party libraries always use global variables. This makes it very flexible. Instead of symlinks you could use global variables.

Offline Thoth

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Project Base Path and Soft Links
« Reply #3 on: July 31, 2021, 06:13:13 pm »
Hi Obfuscated,

Thank you for answering.

1. Use a VCS to share projects between computers
I did not realize I had given the impression that I was not using a version control system.
I am.
Subversion is my VCS of choice and is what I am using. Upstream, the company I work for also uses Subversion.

2. Try Settings -> Global variables https://wiki.codeblocks.org/index.php/Global_compiler_variables
I remember playing with these a few years ago when I still had a Windows 8 development environment. I think I was doing something to help go from Win8 to OSX 9.5 to RHEL 5.10. However, I don't recall the specifics.
At any rate, since CodeBlocks is inserting the mount point is the suggestion to override the project base path with a user defined field?
If so, is the suggestion to use the user defined field in the build options?


In the CB default.conf file two of the entries in the recent projects section are:
Code
<s>
   <![CDATA[/CodeTemp/ins_LPOCode/LPOCheck/CodeBlocks/lpo_check.workspace]]>
</s>
<s>
   <![CDATA[/SG2Data/CodeTemp/ins_LPOCode/LPOCheck/CodeBlocks/lpo_check.cbp]]>
</s>
The above snippet reflects me having opened the project file a few days ago on this computer. Whereas I had opened the workspace a few weeks ago on this computer and removed '/SG2Data' from the default.conf file
I also had to remove '/PIIData' from the .cbp files


Again, thank you for answering.


=thoth=




Offline Thoth

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Project Base Path and Soft Links
« Reply #4 on: July 31, 2021, 06:27:51 pm »
Hello CACB,


I agree with oBFusCATed about this. I have used Code::Blocks for years with different operating systems and computers, and initially I used some odd techniques for sharing projects and source code between computers in my local network. Later I used Bazaar for version control, and since a number of years I use only git for sharing between computers locally and also externally when appropriate (e.g. Github).  I use a common local LAN network share to store local repositories, and clone from there to each local computer. This way it is very easy to synchronize locally without depending on external services.
I am using a VCS. I did not intend on giving the impression that I do not.

I also combine this with extensive use of C::B global variables, references to 3rd party libraries always use global variables. This makes it very flexible. Instead of symlinks you could use global variables.
The symbolic links are there for a different reason.
However, I do see how global variables including user defined fields could help with project resources.
Some of the global variables I use are:
Code
$(CMD_CP) "$(TARGET_OUTPUT_FILE)" "/Code/Archives/$(TARGET_NAME)/$(TARGET_OUTPUT_FILENAME)_$(TDAY)"

/Libs/$(TARGET_NAME)

$(PROJECT_DIRECTORY)../Bin/$(TARGET_NAME)/

Thanks again for answering.


=thoth=

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Project Base Path and Soft Links
« Reply #5 on: July 31, 2021, 07:21:00 pm »
None of the ones you listed was a user defined global variables; do you kown that they exist?

https://wiki.codeblocks.org/index.php/Global_compiler_variables

I hope wiki works for you; my internet connect or the wiki server is junk today.

Tim S.
« Last Edit: July 31, 2021, 07:25:16 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Project Base Path and Soft Links
« Reply #6 on: July 31, 2021, 07:38:26 pm »
Thoth: Are you trying to share the default.conf on multiple computers?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Thoth

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Project Base Path and Soft Links
« Reply #7 on: July 31, 2021, 09:19:23 pm »
Hi stahta01 (Tim S.)

I do.
oBFusCATed referenced them in a reply.

I added those lines to that post to show that I do use variables (although global variables) in the compiler settings.  I thought it would be helpful.

I did read the contents of the URL several times ... especially section 6 ( Custom Members Mini-Tutorial ).
I did not find a way to eliminate the mount point from the path of a newly added file.

Something interesting I did see ...
When I opened a workspace using CodeBlock's  Open File icon, the resulting entry in the Recent Files section of the default.conf did not have the mount point as part of the path.
However, when I opened a 'new' project by double-clicking it in the file manager (thunar and nemo), the mount point was included in the Recent Files section when I reopened CodeBlocks.


Thanks


=thoth=

Offline Thoth

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Project Base Path and Soft Links
« Reply #8 on: July 31, 2021, 09:23:19 pm »
Hi oBFusCATed,

Thoth: Are you trying to share the default.conf on multiple computers?

I was, back when I was using an ARM tablet as a portable development tool.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Project Base Path and Soft Links
« Reply #9 on: July 31, 2021, 11:53:58 pm »
Don't ever, it is only going to cause problems.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]