From 8dc8020f8465027de6c2aaaed90718bc693651ed Mon Sep 17 00:00:00 2001 From: Hugh Sanderson Date: Wed, 31 Jul 2024 10:07:28 +0800 Subject: [PATCH] Add some basic .asm support --- toolchain/msvc-toolchain.xml | 2 ++ tools/hxcpp/BuildTool.hx | 2 ++ tools/hxcpp/Compiler.hx | 15 ++++++++++++--- tools/hxcpp/File.hx | 2 ++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/toolchain/msvc-toolchain.xml b/toolchain/msvc-toolchain.xml index 26c7a826c..83749ba16 100644 --- a/toolchain/msvc-toolchain.xml +++ b/toolchain/msvc-toolchain.xml @@ -108,6 +108,8 @@ + + diff --git a/tools/hxcpp/BuildTool.hx b/tools/hxcpp/BuildTool.hx index a98a00361..cd562929e 100644 --- a/tools/hxcpp/BuildTool.hx +++ b/tools/hxcpp/BuildTool.hx @@ -900,6 +900,7 @@ class BuildTool case "objcflag" : c.mOBJCFlags.push(substitute(el.att.value)); case "rcflag" : c.mRcFlags.push( substitute((el.att.value)) ); case "mmflag" : c.mMMFlags.push(substitute(el.att.value)); + case "asmflag" : c.mAsmFlags.push(substitute(el.att.value)); case "pchflag" : c.mPCHFlags.push(substitute(el.att.value)); case "objdir" : c.mObjDir = substitute((el.att.value)); case "outflag" : c.mOutFlag = substitute((el.att.value)); @@ -907,6 +908,7 @@ class BuildTool case "rcexe" : c.mRcExe = substitute((el.att.name)); case "rcext" : c.mRcExt = substitute((el.att.value)); case "ext" : c.mExt = substitute((el.att.value)); + case "asmExe" : c.mAsmExe = substitute((el.att.value)); case "pch" : c.setPCH( substitute((el.att.value)) ); case "getversion" : c.mGetCompilerVersion = substitute((el.att.value)); case "section" : createCompiler(el,c); diff --git a/tools/hxcpp/Compiler.hx b/tools/hxcpp/Compiler.hx index bf3c2372f..2d0b5bb17 100644 --- a/tools/hxcpp/Compiler.hx +++ b/tools/hxcpp/Compiler.hx @@ -35,8 +35,10 @@ class Compiler public var mCPPFlags:Array; public var mOBJCFlags:Array; public var mPCHFlags:Array; + public var mAsmFlags:Array; public var mAddGCCIdentity:Bool; public var mExe:String; + public var mAsmExe:String; public var mOutFlag:String; public var mObjDir:String; public var mRelObjDir:String; @@ -72,12 +74,14 @@ class Compiler mOBJCFlags = []; mMMFlags = []; mPCHFlags = []; + mAsmFlags = []; mAddGCCIdentity = false; mCompilerVersion = null; mRcExt = ".res"; mObjDir = "obj"; mOutFlag = "-o"; mExe = inExe; + mAsmExe = inExe; mID = inID; mExt = ".o"; mPCHExt = ".pch"; @@ -172,12 +176,13 @@ class Compiler function getArgs(inFile:File) { var nvcc = inFile.isNvcc(); + var asm = inFile.isAsm(); var isRc = mRcExe!=null && inFile.isResource(); var args = nvcc ? inFile.mGroup.mCompilerFlags.concat( BuildTool.getNvccFlags() ) : inFile.mCompilerFlags.concat(inFile.mGroup.mCompilerFlags); var tagFilter = inFile.getTags().split(","); addOptimTags(tagFilter); - if (!isRc) + if (!isRc && !asm) for(flag in mFlags) flag.add(args,tagFilter); var ext = mExt.toLowerCase(); @@ -191,7 +196,10 @@ class Compiler addIdentity(ext,args); var allowPch = false; - if (nvcc) + + if (asm) + args = args.concat(mAsmFlags); + else if (nvcc) args = args.concat(mNvccFlags); else if (isRc) args = args.concat(mRcFlags); @@ -297,7 +305,8 @@ class Compiler var obj_name = getObjName(inFile); var args = getArgs(inFile); var nvcc = inFile.isNvcc(); - var exe = nvcc ? BuildTool.getNvcc() : mExe; + var asm = inFile.isAsm(); + var exe = asm ? mAsmExe : nvcc ? BuildTool.getNvcc() : mExe; var isRc = mRcExe!=null && inFile.isResource(); if (isRc) exe = mRcExe; diff --git a/tools/hxcpp/File.hx b/tools/hxcpp/File.hx index 7b04621a6..f31b9ee9c 100644 --- a/tools/hxcpp/File.hx +++ b/tools/hxcpp/File.hx @@ -44,6 +44,8 @@ class File public function isNvcc() return mGroup.mNvcc; + public function isAsm() return mName.endsWith(".asm"); + public function isResource() return mName.endsWith(".rc"); public function keep(inDefines:Map)