diff --git a/tools/workspace/libjpeg/package-macos.BUILD.bazel b/tools/workspace/libjpeg/package-macos.BUILD.bazel new file mode 100644 index 000000000000..90fcd0680f6e --- /dev/null +++ b/tools/workspace/libjpeg/package-macos.BUILD.bazel @@ -0,0 +1,15 @@ +# -*- python -*- + +licenses(["notice"]) # IJG + +cc_library( + name = "libjpeg", + hdrs = glob(["include/*.h"]), + includes = ["include"], + linkopts = [ + "-L/usr/local/opt/jpeg/lib", + "-Wl,-rpath,/usr/local/opt/jpeg/lib", + "-ljpeg", + ], + visibility = ["//visibility:public"], +) diff --git a/tools/workspace/libjpeg/package-ubuntu.BUILD.bazel b/tools/workspace/libjpeg/package-ubuntu.BUILD.bazel new file mode 100644 index 000000000000..280f0c7e067b --- /dev/null +++ b/tools/workspace/libjpeg/package-ubuntu.BUILD.bazel @@ -0,0 +1,14 @@ +# -*- python -*- + +licenses(["notice"]) # IJG + +cc_library( + name = "libjpeg", + hdrs = glob(["include/*.h"]), + includes = ["include"], + linkopts = [ + "-L/usr/lib/x86_64-linux-gnu", + "-ljpeg", + ], + visibility = ["//visibility:public"], +) diff --git a/tools/workspace/libjpeg/repository.bzl b/tools/workspace/libjpeg/repository.bzl index 4d30f34679a7..7d759a481db9 100644 --- a/tools/workspace/libjpeg/repository.bzl +++ b/tools/workspace/libjpeg/repository.bzl @@ -1,20 +1,40 @@ -# -*- mode: python -*- +# -*- python -*- -load( - "@drake//tools/workspace:pkg_config.bzl", - "pkg_config_repository", -) +load("@drake//tools/workspace:os.bzl", "determine_os") + +def _impl(repository_ctx): + os_result = determine_os(repository_ctx) + + if os_result.error != None: + fail(os_result.error) -def libjpeg_repository( - name, - licenses = ["notice"], # IJG - modname = "libjpeg", - pkg_config_paths = ["/usr/local/opt/libjpeg/lib/pkgconfig"], - **kwargs): - pkg_config_repository( - name = name, - licenses = licenses, - modname = modname, - pkg_config_paths = pkg_config_paths, - **kwargs - ) + if os_result.is_macos: + repository_ctx.symlink("/usr/local/opt/jpeg/include", "include") + repository_ctx.symlink( + Label("@drake//tools/workspace/libjpeg:package-macos.BUILD.bazel"), + "BUILD.bazel", + ) + elif os_result.is_ubuntu: + for hdr in ["jerror.h", "jmorecfg.h", "jpegint.h", "jpeglib.h"]: + repository_ctx.symlink( + "/usr/include/{}".format(hdr), + "include/{}".format(hdr), + ) + repository_ctx.symlink( + "/usr/include/x86_64-linux-gnu/jconfig.h", + "include/jconfig.h", + ) + repository_ctx.symlink( + Label( + "@drake//tools/workspace/libjpeg:package-ubuntu.BUILD.bazel", + ), + "BUILD.bazel", + ) + else: + fail("Operating system is NOT supported", attr = os_result) + +libjpeg_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +) diff --git a/tools/workspace/yaml_cpp/package-macos.BUILD.bazel b/tools/workspace/yaml_cpp/package-macos.BUILD.bazel new file mode 100644 index 000000000000..8d6c183e9cc6 --- /dev/null +++ b/tools/workspace/yaml_cpp/package-macos.BUILD.bazel @@ -0,0 +1,15 @@ +# -*- python -*- + +licenses(["notice"]) # X11 + +cc_library( + name = "yaml_cpp", + hdrs = glob(["include/yaml-cpp/*.h"]), + includes = ["include"], + linkopts = [ + "-L/usr/local/opt/yaml-cpp/lib", + "-Wl,-rpath,/usr/local/opt/yaml-cpp/lib", + "-lyaml-cpp", + ], + visibility = ["//visibility:public"], +) diff --git a/tools/workspace/yaml_cpp/package-ubuntu-18.04.BUILD.bazel b/tools/workspace/yaml_cpp/package-ubuntu-18.04.BUILD.bazel new file mode 100644 index 000000000000..46999b4398c1 --- /dev/null +++ b/tools/workspace/yaml_cpp/package-ubuntu-18.04.BUILD.bazel @@ -0,0 +1,15 @@ +# -*- python -*- + +licenses(["notice"]) # X11 + +cc_library( + name = "yaml_cpp", + hdrs = glob(["include/yaml-cpp/*.h"]), + includes = ["include"], + linkopts = [ + "-L/usr/lib/x86_64-linux-gnu", + "-lyaml-cpp", + ], + visibility = ["//visibility:public"], + deps = ["@boost//:boost_headers"], +) diff --git a/tools/workspace/yaml_cpp/package-ubuntu-20.04.BUILD.bazel b/tools/workspace/yaml_cpp/package-ubuntu-20.04.BUILD.bazel new file mode 100644 index 000000000000..82fba0b6b0ab --- /dev/null +++ b/tools/workspace/yaml_cpp/package-ubuntu-20.04.BUILD.bazel @@ -0,0 +1,14 @@ +# -*- python -*- + +licenses(["notice"]) # X11 + +cc_library( + name = "yaml_cpp", + hdrs = glob(["include/yaml-cpp/*.h"]), + includes = ["include"], + linkopts = [ + "-L/usr/lib/x86_64-linux-gnu", + "-lyaml-cpp", + ], + visibility = ["//visibility:public"], +) diff --git a/tools/workspace/yaml_cpp/repository.bzl b/tools/workspace/yaml_cpp/repository.bzl index aff1a7716bbc..65ee6b9fbeda 100644 --- a/tools/workspace/yaml_cpp/repository.bzl +++ b/tools/workspace/yaml_cpp/repository.bzl @@ -1,24 +1,40 @@ -# -*- mode: python -*- +# -*- python -*- -load( - "@drake//tools/workspace:pkg_config.bzl", - "pkg_config_repository", -) +load("@drake//tools/workspace:os.bzl", "determine_os") + +def _impl(repository_ctx): + os_result = determine_os(repository_ctx) + + if os_result.error != None: + fail(os_result.error) -def yaml_cpp_repository( - name, - licenses = ["notice"], # X11 - modname = "yaml-cpp", - atleast_version = "0.5.2", - extra_deps = ["@boost//:boost_headers"], - pkg_config_paths = ["/usr/local/opt/yaml-cpp/lib/pkgconfig"], - **kwargs): - pkg_config_repository( - name = name, - licenses = licenses, - modname = modname, - atleast_version = atleast_version, - extra_deps = extra_deps, - pkg_config_paths = pkg_config_paths, - **kwargs - ) + if os_result.is_macos: + repository_ctx.symlink( + "/usr/local/opt/yaml-cpp/include/yaml-cpp", + "include/yaml-cpp", + ) + repository_ctx.symlink( + Label( + "@drake//tools/workspace/yaml_cpp:package-macos.BUILD.bazel", + ), + "BUILD.bazel", + ) + elif os_result.is_ubuntu: + repository_ctx.symlink("/usr/include/yaml-cpp", "include/yaml-cpp") + repository_ctx.symlink( + Label( + ("@drake//tools/workspace/yaml_cpp" + + ":package-ubuntu-{}.BUILD.bazel").format( + os_result.ubuntu_release, + ), + ), + "BUILD.bazel", + ) + else: + fail("Operating system is NOT supported", attr = os_result) + +yaml_cpp_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +)