Support .asm files for assembly

am: 91e9004086

Change-Id: I01a4e6c1af780192923a9692a9a76375bdd43012
This commit is contained in:
Colin Cross 2016-12-03 07:16:00 +00:00 committed by android-build-merger
commit 909d6c424c
7 changed files with 49 additions and 0 deletions

View file

@ -158,6 +158,16 @@ var (
Description: "tidy $out",
},
"cFlags", "tidyFlags")
yasmCmd = pctx.SourcePathVariable("yasmCmd", "prebuilts/misc/${config.HostPrebuiltTag}/yasm/yasm")
yasm = pctx.AndroidStaticRule("yasm",
blueprint.RuleParams{
Command: "$yasmCmd $asFlags -o $out $in",
CommandDeps: []string{"$yasmCmd"},
Description: "yasm $out",
},
"asFlags")
)
func init() {
@ -183,6 +193,7 @@ type builderFlags struct {
yaccFlags string
protoFlags string
tidyFlags string
yasmFlags string
toolchain config.Toolchain
clang bool
tidy bool
@ -240,6 +251,19 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
objFiles[i] = objFile
if srcFile.Ext() == ".asm" {
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: yasm,
Output: objFile,
Input: srcFile,
OrderOnly: deps,
Args: map[string]string{
"asFlags": flags.yasmFlags,
},
})
continue
}
var moduleCflags string
var ccCmd string
tidy := flags.tidy && flags.clang

View file

@ -101,6 +101,7 @@ type Flags struct {
LdFlags []string // Flags that apply to linker command lines
libFlags []string // Flags to add libraries early to the link order
TidyFlags []string // Flags that apply to clang-tidy
YasmFlags []string // Flags that apply to yasm assembly source files
Toolchain config.Toolchain
Clang bool

View file

@ -147,6 +147,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
flags.CppFlags = append(flags.CppFlags, esc(compiler.Properties.Cppflags)...)
flags.ConlyFlags = append(flags.ConlyFlags, esc(compiler.Properties.Conlyflags)...)
flags.AsFlags = append(flags.AsFlags, esc(compiler.Properties.Asflags)...)
flags.YasmFlags = append(flags.YasmFlags, esc(compiler.Properties.Asflags)...)
flags.YaccFlags = append(flags.YaccFlags, esc(compiler.Properties.Yaccflags)...)
// Include dir cflags
@ -281,6 +282,8 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
} else {
flags.CppFlags = append(flags.CppFlags, tc.Cppflags())
}
flags.YasmFlags = append(flags.YasmFlags, tc.YasmFlags())
}
if flags.Clang {

View file

@ -66,6 +66,8 @@ type Toolchain interface {
ClangLdflags() string
ClangInstructionSetFlags(string) (string, error)
YasmFlags() string
Is64Bit() bool
ShlibSuffix() string
@ -127,6 +129,10 @@ func (toolchainBase) ClangAsflags() string {
return ""
}
func (toolchainBase) YasmFlags() string {
return ""
}
func (toolchainBase) SanitizerRuntimeLibraryArch() string {
return ""
}

View file

@ -166,6 +166,9 @@ func init() {
pctx.StaticVariable("X86_64ClangLdflags", strings.Join(ClangFilterUnknownCflags(x86_64Ldflags), " "))
pctx.StaticVariable("X86_64ClangCppflags", strings.Join(ClangFilterUnknownCflags(x86_64Cppflags), " "))
// Yasm flags
pctx.StaticVariable("X86_64YasmFlags", "-f elf64 -m amd64")
// Extended cflags
// Architecture variant cflags
@ -245,6 +248,10 @@ func (t *toolchainX86_64) ClangLdflags() string {
return "${config.X86_64Ldflags}"
}
func (t *toolchainX86_64) YasmFlags() string {
return "${config.X86_64YasmFlags}"
}
func (toolchainX86_64) SanitizerRuntimeLibraryArch() string {
return "x86_64"
}

View file

@ -188,6 +188,9 @@ func init() {
pctx.StaticVariable("X86ClangLdflags", strings.Join(ClangFilterUnknownCflags(x86Ldflags), " "))
pctx.StaticVariable("X86ClangCppflags", strings.Join(ClangFilterUnknownCflags(x86Cppflags), " "))
// Yasm flags
pctx.StaticVariable("X86YasmFlags", "-f elf32 -m x86")
// Extended cflags
// Architecture variant cflags
@ -267,6 +270,10 @@ func (t *toolchainX86) ClangLdflags() string {
return "${config.X86Ldflags}"
}
func (t *toolchainX86) YasmFlags() string {
return "${config.X86YasmFlags}"
}
func (toolchainX86) SanitizerRuntimeLibraryArch() string {
return "i686"
}

View file

@ -97,6 +97,7 @@ func flagsToBuilderFlags(in Flags) builderFlags {
ldFlags: strings.Join(in.LdFlags, " "),
libFlags: strings.Join(in.libFlags, " "),
tidyFlags: strings.Join(in.TidyFlags, " "),
yasmFlags: strings.Join(in.YasmFlags, " "),
toolchain: in.Toolchain,
clang: in.Clang,
tidy: in.Tidy,