SlideShare wird heruntergeladen. ×
0
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Introduction to s cons
Nächste SlideShare
Wird geladen in ...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introduction to s cons

4,647

Published on

Published in: Technologie
0 Kommentare
2 Gefällt mir
Statistiken
Notizen
  • Hinterlassen Sie den ersten Kommentar

Keine Downloads
Views
Gesamtviews
4,647
Bei Slideshare
0
Aus Einbettungen
0
Anzahl an Einbettungen
0
Aktionen
Geteilt
0
Downloads
14
Kommentare
0
Gefällt mir
2
Einbettungen 0
No embeds

Inhalte melden
Als unangemessen gemeldet Als unangemessen melden
Als unangemessen melden

Wählen Sie Ihren Grund, warum Sie diese Präsentation als unangemessen melden.

Löschen
No notes for slide

Transcript

  • 1. Introduction to SCons Steve Christensen [email_address] Presented to Utah Python Users Group http://www.utahpython.org
  • 2. What is SCons? <ul><li>SCons is an Open Source software construction tool </li></ul><ul><li>Think of SCons as an improved, cross-platform substitute for the classic Make utility with integrated functionality similar to autoconf/automake and compiler caches such as ccache. </li></ul><ul><li>In short, SCons is an easier, more reliable way to build software. </li></ul>
  • 3. SCons Benefits <ul><li>Both SCons configuration files and user-created extensions to SCons are Python scripts </li></ul><ul><li>Global view of dependencies for entire project. </li></ul><ul><li>Support for sharing cached build results among developers </li></ul>
  • 4. SCons Benefits (continued) <ul><li>Improved support for parallel builds -- like ‘make –j’ but keeps N jobs running simultaneously regardless of directory hierarchy. </li></ul><ul><li>Reliable detection of build changes using MD5 signatures (signatures track file content as well as command-line options) </li></ul>
  • 5. SCons Benefits (continued) <ul><li>Reliable, automatic dependency analysis for C, C++, and Fortran. (extendible) </li></ul><ul><li>Built-in support for C, C++, D, Java, Fortran, Yacc, Lex, Qt, SWIG, building TeX and LaTeX documents, and many others. (extendible) </li></ul><ul><li>Great way for Python to infiltrate your C/C++ work environment </li></ul>
  • 6. SCons Drawbacks <ul><li>Java support isn’t as complete as the C/C++ support </li></ul><ul><li>Incremental / no-op build performance is bad. </li></ul><ul><ul><li>Compared to other tools, SCons can be significantly slower (e.g. 1-2 minute no-op build?) </li></ul></ul><ul><ul><li>Recipes on the Wiki / Mail Lists for speed ups </li></ul></ul><ul><li>Complex builds require a fair amount of Python code to achieve the functionality built- in to some other build tools (e.g. variant builds ala BoostJam) </li></ul>
  • 7. SCons Basics <ul><li>At startup, SCons will look for a file named ‘SConstruct’ in the current directory. </li></ul><ul><li>SConstruct is a Python script. SCons processes the script to build a dependency graph. Any nodes in the dependency graph that are out-of-date will be rebuilt. </li></ul><ul><li>SCons tracks dependencies by creating ‘.sconsign’ files to store build signatures. </li></ul>
  • 8. Example #1: HelloWorld <ul><li>Simple helloworld.c : </li></ul><ul><li>int main() { </li></ul><ul><li>printf(“Hello, world!n”); </li></ul><ul><li>} </li></ul><ul><li>Simple SConstruct: </li></ul><ul><li>Program('helloworld.c') </li></ul>
  • 9. Example #2: Static Libraries
  • 10. Example #2.1 : Shared Libraries
  • 11. Example #3: Builders return Lists
  • 12. Example #3.1 : Why lists? <ul><li>In addition to file prefix / suffix problems, the same builder may produce a different number of output files on different platforms / compilers. </li></ul><ul><li>E.g. SharedLibrary(‘foo’,foo_sources) will return a single-item list on win32/cygwin [<Node: ‘foo.dll’>], and a three-item list on win32/msvc [<Node: ‘foo.dll’>,<Node: ‘foo.lib’>, <Node: ‘foo.exp’>] </li></ul>
  • 13. Example #4: Construction Environments <ul><li>What if we want to compile the program in multiple ways? </li></ul>
  • 14. Example #4.2: Modifying a Construction Environment <ul><li>Result: </li></ul><ul><li>gcc -DFIRST -DDEFINE2 -DLAST -c -o helloworld.o helloworld.c </li></ul><ul><li>gcc -o helloworld.exe helloworld.o </li></ul>
  • 15. Hierarchical Builds <ul><li>Source files of large projects are typically organized into a hierarchy of directories. Builds with SCons use a hierarchy of SCons build scripts. </li></ul><ul><li>The top-level build script remains named ‘SConstruct’ </li></ul><ul><li>The lower-level build scripts are conventionally named ‘SConscript’, and are executed via SConscript() method in the calling script(s). </li></ul>
  • 16. Example #5: Heirarchical Builds
  • 17. Example #6: Source vs. Build Directories?
  • 18. Variant Builds <ul><li>BuildDir is cool, but I want release / debug and win32 / cygwin binaries and objects built into separate trees. </li></ul><ul><li>And, I want separate bin/lib/obj directories. </li></ul>
  • 19. Example #7: Variant Builds
  • 20. Example #7: Variant Builds (cont’d)
  • 21. Example #7: Variant Builds (cont’d)
  • 22. Example #8: Caching Built Files <ul><li>Need a network share with read/write access for all your developers </li></ul><ul><li>Add ‘CacheDir(“/my/fancy/bulidcache”)’ to your build script. </li></ul><ul><li>Command-line options can be used to enable or disable uploads/downloads from the cache. </li></ul>
  • 23. Example #9: Extending SCons
  • 24. Example #9: Extending SCons <ul><li>sed 's/x/y/' < baz.in > baz.out </li></ul>
  • 25. Example #9: Extending SCons <ul><li>sed 's/x/y/' < baz.input > baz.output </li></ul>
  • 26. Example #9: Extending SCons
  • 27. Example #10: Java Builds
  • 28. Example #11: MSVC PDB, PCH, Resources
  • 29. More examples? <ul><li>Options? </li></ul><ul><li>Configuration? </li></ul>
  • 30. References <ul><li>SCons Homepage </li></ul><ul><li>SCons Wiki </li></ul><ul><li>Article (Freshmeat.net): Make Alternatives </li></ul><ul><li>Article (Games from Within): The Quest for the Perfect Build System </li></ul>

×