summaryrefslogtreecommitdiff
path: root/src/pal/automation/compile.py
blob: bb9d1b88ac8a2b65c4b31e8dad0baffe0efaec4d (plain)
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
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