summaryrefslogtreecommitdiff
path: root/src/pal/automation
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-11-23 19:09:09 +0900
commit4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch)
tree98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/automation
parentfa45f57ed55137c75ac870356a1b8f76c84b229c (diff)
downloadcoreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/automation')
-rw-r--r--src/pal/automation/automation.py78
-rw-r--r--src/pal/automation/compile.py70
-rw-r--r--src/pal/automation/tests.py33
-rw-r--r--src/pal/automation/util.py97
4 files changed, 278 insertions, 0 deletions
diff --git a/src/pal/automation/automation.py b/src/pal/automation/automation.py
new file mode 100644
index 0000000000..d8ddaa9117
--- /dev/null
+++ b/src/pal/automation/automation.py
@@ -0,0 +1,78 @@
+import logging as log
+import sys
+import getopt
+import os
+import subprocess
+import shutil
+import compile
+import tests
+import util
+
+target = ""
+arch = ""
+platform = ""
+workspace = ""
+fullbuilddirpath = ""
+cleanUp = True
+
+def ParseArgs(argv):
+ global target
+ global platform
+ global arch
+ global cleanUp
+
+ returncode,target,platform,arch,cleanUp = util.ParseArgs(argv)
+ return returncode
+
+def Initialize():
+ global workspace
+ workspace = util.Initialize(platform)
+ return 0
+
+def SetupDirectories():
+ global fullbuilddirpath
+ fullbuilddirpath = util.SetupDirectories(target, arch, platform)
+
+ return 0
+
+def CopyBinaries():
+ print "\n==================================================\n"
+ print "Stub for copying binaries"
+ print "\n==================================================\n"
+
+ return 0
+
+def main(argv):
+ returncode = ParseArgs(argv)
+ if returncode != 0:
+ return returncode
+
+ returncode += Initialize()
+ if returncode != 0:
+ return returncode
+
+ returncode += SetupDirectories()
+ if returncode != 0:
+ return returncode
+
+ returncode += compile.Compile(workspace, target, platform, arch)
+ if returncode != 0:
+ return returncode
+
+ returncode += CopyBinaries()
+ if returncode != 0:
+ return returncode
+
+ returncode += tests.RunTests(platform, fullbuilddirpath, workspace)
+ if returncode != 0:
+ return returncode
+
+ return returncode
+
+if __name__ == "__main__":
+ returncode = main(sys.argv[1:])
+
+ util.Cleanup(cleanUp,workspace)
+
+ sys.exit(returncode)
+
diff --git a/src/pal/automation/compile.py b/src/pal/automation/compile.py
new file mode 100644
index 0000000000..bb9d1b88ac
--- /dev/null
+++ b/src/pal/automation/compile.py
@@ -0,0 +1,70 @@
+import logging as log
+import sys
+import getopt
+import os
+import subprocess
+import shutil
+
+def RunCMake(workspace, target, platform):
+ # run CMake
+ print "\n==================================================\n"
+
+ returncode = 0
+ if platform == "windows":
+ print "Running: vcvarsall.bat x86_amd64 && " + workspace + "\ProjectK\NDP\clr\src\pal\\tools\gen-buildsys-win.bat " + workspace + "\ProjectK\NDP\clr"
+ print "\n==================================================\n"
+ sys.stdout.flush()
+ returncode = subprocess.call(["vcvarsall.bat", "x86_amd64", "&&", workspace + "\ProjectK\NDP\clr\src\pal\\tools\gen-buildsys-win.bat", workspace + "\ProjectK\NDP\clr"])
+ elif platform == "linux":
+ print "Running: " + workspace + "/ProjectK/NDP/clr/src/pal/tools/gen-buildsys-clang.sh " + workspace + "/ProjectK/NDP/clr DEBUG"
+ print "\n==================================================\n"
+ sys.stdout.flush()
+ returncode = subprocess.call(workspace + "/ProjectK/NDP/clr/src/pal/tools/gen-buildsys-clang.sh " + workspace + "/ProjectK/NDP/clr " + target, shell=True)
+
+ if returncode != 0:
+ print "ERROR: cmake failed with exit code " + str(returncode)
+
+ return returncode
+
+def RunBuild(target, platform, arch):
+ if platform == "windows":
+ return RunMsBuild(target, arch)
+ elif platform == "linux":
+ return RunMake()
+
+def RunMsBuild(target, arch):
+ # run MsBuild
+ print "\n==================================================\n"
+ print "Running: vcvarsall.bat x86_amd64 && msbuild CoreCLR.sln /p:Configuration=" + target + " /p:Platform=" + arch
+ print "\n==================================================\n"
+ sys.stdout.flush()
+
+ returncode = subprocess.call(["vcvarsall.bat","x86_amd64","&&","msbuild","CoreCLR.sln","/p:Configuration=" + target,"/p:Platform=" + arch])
+
+ if returncode != 0:
+ print "ERROR: vcvarsall.bat failed with exit code " + str(returncode)
+
+ return returncode
+
+def RunMake():
+ print "\n==================================================\n"
+ print "Running: make"
+ print "\n==================================================\n"
+ sys.stdout.flush()
+ returncode = subprocess.call(["make"])
+
+ if returncode != 0:
+ print "ERROR: make failed with exit code " + str(returncode)
+
+ return returncode
+
+def Compile(workspace, target, platform, arch):
+ returncode = RunCMake(workspace, target, platform)
+ if returncode != 0:
+ return returncode
+
+ returncode += RunBuild(target, platform, arch)
+ if returncode != 0:
+ return returncode
+
+ return returncode
diff --git a/src/pal/automation/tests.py b/src/pal/automation/tests.py
new file mode 100644
index 0000000000..e48e84fd1d
--- /dev/null
+++ b/src/pal/automation/tests.py
@@ -0,0 +1,33 @@
+import sys
+import getopt
+import os
+import subprocess
+import shutil
+import logging as log
+
+def RunPalTests(fullbuilddirpath, workspace):
+ print "\n==================================================\n"
+ print "Running PAL Tests."
+ print "\n==================================================\n"
+
+ print "Running: " + workspace + "/ProjectK/NDP/clr/src/pal/tests/palsuite/runpaltests.sh " + fullbuilddirpath + " " + fullbuilddirpath + "/PalTestOutput"
+ print "\n==================================================\n"
+ sys.stdout.flush()
+ returncode = subprocess.call(workspace + "/ProjectK/NDP/clr/src/pal/tests/palsuite/runpaltests.sh " + fullbuilddirpath + " " + fullbuilddirpath + "/PalTestOutput", shell=True)
+
+ if returncode != 0:
+ print "ERROR: there were errors failed with exit code " + str(returncode)
+
+ return returncode
+
+
+def RunTests(platform, fullbuilddirpath, workspace):
+ returncode = 0
+
+ if platform == "linux":
+ # Execute PAL tests
+ returncode = RunPalTests(fullbuilddirpath, workspace)
+
+ return returncode
+
+
diff --git a/src/pal/automation/util.py b/src/pal/automation/util.py
new file mode 100644
index 0000000000..790cbc4dbf
--- /dev/null
+++ b/src/pal/automation/util.py
@@ -0,0 +1,97 @@
+import sys
+import getopt
+import os
+import subprocess
+import shutil
+import logging as log
+
+def Initialize(platform):
+ print "Initializing Workspace"
+ global workspace
+ workspace = os.environ['WORKSPACE']
+ if platform == "windows":
+ # Jenkins puts quotes in the path, which is wrong. Remove quotes.
+ os.environ['PATH'] = os.environ['PATH'].replace('"','')
+
+ return workspace
+
+def ParseArgs(argv):
+ print "Parsing arguments for compile"
+ try:
+ opts, args = getopt.getopt(argv, "t:p:a:v", ["target=", "platform=", "arch=", "verbose","noclean"])
+ except getopt.GetoptError:
+ print "ERROR: \n\t usage: python compile.py --target <target> --platform <windows|linux> --arch <arch> [--verbose] [--noclean]"
+ return 2,"","","",True
+
+ verbose = False
+ cleanUp = True
+
+ acceptedPlatforms = ['windows','linux']
+
+ for opt, arg in opts:
+ if opt in ("-t", "--target"):
+ target = arg
+ elif opt in ("-p", "--platform"):
+ if arg.lower() not in acceptedPlatforms:
+ print "ERROR: " + arg + "not an accepted platform. Use windows or linux."
+ sys.exit(2)
+ platform = arg.lower()
+ elif opt in ("-a", "--arch"):
+ arch = arg
+ elif opt in ("-v", "--verbose"):
+ verbose = True
+ elif opt in ("-c", "--noclean"):
+ cleanUp = False
+
+ if verbose:
+ log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG)
+ log.info("In verbose mode.")
+ else:
+ log.basicConfig(format="%(levelname)s: %(message)s")
+
+ if target == "" or platform == "" or arch == "":
+ # must specify target, project and arch
+ log.error("Must specify target, project and arch")
+ return 2,"","","",True
+
+ return 0,target,platform,arch,cleanUp
+
+def SetupDirectories(target, arch, platform):
+ log.info("Setting up directories")
+
+ global rootdir
+ global builddir
+ global fullBuildDirPath
+
+ rootdir = "build"
+ if not os.path.isdir(rootdir):
+ os.mkdir(rootdir)
+ os.chdir(rootdir)
+
+ builddir = "build-" + platform
+
+ if platform == "windows":
+ builddir = builddir + "-" + arch + "-" + target
+
+ if os.path.isdir(builddir):
+ shutil.rmtree(builddir)
+ os.mkdir(builddir)
+ os.chdir(builddir)
+
+ fullbuilddirpath = workspace + "/" + rootdir + "/" + builddir
+
+ return fullbuilddirpath
+
+def Cleanup(cleanUp,workspace):
+ print "\n==================================================\n"
+ print "Cleaning Up."
+ print "\n==================================================\n"
+
+ if cleanUp:
+ os.chdir(workspace + "/" + rootdir)
+ shutil.rmtree(builddir)
+ os.chdir("..")
+ shutil.rmtree(rootdir)
+
+ log.shutdown()
+ return 0