{"action":"created","issue":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/2625","repository_url":"https://api.github.com/repos/bazelbuild/bazel","labels_url":"https://api.github.com/repos/bazelbuild/bazel/issues/2625/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/bazel/issues/2625/comments","events_url":"https://api.github.com/repos/bazelbuild/bazel/issues/2625/events","html_url":"https://github.com/bazelbuild/bazel/issues/2625","id":211572690,"number":2625,"title":"How to setup WORKSPACE/CROSSTOOL for linux & darwin toolchains","user":{"login":"jemdiggity","id":1940552,"avatar_url":"https://avatars2.githubusercontent.com/u/1940552?v=3","gravatar_id":"","url":"https://api.github.com/users/jemdiggity","html_url":"https://github.com/jemdiggity","followers_url":"https://api.github.com/users/jemdiggity/followers","following_url":"https://api.github.com/users/jemdiggity/following{/other_user}","gists_url":"https://api.github.com/users/jemdiggity/gists{/gist_id}","starred_url":"https://api.github.com/users/jemdiggity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jemdiggity/subscriptions","organizations_url":"https://api.github.com/users/jemdiggity/orgs","repos_url":"https://api.github.com/users/jemdiggity/repos","events_url":"https://api.github.com/users/jemdiggity/events{/privacy}","received_events_url":"https://api.github.com/users/jemdiggity/received_events","type":"User","site_admin":false},"labels":[{"id":287449932,"url":"https://api.github.com/repos/bazelbuild/bazel/labels/category:%20extensibility%20%3E%20external%20repositories","name":"category: extensibility > external repositories","color":"d4c5f9","default":false},{"id":192356640,"url":"https://api.github.com/repos/bazelbuild/bazel/labels/type:%20documentation","name":"type: documentation","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-03-03T01:48:37Z","updated_at":"2017-03-20T09:52:17Z","closed_at":null,"body":"I'm trying to setup Bazel for cross-compiling with gcc-arm-none-eabi for developers using either Linux or Mac OS.\r\n\r\nI followed the examples at https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain and setup a workspace that works with gcc-arm-none-eabi on Mac OS (https://github.com/jemdiggity/bazel_arm_none). I would like it to work on Linux as well.\r\n\r\nThe WORKSPACE has gcc-arm-none-eabi toolchain for Mac OS as a dependency so it's automatically fetched. If I add the toolchain for Linux as well, they will both be fetched even though the developer on the Linux host doesn't require the toolchain for Mac OS, and vice versa.\r\n\r\n```python\r\nnew_http_archive(\r\n  name = 'toolchain_gcc_arm_none_darwin',\r\n  build_file = 'compilers/gcc_arm_none.BUILD',\r\n  url = 'https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-mac.tar.bz2',\r\n  strip_prefix = 'gcc-arm-none-eabi-5_4-2016q3',\r\n)\r\n```\r\n\r\nIt doesn't seem to be possible to make the external dependencies in the WORKSPACE file dependent on the host OS.\r\n\r\nI would like only the relevant toolchain to be fetched and to use the same wrapper scripts and CROSSTOOL file on either linux or mac os.\r\n\r\nDo I need to write a custom repository rule? Similar to https://github.com/tensorflow/tensorflow/blob/master/third_party/gpus/cuda_configure.bzl.\r\n\r\nIs there a simpler approach? Any guidance would be appreciated.\r\n\r\nThanks for your time.\r\n\r\n### Environment info\r\n* Operating System:\r\nmacOS 10.12.3 (16D32)\r\n\r\n* Bazel version (output of `bazel info release`):\r\nrelease 0.4.4-homebrew\r\n\r\n* If `bazel info release` returns \"development version\" or \"(@non-git)\", please tell us what source tree you compiled Bazel from; git commit hash is appreciated (`git rev-parse HEAD`):\r\n"},"comment":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/comments/287714764","html_url":"https://github.com/bazelbuild/bazel/issues/2625#issuecomment-287714764","issue_url":"https://api.github.com/repos/bazelbuild/bazel/issues/2625","id":287714764,"user":{"login":"jemdiggity","id":1940552,"avatar_url":"https://avatars2.githubusercontent.com/u/1940552?v=3","gravatar_id":"","url":"https://api.github.com/users/jemdiggity","html_url":"https://github.com/jemdiggity","followers_url":"https://api.github.com/users/jemdiggity/followers","following_url":"https://api.github.com/users/jemdiggity/following{/other_user}","gists_url":"https://api.github.com/users/jemdiggity/gists{/gist_id}","starred_url":"https://api.github.com/users/jemdiggity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jemdiggity/subscriptions","organizations_url":"https://api.github.com/users/jemdiggity/orgs","repos_url":"https://api.github.com/users/jemdiggity/repos","events_url":"https://api.github.com/users/jemdiggity/events{/privacy}","received_events_url":"https://api.github.com/users/jemdiggity/received_events","type":"User","site_admin":false},"created_at":"2017-03-20T09:52:17Z","updated_at":"2017-03-20T09:52:17Z","body":"I made a repository rule similar to http_archive but selects archive based on the OS.\r\nhttps://github.com/jemdiggity/rules_os_dependent_http_archive\r\n\r\n```python\r\nos_dependent_http_archive(\r\n  name = \"toolchain_gcc_arm_none\",\r\n  build_file = \"//:compilers/gcc_arm_none.BUILD\",\r\n  strip_prefix = 'gcc-arm-none-eabi-5_4-2016q3',\r\n  urls = {\r\n    \"linux\" : [\"https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2\"],\r\n    \"darwin\" : ['https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-mac.tar.bz2'],\r\n  },\r\n  sha256 = {\r\n    \"linux\" : \"a397c49bdd0cf17a38a494cb691baf68b8dcffa4d4c06561ef3d71b2ab4c92a1\",\r\n    \"darwin\" : \"5656cdec40f99d5c054a85bbc694276e1c4a1488cdacbbc448bc6acd3bbe070d\",\r\n  },\r\n)\r\n```"}}
{"actor":{"display_login":"jemdiggity"}}