Skip to content

Commit

Permalink
bump build-torch-core.sh to support FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
stites committed Nov 14, 2017
1 parent 15d9fc5 commit 6446493
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions codegen-and-rebuild.sh
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -eu

stack build hasktorch-codegen || {
echo "can't build torch-codegen, exiting early"
Expand Down
20 changes: 15 additions & 5 deletions interface/src/build-bindings.sh
@@ -1,22 +1,32 @@
#!/bin/bash -eu
#!/usr/bin/env bash
set -eu

# Build TorchStructs.hsc
c2hsc torch_structs.h

if [ "$(uname)" == "Darwin" ]; then
## OSX
case "$(uname -s)" in
"Darwin"|"FreeBSD")
## Treat FreeBSD the same as OSX for now
sed -i '' 's/<bindings.dsl.h>/"bindings.dsl.h"/g' TorchStructs.hsc
sed -i '' 's/^#synonym_t.*//g' TorchStructs.hsc
hsc2hs TorchStructs.hsc -o TorchStructs.hs
sed -i '' '/.*LINE.*/d' TorchStructs.hs
rm ./TorchStructs.hsc
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
;;

"Linux")
## Linux
sed -i 's/<bindings.dsl.h>/"bindings.dsl.h"/g' TorchStructs.hsc
sed -i 's/^#synonym_t.*//g' TorchStructs.hsc
hsc2hs TorchStructs.hsc -o TorchStructs.hs
sed -i '/.*LINE.*/d' TorchStructs.hs
rm ./TobchStructs.hsc
fi
;;

*)
echo "Unknown OS"
exit 1
;;
esac

echo "Done"
1 change: 1 addition & 0 deletions output/refresh.sh
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -eu

rsync -arv ./raw/src/*.hs ../raw/src/
rsync -arv ./raw/src/generic/*.hs ../raw/src/generic/
28 changes: 22 additions & 6 deletions vendor/build-torch-core.sh
@@ -1,30 +1,46 @@
#!/bin/bash -eu
#!/usr/bin/env bash
set -eu

# rm -rf ./build
mkdir -p ./build
# mkdir -p ./build-THS
# mkdir -p ./build-THNN

if [ "$(uname)" == "Darwin" ]; then
case "$(uname)" in
"Darwin")
if ! [ -x "$(command -v gcc-6)" ]; then
echo 'Error: gcc-6 is not installed, use homebrew to install it.' >&2
exit 1
fi
echo "Running as OSX ..."
CXX=g++-6
CC=gcc-6
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
;;

"Linux")
if ! [ -x "$(command -v gcc)" ]; then
echo 'Error: gcc is not installed.' >&2
exit 1
fi
echo "Running as Linux ..."
CXX=g++
CC=gcc
else
;;

"FreeBSD")
if ! [ -x "$(command -v gcc)" ]; then
echo 'Error: gcc is not installed.' >&2
exit 1
fi
echo "Running as FreeBSD..."
CXX=g++
CC=gcc
;;
*)
echo "Unknown OS"
exit
fi
exit 1
;;
esac

echo "Compilers:"
echo " $CXX"
Expand Down

0 comments on commit 6446493

Please sign in to comment.