diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..781046e --- /dev/null +++ b/.clang-format @@ -0,0 +1,96 @@ +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: TopLevelDefinitions +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces : Custom +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: true + BeforeElse: true + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: false +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: true +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 2 +UseTab: Never + + + diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..66acbfd --- /dev/null +++ b/.cproject @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e642982 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# scons +.sconsign.dblite + +helloworld* +env.txt diff --git a/.project b/.project new file mode 100644 index 0000000..52a7be7 --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ + + + scons + + + + + + org.python.pydev.PyDevBuilder + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.python.pydev.pythonNature + + diff --git a/.pydevproject b/.pydevproject new file mode 100644 index 0000000..d001f0a --- /dev/null +++ b/.pydevproject @@ -0,0 +1,5 @@ + + +Default +python interpreter + diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml new file mode 100644 index 0000000..c81cbb3 --- /dev/null +++ b/.settings/language.settings.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/README.md b/README.md index 1dd921f..f977db2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # scons-presentation -A presentation titled "SCons; A Python-Based Build System" + +A talk titled "SCons; A Python-Based Build System" + diff --git a/pptx/SCons.pptx b/pptx/SCons.pptx new file mode 100644 index 0000000..0416efa Binary files /dev/null and b/pptx/SCons.pptx differ diff --git a/src/execEx/01/SConstruct b/src/execEx/01/SConstruct new file mode 100644 index 0000000..40233ce --- /dev/null +++ b/src/execEx/01/SConstruct @@ -0,0 +1,124 @@ + +Help(""" + + This is the first scons example. In this example we see a very simple way + of calling scons to create an executable + +>> ls +main.cpp SConstruct + +>> scons -h (get this help message) +>> scons -H (get scons command help) +usage: scons [OPTION] [TARGET] ... + +SCons Options: + -b, -d, -e, -m, -S, -t, -w, --environment-overrides, --no-keep-going, + --no-print-directory, --print-directory, --stop, --touch + Ignored for compatibility. + -c, --clean, --remove Remove specified targets and dependencies. + -C DIR, --directory=DIR Change to DIR before doing anything. + --cache-debug=FILE Print CacheDir debug info to FILE. + --cache-disable, --no-cache + Do not retrieve built targets from CacheDir. + --cache-force, --cache-populate + Copy already-built targets into the CacheDir. + --cache-readonly Do not update CacheDir with built targets. + --cache-show Print build actions for files from CacheDir. + --config=MODE Controls Configure subsystem: auto, force, + cache. + -D Search up directory tree for SConstruct, + build all Default() targets. + --debug=TYPE Print various types of debugging information: + count, duplicate, explain, findlibs, includes, + memoizer, memory, objects, pdb, prepare, + presub, stacktrace, time. + --diskcheck=TYPE Enable specific on-disk checks. + --duplicate=DUPLICATE Set the preferred duplication methods. Must be + one of hard-soft-copy, soft-hard-copy, + hard-copy, soft-copy, copy + -f FILE, --file=FILE, --makefile=FILE, --sconstruct=FILE + Read FILE as the top-level SConstruct file. + -h, --help Print defined help message, or this one. + -H, --help-options Print this message and exit. + -i, --ignore-errors Ignore errors from build actions. + -I DIR, --include-dir=DIR Search DIR for imported Python modules. + --implicit-cache Cache implicit dependencies + --implicit-deps-changed Ignore cached implicit dependencies. + --implicit-deps-unchanged Ignore changes in implicit dependencies. + --interact, --interactive Run in interactive mode. + -j N, --jobs=N Allow N jobs at once. + -k, --keep-going Keep going when a target can't be made. + --max-drift=N Set maximum system clock drift to N seconds. + --md5-chunksize=N Set chunk-size for MD5 signature computation to + N kilobytes. + -n, --no-exec, --just-print, --dry-run, --recon + Don't build; just print commands. + --no-site-dir Don't search or use the usual site_scons dir. + --profile=FILE Profile SCons and put results in FILE. + -q, --question Don't build; exit status says if up to date. + -Q Suppress "Reading/Building" progress messages. + --random Build dependencies in random order. + -s, --silent, --quiet Don't print commands. + --site-dir=DIR Use DIR instead of the usual site_scons dir. + --stack-size=N Set the stack size of the threads used to run + jobs to N kilobytes. + --taskmastertrace=FILE Trace Node evaluation to FILE. + --tree=OPTIONS Print a dependency tree in various formats: all, + derived, prune, status. + -u, --up, --search-up Search up directory tree for SConstruct, + build targets at or below current directory. + -U Search up directory tree for SConstruct, + build Default() targets from local SConscript. + -v, --version Print the SCons version number and exit. + --warn=WARNING-SPEC, --warning=WARNING-SPEC + Enable or disable warnings. + -Y REPOSITORY, --repository=REPOSITORY, --srcdir=REPOSITORY + Search REPOSITORY for source and target files. + +>> scons +scons: Reading SConscript files ... +scons: done reading SConscript files. +scons: Building targets ... +g++ -o main.o -c main.cpp +g++ -o helloworld main.o +scons: done building targets. + + +>> scons +scons: Reading SConscript files ... +scons: done reading SConscript files. +scons: Building targets ... +scons: `.' is up to date. +scons: done building targets. + + +>> ls -a +total 32 +drwxr-xr-x 2 brgirgis users 96 Sep 26 22:50 ./ +drwxr-xr-x 5 brgirgis users 36 Sep 26 22:44 ../ +-rwxr-xr-x 1 brgirgis users 13176 Sep 26 22:50 helloworld* +-rw-r--r-- 1 brgirgis users 94 Sep 26 22:20 main.cpp +-rw-r--r-- 1 brgirgis users 2728 Sep 26 22:50 main.o +-rw-r--r-- 1 brgirgis users 1749 Sep 26 22:50 .sconsign.dblite +-rw-r--r-- 1 brgirgis users 400 Sep 26 22:50 SConstruct + +>> scons -c +scons: Reading SConscript files ... +scons: done reading SConscript files. +scons: Cleaning targets ... +Removed main.o +Removed helloworld +scons: done cleaning targets. + + +>> ls -a +total 12 +drwxr-xr-x 2 brgirgis users 64 Sep 26 22:53 ./ +drwxr-xr-x 5 brgirgis users 36 Sep 26 22:44 ../ +-rw-r--r-- 1 brgirgis users 94 Sep 26 22:20 main.cpp +-rw-r--r-- 1 brgirgis users 1759 Sep 26 22:51 .sconsign.dblite +-rw-r--r-- 1 brgirgis users 1178 Sep 26 22:54 SConstruct + +""") + +Program('helloworld', 'main.cpp') diff --git a/src/execEx/01/main.cpp b/src/execEx/01/main.cpp new file mode 100644 index 0000000..14e169c --- /dev/null +++ b/src/execEx/01/main.cpp @@ -0,0 +1,10 @@ + +#include + +int +main() +{ + std::cout << "Hello World!" << std::endl; + + return 0; +} diff --git a/src/execEx/02/SConstruct b/src/execEx/02/SConstruct new file mode 100644 index 0000000..8178cd4 --- /dev/null +++ b/src/execEx/02/SConstruct @@ -0,0 +1,73 @@ + +Help(""" + + This is the second scons example. In this example we explore more options in + scons. Once you start doing anything useful with scons other than showing + how simple scons works, you will have to create an environment to have more + control on the build. + + One can "Dump()" the environment to see all the underlying details. We can + also compare between Linux and windows environments. + +>> ls +foo.cpp foo.hpp main.cpp SConstruct + +>> scons +scons: Reading SConscript files ... +------------------>starting +------------------>ending +scons: done reading SConscript files. +scons: Building targets ... +g++ -o foo.o -c foo.cpp +g++ -o main.o -c main.cpp +g++ -o helloworld main.o foo.o +scons: done building targets. + + +>> ls -a +total 68 +drwxr-xr-x 2 brgirgis users 154 Sep 26 23:04 ./ +drwxr-xr-x 5 brgirgis users 36 Sep 26 22:44 ../ +-rw-r--r-- 1 brgirgis users 21096 Sep 26 23:04 env.txt +-rw-r--r-- 1 brgirgis users 48 Sep 26 22:42 foo.cpp +-rw-r--r-- 1 brgirgis users 109 Sep 26 22:40 foo.hpp +-rw-r--r-- 1 brgirgis users 1256 Sep 26 23:03 foo.o +-rwxr-xr-x 1 brgirgis users 13288 Sep 26 23:03 helloworld* +-rw-r--r-- 1 brgirgis users 117 Sep 26 22:41 main.cpp +-rw-r--r-- 1 brgirgis users 2872 Sep 26 23:03 main.o +-rw-r--r-- 1 brgirgis users 2441 Sep 26 23:04 .sconsign.dblite +-rw-r--r-- 1 brgirgis users 1348 Sep 26 23:04 SConstruct + + +>> scons --tree=all helloworld +scons: Reading SConscript files ... +------------------>starting +------------------>ending +scons: done reading SConscript files. +scons: Building targets ... +scons: `helloworld' is up to date. ++-helloworld + +-main.o + | +-main.cpp + | +-foo.hpp + | +-/usr/bin/g++ + +-foo.o + | +-foo.cpp + | +-foo.hpp + | +-/usr/bin/g++ + +-/usr/bin/g++ +scons: done building targets. + + +""") + +print('------------------>starting') +env = Environment() + +open('env.txt', 'w').write(env.Dump()) + +env.Program(target='helloworld', + source=['main.cpp', 'foo.cpp']) + +print('------------------>ending') + diff --git a/src/execEx/02/foo.cpp b/src/execEx/02/foo.cpp new file mode 100644 index 0000000..8836de5 --- /dev/null +++ b/src/execEx/02/foo.cpp @@ -0,0 +1,8 @@ + +#include "foo.hpp" + +int +foo() +{ + return 32; +} diff --git a/src/execEx/02/foo.hpp b/src/execEx/02/foo.hpp new file mode 100644 index 0000000..132602a --- /dev/null +++ b/src/execEx/02/foo.hpp @@ -0,0 +1,6 @@ +#ifndef SRC_EXECEX_02_FOO_HPP_ +#define SRC_EXECEX_02_FOO_HPP_ + +int foo(); + +#endif // SRC_EXECEX_02_FOO_HPP_ diff --git a/src/execEx/02/main.cpp b/src/execEx/02/main.cpp new file mode 100644 index 0000000..f8b2c0b --- /dev/null +++ b/src/execEx/02/main.cpp @@ -0,0 +1,12 @@ + +#include "foo.hpp" + +#include + +int +main() +{ + std::cout << "foo = " << foo() << std::endl; + + return 0; +} diff --git a/src/execEx/03/SConstruct b/src/execEx/03/SConstruct new file mode 100644 index 0000000..519e781 --- /dev/null +++ b/src/execEx/03/SConstruct @@ -0,0 +1,15 @@ + + +env = Environment() + +open('env.txt', 'w').write(env.Dump()) + +env.Program(target='helloworld', + source=['main.cpp', 'foo.cpp']) + +envClang = env.Clone() +envClang.Replace(CXX='clang') + +envClang.Program(target='helloworld-clang', + source=['main.cpp', 'foo.cpp']) + diff --git a/src/execEx/03/foo.cpp b/src/execEx/03/foo.cpp new file mode 100644 index 0000000..8836de5 --- /dev/null +++ b/src/execEx/03/foo.cpp @@ -0,0 +1,8 @@ + +#include "foo.hpp" + +int +foo() +{ + return 32; +} diff --git a/src/execEx/03/foo.hpp b/src/execEx/03/foo.hpp new file mode 100644 index 0000000..132602a --- /dev/null +++ b/src/execEx/03/foo.hpp @@ -0,0 +1,6 @@ +#ifndef SRC_EXECEX_02_FOO_HPP_ +#define SRC_EXECEX_02_FOO_HPP_ + +int foo(); + +#endif // SRC_EXECEX_02_FOO_HPP_ diff --git a/src/execEx/03/main.cpp b/src/execEx/03/main.cpp new file mode 100644 index 0000000..f8b2c0b --- /dev/null +++ b/src/execEx/03/main.cpp @@ -0,0 +1,12 @@ + +#include "foo.hpp" + +#include + +int +main() +{ + std::cout << "foo = " << foo() << std::endl; + + return 0; +}