Skip to content

Commit

Permalink
add more example script for building example
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Oct 7, 2018
1 parent 3f38d5d commit 6108d30
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 18 deletions.
63 changes: 46 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ libcopp

Cross-platform coroutine library in C++ .

| | [Linux+OSX(Clang+GCC)][linux-link] | [Windows(VC+MinGW)][windows-link] | [Coveralls][coverage-link] |
|:---------------:|:----------------------------------:|:---------------------------------:|:-----------------------------------:|
Build & Unit Test | ![linux-badge] | ![windows-badge] | ![coverage-badge] |
| Compilers | linux-gcc-4.4 <br /> linux-gcc-4.6 <br /> linux-gcc-4.9 <br /> linux-gcc-8 <br /> macos-apple-clang-6.0 <br /> | MSVC 12(Visual Studio 2013) <br /> MSVC 14(Visual Studio 2015) <br /> MSVC 15(Visual Studio 2017) <br /> MinGW64-gcc | |
| | [Linux+OSX(Clang+GCC)][linux-link] | [Windows(VC+MinGW)][windows-link] | [Coveralls][coverage-link] |
| :---------------: | :------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------: | :------------------------: |
| Build & Unit Test | ![linux-badge] | ![windows-badge] | ![coverage-badge] |
| Compilers | linux-gcc-4.4 <br /> linux-gcc-4.6 <br /> linux-gcc-4.9 <br /> linux-gcc-8 <br /> macos-apple-clang-6.0 <br /> | MSVC 12(Visual Studio 2013) <br /> MSVC 14(Visual Studio 2015) <br /> MSVC 15(Visual Studio 2017) <br /> MinGW64-gcc | |

[Gitter][gitter-link]: ![gitter-badge]

Expand Down Expand Up @@ -92,23 +92,52 @@ cmake --build . --config RelWithDebInfo --target install # or make install when
### CMake Options
Options can be cmake options. such as set compile toolchains, source directory or options of libcopp that control build actions. libcopp options are listed below:

| Option | Description |
|---------|-------------|
BUILD\_SHARED\_LIBS=YES\|NO | [default=NO] Build dynamic library.
LIBCOPP\_ENABLE\_SEGMENTED\_STACKS=YES\|NO | [default=NO] Enable split stack supported context.(it's only availabe in linux and gcc 4.7.0 or upper)
LIBCOPP\_ENABLE\_VALGRIND=YES\|NO | [default=YES] Enable valgrind supported context.
PROJECT\_ENABLE\_UNITTEST=YES\|NO | [default=NO] Build unit test.
PROJECT\_ENABLE\_SAMPLE=YES\|NO | [default=NO] Build samples.
PROJECT\_DISABLE\_MT=YES\|NO | [default=NO] Disable multi-thread support.
LIBCOTASK\_ENABLE=YES\|NO | [default=YES] Enable build libcotask.
LIBCOPP\_FCONTEXT\_USE\_TSX=YES\|NO | [default=NO] Enable [Intel Transactional Synchronisation Extensions (TSX)](https://software.intel.com/en-us/node/695149).
GTEST\_ROOT=[path] | set gtest library install prefix path
BOOST\_ROOT=[path] | set Boost.Test library install prefix path
| Option | Description |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| BUILD\_SHARED\_LIBS=YES\|NO | [default=NO] Build dynamic library. |
| LIBCOPP\_ENABLE\_SEGMENTED\_STACKS=YES\|NO | [default=NO] Enable split stack supported context.(it's only availabe in linux and gcc 4.7.0 or upper) |
| LIBCOPP\_ENABLE\_VALGRIND=YES\|NO | [default=YES] Enable valgrind supported context. |
| PROJECT\_ENABLE\_UNITTEST=YES\|NO | [default=NO] Build unit test. |
| PROJECT\_ENABLE\_SAMPLE=YES\|NO | [default=NO] Build samples. |
| PROJECT\_DISABLE\_MT=YES\|NO | [default=NO] Disable multi-thread support. |
| LIBCOTASK\_ENABLE=YES\|NO | [default=YES] Enable build libcotask. |
| LIBCOPP\_FCONTEXT\_USE\_TSX=YES\|NO | [default=NO] Enable [Intel Transactional Synchronisation Extensions (TSX)](https://software.intel.com/en-us/node/695149). |
| GTEST\_ROOT=[path] | set gtest library install prefix path |
| BOOST\_ROOT=[path] | set Boost.Test library install prefix path |

USAGE
=====

> Just include headers and linking library file of your platform to use libcopp
Just include headers and linking library file of your platform to use libcopp.

```bash
LIBCOPP_PREFIX=<WHERE TO INSTALL libcopp>

# Example command for build sample with gcc 4.9 or upper on Linux
for source in sample_readme_*.cpp; do
g++ -std=c++14 -O2 -g -ggdb -Wall -Werror -fPIC -rdynamic -fdiagnostics-color=auto -Wno-unused-local-typedefs \
-I$LIBCOPP_PREFIX/include -L$LIBCOPP_PREFIX/lib -lcopp -lcotask $source -o $source.exe;
done

# Example command for build sample with clang 3.9 or upper and libc++ on Linux
for source in sample_readme_*.cpp; do
clang++ -std=c++17 -stdlib=libc++ -O2 -g -ggdb -Wall -Werror -fPIC -rdynamic \
-I$LIBCOPP_PREFIX/include -L$LIBCOPP_PREFIX/lib -lcopp -lcotask -lc++ -lc++abi \
$source -o $source.exe;
done

# AppleClang on macOS just like those scripts upper.
# If you are using MinGW on Windows, it's better to add -static-libstdc++ -static-libgcc to
# use static linking and other scripts are just like those on Linux.

```

```powershell
# Example command for build sample with MSVC 1914 or upper on Windows & powershell(Debug Mode /MDd)
foreach ($source in Get-ChildItem -File -Name .\sample_readme_*.cpp) {
cl /nologo /MP /W4 /wd"4100" /wd"4125" /EHsc /std:c++17 /Zc:__cplusplus /O2 /MDd /I$LIBCOPP_PREFIX/include $LIBCOPP_PREFIX/lib64/copp.lib $LIBCOPP_PREFIX/lib64/cotask.lib $source
}
```

Get Start & Example
-------
Expand Down
31 changes: 30 additions & 1 deletion docs/md/020_USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,36 @@
USAGE
=====

> Just include headers and linking library file of your platform to use libcopp
Just include headers and linking library file of your platform to use libcopp.

```bash
LIBCOPP_PREFIX=<WHERE TO INSTALL libcopp>

# Example command for build sample with gcc 4.9 or upper on Linux
for source in sample_readme_*.cpp; do
g++ -std=c++14 -O2 -g -ggdb -Wall -Werror -fPIC -rdynamic -fdiagnostics-color=auto -Wno-unused-local-typedefs \
-I$LIBCOPP_PREFIX/include -L$LIBCOPP_PREFIX/lib -lcopp -lcotask $source -o $source.exe;
done

# Example command for build sample with clang 3.9 or upper and libc++ on Linux
for source in sample_readme_*.cpp; do
clang++ -std=c++17 -stdlib=libc++ -O2 -g -ggdb -Wall -Werror -fPIC -rdynamic \
-I$LIBCOPP_PREFIX/include -L$LIBCOPP_PREFIX/lib -lcopp -lcotask -lc++ -lc++abi \
$source -o $source.exe;
done

# AppleClang on macOS just like those scripts upper.
# If you are using MinGW on Windows, it's better to add -static-libstdc++ -static-libgcc to
# use static linking and other scripts are just like those on Linux.

```

```powershell
# Example command for build sample with MSVC 1914 or upper on Windows & powershell(Debug Mode /MDd)
foreach ($source in Get-ChildItem -File -Name .\sample_readme_*.cpp) {
cl /nologo /MP /W4 /wd"4100" /wd"4125" /EHsc /std:c++17 /Zc:__cplusplus /O2 /MDd /I$LIBCOPP_PREFIX/include $LIBCOPP_PREFIX/lib64/copp.lib $LIBCOPP_PREFIX/lib64/cotask.lib $source
}
```

Get Start & Example
-------
Expand Down

0 comments on commit 6108d30

Please sign in to comment.