forked from BerkeleyAutomation/python-fcl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_win32.ps1
131 lines (101 loc) · 3.88 KB
/
build_win32.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<#
***************************************************************************
Run using Administrator PowerShell prompt. WILL FAIL WITHOUT PROPER ACCESS
This is because the script places build artifacts in C:\Program Files (x86)
***************************************************************************
This script builds fcl and it's dependencies for python-fcl on Windows.
It downloads, builds, installs, and then deletes:
* fcl
* libccd
* eigen
* octomap
#>
# Ensure that paths are constant between runs
pushd $PSScriptRoot
# Create a directory that encapsulates all Git repos
mkdir fcl; cd fcl
#------------------------------------------------------------------------------
# Eigen
Write-Host "Building Eigen"
git clone https://gitlab.com/libeigen/eigen.git
cd eigen
mkdir build; cd build
cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=ON ..
cmake --build . --config Release --target install
Write-Host "Done"
cd ../..
# ------------------------------------------------------------------------------
# LibCCD
Write-Host "Building LibCCD"
git clone https://github.com/danfis/libccd
cd libccd
mkdir build; cd build
cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=ON ..
cmake --build . --config Release --target install
Write-Host "Done"
cd ../..
# FCL won't be able to find libccd unless it is named "ccd" exactly
Rename-Item "C:\Program Files (x86)\libccd" ccd
# ------------------------------------------------------------------------------
# Octomap
Write-Host "Building Octomap"
git clone https://github.com/OctoMap/octomap
cd octomap
mkdir build; cd build
cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=ON ..
# Build Octomap (won't install for some reason)
cmake --build . --config Release --target install
# Now rebuild, which installs correctly
cmake --build . --config Release --target install
Write-Host "Done"
cd ../../
# FCL won't be able to find octomap unless it is named "octomap" exactly
Rename-Item "C:\Program Files (x86)\octomap-distribution" octomap
# ------------------------------------------------------------------------------
# FCL
Write-Host "Building FCL"
git clone https://github.com/flexible-collision-library/fcl
cd fcl
# Checkout specific version 0.5.0 (only one compatible with python-fcl)
git checkout 7075caf32ddcd5825ff67303902e3db7664a407a
mkdir build; cd build
# Fiddle with build file to help fcl find LibCCD and Octomap
# Also tells compiler to dynamically link with C runtime (matches Cython)
$build_script_modification = @"
find_package(ccd QUIET)
find_package(octomap QUIET)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL$<$<CONFIG:Debug>:Debug>")
"@
$filePath = "../CMakeLists.txt"
$lineNumber = 11
$fileContent = Get-Content $filePath
$fileContent[$lineNumber-1] = $build_script_modification
$fileContent | Set-Content $filePath
# Now perform actual build
cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" ..
cmake --build . --config Release --target install
Write-Host "Done"
cd ../../
# ------------------------------------------------------------------------------
# Python-FCL
cd ../
# Delete compilation directory since it is no longer needed
del -Force -Recurse fcl
cd ../
$fcl_dir = './fcl'
Write-Host "Copying dependent DLLs"
ls "C:/Program Files (x86)/octomap/bin/*.dll" | cp -destination $fcl_dir
cp "C:/Program Files (x86)/ccd/bin/ccd.dll" $fcl_dir
Start-Sleep -s 5
# Now build Cython extension
python setup-win32.py install
Write-Host "Successfully built python-fcl"
# Now delete all of the installed dependencies (after building python-fcl)
Write-Host "Removing build directories for Eigen, LibCCD, FCL, and Octomap"
rmdir -r 'C:\Program Files (x86)\Eigen3'
rmdir -r 'C:\Program Files (x86)\ccd'
rmdir -r 'C:\Program Files (x86)\fcl'
rmdir -r 'C:\Program Files (x86)\octomap'
Write-Host "All done!"
# Make sure to return the cwd to wherever it was before the build
popd