Skip to content

Commit

Permalink
Merge pull request #66 from alesiong/devel
Browse files Browse the repository at this point in the history
Refine some release generation
  • Loading branch information
Yexiaoxing authored May 12, 2017
2 parents daceb16 + 9b3cac3 commit 94b84b1
Show file tree
Hide file tree
Showing 13 changed files with 422 additions and 62 deletions.
78 changes: 40 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,62 +38,64 @@ compiler:
script:
- mkdir build && cd build
- cmake .. -DTESTING=1 -DSAMPLES=0 -DCMAKE_BUILD_TYPE=Debug
- make -j
- make -j4
- CTEST_OUTPUT_ON_FAILURE=1 make test
notifications:
email: false
sudo: false

after_success: |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
if [[ "$CXX" == "g++-4.9" ]]; then
if [[ ( $TRAVIS_OS_NAME = linux ) && ( $CXX = g++-4.9 ) ]]; then
cd $TRAVIS_BUILD_DIR
chmod +x generateDocument.sh
./generateDocument.sh
touch docs/.nojekyll
fi
fi
if [[ "$CXX" == "g++-4.9" ]]; then
CC="gcc"
fi
if [[ "$CXX" = "clang++-3.7" ]]; then
CC="clang"
fi
cd $TRAVIS_BUILD_DIR/build
OS_NAME=$TRAVIS_OS_NAME
if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
OS_NAME=macos
fi
if [ $TRAVIS_TAG ]; then
mkdir release && cd release
cmake ../.. -DTESTING=0 -DCMAKE_BUILD_TYPE=Release
make -j
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
cp -r ../../src/include ./include
tar -czvf linux-$CC.tar.gz libcuhkszlib.a include
else
tar -cvf macos.tar libcuhkszlib.a
cd ../../src
tar -rvf ../build/release/macos.tar include
cd ../build/release
tar -cvzf macos-$CC.tar.gz @macos.tar
make -j4
if [[ "$CXX" == "g++-4.9" ]]; then
CC="gcc"
fi
if [[ "$CXX" = "clang++-3.7" ]]; then
CC="clang"
fi
cp -r ../../src/include ./include
mkdir lib
mv libcuhkszlib.a lib/libcuhkszlib.a
tar -czvf $OS_NAME-$CC.tar.gz lib include
if [[ (( $TRAVIS_OS_NAME = linux ) && ( $CXX = g++-4.9 )) || (( $TRAVIS_OS_NAME = osx ) && ( $CXX = clang++ ))]]; then
rm -rf samples/*.cmake
rm -rf samples/Makefile
rm -rf samples/CMakeFiles
tar -czvf $OS_NAME-samples.tar.gz samples/*
fi
fi
deploy:
provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
on:
branch:
master
condition: " (( $TRAVIS_OS_NAME = linux ) && ( $CXX = g++-4.9 ) && ($GITHUB_TOKEN)) "
local_dir: $TRAVIS_BUILD_DIR/docs
- provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
on:
branch:
master
condition: " (( $TRAVIS_OS_NAME = linux ) && ( $CXX = g++-4.9 ) && ($GITHUB_TOKEN)) "
local_dir: $TRAVIS_BUILD_DIR/docs

deploy:
skip_cleanup: true
api_key: $RELEASE_TOKEN
provider: releases
file_glob: true
file: "*.tar.gz"
on:
all_branches: true
condition: " ($TRAVIS_TAG) "
tag: true
- provider: releases
skip_cleanup: true
api_key: $RELEASE_TOKEN
file_glob: true
file: "*.tar.gz"
on:
all_branches: true
condition: " ($TRAVIS_TAG) "
tag: true
78 changes: 65 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,92 @@
[![Build status](https://ci.appveyor.com/api/projects/status/634a6wrw9xheiu0e/branch/master?svg=true)](https://ci.appveyor.com/project/alesiong/cuhkszlib-cmxvy/branch/master)

## Requirements
1. cmake >= 2.8
### macOS and Linux
1. cmake (>= 2.8)
2. make
3. gcc/clang/msvc(2015+)
3. gcc/clang (need to have full C++11 support)

### Windows
1. cmake (>= 2.8)
2. Visual Studio (>= 2015) with C++ component OR
3. MSYS2

## Usage
### Compile
### Build

#### macOS and Linux
First clone the repository:
1. Clone the repository:
```
git clone --recursive https://github.com/cuhkshenzhen/CUHKSZLib.git
```
Then configure and compile:
2. Configure and compile:
```
cd CUHKSZLib
mkdir build && cd build
cmake ..
make -j4
```
Add `-DCMAKE_BUILD_TYPE=Debug` or `-DCMAKE_BUILD_TYPE=Release` flags to `cmake` to specify the build type, `-DSAMPLES=0` to disable building samples, `-DTESTING=1` to enable building tests.
3. `libcuhkszlib.a` in the `build` directory is the library file

#### Windows (MSVC)
1. Download and install `cmake` from https://cmake.org/download/, make sure to choose the windows installer.
2. Make sure you have installed the Visual Studio with C++ component and it works.
3. Clone or download this repository
4. Open Cmake GUI, choose this repository as source and `CUHKSZLib/build` as build. (TODO: details and pics to be added)
5. Click `Configure`, and then click `Open Project`
6. Build with Visual Studio.
3. Download and install `git` from https://git-scm.com/downloads/, make sure to choose "Use Git from the Windows Command Prompt" during installation.
4. Clone the repository in command prompt with
```
git clone --recursive https://github.com/cuhkshenzhen/CUHKSZLib.git
```
5. Open Cmake GUI, choose this repository as source and `CUHKSZLib/build` as build. (TODO: details and pics to be added)
6. Click `Configure`, and then click `Open Project`
7. Build with Visual Studio.
8. Get the library file in the `build/Debug` or `build/Release` directory.

#### Windows (MSYS2)
1. Open "MSYS2 MinGW 64-bit" shell
2. Install the dependencies with
```
pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake git
```
3. Clone the repository
```
git clone --recursive https://github.com/cuhkshenzhen/CUHKSZLib.git
```
4. Configure and compile:
```
cd CUHKSZLib
mkdir build && cd build
cmake .. -G "MSYS Makefiles" -DCMAKE_MAKE_PROGRAM=mingw32-make
mingw32-make -j4
```
Add `-DCMAKE_BUILD_TYPE=Debug` or `-DCMAKE_BUILD_TYPE=Release` flags to `cmake` to specify the build type, `-DSAMPLES=0` to disable building samples, `-DTESTING=1` to enable building tests.
5. `libcuhkszlib.a` in the `build` directory is the library file

### Generate Documentation with Doxygen
#### macOS
1. Install brew
2. Run `brew install doxygen`
3. Make a directory called `docs`
3. Clone the repository
4. Run `doxygen Doxyfile` in the repository root.
5. Open `docs/index.html` with browser.

### Use with your code
The library file is the `build/libcuhkszlib.a`, and the include directory
is `src/include`. So add `src/include` into your inlcude path and `build/` to
your lib search path. And add `-lcuhkszlib` to your link flags.
The library file is `cuhkszlib.lib` if you use MSVC or `libcuhkszlib.a` otherwise, and the include directory is `src/include`.

You can also download our prebuilt library in the Release section on Github. The prebuilt package inclues library file in the `lib` directory and headers in the `include` directory. The MSVC versions are also shipped with a Visual Studio solution file.

If you are using IDEs other than Visual Studio, you can find the project file in `ide-project-files` directory. Currently we support CLion and Qt Creator. You need to copy the `ide-project-files/src` to your project directory.

For example, you are using Qt Creator with MinGW32 on Windows. You copy the contents of `ide-project-files/qt` directory to anywhere you like, say `my-project`. Then you also need to copy `ide-project-files/src` to `myproject` directory, so that `my-project` now has a `.pro` file and a `src` directory. Now you can download the prebuilt library: `windows-x86-mingw.zip` and unzip the contents to `my-project`.

## FAQ
1. Which prebuilt library should I choose?
> The release files are named as `os-(platform)-compiler`. So you need first to choose according to your operating system. Then if you are using windows, choose the platform(x86 for 32 bit and x64 for 64 bit) according to the **compiler** you use (not the system). (By the way, for macOS and Linux, all are for 64 bit) Finally of course, choose the compiler according to your compiler. A simple list:
| Environment | Package to use |
|-----------------------------|-----------------------|
| Linux (default) | linux-gcc |
| macOS (default) | macos-clang |
| Visual Studio 2015 on win32 | windows-x86-msvc-2015 |
| Visual Studio 2015 on win64 | windows-x64-msvc-2015 |
| Qt Creator with MinGW32 | windows-x86-mingw |
28 changes: 17 additions & 11 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ build:
build_script: |
cd build
if "%TOOLSET%"=="mingw" cmake --build . -- -j
if "%TOOLSET%"=="mingw" cmake --build . -- -j4
if "%APPVEYOR_REPO_TAG%"=="true" if NOT "%TOOLSET%"=="mingw" cmake --build . --config Release
if NOT "%TOOLSET%"=="mingw" cmake --build . --config Debug
Expand All @@ -87,26 +87,32 @@ test_script:
after_build:
- ps: |
if ($env:TOOLSET -eq "mingw")
{
if ($env:TOOLSET -eq "mingw") {
mkdir lib
if ($env:appveyor_repo_tag -eq "true") {
mkdir release
cd release
cmake -G "$generator" ../.. -DTESTING=0 -DCMAKE_BUILD_TYPE=Release
cmd /C 'cmake --build . -- -j'
cmd /C 'cmake --build . -- -j4'
cp libcuhkszlib.a ..\lib
cd ..
7z a -tzip windows-$env:PLATFORM-mingw.zip ..\build\release\libcuhkszlib.a ..\src\include
} else {
7z a -tzip windows-$env:PLATFORM-mingw.zip ..\build\libcuhkszlib.a ..\src\include
cp libcuhkszlib.a ..\lib
}
}
else
{
7z a -tzip windows-$env:PLATFORM-mingw.zip ..\build\lib ..\src\include
} else {
mkdir lib
if ($env:appveyor_repo_tag -eq "true") {
7z a -tzip windows-$env:PLATFORM-msvc-$env:TOOLSET.zip ..\build\Debug ..\build\Release ..\src\include
cp -r ..\build\Debug lib
cp -r ..\build\Release lib
if ($env:Toolset -eq "2017") {
cp ..\build\samples\EnglishWords.txt ..\build\samples\Release
7z a -tzip windows-$env:PLATFORM-samples.zip ..\build\samples\Release\*
}
} else {
7z a -tzip windows-$env:PLATFORM-msvc-$env:TOOLSET.zip ..\build\Debug ..\src\include
cp -r ..\build\Debug lib
}
7z a -tzip windows-$env:PLATFORM-msvc-$env:TOOLSET.zip lib ..\src\include ..\ide-project-files\vs-$env:PLATFORM\* ..\ide-project-files\src
}
artifacts:
Expand Down
11 changes: 11 additions & 0 deletions ide-project-files/clion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.7)
project(cuhkszlib_cmake)

set(CMAKE_CXX_STANDARD 11)

INCLUDE_DIRECTORIES(include/)
LINK_DIRECTORIES(lib/)

set(SOURCE_FILES src/main.cpp)
add_executable(cuhkszlib_cmake ${SOURCE_FILES})
target_link_libraries(cuhkszlib_cmake cuhkszlib)
14 changes: 14 additions & 0 deletions ide-project-files/qt-msvc/CUHKSZLib-sample-project.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

INCLUDEPATH +=$$PWD/include
CONFIG(debug, debug|release) {
LIBS += $$PWD/lib/Debug/cuhkszlib.lib
} else {
LIBS += $$PWD/lib/Release/cuhkszlib.lib
}


SOURCES += src/main.cpp
11 changes: 11 additions & 0 deletions ide-project-files/qt/CUHKSZLib-sample-project.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

INCLUDEPATH +=$$PWD/include

LIBS += $$PWD/lib/libcuhkszlib.a


SOURCES += src/main.cpp
10 changes: 10 additions & 0 deletions ide-project-files/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "random.h"
#include <iostream>

using namespace std;
using namespace cuhksz;

int main()
{
cout << randomDouble() << endl;
}
22 changes: 22 additions & 0 deletions ide-project-files/vs-x64/CUHKSZLib-sample-project.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CUHKSZLib-sample-project", "CUHKSZLib-sample-project.vcxproj", "{3B6C0BED-7EE2-4BB5-8968-29068081692C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B6C0BED-7EE2-4BB5-8968-29068081692C}.Debug|x64.ActiveCfg = Release|x64
{3B6C0BED-7EE2-4BB5-8968-29068081692C}.Debug|x64.Build.0 = Release|x64
{3B6C0BED-7EE2-4BB5-8968-29068081692C}.Release|x64.ActiveCfg = Release|x64
{3B6C0BED-7EE2-4BB5-8968-29068081692C}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading

0 comments on commit 94b84b1

Please sign in to comment.