Add support for Windows Message Compiler
We've only got one user of this currently, but since it needs the location of the toolchain, and different flags based on 32 vs 64-bit, it's easier just to add support than to get this into a genrule. Test: Convert external/mdnsresponder to Soong, build Change-Id: I6c19a82bc14f6ab556f6cc5f37164862ba5f9083
This commit is contained in:
parent
ace7a6ba43
commit
4f1c3d4116
|
@ -158,6 +158,13 @@ var (
|
|||
},
|
||||
"asFlags")
|
||||
|
||||
windres = pctx.AndroidStaticRule("windres",
|
||||
blueprint.RuleParams{
|
||||
Command: "$windresCmd $flags -I$$(dirname $in) -i $in -o $out",
|
||||
CommandDeps: []string{"$windresCmd"},
|
||||
},
|
||||
"windresCmd", "flags")
|
||||
|
||||
_ = pctx.SourcePathVariable("sAbiDumper", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/header-abi-dumper")
|
||||
|
||||
// -w has been added since header-abi-dumper does not need to produce any sort of diagnostic information.
|
||||
|
@ -332,7 +339,8 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
|
||||
objFiles[i] = objFile
|
||||
|
||||
if srcFile.Ext() == ".asm" {
|
||||
switch srcFile.Ext() {
|
||||
case ".asm":
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: yasm,
|
||||
Description: "yasm " + srcFile.Rel(),
|
||||
|
@ -344,6 +352,19 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
},
|
||||
})
|
||||
continue
|
||||
case ".rc":
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: windres,
|
||||
Description: "windres " + srcFile.Rel(),
|
||||
Output: objFile,
|
||||
Input: srcFile,
|
||||
OrderOnly: deps,
|
||||
Args: map[string]string{
|
||||
"windresCmd": gccCmd(flags.toolchain, "windres"),
|
||||
"flags": flags.toolchain.WindresFlags(),
|
||||
},
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
var moduleCflags string
|
||||
|
|
|
@ -429,6 +429,11 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
|
|||
"-I"+android.PathForModuleGen(ctx, "yacc", ctx.ModuleDir()).String())
|
||||
}
|
||||
|
||||
if compiler.hasSrcExt(".mc") {
|
||||
flags.GlobalFlags = append(flags.GlobalFlags,
|
||||
"-I"+android.PathForModuleGen(ctx, "windmc", ctx.ModuleDir()).String())
|
||||
}
|
||||
|
||||
if compiler.hasSrcExt(".aidl") {
|
||||
if len(compiler.Properties.Aidl.Local_include_dirs) > 0 {
|
||||
localAidlIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Aidl.Local_include_dirs)
|
||||
|
|
|
@ -70,6 +70,8 @@ type Toolchain interface {
|
|||
|
||||
YasmFlags() string
|
||||
|
||||
WindresFlags() string
|
||||
|
||||
Is64Bit() bool
|
||||
|
||||
ShlibSuffix() string
|
||||
|
@ -135,6 +137,10 @@ func (toolchainBase) YasmFlags() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (toolchainBase) WindresFlags() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (toolchainBase) SanitizerRuntimeLibraryArch() string {
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -172,6 +172,14 @@ func (t *toolchainWindows) IncludeFlags() string {
|
|||
return "${config.WindowsIncludeFlags}"
|
||||
}
|
||||
|
||||
func (t *toolchainWindowsX86) WindresFlags() string {
|
||||
return "-F pe-i386"
|
||||
}
|
||||
|
||||
func (t *toolchainWindowsX8664) WindresFlags() string {
|
||||
return "-F pe-x86-64"
|
||||
}
|
||||
|
||||
func (t *toolchainWindows) ClangSupported() bool {
|
||||
return false
|
||||
}
|
||||
|
|
31
cc/gen.go
31
cc/gen.go
|
@ -54,6 +54,13 @@ var (
|
|||
Deps: blueprint.DepsGCC,
|
||||
},
|
||||
"aidlFlags", "outDir")
|
||||
|
||||
windmc = pctx.AndroidStaticRule("windmc",
|
||||
blueprint.RuleParams{
|
||||
Command: "$windmcCmd -r$$(dirname $out) -h$$(dirname $out) $in",
|
||||
CommandDeps: []string{"$windmcCmd"},
|
||||
},
|
||||
"windmcCmd")
|
||||
)
|
||||
|
||||
func genYacc(ctx android.ModuleContext, yaccFile android.Path, outFile android.ModuleGenPath, yaccFlags string) (headerFile android.ModuleGenPath) {
|
||||
|
@ -100,6 +107,26 @@ func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.Mod
|
|||
})
|
||||
}
|
||||
|
||||
func genWinMsg(ctx android.ModuleContext, srcFile android.Path, flags builderFlags) (android.Path, android.Path) {
|
||||
headerFile := android.GenPathWithExt(ctx, "windmc", srcFile, "h")
|
||||
rcFile := android.GenPathWithExt(ctx, "windmc", srcFile, "rc")
|
||||
|
||||
windmcCmd := gccCmd(flags.toolchain, "windmc")
|
||||
|
||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||
Rule: windmc,
|
||||
Description: "windmc " + srcFile.Rel(),
|
||||
Output: rcFile,
|
||||
ImplicitOutput: headerFile,
|
||||
Input: srcFile,
|
||||
Args: map[string]string{
|
||||
"windmcCmd": windmcCmd,
|
||||
},
|
||||
})
|
||||
|
||||
return rcFile, headerFile
|
||||
}
|
||||
|
||||
func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
buildFlags builderFlags) (android.Paths, android.Paths) {
|
||||
|
||||
|
@ -137,6 +164,10 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
|||
cppFile := rsGeneratedCppFile(ctx, srcFile)
|
||||
rsFiles = append(rsFiles, srcFiles[i])
|
||||
srcFiles[i] = cppFile
|
||||
case ".mc":
|
||||
rcFile, headerFile := genWinMsg(ctx, srcFile, buildFlags)
|
||||
srcFiles[i] = rcFile
|
||||
deps = append(deps, headerFile)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue