Add build libgd example, add it to tests (#42)

Unfortunately, many additional variables needed to make CMake find libraries.
This commit is contained in:
irengrig 2018-08-20 21:22:45 +02:00 committed by GitHub
parent 3dd96c7a14
commit cfa5c56f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 92 additions and 5 deletions

View File

@ -70,3 +70,23 @@ http_archive(
load("@gmaven_rules//:gmaven.bzl", "gmaven_rules")
gmaven_rules()
new_http_archive(
name = "freetype",
build_file_content = all_content,
sha256 = "e6ffba3c8cef93f557d1f767d7bc3dee860ac7a3aaff588a521e081bc36f4c8a",
strip_prefix = "freetype-2.9",
urls = [
"https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.bz2",
],
)
new_http_archive(
name = "libgd",
build_file_content = all_content,
sha256 = "8c302ccbf467faec732f0741a859eef4ecae22fea2d2ab87467be940842bde51",
strip_prefix = "libgd-2.2.5",
urls = [
"https://github.com/libgd/libgd/releases/download/gd-2.2.5/libgd-2.2.5.tar.xz",
],
)

View File

@ -1,6 +1,7 @@
test_suite(
name = "tests",
tests = [
"//examples/cmake:test_libgd",
"//examples/cmake:test_libpng",
"//examples/cmake:test_zlib",
],

View File

@ -7,11 +7,13 @@ cmake_external(
cmake_external(
name = "libpng",
cache_entries = {
"ZLIB_ROOT": "$EXT_BUILD_DEPS/libz",
},
lib_source = "@libpng//:all",
out_include_dir = "include/libpng16",
static_libraries = ["libpng16.a"],
deps = [":libz"],
postfix_script = "echo \"POST\""
)
cc_binary(
@ -33,13 +35,74 @@ sh_test(
name = "test_zlib",
srcs = ["test_zlib.sh"],
data = [":zlib_usage_example"],
visibility = ["//:__pkg__"]
visibility = ["//:__pkg__"],
)
sh_test(
name = "test_libpng",
srcs = ["test_libpng.sh"],
data = [":libpng_usage_example", "bazel-icon-transparent.png",],
args = ["$(location bazel-icon-transparent.png) out.png"],
visibility = ["//:__pkg__"]
)
data = [
"bazel-icon-transparent.png",
":libpng_usage_example",
],
visibility = ["//:__pkg__"],
)
cmake_external(
name = "freetype",
cache_entries = {
"ZLIB_ROOT": "$EXT_BUILD_DEPS/libz",
"PNG_LIBRARY": "$EXT_BUILD_DEPS/libpng/lib/libpng16.a",
"PNG_PNG_INCLUDE_DIR": "$EXT_BUILD_DEPS/libpng/include",
},
lib_source = "@freetype//:all",
out_include_dir = "include/freetype2",
static_libraries = ["libfreetype.a"],
deps = [
":libpng",
":libz",
],
)
cmake_external(
name = "libgd",
cache_entries = {
"BUILD_SHARED_LIBS": "OFF",
"BUILD_STATIC_LIBS": "ON",
"ENABLE_PNG": "1",
"ENABLE_FREETYPE": "1",
"ZLIB_ROOT": "$EXT_BUILD_DEPS/libz",
"PNG_LIBRARY": "$EXT_BUILD_DEPS/libpng/lib/libpng16.a",
"PNG_PNG_INCLUDE_DIR": "$EXT_BUILD_DEPS/libpng/include",
"FREETYPE_LIBRARY": "$EXT_BUILD_DEPS/freetype/lib/libfreetype.a",
"FREETYPE_INCLUDE_DIRS": "$EXT_BUILD_DEPS/freetype/include/freetype2",
},
defines = ["HAVE_LIBPNG"],
lib_source = "@libgd//:all",
deps = [
":freetype",
":libpng",
":libz",
],
)
cc_binary(
name = "libgd_with_png_example",
srcs = ["arc.c"],
deps = [
":freetype",
":libgd",
":libpng",
":libz",
],
)
sh_test(
name = "test_libgd",
srcs = ["test_libgd.sh"],
data = [
":libgd_with_png_example",
],
visibility = ["//:__pkg__"],
)

3
examples/cmake/test_libgd.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
${TEST_SRCDIR}/rules_foreign_cc/examples/cmake/libgd_with_png_example $@