Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
coder137 merged 79 commits intomainfromupdate_lowlevel_examples
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
79 commits
Select commitHold shift + click to select a range
5a4dcbd
Update build.cpp
coder137Jan 1, 2022
96e95e6
Update build.cpp
coder137Jan 1, 2022
0cadf2c
Update build.cpp
coder137Jan 1, 2022
d755923
Added examples docs
coder137Jan 1, 2022
1b0e08a
Updated examples
coder137Jan 1, 2022
670756f
Update build.cpp
coder137Jan 1, 2022
2ca6a7b
Update build.cpp
coder137Jan 1, 2022
db3b447
Update build.cpp
coder137Jan 1, 2022
3e6798c
Update msvc.rst
coder137Jan 1, 2022
1f25ec6
Update msvc.rst
coder137Jan 1, 2022
1057475
Added GetDllPath API
coder137Jan 1, 2022
89cfee7
Update build.cpp
coder137Jan 1, 2022
d1134eb
Update msvc.rst
coder137Jan 1, 2022
d58af01
Update msvc.rst
coder137Jan 1, 2022
45aa7f1
Update build.cpp
coder137Jan 1, 2022
d8bbff1
Update msvc.rst
coder137Jan 1, 2022
4e9a1fb
Update build.cpp
coder137Jan 1, 2022
05eff6d
Update build.cpp
coder137Jan 1, 2022
0335c6e
Update msvc.rst
coder137Jan 1, 2022
813e2f8
Update msvc.rst
coder137Jan 1, 2022
e1768a3
Update testing.rst
coder137Jan 1, 2022
abf56bd
Update gcc.rst
coder137Jan 1, 2022
2bc150c
Update build.cpp
coder137Jan 1, 2022
0a1a4c5
Update build.cpp
coder137Jan 1, 2022
4da93c4
Update gcc.rst
coder137Jan 1, 2022
60b4d59
Update gcc.rst
coder137Jan 1, 2022
d8d9c60
Update build.cpp
coder137Jan 1, 2022
0fb467f
Update gcc.rst
coder137Jan 1, 2022
9c6f49e
Update msvc.rst
coder137Jan 1, 2022
80623cd
Update build.cpp
coder137Jan 1, 2022
1300356
Update gcc.rst
coder137Jan 1, 2022
ba714e1
Update build.cpp
coder137Jan 1, 2022
ff34aab
Update msvc.rst
coder137Jan 1, 2022
4021c43
Update gcc.rst
coder137Jan 1, 2022
f202585
Update gcc.rst
coder137Jan 1, 2022
e80298b
Update build.cpp
coder137Jan 1, 2022
08407af
Update build.cpp
coder137Jan 1, 2022
3afe812
Update build.cpp
coder137Jan 1, 2022
bb3c1b1
Update build.cpp
coder137Jan 1, 2022
b32c490
Update gcc.rst
coder137Jan 1, 2022
11b6343
Update gcc.rst
coder137Jan 1, 2022
db73502
Update gcc.rst
coder137Jan 1, 2022
4b065aa
Update gcc.rst
coder137Jan 1, 2022
0b93652
Update build.cpp
coder137Jan 1, 2022
ef1216e
Update gcc.rst
coder137Jan 1, 2022
2e5e7c8
Update gcc.rst
coder137Jan 1, 2022
391201e
Update build.cpp
coder137Jan 1, 2022
d38b037
Added clang and mingw compilers
coder137Jan 1, 2022
c943363
Update hybrid.rst
coder137Jan 1, 2022
58ce6ed
Update hybrid.rst
coder137Jan 1, 2022
66d521e
Update hybrid.rst
coder137Jan 1, 2022
370d801
Update hybrid.rst
coder137Jan 2, 2022
588fd94
Update hybrid.rst
coder137Jan 2, 2022
8c91d71
Update hybrid.rst
coder137Jan 2, 2022
ad1c946
Update build.cpp
coder137Jan 2, 2022
25b4bc0
Update build.cpp
coder137Jan 2, 2022
5ab2231
Update build.cpp
coder137Jan 2, 2022
f07032b
Update hybrid.rst
coder137Jan 2, 2022
166688a
Update hybrid.rst
coder137Jan 2, 2022
cce61fc
Update build.main.cpp
coder137Jan 2, 2022
8bdc061
Renamed base::Target to BaseTarget
coder137Jan 2, 2022
740103b
Update hybrid.rst
coder137Jan 2, 2022
188fb94
Update hybrid.rst
coder137Jan 2, 2022
40c2155
Update hybrid.rst
coder137Jan 2, 2022
1c34dc2
Update build.main.cpp
coder137Jan 2, 2022
bb70f01
Update hybrid.rst
coder137Jan 2, 2022
311dd4b
Update build.main.cpp
coder137Jan 2, 2022
4b31bb9
Update hybrid.rst
coder137Jan 2, 2022
32aea5d
Update hybrid.rst
coder137Jan 2, 2022
f94ee98
Update hybrid.rst
coder137Jan 2, 2022
7a6dfe9
Update hybrid.rst
coder137Jan 2, 2022
7f24638
Update build.cpp
coder137Jan 2, 2022
c70bd4a
Update hybrid.rst
coder137Jan 2, 2022
b8cd6a9
Update build.cpp
coder137Jan 2, 2022
ae0d2a3
Update hybrid.rst
coder137Jan 2, 2022
64985fe
Update build.cpp
coder137Jan 2, 2022
b7cdd4b
Update hybrid.rst
coder137Jan 3, 2022
d09d0c9
Update hybrid.rst
coder137Jan 3, 2022
79577b9
Update hybrid.rst
coder137Jan 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletionbuildcc/targets/include/targets/target_msvc.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -126,9 +126,15 @@ class DynamicTarget_msvc : public BaseTarget {
DynamicTarget_msvc(const std::string &name, const BaseToolchain &toolchain,
const TargetEnv &env,
const TargetConfig &config = MsvcConfig::DynamicLib())
: Target(name, TargetType::DynamicLibrary, toolchain, env, config) {
: Target(name, TargetType::DynamicLibrary, toolchain, env, config),
dll_(fmt::format("{}.dll", GetTargetPath().string())) {
DefaultMsvcOptions(*this);
}

const fs::path &GetDllPath() { return dll_; }

private:
fs::path dll_;
};

} // namespace buildcc
Expand Down
2 changes: 1 addition & 1 deletiondocs/source/arch/testing.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -143,4 +143,4 @@ args
plugins
^^^^^^^^

.. note: Incomplete implementation and tests
.. note:: Incomplete implementation and tests
4 changes: 4 additions & 0 deletionsdocs/source/examples/clang.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
Clang
======

Lowlevel Clang Tests
268 changes: 268 additions & 0 deletionsdocs/source/examples/gcc.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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
Loading

[8]ページ先頭

©2009-2025 Movatter.jp