2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-12-04 08:02:31 +00:00
rules_foreign_cc/examples/configure_gnuplot/BUILD
irengrig c51480261c
Extract shell fragments into a toolchain (#196)
* Extract shell fragments into a toolchain

Construct script in framework.bzl using special notation for calling
shell fragments, defining and referencing environment variables;
have the script converted from this special notation into a real script
(see README.md notes.)
The special notation is used to keep script construction in code still readable.

Tools scripts (cmake, ninja) were also converted.

* Fix reference to environment variables in examples

.. and reference it correctly $$var_name$$ so it is replaced further

* Review comments: documentation, explicitly mark functions from toolchain

- mark functions from shell toolchain as ##funname##, so that they
can not be mixed with usual shell functions

* Fix operating system name for windows in toolchain file

* Additional env vars for windows

* Correct cmake tool build

* Do not build ninja on Windows

* When run on Windows under msys, find utility from Window could "leak"...

into the script. Use heuristics to use /usr/bin/find if it exists.
Also, use pwd -W to get Windows-styled paths (for cmake)
2019-01-18 18:06:10 +01:00

108 lines
2.2 KiB
Python

load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")
load("@bazel_tools//tools/build_rules:test_rules.bzl", "file_test")
configure_make(
name = "libz",
lib_source = "@zlib//:all",
)
configure_make(
name = "libpng",
lib_source = "@libpng//:all",
out_include_dir = "include/libpng16",
static_libraries = ["libpng16.a"],
deps = [":libz"],
)
configure_make(
name = "freetype",
lib_source = "@freetype//:all",
out_include_dir = "include/freetype2",
static_libraries = ["libfreetype.a"],
configure_options = [
"--with-png=\"$$EXT_BUILD_DEPS$$/libpng\"",
"--with-zlib=\"$$EXT_BUILD_DEPS$$/libz\"",
],
deps = [
":libpng",
":libz",
],
)
libgd_name = select({
"@bazel_tools//src/conditions:windows": ["libgd.lib"],
"//conditions:default": ["libgd.a"],
})
configure_make(
name = "libgd",
binaries = [
"webpng",
"gdtopng",
],
configure_options = [
"--disable-shared",
"--with-png=\"$$EXT_BUILD_DEPS$$/libpng\"",
"--with-freetype=\"$$EXT_BUILD_DEPS$$/freetype\"",
"--with-zlib=\"$$EXT_BUILD_DEPS$$/libz\"",
],
lib_source = "@libgd//:all",
static_libraries = libgd_name,
deps = [
":freetype",
":libpng",
":libz",
],
)
filegroup(
name = "gdtopng_fg",
srcs = [":libgd"],
output_group = "gdtopng",
)
genrule(
name = "invoke_gdtopng",
srcs = [],
outs = ["out.txt"],
cmd = "./$(location gdtopng_fg) > $(location out.txt) 2>&1 || true",
tools = [":gdtopng_fg"],
)
file_test(
name = "test_gdtopng",
content = "Usage: gdtopng filename.gd filename.png\n",
file = ":invoke_gdtopng",
)
cc_test(
name = "test_zlib",
srcs = ["zlib-example.cpp"],
deps = [":libz"],
)
cc_test(
name = "test_libpng",
srcs = ["libpng_usage_example.cpp"],
args = ["$(location bazel-icon-transparent.png) out.png"],
data = ["bazel-icon-transparent.png"],
deps = [
":libpng",
],
)
cc_test(
name = "test_libgd",
srcs = ["arc.c"],
deps = [":libgd"],
)
test_suite(
name = "configure_libgd_tests",
tests = [
":test_libgd",
":test_libpng",
":test_zlib",
],
)