Skip to content

Commit

Permalink
Fixes for building on Windows.
Browse files Browse the repository at this point in the history
* Updated glog to version 0.5.0 to account for
  google/glog#472.

* Updated .bazelrc to specify C++17 correctly for Windows.

* Added documentation.
  • Loading branch information
Andrey-Russe authored and benh committed Aug 2, 2021
1 parent 51fa99d commit 5eb7153
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 8 deletions.
8 changes: 7 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Specific Bazel build/test options.

build --cxxopt='-std=c++17'
build --enable_platform_specific_config

build:windows --compiler="clang-cl" --cxxopt="/std:c++17"

build:macos --cxxopt=-std=c++17

build:linux --cxxopt=-std=c++17
17 changes: 17 additions & 0 deletions README_Build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Building/Testing
Currently we only support Bazel and expect/use C++17.
```
1. Build the library Eventuals with:
```
bazel build :eventuals
```
After the running command above the new directory "bazel-bin" in your project folder is created which includes eventuals.lib.

2. Build the tests with:
```
bazel build test:eventuals
```
Build and run the tests with:
```
bazel test test:eventuals
```
23 changes: 23 additions & 0 deletions README_Install_Linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Installation

## Linux installation

Here we offer a proven way to configure the development environment for [Bazel](https://bazel.build) in the [Linux](https://www.linux.org) operating system.

1. Install a convenient development environment [Visual Studio Code](https://code.visualstudio.com/download) that is adapted to work with [Bazel](https://bazel.build).
2. Run [Visual Studio Code](https://code.visualstudio.com/download) and install the necessary extensions:
1. [Bazel plugin](https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel). This extension provides support for Bazel in Visual Studio Code.
2. [C/C++ plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools). The C/C++ extension adds language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging.
3. [Clang-format plugin](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format). This extension allows you to comply with the clang format for your code. Read the plugin overview for configuration.
4. [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb). This extension allows you to debug your code. Read the plugin overview for configuration.
3. Install [Bazel](https://bazel.build).
4. Install the latest version of the compiler [LLLM](https://llvm.org) ([LLVM Download Page](https://releases.llvm.org/download.html)).
5. Install [Git](https://git-scm.com/downloads)
6. Make an empty directory for your projects and clone the [stout-eventuals](https://github.com/3rdparty/stout-eventuals) via the git clone link:
```
https://github.com/3rdparty/stout-eventuals.git
```
7. Start [VS Code](https://code.visualstudio.com).
8. Open the stout-eventuals folder via VS Code.
9. Check the checkboxes about "Trust the authors".
10. VS Code -> Terminal -> New Terminal
38 changes: 38 additions & 0 deletions README_Install_MacOS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Installation

## MacOS installation

Here we offer a proven way to configure the development environment for [Bazel](https://bazel.build) in the [MacOS](https://www.apple.com) operating system.

1. Install a convenient development environment [Visual Studio Code](https://code.visualstudio.com/download) that is adapted to work with [Bazel](https://bazel.build).
2. Run [Visual Studio Code](https://code.visualstudio.com/download) and install the necessary extensions:
1. [Bazel plugin](https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel). This extension provides support for Bazel in Visual Studio Code.
2. [C/C++ plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools). The C/C++ extension adds language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging.
3. [Clang-format plugin](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format). This extension allows you to comply with the clang format for your code. Read the plugin overview for configuration.
4. [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb). This extension allows you to debug your code. Read the plugin overview for configuration.
3. Install [Bazel](https://bazel.build).
Here we provide some details to help you:
1. Check the presence of [Bazel](https://bazel.build) in your [MacOS](https://www.apple.com) using the following command in your terminal:
```
$ bazel --version
```
2. If you have no Bazel - install it using Homebrew. Install Homebrew(if needed):
```
$ /bin/bash -c "$(curl -fsSL \ https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```
3. Install the Bazel package via Homebrew as follows:
```
$ brew install bazel
```
4. Upgrade to a newer version of Bazel using the following command(if needed):
```
$ brew upgrade bazel
```
4. Make an empty directory for your projects and clone the [stout-eventuals](https://github.com/3rdparty/stout-eventuals) via the git clone link:
```
https://github.com/3rdparty/stout-eventuals.git
```
5. Start [VS Code](https://code.visualstudio.com).
6. Open the stout-eventuals folder via VS Code.
7. Check the checkboxes about "Trust the authors".
8. VS Code -> Terminal -> New Terminal
36 changes: 36 additions & 0 deletions README_Install_Windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Installation

## Windows installation

Here we offer a proven way to configure the development environment for [Bazel](https://bazel.build) in the [Windows](https://www.microsoft.com) operating system.

1. Install a convenient development environment [Visual Studio Code](https://code.visualstudio.com/download) that is adapted to work with [Bazel](https://bazel.build).
2. Run [Visual Studio Code](https://code.visualstudio.com/download) and install the necessary extensions:
1. [Bazel plugin](https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel). This extension provides support for Bazel in Visual Studio Code.
2. [C/C++ plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools). The C/C++ extension adds language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging.
3. [Clang-format plugin](https://marketplace.visualstudio.com/items?itemName=xaver.clang-format). This extension allows you to comply with the clang format for your code. Read the plugin overview for configuration.
Short instuction how you can use Visual Studio `clang-format`:
1. Create a folder `.vscode`in your project folder.
2. Create a file `settings.json` in the folder `.vscode`
3. Add the data to the file (check the path to your `clang-format.exe`):
```
{
"clang-format.style": "Google",
"clang-format.executable": "C:/Program Files (x86)/Microsoft Visual Studio/2019/
Community/VC/Tools/Llvm/x64/bin/clang-format.exe",
"editor.formatOnSave": true
}
```
4. [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb). This extension allows you to debug your code. Read the plugin overview for configuration.
3. Install [Bazel](https://bazel.build). Detailed installation instructions for Windows can be found here: [Installing Bazel on Windows](https://docs.bazel.build/versions/4.1.0/install-windows.html). This is an important step. You must follow all the instructions, otherwise you will get various errors at the compilation stage.
4. Install the latest version of the compiler [LLLM](https://llvm.org) ([LLVM Download Page](https://releases.llvm.org/download.html)).
5. Install [Git](https://git-scm.com/downloads)
6. Restart your PC.
7. Make an empty directory for your projects and clone the [stout-eventuals](https://github.com/3rdparty/stout-eventuals) via the git clone link:
```
https://github.com/3rdparty/stout-eventuals.git
```
8. Start [VS Code](https://code.visualstudio.com).
9. Open the stout-eventuals folder via VS Code.
10. Check the checkboxes about "Trust the authors".
11. VS Code -> Terminal -> New Terminal
8 changes: 5 additions & 3 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ http_archive(

########################################################################

# NOTE: using glog version 0.5.0 since older versions failed to
# compile on Windows, see: https://github.com/google/glog/issues/472
http_archive(
name = "com_github_google_glog",
url = "https://github.com/google/glog/archive/v0.4.0.tar.gz",
sha256 = "f28359aeba12f30d73d9e4711ef356dc842886968112162bc73002645139c39c",
strip_prefix = "glog-0.4.0",
sha256 = "eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5",
strip_prefix = "glog-0.5.0",
url = "https://github.com/google/glog/archive/refs/tags/v0.5.0.tar.gz",
)

########################################################################
Expand Down
1 change: 1 addition & 0 deletions stout/callback.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cassert>
#include <type_traits> // For std::aligned_storage.

////////////////////////////////////////////////////////////////////////
Expand Down
9 changes: 5 additions & 4 deletions stout/semaphore.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#pragma once

#include "glog/logging.h" // NOTE: must be included before <windows.h>.

#ifdef __MACH__
#include <mach/mach.h>
#elif __WINDOWS__
#elif _WIN32
#include <windows.h>
#else
#include <semaphore.h>
#endif // __MACH__

#include "glog/logging.h"

////////////////////////////////////////////////////////////////////////

namespace stout {
Expand Down Expand Up @@ -50,7 +51,7 @@ class Semaphore
private:
semaphore_t semaphore;
};
#elif __WINDOWS__
#elif _WIN32
class Semaphore
{
public:
Expand Down

0 comments on commit 5eb7153

Please sign in to comment.