Skip to content

Commit

Permalink
Remove some glitches to prepare nice pull request
Browse files Browse the repository at this point in the history
Some changes got into this branch by accident. This patch undos
them in order to have a pull request which cares only about the
experimental/non-experimental namespace/include problem.
  • Loading branch information
andreasbuhr committed Oct 10, 2020
1 parent 75fbc10 commit 48a7b99
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 91 deletions.
68 changes: 2 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2859,20 +2859,18 @@ Given a type, `S`, that implements the `DelayedScheduler` and an instance, `s` o

The cppcoro library supports building under Windows with Visual Studio 2017 and Linux with Clang 5.0+.

This library makes use of either the [Cake build system](https://github.com/lewissbaker/cake) (no, not the [C# one](http://cakebuild.net/)) or CMake.
This library makes use of the [Cake build system](https://github.com/lewissbaker/cake) (no, not the [C# one](http://cakebuild.net/)).

The cake build system is checked out automatically as a git submodule so you don't need to download or install it separately.

## Building on Windows

This library currently requires Visual Studio 2017 or later and the Windows 10 SDK.

Support for Linux ([#15](https://github.com/lewissbaker/cppcoro/issues/15)) is planned.
Support for Clang ([#3](https://github.com/lewissbaker/cppcoro/issues/3)) and Linux ([#15](https://github.com/lewissbaker/cppcoro/issues/15)) is planned.

### Prerequisites

The CMakeLists requires version 3.13 or later.

The Cake build-system is implemented in Python and requires Python 2.7 to be installed.

Ensure Python 2.7 interpreter is in your PATH and available as 'python'.
Expand Down Expand Up @@ -2905,68 +2903,6 @@ c:\Code\cppcoro> git submodule update --init --recursive

### Building from the command-line

#### With CMake

Cppcoro follows the usual CMake workflow with no custom options added. Notable [standard CMake options](https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html):

| Flag | Description | Default Value |
|----------------------|------------------------------|------------------------|
| BUILD_TESTING | Build the unit tests | ON |
| BUILD_SHARED_LIBS | Build as a shared library | OFF |
| CMAKE_BUILD_TYPE | Build as `Debug`/`Release` | <empty> |
| CMAKE_INSTALL_PREFIX | Where to install the library | `/usr/local` (on Unix) |

CMake also respects the [conventional environment variables](https://cmake.org/cmake/help/latest/manual/cmake-env-variables.7.html):

| Environment Variable | Description |
|----------------------|-------------------------------|
| CXX | Path to the C++ compiler |
| CXXFLAGS | C++ compiler flags to prepend |
| LDFLAGS | Linker flags to prepend |

Example:

```bash
cd <this/repo>
mkdir build
cd build
export CXX=clang++
export CXXFLAGS="-stdlib=libc++ -march=native"
export LDFLAGS="-stdlib=libc++ -fuse-ld=lld -Wl,--gdb-index"
cmake .. [-GNinja] -DCMAKE_INSTALL_PREFIX=$HOME/.local -DBUILD_SHARED_LIBS=ON
ninja # or make -jN
ninja test # Run the tests
ninja install
```

The CMake build scripts will also install a `cppcoroConfig.cmake` file for consumers to use.
It will check at the consumer site that coroutines are indeed supported by the system and enable the appropriate compiler flag for Clang or MSVC, respectively.
Assuming cppcoro has been installed to `$HOME/.local` like in the example above it can be consumed like this:

```cmake
find_package(cppcoro REQUIRED)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE cppcoro::cppcoro)
```

```bash
$ cmake . -Dcppcoro_ROOT=$HOME/.local
# ...
-- Performing Test Coroutines_SUPPORTS_MS_FLAG
-- Performing Test Coroutines_SUPPORTS_MS_FLAG - Failed
-- Performing Test Coroutines_SUPPORTS_GNU_FLAG
-- Performing Test Coroutines_SUPPORTS_GNU_FLAG - Success
-- Looking for C++ include coroutine
-- Looking for C++ include coroutine - not found
-- Looking for C++ include experimental/coroutine
-- Looking for C++ include experimental/coroutine - found
-- Configuring done
-- Generating done
# ...
```

#### With Cake

To build from the command-line just run 'cake.bat' in the workspace root.

eg.
Expand Down
6 changes: 0 additions & 6 deletions test/async_generator_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,6 @@ TEST_CASE("exception thrown after first yield is rethrown from increment operato
}());
}

#if (defined(__GNUC__) && !defined(__clang__))
#define GCC_COMPILER 1
#endif
// GCC 10.1 doesn't support "for co_await"
#ifndef GCC_COMPILER
TEST_CASE("large number of synchronous completions doesn't result in stack-overflow")
{

Expand Down Expand Up @@ -303,7 +298,6 @@ TEST_CASE("large number of synchronous completions doesn't result in stack-overf
consumer(makeSequence(event)),
unblocker(event)));
}
#endif // GCC_COMPILER

TEST_CASE("fmap")
{
Expand Down
10 changes: 4 additions & 6 deletions test/counted.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#ifndef CPPCORO_TESTS_COUNTED_HPP_INCLUDED
#define CPPCORO_TESTS_COUNTED_HPP_INCLUDED

#include <iostream>

struct counted
{
static int default_construction_count;
Expand Down Expand Up @@ -34,10 +32,10 @@ struct counted
return construction_count() - destruction_count;
}

counted() : id(default_construction_count++) { std::cout << "constructed" << std::endl; }
counted(const counted& other) : id(other.id) { ++copy_construction_count; std::cout << "copied" << std::endl; }
counted(counted&& other) : id(other.id) { ++move_construction_count; other.id = -1; std::cout << "moved" << std::endl; }
~counted() { ++destruction_count; std::cout <<"destructed" << std::endl; }
counted() : id(default_construction_count++) {}
counted(const counted& other) : id(other.id) { ++copy_construction_count; }
counted(counted&& other) : id(other.id) { ++move_construction_count; other.id = -1; }
~counted() { ++destruction_count; }

};

Expand Down
5 changes: 1 addition & 4 deletions test/recursive_generator_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,7 @@ namespace
{
while (start < end)
{
// GCC 10.1 workaround: "co_yield start++ always returns the same value, resulting in an infinite loop
// ((++start)-1) seems to have the same issue, while ++start works, but breaks the test
start++;
co_yield start-1;
co_yield start++;
}
}

Expand Down
2 changes: 0 additions & 2 deletions test/shared_task_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ TEST_CASE("waiting on shared_task in loop doesn't cause stack-overflow")
int result = 0;
for (int i = 0; i < 1'000'000; ++i)
{
// GCC 10.1 workaround: GCC doesn't generate any code for a for loop with only a co_await in it
[](){}();
result += co_await completesSynchronously();
}
CHECK(result == 1'000'000);
Expand Down
5 changes: 1 addition & 4 deletions test/task_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ TEST_CASE("passing parameter by value to task coroutine calls move-constructor e
auto t = f(c);

// Should have called copy-constructor to pass a copy of 'c' into f by value.
// GCC 10.1 performs 2 copies
CHECK(counted::copy_construction_count >= 1);
CHECK(counted::copy_construction_count == 1);

// Inside f it should have move-constructed parameter into coroutine frame variable
//WARN_MESSAGE(counted::move_construction_count == 1,
Expand Down Expand Up @@ -339,8 +338,6 @@ TEST_CASE("lots of synchronous completions doesn't result in stack-overflow")
int sum = 0;
for (int i = 0; i < 1'000'000; ++i)
{
// GCC 10.1 workaround: GCC doesn't generate any code for a for loop with only a co_await in it
[](){}();
sum += co_await completesSynchronously();
}
CHECK(sum == 1'000'000);
Expand Down
3 changes: 0 additions & 3 deletions test/when_all_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ TEST_CASE("when_all() with all task types")

CHECK(a == "foo");
CHECK(b.id == 0);
// GCC 10.1 fails this check: at this point there are 3 objects alive
// * One will be destructed later
// * One object is completely leaked
CHECK(counted::active_count() == 1);
};

Expand Down

0 comments on commit 48a7b99

Please sign in to comment.