# This script should be executed on the parent folder of the repository 'tensorflow-windows-build-script' (be it a fork or @guikarist original repo) # Updated according to new .so filenames in 1.15 # Changes: added compatibility for 1.15 (name changes, etc.) + copy several other needed headers from core/ and cc/ # Reminder to self: piping a command with verbose to Out-Null avoids printing to stdout! $TFVersion = Read-Host "Enter built tensorflow version (> 1.13 => '15', <=1.13 ==> '13')" if ($TFVersion -eq "15") { Write-Output "--------------- TF version > 1.13 ---------------" } else { Write-Output "--------------- TF version <= 1.13 ---------------" } Set-StrictMode -Version latest $ErrorActionPreference = "Stop" Remove-Item bin -ErrorAction SilentlyContinue -Force -Recurse # =================== Change bin and source dir to accomodate your needs =================== $tensorFlowBinDir = "$pwd\bin" mkdir $tensorFlowBinDir | Out-Null $tensorFlowSourceDir = "$pwd\tensorflow-windows-build-script\source" # =================== Tensorflow lib and includes =================== mkdir "$tensorFlowBinDir/tensorflow/lib" | Out-Null Write-Output "Copying tensorflow_cc.lib and tensorflow_cc.dll..." if ($TFVersion -eq "15") { # Note: if you run bazel build ... tensorflow_cc.lib, the second copy instruction may be not correct, as you will already have a .lib, if so change this as needed! Copy-Item $tensorFlowSourceDir\bazel-bin\tensorflow\tensorflow_cc.dll $tensorFlowBinDir\tensorflow\lib\tensorflow_cc.dll Copy-Item $tensorFlowSourceDir\bazel-bin\tensorflow\libtensorflow_cc.dll.ifso $tensorFlowBinDir\tensorflow\lib\tensorflow_cc.lib } else { Copy-Item $tensorFlowSourceDir\bazel-bin\tensorflow\libtensorflow_cc.so $tensorFlowBinDir\tensorflow\lib\tensorflow_cc.dll Copy-Item $tensorFlowSourceDir\bazel-bin\tensorflow\libtensorflow_cc.so.if.so $tensorFlowBinDir\tensorflow\lib\tensorflow_cc.lib } # =================== 1. Copy cc/ and core/ headers =================== Write-Output "Copying cc/ and core/ headers..." Robocopy $tensorFlowSourceDir\tensorflow\core $tensorFlowBinDir\tensorflow\include\tensorflow\core "*.h" /S | Out-Null Robocopy $tensorFlowSourceDir\tensorflow\cc $tensorFlowBinDir\tensorflow\include\tensorflow\cc "*.h" /S | Out-Null # =================== 2. Copy external and third party dependencies properly resolving with a deep copy the symlinks =================== Write-Output "Copying external and third_party dependencies..." # external/eigen: Robocopy $tensorFlowSourceDir\bazel-source\external\eigen_archive $tensorFlowBinDir\tensorflow\include\external\eigen_archive /S | Out-Null # absl (in earlier versions than 1.13 this package may be outside 'com_google' with the name 'absl' or similar) Robocopy $tensorFlowSourceDir\bazel-source\external\com_google_absl $tensorFlowBinDir\tensorflow\include\external\com_google_absl /S | Out-Null # nsync Robocopy $tensorFlowSourceDir\bazel-source\external\nsync $tensorFlowBinDir\tensorflow\include\external\nsync /S | Out-Null # protobuf (at least in 1.15, is under com_google_protobuf. We do not know if this change is present in 1.14, check it.) if ($TFVersion -eq "15") { Robocopy $tensorFlowSourceDir\bazel-source\external\com_google_protobuf $tensorFlowBinDir\tensorflow\include\external\com_google_protobuf /S | Out-Null } else { Robocopy $tensorFlowSourceDir\bazel-source\external\protobuf_archive $tensorFlowBinDir\tensorflow\include\external\protobuf_archive /S | Out-Null } # snappy Robocopy $tensorFlowSourceDir\bazel-source\external\snappy $tensorFlowBinDir\tensorflow\include\external\snappy /S | Out-Null # third_party/eigen3 Robocopy $tensorFlowSourceDir\bazel-source\third_party\eigen3 $tensorFlowBinDir\tensorflow\include\third_party\eigen3 /S | Out-Null # =================== 3. Copy more headers (.pb.h and .h) =================== Write-Output "Copying more .pb.h headers (protobuf, framework, lib/core)..." # .pb.h from core/framework: Robocopy $tensorFlowSourceDir\bazel-genfiles\tensorflow\core\framework $tensorFlowBinDir\tensorflow\include\tensorflow\core\framework "*.pb.h" /S | Out-Null # .pb.h from core/protobuf: Robocopy $tensorFlowSourceDir\bazel-genfiles\tensorflow\core\protobuf $tensorFlowBinDir\tensorflow\include\tensorflow\core\protobuf "*.pb.h" /S | Out-Null # .pb.h from core\lib\core: Robocopy $tensorFlowSourceDir\bazel-genfiles\tensorflow\core\lib\core $tensorFlowBinDir\tensorflow\include\tensorflow\core\lib\core "*.pb.h" /S | Out-Null # .h from cc\ops: Robocopy $tensorFlowSourceDir\bazel-genfiles\tensorflow\cc\ops $tensorFlowBinDir\tensorflow\include\tensorflow\cc\ops "*.h" /S | Out-Null Write-Output "Everything copied to '$tensorFlowBinDir', exitting script!"