-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33960ae
commit cb7def3
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/env python | ||
# | ||
# Build script for CMAKE module | ||
# | ||
# Assumes FSLDIR is set. If FSLDEVDIR is also set, this will be used as the installation | ||
# prefix | ||
# | ||
# Note that arch is only currently used for Windows to set the correct VC compiler architecture | ||
|
||
import os, sys | ||
import shutil | ||
import traceback | ||
import stat | ||
|
||
def remove_readonly(func, path, excinfo): | ||
os.chmod(path, stat.S_IWRITE) | ||
func(path) | ||
|
||
def rmdir(d): | ||
try: | ||
shutil.rmtree(d, onerror=remove_readonly) | ||
except: | ||
print("Error removing %s" % d) | ||
traceback.print_exc(limit=0) | ||
|
||
win = sys.platform.startswith("win") | ||
osx = sys.platform.startswith("darwin") | ||
|
||
if len(sys.argv) < 3: | ||
print("Usage: build.py <type> <arch> [--install]") | ||
sys.exit(1) | ||
|
||
build_type = sys.argv[1] | ||
arch = sys.argv[2] | ||
install = "--install" in sys.argv | ||
|
||
rootdir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) | ||
builddir = os.path.join(rootdir, "build_%s" % build_type) | ||
rmdir(builddir) | ||
os.makedirs(builddir) | ||
cwd = os.getcwd() | ||
os.chdir(builddir) | ||
|
||
cmake_opts = "-DCMAKE_BUILD_TYPE=%s" % build_type | ||
if install: | ||
installdir = os.environ.get("FSLDEVDIR", os.environ["FSLDIR"]) | ||
cmake_opts += ' -DCMAKE_INSTALL_PREFIX="%s"' % installdir | ||
|
||
if win: | ||
if "VCINSTALLDIR" not in os.environ: | ||
print("You must run this script from the Visual Studio tools command line") | ||
sys.exit(1) | ||
os.system('"%s/vcvarsall" %s' % (os.environ["VCINSTALLDIR"], arch)) | ||
cmake_opts += ' -G "NMake Makefiles"' | ||
make = "nmake" | ||
else: | ||
make = "make" | ||
|
||
os.system("cmake .. %s" % cmake_opts) | ||
os.system(make) | ||
if install: | ||
os.system("%s install" % make) | ||
else: | ||
os.system(make) | ||
|
||
os.chdir(cwd) | ||
|