Permalink
Browse files

Adding bazel build files

  • Loading branch information...
vibhavg committed Aug 21, 2018
1 parent abef2d3 commit 4f5cd56f24c0493fb9bdf5ff3eea522705cb3909
128 BUILD
@@ -0,0 +1,128 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "gams",
copts = ["-w"],
deps = [
"@gams//src/gams/algorithms",
"@gams//src/gams/algorithms/area_coverage",
"@gams//src/gams/auctions",
"@gams//src/gams/controllers",
"@gams//src/gams/elections",
"@gams//src/gams/formations",
"@gams//src/gams/groups",
"@gams//src/gams/loggers",
"@gams//src/gams/platforms",
"@gams//src/gams/pose",
"@gams//src/gams/utility",
"@gams//src/gams/variables",
"@madara",
],
)

cc_library(
name = "gams_base",
hdrs = [
"src/gams/CPP11_compat.h",
"src/gams/GamsExport.h",
"src/gams/Namespaces.h",
],
copts = ["-w"],
strip_include_prefix = "src",
)

cc_library(
name = "jni_headers",
srcs = [
"@local_jdk//:jni_header",
"@local_jdk//:jni_md_header-linux",
],
hdrs = [
"@local_jdk//:jni_header",
"@local_jdk//:jni_md_header-linux",
],
copts = ["-w"],
linkstatic = 1,
visibility = [
"//visibility:public",
],
)

cc_library(
name = "gams_jni_h",
srcs = glob(["port/java/jni/*.h"]),
hdrs = glob(["port/java/jni/*.h"]),
copts = ["-w"],
includes = [
"external/local_jdk/include/linux",
"external/local_jdk/inlude",
],
strip_include_prefix = "port/java/jni",
deps = ["jni_headers"],
)

cc_library(
name = "gams_jni",
copts = ["-w"],
linkstatic = 1,
deps = [
"@gams//src/gams/algorithms",
"@gams//src/gams/algorithms/area_coverage",
"@gams//src/gams/auctions",
"@gams//src/gams/controllers:controllers_java",
"@gams//src/gams/elections",
"@gams//src/gams/formations",
"@gams//src/gams/groups",
"@gams//src/gams/loggers",
"@gams//src/gams/platforms",
"@gams//src/gams/platforms:platforms_java",
"@gams//src/gams/pose",
"@gams//src/gams/utility",
"@gams//src/gams/variables",
"@madara",
],
)

# Shared binary with the JNI support
cc_binary(
name = "libGAMS.so",
srcs = glob([
"port/java/jni/*.cpp",
"port/java/jni/*.h",
]) + [
"@local_jdk//:jni_header",
"@local_jdk//:jni_md_header-linux",
],
copts = [
"-I external/local_jdk/include",
"-I external/local_jdk/include/linux",
"-D_GAMS_JAVA_",
"-w",
],
linkshared = 1,
deps = [
":gams_jni",
":gams_jni_h",
],
)

java_library(
name = "gams_java",
srcs = glob(["port/java/src/main/java/ai/gams/**/*.java"]),
deps = ["@madara//:madara_java"],
)

#load("@bazel_module//bazel_rules:auxiliary.bzl", "map", "basename")
#DISABLED_JAVA_TESTS = ["TestDebuggerLoop",
# "TestMessagingThroughput",
# "TestMultiController",
# "TestUtility"]
#
#[java_test(
# name = f,
# main_class = "ai.gams.tests." + f,
# runtime_deps = [
# ":gams_java", "@madara//:madara_java", "@madara//:libMADARA.so", "@ace//:ace", ":libGAMS.so",
# ],
# use_testrunner = 0
#) for f in map(basename, glob(["port/java/src/main/java/ai/gams/tests/*.java"])) if f not in DISABLED_JAVA_TESTS]
@@ -0,0 +1,31 @@
workspace(name = "gams")

http_archive(
name = "madara",
strip_prefix = "madara-a05f82a1b72f0facc51a783c2f890988468db197",
urls = ["https://gitlab.com/shield-ai/public/madara/-/archive/a05f82a1b72f0facc51a783c2f890988468db197/madara-a05f82a1b72f0facc51a783c2f890988468db197.tar.gz"],
)

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "ace",
remote = "https://gitlab.com/shield-ai/public/ace.git",
tag = "stable",
)

git_repository(
name = "bazel_module",
remote = "https://gitlab.com/shield-ai/public/bazel_module.git",
tag = "stable",
)

load("@bazel_module//bazel_rules:generate_modules.bzl", "generate_modules")

generate_modules(
root_path = __workspace_dir__,
)

load("@bazel_module//bazel_rules:module.bzl", "add_modules")

add_modules()
@@ -62,7 +62,7 @@
#include "gams/variables/Sensor.h"
#include "gams/variables/Agent.h"
#include "madara/knowledge/KnowledgeBase.h"
#include "AlgorithmFactory.h"
#include "gams/algorithms/AlgorithmFactory.h"

namespace gams
{
@@ -0,0 +1,82 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "base_algorithm",
srcs = [
"AlgorithmFactory.cpp",
"AlgorithmFactory.h",
"BaseAlgorithm.cpp",
"BaseAlgorithm.h",
],
hdrs = [
"AlgorithmFactory.h",
"BaseAlgorithm.h",
],
include_prefix = "gams/algorithms",
deps = [
"@gams//src/gams/loggers",
"@gams//src/gams/platforms",
"@gams//src/gams/pose",
"@gams//src/gams/variables",
],
)

ALGORITHM_FILES = [
"AlgorithmFactoryRepository",
"Hold",
"Spell",
"Land",
"Move",
"DebugAlgorithm",
"NullAlgorithm",
"FormationCoverage",
"FormationSync",
"KarlEvaluator",
"ZoneCoverage",
"Takeoff",
"Home",
"Follow",
"MessageProfiling",
"PerimeterPatrol",
"Executor",
"Wait",
"PerformanceProfiling",
"GroupBarrier",
"FormationFlying",
]

cc_library(
name = "algorithms",
srcs = [file + filetype for file in ALGORITHM_FILES for filetype in [
".cpp",
".h",
]],
hdrs = [file + ".h" for file in ALGORITHM_FILES],
include_prefix = "gams/algorithms",
deps = [
":base_algorithm",
"@gams//src/gams/algorithms/area_coverage",
"@gams//src/gams/loggers",
"@madara",
],
)

cc_library(
name = "algorithms_java",
srcs = glob([
"java/*.cpp",
"java/*.h",
]),
hdrs = glob(["java/*.h"]),
copts = [
"-I external/local_jdk/include",
"-I external/local_jdk/include/linux",
],
defines = ["_GAMS_JAVA_"],
include_prefix = "gams/algorithms",
deps = [
":algorithms",
"@gams//:gams_jni_h",
"@gams//src/gams/utility:utility_java",
],
)
@@ -0,0 +1,40 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "base_area_coverage",
srcs = [
"BaseAreaCoverage.cpp",
"BaseAreaCoverage.h",
],
hdrs = ["BaseAreaCoverage.h"],
include_prefix = "gams/algorithms/area_coverage",
deps = ["@gams//src/gams/algorithms:base_algorithm"],
)

AREA_COVERAGE_FILES = [
"LocalPheremoneAreaCoverage",
"MinTimeAreaCoverage",
"PerimeterPatrolCoverage",
"PrioritizedMinTimeAreaCoverage",
"PriorityWeightedRandomAreaCoverage",
"SnakeAreaCoverage",
"UniformRandomAreaCoverage",
"UniformRandomEdgeCoverage",
"WaypointsCoverage",
]

[cc_library(
name = area_coverage,
srcs = [
area_coverage + ".cpp",
area_coverage + ".h",
],
hdrs = [area_coverage + ".h"],
include_prefix = "gams/algorithms/area_coverage",
deps = [":base_area_coverage"],
) for area_coverage in AREA_COVERAGE_FILES]

cc_library(
name = "area_coverage",
deps = [":" + area_coverage for area_coverage in AREA_COVERAGE_FILES],
)
@@ -0,0 +1,35 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "auctions",
srcs = glob([
"*.cpp",
"*.h",
]),
hdrs = [
"AuctionBase.h",
"AuctionBase.inl",
"AuctionBid.h",
"AuctionBid.inl",
"AuctionFactory.h",
"AuctionFactoryRepository.h",
"AuctionFactoryRepository.inl",
"AuctionMaximumBid.h",
"AuctionMinimumBid.h",
"AuctionMinimumDistance.h",
"AuctionTypesEnum.h",
],
include_prefix = "gams/auctions",
textual_hdrs = [
"AuctionBase.inl",
"AuctionBid.inl",
"AuctionFactoryRepository.inl",
],
deps = [
"@gams//:gams_base",
"@gams//src/gams/groups",
"@gams//src/gams/platforms",
"@gams//src/gams/utility",
"@madara",
],
)
@@ -0,0 +1,45 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "controllers",
srcs = glob([
"*.cpp",
"*.h",
]),
hdrs = glob(["*.h"]),
include_prefix = "gams/controllers",
deps = [
"@gams//:gams_base",
"@gams//src/gams/algorithms",
"@gams//src/gams/groups",
"@gams//src/gams/platforms",
"@gams//src/gams/variables",
"@madara",
],
)

# controllers_java can't depend on controllers since
# the sources are not separated, but the jni bits
# are hidden behind the preprocesor directive, so
# it repeates the srcs and headers.
# Warning: do not depend both on controllers and
# controllers_java, that leads to the multiple defined
# references during the link time.
cc_library(
name = "controllers_java",
srcs = glob([
"*.cpp",
"*.h",
]),
hdrs = glob(["*.h"]),
copts = [
"-I external/local_jdk/include",
"-I external/local_jdk/include/linux",
],
defines = ["_GAMS_JAVA_"],
include_prefix = "gams/controllers",
deps = [
"@gams//src/gams/algorithms:algorithms_java",
"@gams//src/gams/platforms:platforms_java",
],
)
Oops, something went wrong.

0 comments on commit 4f5cd56

Please sign in to comment.