PSoC Designer: common files in different projects

A catchall for PSoC Mixed-Signal Array (microcontroller) discussions not captured by the other forums.

Moderator: ericb

PSoC Designer: common files in different projects

Postby Peterle on Sat Feb 25, 2006 1:16 pm

Is it possible to share files (source or headers) between different projects in a common place?
This would simplify al lot in my actual tasks, where most of the headers and some of the sources are identical. Libraries are no solution!

It would be enoug to prevent PSoC Designer from copying files when adding them to a project

any ideas ?

Peter
User avatar
Peterle
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 20
Joined: Thu Feb 03, 2005 12:56 am
Location: Germany

Postby graaja on Sat Feb 25, 2006 7:49 pm

Hello Peter,

You can create your own centrally located libraries and link them to other projects. This can be done by specifying the object file name and the location of the object file in the Project >> Settings, Linker tab. For details about creating the library, refer to Section 3.3 of the IDE User's guide, "Linker Tab - Object/Library modules".
User avatar
graaja
PSoC Master
PSoC Master
 
Posts: 3078
Joined: Thu Dec 18, 2003 4:35 pm
Location: India

Postby Peterle on Sun Feb 26, 2006 12:58 am

Hi graaja,

the point is that I want to use shared source files.

To give you more details:
I have a control unit with several add-on hardware modules.
The modules are equal in some basic functions, but the over all functionality is different. The pin assignment and psoc type is not necessarily identical.

The common parts are (for example)
- headers with error codes and function prototypes
- bootloader and communication modules

different parts may be:
- headers with pin assignments
- command parser

If I add functionality to one module, it should be included in the other modules, too.
But I need to compile the local module code

regards
Peter
User avatar
Peterle
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 20
Joined: Thu Feb 03, 2005 12:56 am
Location: Germany

Postby graaja on Sun Feb 26, 2006 7:19 am

Hi Peter,

I think it is not possible to have common source files. The linker only provides for external object files to be linked.

I guess other users may have better ideas of doing this.
User avatar
graaja
PSoC Master
PSoC Master
 
Posts: 3078
Joined: Thu Dec 18, 2003 4:35 pm
Location: India

Can do

Postby Matt Pleis on Mon Feb 27, 2006 12:43 pm

In PSoC Designer (PSD) 4.2 service pack 3 there is a new IDE User Guide. In there is an Appendix B that describes the Build Process. Section B.4.3 describes how to include "External Files" (sources).

You want to amend information (i.e. rules and assignments) to the overall GNU Make process using "local.mk", which is project specific.

Assume I have a project in C:\temp_b\Diamond. I want to include "common" source from another location, say C:\temp\T

In C:\temp\T I have foo.c and foo.h.

foo.c looks like:
Code: Select all
#include <m8c.h>
#include "c:/temp/T/foo.h"

void foo( int k)
{
   int i;
   i = k * CONSTANT0;
}


Since the "build" process is project directory centric, I add the absolute path in the #include statement so that other projects can use it.

foo.h looks like:
Code: Select all
#define CONSTANT0  0x34

'local.mk' looks like:
Code: Select all
OBJECT_SOURCES:=$(OBJECT_SOURCES) foo.c
CSRCS:=$(CSRCS) ../../temp/T/foo.c

obj/%.o : ../../temp/T/%.c
ifeq ($ECHO_COMMANDS), novice)
   echo $(call correct_path,$<)
endif

   $(CCMD)  $(CFLAGS) $(CDEFINES) $(INCLUDEFLAGS)   $(DEFAULTCFLAGS) -o $@ $(call correct_path,$<)


Adding foo.c to OBJECT_SOURCES (without the path) places the .o file in the "obj" folder of the project - facilitating the debugger (symbols).

Adding ../../temp/T/foo.c to the CSRCS helps the dependencies (project.dep) to built properly.

local.mk also include a "rule" that specifically knows how to "compile" these external file(s).

Your external code can be "debugged" as well.

Hope this helps.
Last edited by Matt Pleis on Tue Feb 28, 2006 2:19 pm, edited 1 time in total.
User avatar
Matt Pleis
Cheese Wheel
Cheese Wheel
 
Posts: 100
Joined: Mon Jan 26, 2004 10:16 am
Location: Carnation, WA

Postby Peterle on Mon Feb 27, 2006 2:03 pm

Hi Matt,

this sounds exactly like what I am looking for.

I havn't upgraded to SP3 - everything is running so nice at the moment :D - but SP2 may work also.

thanx
Peter
User avatar
Peterle
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 20
Joined: Thu Feb 03, 2005 12:56 am
Location: Germany

Postby Peterle on Tue Feb 28, 2006 2:06 pm

Hi Matt,
unfortunately there is thomething running unexpectedly.

If I make all changes corresponding to your proposal makemake gives up with the error message: 'local.mk:31: *** missing separator. Stop.'
This is the last line with the $(CCMD) rule!

When I disable this line, make is happy, but the external source files are not compiled.
(By the way: is it correct that the CFLAGS variable is included twice?)

Any hints ?
User avatar
Peterle
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 20
Joined: Thu Feb 03, 2005 12:56 am
Location: Germany

Check edit to my last post.

Postby Matt Pleis on Tue Feb 28, 2006 3:25 pm

I've edited my last post
User avatar
Matt Pleis
Cheese Wheel
Cheese Wheel
 
Posts: 100
Joined: Mon Jan 26, 2004 10:16 am
Location: Carnation, WA

Re: PSoC Designer: common files in different projects

Postby pabbott on Tue Jan 18, 2011 1:31 pm

Sorry to dig up such an old post, but it seems this feature is still missing.
PD 5.0 IDE User Guide still has the appendix section describing the "trick".

So, if I use this trick, do I have to explicitly name each .c file? Do my .c files have to reference the full path to the .h files?
Seems like more trouble than it's worth.
Maybe there's another way someone can suggest.

I have a project with 9 .c files and 9 .h files. I have 2 target processors (CY8C27243 and CY8C27443). 8 of the nine .c/.h files are common between the target. Only main.c/.h is different. Of course the .app, .cmx etc. files are different as well.

I don't want to maintain separate copies of the source files, since I may be working on one target, find a bug, and fix it only in that source file.
Freescale Codewarrior allows me to include source files from outside the project directory. That way I can have a "shared" source folder for different targets.

I tried using GIT and having each target as a different "branch". But it's not really what I'm looking for. Branches can diverge and it's hard to keep track of which files should be shared.

Any ideas?
pabbott
Newbie
Newbie
 
Posts: 8
Joined: Wed Oct 13, 2010 7:56 am

Re: PSoC Designer: common files in different projects

Postby slandrum on Tue Jan 18, 2011 3:43 pm

There's a trick I've used successfully. I have several projects in the same folder, basically to make builds of the same firmware with slightly different configuration parameters. You can select which source files are part of your project, and which are not. In your case, you'll want something like main1.c in one project and main2.c in the other. What will get difficult is if you want different header files in your project that are referenced by other files - there's no easy way to tell your other source files to include main1.h vs. main2.h.

I've done this by duplicating the *.SOC and the *.WNP files, and then adding different source files to the two projects. A warning when you do this, if you remove a file from one of the projects that's actually used in another project, make sure that you make a backup copy of the file first, as the designer will delete that file when you close and save the project. If you still want that file in the other project, you'll have to manually restore the file.

One final note - This was all done using PSoC Designer 4.x - I haven't verified that it will behave properly under 5.x version

Also note - the hardware settings used for the projects have to be the same (the same .xml file will be used for both). Your base hardware is the same in both cases, so the same .xml file can be used. You will just have different pins physically available. Internally the chips are actually the same. You can send a file built for the 27443 to a 27243 device w/o problems. If you do need something to be fundamentally different, then this trick won't work. It's unfortunate that the .xml file is not given a project specific name, this would facilitate having multiple projects in the same folder.
slandrum
The Big Cheese
The Big Cheese
 
Posts: 451
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: PSoC Designer: common files in different projects

Postby pabbott on Thu Jan 27, 2011 4:30 pm

I may have come up with a solution using hard links in windows XP. (Not sure what kind of demons I'm going to unleash :)
Also not sure how GIT (or SVN) will handle this.

Here's my directory structure:
Firmware>
-->shared>
-->mobile>
-->desktop>

put this bat file in Firmware\mobile\mobile and in Firmware\desktop\desktop
link-winxp.bat
Code: Select all
@ECHO OFF
PUSHD %~dp0..\..\shared
FOR %%f IN (*.*) DO (
IF EXIST "%~dp0\%%f" (
SET /P _ans="%%f exists, overwrite? [y/n]^>"
IF /i "%_ans%" == "y" (
DEL "%~dp0%%f"
fsutil hardlink create "%~dp0%%f" "%%f"
)
) ELSE (
fsutil hardlink create "%~dp0%%f" "%%f"
)
)
POPD

When you run it, it will create links from each file in ..\..\shared to the batch file's directory. Now if I edit a file in either project, it's automagically changed in the other. Yea!
Note, the bat file only works from the command line (no double-click). Not sure why...
pabbott
Newbie
Newbie
 
Posts: 8
Joined: Wed Oct 13, 2010 7:56 am

Re: PSoC Designer: common files in different projects

Postby aut18 on Fri Jan 28, 2011 1:25 am

Hi Pabb0tt.
Note, the bat file only works from the command line (no double-click). Not sure why...

Because it is the prehistory of DOS.
Text files *. bat was called with the configuration files. There was a short program - initialization.
WIN historically remained with the possibility of starting from the command line.

I applied the method save as ..
I often change the source files in the trial and error.
I'm afraid that I lose something good before.
I can always go back and try a different folder.
Best regards Chris.
Best regards, Chris.
R&D Engineer
aut18
Cheese Cube
Cheese Cube
 
Posts: 46
Joined: Sun May 16, 2010 11:23 am
Location: at present in France

Re: PSoC Designer: common files in different projects

Postby jannypan on Wed Feb 16, 2011 6:02 pm

You want to amend information (i.e. rules and assignments) to the overall GNU Make process using "local.mk", which is project specific.
jannypan
Newbie
Newbie
 
Posts: 7
Joined: Wed Feb 16, 2011 5:55 pm

Re: PSoC Designer: common files in different projects

Postby pabbott on Fri Feb 18, 2011 7:05 am

slandrum wrote:One final note - This was all done using PSoC Designer 4.x - I haven't verified that it will behave properly under 5.x version.

This won't work in 5.x because of the requirement that the source folder has the same name as the project file. Seems like they are intentionally making this difficult.

jannypan wrote:You want to amend information (i.e. rules and assignments) to the overall GNU Make process using "local.mk", which is project specific.

I looked into this previously, but it was complicated and the IDE can't open the shared files for editing and debugging. Can someone please give an example local.mk that works?

Regarding my last post about using hard-links in windows xp, the IDE seems to be destroying the links somehow. The files are not updating in the shared folder.
Maybe the IDE is deleting the files and re-creating them? Why would they do that?

Looks like my only option is to maintain 2 branches in version control and remember to merge changes between them.
pabbott
Newbie
Newbie
 
Posts: 8
Joined: Wed Oct 13, 2010 7:56 am

Re: PSoC Designer: common files in different projects

Postby dt1 on Fri Mar 04, 2011 4:04 am

Here's an example of how I handle this (XP). It allows me to share source and maintain easy version control by simply renaming my c files.

main.c contains only the following:

Code: Select all
include "c:\Documents and Settings\dt\My Documents\Circuits\CY\common\main-252.c"   //version 2.5.2

void main(void)
{
   main2();   //call common source file
}


main-252.c then contains everything that you would normally put in main.c. This would normally have a void main(void) function which I call void main2(void).

Code: Select all
//--------------------------------------
// Included files
//--------------------------------------

#include <m8c.h>        //part specific constants and macros
#include "lpradio.h"   //radio driver
#include "flash.h"      //read/write flash
#include "PSoCAPI.h"   //timer
#include "PSoCGPIOINT.h"//port definitions
   
//--------------------------------------
// Function Declarations
//--------------------------------------

void main2(void);      //'main' function called from main.c in PD5.1 IDE


//--------------------------------------------------------------------------
//main
//--------------------------------------------------------------------------

void main2(void)
{
}


Hope this helps,
David.
dt1
Cheese Cube
Cheese Cube
 
Posts: 27
Joined: Wed May 27, 2009 10:26 am


Return to PSoC1 General

Who is online

Users browsing this forum: No registered users and 1 guest