Hi there! In a few weeks, I might have to derive a product from another products. The hardware is the same, but the software is slightly different. I think, it would be a drag to copy the sources to another directory and and take care of two code versions. So it would be nice to know, which project it is while compilation time, so that I could use some #ifdef statement to get conditional compilation. Other than that, I just had the idea to have a "higher source level files that define a compiler constant and then include the low level source files. Like:
"highlevel.c" #define OEM #include "lowlevel.c" "lowlevel.c" #ifdef OEM #include ... #else #include ... #endif // some common source #ifdef OEM // OEM source only #else // non OEM source #endif // some common source
"Then I only need a different linker file to get different fuctions, but only one source file set." Really: Then you only need a different COMPILE AND LINK to get different versions. Post your e-mail address or send me a ping at erikm@digrec.com and I will send you a sample of doing just that. Ha' en rar dag Erik
If you use uVision2, you can create a target for each program. In each target, you may specify completely different compiler, assembler, and linker options. You may define macros for the compiler and assembler in the project dialog. You can even specify a different compiler (c51 vs c166). In each target you can include or exclude files or groups from the build. If you have a bunch of files that are only used in one program, add them to a group. In the program where they are not used, you can uncheck Include in Build and uVision2 excludes these files from the linkage. So, you can, in effect, have a conditional linkage. The benchmarks listed on this web site: http://www.keil.com/benchmks/c166_v4_small.asp http://www.keil.com/benchmks/c251_v3_xtiny.asp http://www.keil.com/benchmks/c51_v6_small.asp were created using a single project with multiple targets (each configured for the appropriate compiler). The benchmarks do a lot of stuff and I saw no need to maintain 3 separate projects. Let me know if you need more details. Jon
There's a knowledgebase article that you may want to check as well: http://www.keil.com/support/docs/1902.htm Jon
"If you use uVision2, you can create a target for each program." The trouble with that is that each target is completely independent - so if you want to make a chage which needs to go into every taget, you have to change each target individually :-( What uVision needs is an extra level in the hierarchy, where you can specify "global" options common to all targets - in addition to the existing target-specific, group-specific and file-specific options.
", it would be a drag to copy the sources to another directory" There is no need to copy the files - uVision doesn't rely on source files being in the same folder as the Project. You can simply enter the path (which can be relative) when you add the file to the Project.
"There is no need to copy the files. You can simply enter the path (which can be relative) when you add the file to the Project" Yes, and no - if you have a version identifier in the path, it is a lot easier to copy *.c, *.h and *.a51 to a workfile than it is to change all path statements. Erik
The trouble with that is that each target is completely independent - so if you want to make a chage which needs to go into every taget, you have to change each target individually :-( Huh? We must be talking about different stuff. I have several projects with multiple targets that I make global changes to (ie. changes that affect every target). You must be talking about something different. Jon
Here is my experience. (In other words why I gave up on targets and now make separate UV2 projects.) UV2 is "different" than other IDE's. In other IDE's you create "targets" each having there own "file source list" (and options). In the UV2 IDE's you create one "file source list" which contain "targets" that have there own "exclude from the build list" (and options). In other words all "targets" share the same file list. To remove a file you must leave it in the list and set "exclude from the build flag". To add a file you must add it and then go to all the other "targets" and set their "exclude from the build flag".
Ahhh. I think I understand. Are you creating complete different programs? If that's the case, then you should create a separate project for each program. If you are creating the same program (just for different chips or configurations) then uVision2 targets and groups works beautifully. To further explain... I have a project with about 25 targets. Each target generates a program for a different 8051 derivative. Each target creates the same program--just for a different chip. I have targets for Philips MX, Dallas 390, Infineon C167, Standard 8051, and so on. Most of the files in my project are common between all targets. However, I do have some special files (device drivers, mainly) that are only included for each target. So, I have a file group for Philips MX, Dallas 390, Infineon C167, and Standard 8051. The Philips MX group is set as "Do Not Include" for all targets bu the Philips MX. The same goes for the Dallas 390, Infineon C167, and Standard 8051. When I start a project that I know I will use on multiple targets, I create a group for each target (so I can put target-specific files there). Then, in my first target, I set these as "Do Not Include". When I create new targets, I copy the settings of the original target. Then, all I must do is enable the required groups for the new target. But, hey. That's just my solution. Jon
"...projects with multiple targets that I make global changes to (ie. changes that affect every target)." How? I have uVision v2.23. Only one target is ever visible in the Project window at any one time - it is at the "root" of the displayed structure. If I make a change at this "root" level (ie, at the Target level), it will only affect the currently-displayed Target; if I want to make the same change in a different Target, I must change to that Target and then make the same change again "You must be talking about something different." This is quite possible!