aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/mksdcard/build.gradle
blob: 1ea266d9ddbf863f437bae78e6290cc6bf906b34 (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
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
apply plugin: 'c'
apply plugin: 'sdk-files'

executables {
    mksdcard {}
}

sources {
    mksdcard {
        c {
            source {
                srcDir "src/source"
                include "**/*.c"
            }
        }
    }
}

model {
    platforms {
        linux {
            architecture "i386"
            operatingSystem "linux"
        }
        darwin {
            architecture "i386"
            operatingSystem "osx"
        }
        windows {
            architecture "i386"
            operatingSystem "windows"
        }
    }

    toolChains {
        host(Clang)
        mingw(Gcc) {
//            path "$project.rootDir/../prebuilts/gcc/linux-x86/host/i586-mingw32msvc-4.8/bin"

            addPlatformConfiguration(new MingwOnLinuxConfiguration(project))

            getCCompiler().executable =         'i586-mingw32msvc-gcc'
            getCppCompiler().executable =       'i586-mingw32msvc-g++'
            getLinker().executable =            'i586-mingw32msvc-gcc'
            getAssembler().executable =         'i586-mingw32msvc-as'
            getStaticLibArchiver().executable = 'i586-mingw32msvc-ar'
        }
    }
}

sdk {
    mac {
        item( { getExeName("darwin") } ) {
            executable true
            builtBy 'darwinMksdcardExecutable'
        }
    }
    linux {
        item( { getExeName("linux") } ) {
            executable true
            builtBy 'linuxMksdcardExecutable'
        }
    }
    windows {
        item( { getExeName("windows") } ) {
            name 'mksdcard.exe'
            builtBy 'windowsMksdcardExecutable'
        }
    }
}

def getExeName(String platform) {
    // binaries will return a set of binaries
    def binaries = executables.mksdcard.binaries.matching { it.name == "${platform}MksdcardExecutable" }
    // calling .exeFile on the set returns an array with the result from each item in the set...
    return binaries.executableFile.get(0)
}

class MingwOnLinuxConfiguration implements TargetPlatformConfiguration {

    Project project

    MingwOnLinuxConfiguration(Project project) {
        this.project = project
    }
    boolean supportsPlatform(Platform element) {
        return element.getOperatingSystem().name == "windows"
    }

    List<String> getCppCompilerArgs() {
        []
    }

    List<String> getCCompilerArgs() {
        ['-DUSE_MINGW', '-D__STDC_FORMAT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__USE_MINGW_ANSI_STDIO']
    }

    List<String> getObjectiveCCompilerArgs() {
        []
    }

    List<String> getObjectiveCppCompilerArgs() {
        []
    }

    List<String> getAssemblerArgs() {
        []
    }

    List<String> getLinkerArgs() {
        ['-enable-stdcall-fixup']
    }

    List<String> getStaticLibraryArchiverArgs() {
        []
    }
}