Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

msbuild - What is the best way to share Delphi source files among projects?

What is the best way to share Delphi source files among projects?

Clarification: We want to use a single source file in multiple Delphi projects. We've been using our SCM tool to put the same file into multiple folders, but this is not a super-elegant experience and we are also considering migrating to a tool that doesn't support this.

As I’ve been investigating this question, I’ve considered a few different approaches, but I’d like to know what you’re doing and how you find your approach.

Important Scenarios:

  • Code-time
    • Adding a new sharing dependency should require explicit declaration, so that sharing is managed.
    • Adding a new sharing dependency should still be relatively simple; it should not require a complicated process.
      • One file which lists all of the project’s “imported” files (from externally) would be nice.
  • Compile-time
    • All projects should always build with the one current version (current as of the source sync state plus local edits).
      • (Maintaining different versions in different locations should use file branching, which is not the topic, here.)
    • Whether each project should be able to affect the shared file’s compilation with different compiler settings (including flags) is arguable.
      • It’s arguably easier to maintain (i.e. long-term) source code that is always built consistently.
      • It’s arguably easier to make maintenance fixes (i.e. short-term) if the scope of said changes can easily be restricted to one project.
  • Debug-time
    • The correct version of the source should automatically open, when stepping into a routine or setting a breakpoint.
    • Editing the displayed source should affect the next build.
      • We do not want to debug against a temporary copy of the source: we'd probably lose code, in the confusion.

Considerations:

  • Near-Term:
    • What approach will be simplest to put in place?
  • Long-Term:
    • What approach will be simplest to use and maintain?

Thanks, in advance, for your feedback!

Mattias


--- UPDATE ---

Thanks for your feedback, via answers, comments, and votes!

I've started down the path of putting shared files into one "producer" project and importing a list of compiled files into each "consumer" project. The projects are being linked together with MSBuild. Once things are more nailed-down, I'll edit this question and the "Library Project" answer, to share what I've learned.

Stay tuned! (But don't hold your breath; you'll asphyxiate within minutes! :P )

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use Source Control System's File Sharing Feature

  • Pro: Fast and easy to set up, if the SCM system supports it.
  • Pro/Con: Each consumer project can independently affect compile-time.
  • Con: There is no official location, in the local working copy of sources.
    • This can lead to confusion.
  • Con: Source changes are not reflected in other locations until checkin and re-retrieve.
    • To properly verify other projects, before checkin, is possible but a royal pain in the butt.
  • Con: Not all SCM systems support shared files.
    • Subversion’s closest feature is folder-level svn:externals.

(Edit: Retitled this to avoid confusion. Of course, everyone should use Source Control! :-) )


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...