7

I have written a program for a company. They want the source code.

The program uses code that I've written over time for several projects for a number of clients.

I want to release only the code that is used by this program. So if a shared file called Utils.pas contains ten functions and this program uses only two of them then I want to release a file called Utils.pas with only those two functions in it.

The code is Borland Pascal, written using Delphi.

Anyone know how I can do this?

Clarification: I am not asking about licensing. I want the customer to have only the source code that is used by their program and nothing else.

gunr2171
  • 16,104
  • 25
  • 61
  • 88
cja
  • 9,512
  • 21
  • 75
  • 129
  • 2
    If you can't do it with your existing file structure, you haven't broken it up into enough pieces. This is a hazard of having catch-all source files. – Blrfl Feb 06 '13 at 16:33
  • If the code you've produced for them makes use of "common libraries" you've produced, why not simply provide the .pas files for their project(s), and the compiled DCU files for your "common libraries"? – LaKraven Feb 06 '13 at 22:06
  • 1
    Anything which is specific to all customers, put it in your own component package, and provide them only the BPL without source. Then, the remaining source will be customer-specific. However, if you have code which is specific to one customer, which you don't want a specific other customer to see, you'll also have to produce a BPL for each customers' code. This is still a large task, and I wish you the best of luck. – Jerry Dodge Feb 07 '13 at 00:31
  • Or you could do a similar solution using DLL's. Keep in mind that you want to give a unique name to each library, no matter what type, which is specific to each customer yet doesn't give the customer's name away. Use like a customer ID as an identifier, which only you know what ID is for who. – Jerry Dodge Feb 07 '13 at 00:34

1 Answers1

2

Break their code out of utils.pas, into client_xxxx_utils.pas. Charge them your usual rate for the work to do this, rebuild, smoke test, etc.. Problem solved.

Ok, in case it's a chore to figure out what to trim... Compile the program, and look at the utils.pas unit. Normally, you'll have Blue Dots in the margin, indicating that you can set break points. "Dead Code" will not have the blue dots in the margin, as that code has been eliminated by the linker. Anything without a blue dot, is something that they don't need.

For a more automatic approach, perhaps Peganza Pascal Analyzer can identify dead code in one of it's many reports.

Here are some related questions here on SO with similar answers (some by me!)

Finding unused (aka "dead") code in Delphi

How to "automatically" remove unused units from uses clause?

Community
  • 1
  • 1
Chris Thornton
  • 15,620
  • 5
  • 37
  • 62