Skip to content

Commit

Permalink
Fix gif build on Windows (tensorflow#4489)
Browse files Browse the repository at this point in the history
Using a genrule to remove "#include<unistd.h>" makes the build successful.
Ideally, we want the include could be configurable, but that's not true in the source code yet.
  • Loading branch information
meteorcloudy authored and martinwicke committed Sep 21, 2016
1 parent a0d929d commit fdcd01e
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions gif.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,49 @@ HEADERS = [
"gif_lib_private.h",
]

config_setting(
name = "windows",
values = {
"cpu": "x64_windows_msvc",
},
visibility = ["//visibility:public"],
)

prefix_dir = "giflib-5.1.4/lib"
prefix_dir_windows = "windows/giflib-5.1.4/lib"

genrule(
name = "srcs_without_unistd",
srcs = [prefix_dir + "/" + source for source in SOURCES],
outs = [prefix_dir_windows + "/" + source for source in SOURCES],
cmd = "for f in $(SRCS); do " +
" sed 's/#include <unistd.h>//g' $$f > $(@D)/%s/$$(basename $$f);" % prefix_dir_windows +
"done",
)

genrule(
name = "hdrs_without_unistd",
srcs = [prefix_dir + "/" + hdrs for hdrs in HEADERS],
outs = [prefix_dir_windows + "/" + hdrs for hdrs in HEADERS],
cmd = "for f in $(SRCS); do " +
" sed 's/#include <unistd.h>//g' $$f > $(@D)/%s/$$(basename $$f);" % prefix_dir_windows +
"done",
)

cc_library(
name = "gif",
srcs = [prefix_dir + "/" + source for source in SOURCES],
hdrs = [prefix_dir + "/" + hdrs for hdrs in HEADERS],
includes = [prefix_dir],
srcs = select({
"//conditions:default" : [prefix_dir + "/" + source for source in SOURCES],
":windows" : [":srcs_without_unistd"],
}),
hdrs = select({
"//conditions:default" : [prefix_dir + "/" + hdrs for hdrs in HEADERS],
":windows" : [":hdrs_without_unistd"],
}),
includes = select({
"//conditions:default" : [prefix_dir],
":windows" : [prefix_dir_windows],
}),
defines = [
"HAVE_CONFIG_H",
],
Expand Down

0 comments on commit fdcd01e

Please sign in to comment.