- Notifications
You must be signed in to change notification settings - Fork3
Update lowlevel examples#177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
79 commits Select commitHold shift + click to select a range
5a4dcbd Update build.cpp
coder13796e95e6 Update build.cpp
coder1370cadf2c Update build.cpp
coder137d755923 Added examples docs
coder1371b0e08a Updated examples
coder137670756f Update build.cpp
coder1372ca6a7b Update build.cpp
coder137db3b447 Update build.cpp
coder1373e6798c Update msvc.rst
coder1371f25ec6 Update msvc.rst
coder1371057475 Added GetDllPath API
coder13789cfee7 Update build.cpp
coder137d1134eb Update msvc.rst
coder137d58af01 Update msvc.rst
coder13745aa7f1 Update build.cpp
coder137d8bbff1 Update msvc.rst
coder1374e9a1fb Update build.cpp
coder13705eff6d Update build.cpp
coder1370335c6e Update msvc.rst
coder137813e2f8 Update msvc.rst
coder137e1768a3 Update testing.rst
coder137abf56bd Update gcc.rst
coder1372bc150c Update build.cpp
coder1370a1a4c5 Update build.cpp
coder1374da93c4 Update gcc.rst
coder13760b4d59 Update gcc.rst
coder137d8d9c60 Update build.cpp
coder1370fb467f Update gcc.rst
coder1379c6f49e Update msvc.rst
coder13780623cd Update build.cpp
coder1371300356 Update gcc.rst
coder137ba714e1 Update build.cpp
coder137ff34aab Update msvc.rst
coder1374021c43 Update gcc.rst
coder137f202585 Update gcc.rst
coder137e80298b Update build.cpp
coder13708407af Update build.cpp
coder1373afe812 Update build.cpp
coder137bb3c1b1 Update build.cpp
coder137b32c490 Update gcc.rst
coder13711b6343 Update gcc.rst
coder137db73502 Update gcc.rst
coder1374b065aa Update gcc.rst
coder1370b93652 Update build.cpp
coder137ef1216e Update gcc.rst
coder1372e5e7c8 Update gcc.rst
coder137391201e Update build.cpp
coder137d38b037 Added clang and mingw compilers
coder137c943363 Update hybrid.rst
coder13758ce6ed Update hybrid.rst
coder13766d521e Update hybrid.rst
coder137370d801 Update hybrid.rst
coder137588fd94 Update hybrid.rst
coder1378c91d71 Update hybrid.rst
coder137ad1c946 Update build.cpp
coder13725b4bc0 Update build.cpp
coder1375ab2231 Update build.cpp
coder137f07032b Update hybrid.rst
coder137166688a Update hybrid.rst
coder137cce61fc Update build.main.cpp
coder1378bdc061 Renamed base::Target to BaseTarget
coder137740103b Update hybrid.rst
coder137188fb94 Update hybrid.rst
coder13740c2155 Update hybrid.rst
coder1371c34dc2 Update build.main.cpp
coder137bb70f01 Update hybrid.rst
coder137311dd4b Update build.main.cpp
coder1374b31bb9 Update hybrid.rst
coder13732aea5d Update hybrid.rst
coder137f94ee98 Update hybrid.rst
coder1377a6dfe9 Update hybrid.rst
coder1377f24638 Update build.cpp
coder137c70bd4a Update hybrid.rst
coder137b8cd6a9 Update build.cpp
coder137ae0d2a3 Update hybrid.rst
coder13764985fe Update build.cpp
coder137b7cdd4b Update hybrid.rst
coder137d09d0c9 Update hybrid.rst
coder13779577b9 Update hybrid.rst
coder137File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
8 changes: 7 additions & 1 deletionbuildcc/targets/include/targets/target_msvc.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletiondocs/source/arch/testing.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -143,4 +143,4 @@ args | ||
| plugins | ||
| ^^^^^^^^ | ||
| .. note:: Incomplete implementation and tests | ||
4 changes: 4 additions & 0 deletionsdocs/source/examples/clang.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Clang | ||
| ====== | ||
| Lowlevel Clang Tests |
268 changes: 268 additions & 0 deletionsdocs/source/examples/gcc.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,268 @@ | ||
| GCC | ||
| ==== | ||
| Lowlevel GCC Tests | ||
| Simple | ||
| -------- | ||
| Compile a single source | ||
| .. code-block:: cpp | ||
| :linenos: | ||
| :emphasize-lines: 8 | ||
| // GCC specialized toolchain | ||
| Toolchain_gcc toolchain; | ||
| // GCC specialized targets | ||
| // Create "Simple" target (meant to use the GCC compiler) | ||
| // On Windows the equivalent is the MinGW compiler | ||
| ExecutableTarget_gcc target("Simple", gcc, ""); | ||
| target.AddSource("main.cpp"); | ||
| target.Build(); | ||
| // Build | ||
| tf::Executor executor; | ||
| executor.run(target.GetTaskflow()); | ||
| executor.wait_for_all(); | ||
| IncludeDir | ||
| ---------- | ||
| Compile multiple sources with header files | ||
| .. code-block:: cpp | ||
| :linenos: | ||
| :emphasize-lines: 12,15 | ||
| // GCC specialized toolchain | ||
| Toolchain_gcc toolchain; | ||
| // GCC specialized targets | ||
| // Create "IncludeDir" target (meant to use the GCC compiler) | ||
| // On Windows the equivalent is the MinGW compiler | ||
| ExecutableTarget_gcc target("IncludeDir", gcc, "files"); | ||
| target.AddSource("main.cpp", "src"); | ||
| target.AddSource("src/random.cpp"); | ||
| // Track header for rebuilds | ||
| target.AddHeader("include/random.h"); | ||
| // Add include dir to search paths | ||
| target.AddIncludeDir("include"); | ||
| target.Build(); | ||
| // Build | ||
| tf::Executor executor; | ||
| executor.run(target.GetTaskflow()); | ||
| executor.wait_for_all(); | ||
| StaticLib | ||
| ---------- | ||
| Compile a static library which is used by an executable | ||
| .. code-block:: cpp | ||
| :linenos: | ||
| :emphasize-lines: 7 | ||
| // GCC specialized toolchain | ||
| Toolchain_gcc toolchain; | ||
| // GCC specialized targets | ||
| // Create "librandom.a" target (meant to use the GCC compiler) | ||
| // On Windows the equivalent is the MinGW compiler | ||
| StaticTarget_gcc statictarget("librandom", gcc, "files"); | ||
| statictarget.AddSource("src/random.cpp"); | ||
| statictarget.AddHeader("include/random.h"); | ||
| statictarget.AddIncludeDir("include"); | ||
| statictarget.Build(); | ||
| // GCC specialized targets | ||
| // Create "statictest" target (meant to use the GCC compiler) | ||
| // On Windows the equivalent is the MinGW compiler | ||
| ExecutableTarget_gcc exetarget("statictest", gcc, "files"); | ||
| exetarget.AddSource("main.cpp", "src"); | ||
| exetarget.AddIncludeDir("include"); | ||
| exetarget.AddLibDep(statictarget); | ||
| exetarget.Build(); | ||
| // Build | ||
| tf::Executor executor; | ||
| tf::Taskflow taskflow; | ||
| // Explicitly setup your dependencies | ||
| tf::Task statictargetTask = taskflow.composed_of(statictarget.GetTaskflow()); | ||
| tf::Task exetargetTask = taskflow.composed_of(exetarget.GetTaskflow()); | ||
| exetargetTask.succeed(statictargetTask); | ||
| // Run | ||
| executor.run(taskflow); | ||
| executor.wait_for_all(); | ||
| DynamicLib | ||
| ----------- | ||
| Compile a dynamic library which is used by an executable | ||
| .. code-block:: cpp | ||
| :linenos: | ||
| :emphasize-lines: 7 | ||
| // GCC specialized toolchain | ||
| Toolchain_gcc toolchain; | ||
| // GCC specialized targets | ||
| // Create "librandom.so" target (meant to use the GCC compiler) | ||
| // On Windows the equivalent is the MinGW compiler | ||
| DynamicTarget_gcc dynamictarget("librandom", gcc, "files"); | ||
| dynamictarget.AddSource("src/random.cpp"); | ||
| dynamictarget.AddHeader("include/random.h"); | ||
| dynamictarget.AddIncludeDir("include"); | ||
| dynamictarget.Build(); | ||
| // GCC specialized targets | ||
| // Create "dynamictest" target (meant to use the GCC compiler) | ||
| // On Windows the equivalent is the MinGW compiler | ||
| ExecutableTarget_gcc target("dynamictest", gcc, "files"); | ||
| target.AddSource("main.cpp", "src"); | ||
| target.AddIncludeDir("include"); | ||
| target.AddLibDep(dynamictarget); | ||
| target.Build(); | ||
| // Build | ||
| tf::Executor executor; | ||
| tf::Taskflow taskflow; | ||
| // Explicitly setup your dependencies | ||
| auto dynamictargetTask = taskflow.composed_of(dynamictarget.GetTaskflow()); | ||
| auto targetTask = taskflow.composed_of(target.GetTaskflow()); | ||
| targetTask.succeed(dynamictargetTask); | ||
| executor.run(taskflow); | ||
| executor.wait_for_all(); | ||
| // Post Build step | ||
| if (target.IsBuilt()) { | ||
| fs::path copy_to_path = | ||
| target.GetTargetBuildDir() / dynamictarget.GetTargetPath().filename(); | ||
| fs::copy(dynamictarget.GetTargetPath(), copy_to_path); | ||
| } | ||
| .. note:: Our ``ExecutableTarget_gcc`` depends on ``DynamicTarget_gcc`` and requires the ``librandom.so`` file to be present in the same folder location as the executable when running. | ||
| Flags | ||
| ------ | ||
| Using **PreprocessorFlags**, **C Compile flags**, **Cpp Compile flags** and **Link flags** | ||
| .. code-block:: cpp | ||
| :linenos: | ||
| :emphasize-lines: 12,13,14,15,23,24,25,26 | ||
| // GCC specialized toolchain | ||
| Toolchain_gcc toolchain; | ||
| // GCC specialized targets | ||
| // Create "CppFlags" target (meant to use the GCC compiler) | ||
| // On Windows the equivalent is the MinGW compiler | ||
| ExecutableTarget_gcc cpptarget("CppFlags", gcc, "files"); | ||
| cpptarget.AddSource("main.cpp", "src"); | ||
| cpptarget.AddSource("src/random.cpp"); | ||
| cpptarget.AddHeader("include/random.h"); | ||
| cpptarget.AddIncludeDir("include"); | ||
| cpptarget.AddPreprocessorFlag("-DRANDOM=1"); | ||
| cpptarget.AddCppCompileFlag("-Wall"); | ||
| cpptarget.AddCppCompileFlag("-Werror"); | ||
| cpptarget.AddLinkFlag("-lm"); | ||
| cpptarget.Build(); | ||
| // Gcc specialized targets | ||
| // Create "CFlags" target (meant to use the GCC compiler) | ||
| // On Windows the equivalent is the MinGW compiler | ||
| ExecutableTarget_gcc ctarget("CFlags", gcc, "files"); | ||
| ctarget.AddSource("main.c", "src"); | ||
| ctarget.AddPreprocessorFlag("-DRANDOM=1"); | ||
| ctarget.AddCCompileFlag("-Wall"); | ||
| ctarget.AddCCompileFlag("-Werror"); | ||
| ctarget.AddLinkFlag("-lm"); | ||
| ctarget.Build(); | ||
| // Build | ||
| tf::Executor executor; | ||
| tf::Taskflow taskflow; | ||
| // There isn't any dependency between the 2 targets | ||
| taskflow.composed_of(cpptarget.GetTaskflow()); | ||
| taskflow.composed_of(ctarget.GetTaskflow()); | ||
| executor.run(taskflow); | ||
| executor.wait_for_all(); | ||
| AfterInstall | ||
| ------------- | ||
| Use BuildCC with CMake | ||
| * Install ``BuildCC`` via CMake to your system and add it to **PATH** | ||
| * Use the script below to **compile** your build script to an executable | ||
| * Copy the **Flags** build example | ||
| * Run the executable from your project root directory | ||
| .. code-block:: cmake | ||
| # Package dependencies | ||
| # fmt is imported by spdlog by default | ||
| find_package(fmt_package NAMES "fmt" REQUIRED) | ||
| find_package(spdlog_package NAMES "spdlog" REQUIRED) | ||
| find_package(flatbuffers_header_only_package NAMES "flatbuffers_header_only" REQUIRED) | ||
| find_package(taskflow_package NAMES "Taskflow" "taskflow" REQUIRED) | ||
| find_package(CLI11_package NAMES "CLI11" REQUIRED) | ||
| find_package(tiny_process_library_package NAMES "tiny-process-library" REQUIRED) | ||
| find_package(buildcc_package NAMES "buildcc" REQUIRED) | ||
| message("Find package: ${fmt_package_DIR}") | ||
| message("Find package: ${spdlog_package_DIR}") | ||
| message("Find package: ${flatbuffers_header_only_package_DIR}") | ||
| message("Find package: ${taskflow_package_DIR}") | ||
| message("Find package: ${CLI11_package_DIR}") | ||
| message("Find package: ${tiny_process_library_package_DIR}") # | ||
| message("Find package: ${buildcc_package_DIR}") | ||
| # build executable | ||
| add_executable(build build.cpp) | ||
| target_include_directories(build PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated) | ||
| target_link_libraries(build PRIVATE | ||
| buildcc | ||
| ) | ||
| if (${MINGW}) | ||
| message(WARNING "-Wl,--allow-multiple-definition for MINGW") | ||
| target_link_options(build PRIVATE -Wl,--allow-multiple-definition) | ||
| endif() | ||
| # Add your constants file for the environment | ||
| configure_file(constants.h.in ${CMAKE_BINARY_DIR}/generated/constants.h @ONLY) | ||
| Plugins | ||
| -------- | ||
| Demonstrating BuildCC supported plugin usage | ||
| * From the **Flags** example above | ||
| * Add the targets for which you would like to generate the `Clang CompileCommands Database <https://clang.llvm.org/docs/JSONCompilationDatabase.html>`_ | ||
| .. code-block:: cpp | ||
| :linenos: | ||
| plugin::ClangCompileCommands({&cppflags, &cflags}).Generate(); | ||
| PrecompileHeader | ||
| ---------------- | ||
| TODO |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.