Skip to content

Commit 62c0e4e

Browse files
mapxmapx
authored andcommitted
Bazel build support
1 parent 76bacfe commit 62c0e4e

17 files changed

Lines changed: 546 additions & 17 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ Testing/*
4747
/buckaroo/
4848
.buckconfig.local
4949
BUCKAROO_DEPS
50+
51+
# Bazel
52+
bazel-*

.travis.yml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ compiler:
99
- clang
1010

1111
env:
12-
- EASTL_CONFIG=Debug
13-
- EASTL_CONFIG=Release
12+
- EASTL_CONFIG=Debug BUILDER=cmake
13+
- EASTL_CONFIG=Release BUILDER=cmake
14+
- EASTL_CONFIG=Debug BUILDER=bazel
15+
- EASTL_CONFIG=Release BUILDER=bazel
1416

1517
addons:
1618
apt:
@@ -23,6 +25,8 @@ addons:
2325
- cmake-data
2426
- g++-7
2527
- clang-5.0
28+
- wget
29+
- pkg-config
2630

2731
matrix:
2832
include:
@@ -34,28 +38,41 @@ matrix:
3438
- os: osx
3539
compiler: gcc
3640

41+
before_install:
42+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/bazelbuild/bazel/releases/download/0.20.0/bazel_0.20.0-linux-x86_64.deb ;fi
43+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/bazelbuild/bazel/releases/download/0.20.0/bazel_0.20.0-linux-x86_64.deb.sha256 ;fi
44+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sha256sum -c bazel_0.20.0-linux-x86_64.deb.sha256 ;fi
45+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo dpkg -i bazel_0.20.0-linux-x86_64.deb ;fi
46+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://github.com/bazelbuild/bazel/releases/download/0.20.0/bazel-0.20.0-installer-darwin-x86_64.sh ;fi
47+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sh bazel-0.20.0-installer-darwin-x86_64.sh ;fi
48+
3749
install:
3850
# MOJI check; exit 1 if non-ascii characters detected in C++
39-
- if [[ -n "$USE_MOJI_CHECK" && -n `git grep -P "[^[:ascii:]]" source test` ]]; then echo "Moji Detected" && exit 1 ;fi
40-
- if [[ -n "$USE_MOJI_CHECK" ]]; then exit 0 ;fi
41-
- if [[ "$CXX" == "g++" ]]; then export CC="gcc-7" ;fi
42-
- if [[ "$CXX" == "g++" ]]; then export CXX="g++-7" ;fi
51+
- if [[ -n "$USE_MOJI_CHECK" && -n `git grep -P "[^[:ascii:]]" source test` ]]; then echo "Moji Detected" && exit 1 ;fi
52+
- if [[ -n "$USE_MOJI_CHECK" ]]; then exit 0 ;fi
53+
- if [[ "$CXX" == "g++" ]]; then export CC="gcc-7" ;fi
54+
- if [[ "$CXX" == "g++" ]]; then export CXX="g++-7" ;fi
4355

4456
# Universal Setup
4557
before_script:
46-
- mkdir build_$EASTL_CONFIG
47-
- cd build_$EASTL_CONFIG
48-
- cmake .. -DEASTL_BUILD_BENCHMARK:BOOL=ON -DEASTL_BUILD_TESTS:BOOL=ON
49-
- cmake --build . --config $EASTL_CONFIG
58+
- if [[ "$BUILDER" == "cmake" ]]; then mkdir build_$EASTL_CONFIG ;fi
59+
- if [[ "$BUILDER" == "cmake" ]]; then cd build_$EASTL_CONFIG ;fi
60+
- if [[ "$BUILDER" == "cmake" ]]; then cmake .. -DEASTL_BUILD_BENCHMARK:BOOL=ON -DEASTL_BUILD_TESTS:BOOL=ON ;fi
61+
- if [[ "$BUILDER" == "cmake" ]]; then cmake --build . --config $EASTL_CONFIG ;fi
5062

5163
script:
5264
# Run Tests
53-
- cd $TRAVIS_BUILD_DIR/build_$EASTL_CONFIG/test
54-
- ctest -C $EASTL_CONFIG -V || exit 1
65+
- if [[ "$BUILDER" == "cmake" ]]; then cd $TRAVIS_BUILD_DIR/build_$EASTL_CONFIG/test ;fi
66+
- if [[ "$BUILDER" == "cmake" ]]; then ctest -C $EASTL_CONFIG -V || exit 1 ;fi
67+
- if [[ "$BUILDER" == "bazel" && "$EASTL_CONFIG" == "Debug" ]]; then bazel run -c dbg --copt "-DEASTL_DEBUG=1" //:test-runner ;fi
68+
- if [[ "$BUILDER" == "bazel" && "$EASTL_CONFIG" == "Release" ]]; then bazel run -c opt --copt "-DEASTL_DEBUG=0" //:test-runner ;fi
5569

5670
# Run Benchmarks
57-
- cd $TRAVIS_BUILD_DIR/build_$EASTL_CONFIG/benchmark
58-
- ctest -C $EASTL_CONFIG -V || exit 1
71+
- if [[ "$BUILDER" == "cmake" ]]; then cd $TRAVIS_BUILD_DIR/build_$EASTL_CONFIG/benchmark ;fi
72+
- if [[ "$BUILDER" == "cmake" ]]; then ctest -C $EASTL_CONFIG -V || exit 1 ;fi
73+
- if [[ "$BUILDER" == "bazel" && "$EASTL_CONFIG" == "Debug" ]]; then bazel run -c dbg --copt "-DEASTL_DEBUG=1" //:benchmark ;fi
74+
- if [[ "$BUILDER" == "bazel" && "$EASTL_CONFIG" == "Release" ]]; then bazel run -c opt --copt "-DEASTL_DEBUG=0" //:benchmark ;fi
75+
5976

6077
branches:
6178
except:

BUILD

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
licenses(["notice"])
2+
3+
exports_files(["LICENSE"])
4+
5+
load(
6+
"//config:copts.bzl",
7+
"EASTL_DEFAULT_COPTS",
8+
"EASTL_TEST_COPTS",
9+
"EASTL_EXCEPTIONS_FLAG",
10+
"EASTL_EXCEPTIONS_FLAG_LINKOPTS",
11+
)
12+
13+
cc_library(
14+
name = "eastl",
15+
srcs = glob([
16+
"source/**/*.cpp",
17+
]),
18+
hdrs = glob([
19+
"include/EASTL/**/*.h",
20+
]),
21+
copts = EASTL_DEFAULT_COPTS + [
22+
"-D_CHAR16T",
23+
"-D_CRT_SECURE_NO_WARNINGS",
24+
"-D_SCL_SECURE_NO_WARNINGS",
25+
"-DEASTL_OPENSOURCE=1",
26+
],
27+
linkopts = EASTL_EXCEPTIONS_FLAG_LINKOPTS,
28+
strip_include_prefix = "include",
29+
visibility = [
30+
"//visibility:public",
31+
],
32+
deps = [
33+
"//test/packages/EABase:eabase",
34+
],
35+
)
36+
37+
cc_library(
38+
name = "test",
39+
srcs = glob(
40+
[
41+
"test/source/**/*.cpp",
42+
"test/source/**/*.h",
43+
],
44+
exclude = [
45+
"test/source/main.cpp",
46+
],
47+
),
48+
hdrs = glob(
49+
[
50+
"test/source/**/*.h",
51+
],
52+
),
53+
copts = EASTL_TEST_COPTS + [
54+
"-DEASTL_OPENSOURCE=1",
55+
"-DEASTL_THREAD_SUPPORT_AVAILABLE=0",
56+
],
57+
linkopts = EASTL_EXCEPTIONS_FLAG_LINKOPTS,
58+
strip_include_prefix = "test/source",
59+
textual_hdrs = glob([
60+
"test/source/**/*.inl",
61+
]),
62+
deps = [
63+
"//:eastl",
64+
"//test/packages/EAAssert:eaassert",
65+
"//test/packages/EABase:eabase",
66+
"//test/packages/EAMain:eamain",
67+
"//test/packages/EAStdC:eastdc",
68+
"//test/packages/EATest:eatest",
69+
"//test/packages/EAThread:eathread",
70+
],
71+
)
72+
73+
cc_binary(
74+
name = "test-runner",
75+
srcs = glob([
76+
"test/source/main.cpp",
77+
]),
78+
copts = EASTL_DEFAULT_COPTS + [
79+
"-DEASTL_OPENSOURCE=1",
80+
"-DEASTL_THREAD_SUPPORT_AVAILABLE=0",
81+
],
82+
linkopts = EASTL_EXCEPTIONS_FLAG_LINKOPTS,
83+
deps = [
84+
"//:test",
85+
],
86+
)
87+
88+
cc_binary(
89+
name = "benchmark",
90+
srcs = glob([
91+
"benchmark/source/**/*.cpp",
92+
"benchmark/source/**/*.h",
93+
]),
94+
copts = EASTL_DEFAULT_COPTS + [
95+
"-DEASTL_OPENSOURCE=1",
96+
"-DEASTL_THREAD_SUPPORT_AVAILABLE=0",
97+
],
98+
linkopts = EASTL_EXCEPTIONS_FLAG_LINKOPTS,
99+
deps = [
100+
"//:eastl",
101+
"//:test",
102+
"//test/packages/EAStdC:eastdc",
103+
"//test/packages/EATest:eatest",
104+
],
105+
)

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,25 @@ popd
7171
```
7272

7373
The value of EASTL_BUILD_BENCHMARK can be toggled to `ON` in order to build projects that include the benchmark program.
74+
75+
### Building using Bazel
76+
77+
EASTL can also be built using [Bazel Build](https://www.bazel.build).
78+
79+
To build EASTL:
80+
81+
```bash
82+
bazel build //:eastl
83+
```
84+
85+
To run the tests:
86+
87+
```bash
88+
bazel run //:test-runner
89+
```
90+
91+
To run the benchmarks:
92+
93+
```bash
94+
bazel run //:benchmark
95+
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# EA Standard Template Library
22

3-
[![Build Status](https://travis-ci.org/electronicarts/EASTL.svg?branch=master)](https://travis-ci.org/electronicarts/EASTL) [![Build status](https://ci.appveyor.com/api/projects/status/dtn82qr8tw8o3vmi?svg=true)](https://ci.appveyor.com/project/rparolin/eastl)
3+
[![Build Status](https://travis-ci.org/mapx/EASTL.svg?branch=bazel_support)](https://travis-ci.org/mapx/EASTL) [![Build status](https://ci.appveyor.com/api/projects/status/qmw0rvk89hj2c1hg?svg=true)](https://ci.appveyor.com/project/mapx/eastl)
44

55
EASTL stands for Electronic Arts Standard Template Library. It is a C++ template library of containers, algorithms, and iterators useful for runtime and tool development across multiple platforms. It is a fairly extensive and robust implementation of such a library and has an emphasis on high performance above all other considerations.
66

WORKSPACE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
workspace(name = "com_ea_eastl")
2+
3+
# Bazel toolchains
4+
http_archive(
5+
name = "bazel_toolchains",
6+
sha256 = "4329663fe6c523425ad4d3c989a8ac026b04e1acedeceb56aa4b190fa7f3973c",
7+
strip_prefix = "bazel-toolchains-bc09b995c137df042bb80a395b73d7ce6f26afbe",
8+
urls = [
9+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/bc09b995c137df042bb80a395b73d7ce6f26afbe.tar.gz",
10+
"https://github.com/bazelbuild/bazel-toolchains/archive/bc09b995c137df042bb80a395b73d7ce6f26afbe.tar.gz",
11+
],
12+
)

config/BUILD

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
load(":compiler_config_setting.bzl", "create_llvm_config")
2+
3+
create_llvm_config(
4+
name = "llvm_compiler",
5+
visibility = ["//:__subpackages__"],
6+
)
7+
8+
# following configs are based on mapping defined in: https://git.io/v5Ijz
9+
config_setting(
10+
name = "ios",
11+
values = {
12+
"cpu": "darwin",
13+
},
14+
visibility = ["//:__subpackages__"],
15+
)
16+
17+
config_setting(
18+
name = "windows",
19+
values = {
20+
"cpu": "x64_windows",
21+
},
22+
visibility = ["//:__subpackages__"],
23+
)
24+
25+
config_setting(
26+
name = "ppc",
27+
values = {
28+
"cpu": "ppc",
29+
},
30+
visibility = ["//:__subpackages__"],
31+
)
32+
33+

config/compiler_config_setting.bzl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Copyright 2018 The Abseil Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
"""Creates config_setting that allows selecting based on 'compiler' value."""
18+
19+
def create_llvm_config(name, visibility):
20+
# The "do_not_use_tools_cpp_compiler_present" attribute exists to
21+
# distinguish between older versions of Bazel that do not support
22+
# "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do.
23+
# In the future, the only way to select on the compiler will be through
24+
# flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can
25+
# be removed.
26+
if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"):
27+
native.config_setting(
28+
name = name,
29+
flag_values = {
30+
"@bazel_tools//tools/cpp:compiler": "llvm",
31+
},
32+
visibility = visibility,
33+
)
34+
else:
35+
native.config_setting(
36+
name = name,
37+
values = {"compiler": "llvm"},
38+
visibility = visibility,
39+
)

0 commit comments

Comments
 (0)