diff --git a/build/buildlib.xs b/build/buildlib.xs
--- a/build/buildlib.xs
+++ b/build/buildlib.xs
* This file contains common routines that are used by the various McBSP
* driver components.
*
- * Copyright (C) 2011-2015, Texas Instruments, Inc.
+ * Copyright (C) 2011-2016, Texas Instruments, Inc.
*****************************************************************************/
-/**************************************************************************
- * FUNCTION NAME : createMiniPkg
- **************************************************************************
- * DESCRIPTION :
- * The function is responsible for creating the mini tar package
- * The MINI package has the following files:-
- * - Driver Source Files.
- * - Header files (exported and internal driver files)
- * - Simple Makefiles.
- **************************************************************************/
-function createMiniPkg(pkgName)
-{
- /* Get the package Name. */
- var packageRepository = xdc.getPackageRepository(Pkg.name);
- var packageBase = xdc.getPackageBase(Pkg.name);
- var packageName = packageBase.substring(packageRepository.length + 1);
-
- /* Convert the Package name by replacing back slashes with forward slashes. This is required because
- * otherwise with long names the tar is unable to change directory. */
- var newPkgName = new java.lang.String(packageRepository);
- var newPkgRep = newPkgName.replace('\\', '/');
-
- /* Step1: Create the MINI Package and add the simple Big and Little Endian Makefiles to the package */
- Pkg.makeEpilogue += "release: mini_pkg\n";
- Pkg.makeEpilogue += "mini_pkg:\n";
- Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -cf packages/" + pkgName + "_mini.tar " + packageName + "simpleC66LE.mak " + packageName + "simpleC66BE.mak\n";
-
- /* Step2: Add the exported header files to the package */
- var includeFiles = libUtility.listAllFiles (".h", ".", false);
- for (var k = 0 ; k < includeFiles.length; k++)
- Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -rf packages/" + pkgName + "_mini.tar " + packageName + includeFiles[k] + "\n";
-
- /* Step3: Add the internal header files to the package */
- includeFiles = libUtility.listAllFiles (".h", "include", true);
- for (var k = 0 ; k < includeFiles.length; k++)
- Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -rf packages/" + pkgName + "_mini.tar " + packageName + includeFiles[k] + "\n";
-
- includeFiles = libUtility.listAllFiles (".h", "device", true);
- for (var k = 0 ; k < includeFiles.length; k++)
- Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -rf packages/" + pkgName + "_mini.tar " + packageName + includeFiles[k] + "\n";
-
- /* Step4: Add the device McBSP file (Example file) which illustrates McBSP device initialization. */
- var deviceSrcFiles = libUtility.listAllFiles (".c", "device", true);
- for (var k = 0 ; k < deviceSrcFiles.length; k++)
- Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -rf packages/" + pkgName + "_mini.tar " + packageName + deviceSrcFiles[k] + "\n";
-
- /* Step5: Add the driver source files to the package; the filter should have generated a source listing */
- Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -T src.lst -rf packages/" + pkgName + "_mini.tar " + "\n";
-
- /* Ensure that we clean up the mini package */
- Pkg.makeEpilogue += "clean::\n";
- Pkg.makeEpilogue += "\t $(RM) packages/" + pkgName + "_mini.tar\n";
-}
-
/**************************************************************************
* FUNCTION NAME : listAllFiles
**************************************************************************
* present in a directory and any directory inside it.
**************************************************************************/
function listAllFiles(ext, dir, recurse)
-{
+{
var srcFile = [];
var d;
recurse = true;
if (dir == undefined)
- d = ".";
+ d = ".";
else
- d = dir;
+ d = dir;
/* Get access to the current directory. */
var file = new java.io.File(d);
}
}
}
+
return srcFile;
}
return null;
}
+
function createMake(makefile)
{
/* Create the main make file */
return makefile;
}
-function createLibMake(makelibname,targetname, objectPath)
+function createLibMake(device, makelibname,targetname, objectPath)
{
var tooldir;
+ var cmdprefix;
+ var targetDir;
var stringname=String(targetname).replace("(xdc.bld.ITarget.Module)","");
- if(stringname.match("ARM11"))
- {
- tooldir="TI_ARM11_GEN_INSTALL_PATH";
- }
- else
- {
- tooldir="C6X_GEN_INSTALL_PATH";
- }
+
switch(stringname)
{
case String(C66LE):
+ tooldir="C6X_GEN_INSTALL_PATH";
+ cmdprefix="";
+ targetDir="c66";
targetname=C66LE;
break;
case String(C66BE):
+ tooldir="C6X_GEN_INSTALL_PATH";
+ cmdprefix="";
+ targetDir="c66";
targetname=C66BE;
break;
+ case String(A15LE):
+ tooldir="TOOLCHAIN_PATH_A15";
+ cmdprefix="CROSS_TOOL_PRFX";
+ targetDir="armv7";
+ targetname=A15LE;
+ break;
+ case String(A9LE):
+ tooldir="TOOLCHAIN_PATH_A9";
+ cmdprefix="CROSS_TOOL_PRFX";
+ targetDir="armv7";
+ targetname=A9LE;
+ break;
+ case String(A8LE):
+ tooldir="TOOLCHAIN_PATH_A8";
+ cmdprefix="CROSS_TOOL_PRFX";
+ targetDir="armv7";
+ targetname=A8LE;
+ break;
+ case String(M4LE):
+ tooldir="TOOLCHAIN_PATH_M4";
+ cmdprefix="";
+ targetDir="m4";
+ targetname=M4LE;
+ break;
+ case String(ARM11):
+ tooldir="TI_ARM11_GEN_INSTALL_PATH";
+ break;
case String(C67LE):
+ tooldir="C6X_GEN_INSTALL_PATH";
+ cmdprefix="";
+ targetDir="c66";
targetname=C67LE;
break;
libmakefile.writeLine("#");
libmakefile.writeLine("empty =");
libmakefile.writeLine("space =$(empty) $(empty)");
-
- if(stringname.match("ti.targets"))
+
+ if ((targetname.name == "A15F") || (targetname.name == "A9F") || (targetname.name == "A8F"))
{
+
+ if(stringname.match("gnu.targets"))
+ {
+ libmakefile.writeLine("CC = $("+tooldir+")/bin/$("+cmdprefix+")gcc");
+ libmakefile.writeLine("AC = $("+tooldir+")/bin/$("+cmdprefix+")as");
+ libmakefile.writeLine("ARIN = $("+tooldir+")/bin/$("+cmdprefix+")ar");
+ libmakefile.writeLine("LD = $("+tooldir+")/bin/$("+cmdprefix+")gcc");
+ }
+ else
+ {
+ print("Error: Non-GNU targets are not currently supported ");
+ java.lang.System.exit(1);
- var rtslibtemp = targetname.lnkOpts.suffix.toString().split("/");
- var rtslib;
- for(n=0;n<rtslibtemp.length;n++)
- {
- if(rtslibtemp[n].match(".lib"))
- {
- rtslib=rtslibtemp[n];
- }
- }
-
- libmakefile.writeLine("CC = $("+tooldir+")/bin/"+targetname.cc.cmd +" "+targetname.ccOpts.prefix+" "+targetname.cc.opts);
- libmakefile.writeLine("AC = $("+tooldir+")/bin/"+targetname.asm.cmd +" "+targetname.asmOpts.prefix+" "+targetname.asm.opts);
- libmakefile.writeLine("ARIN = $("+tooldir+")/bin/"+targetname.ar.cmd +" "+targetname.ar.opts);
- libmakefile.writeLine("LD = $("+tooldir+")/bin/"+targetname.lnk.cmd +" "+targetname.lnk.opts);
- libmakefile.writeLine("RTSLIB = -l $("+tooldir+")/lib/"+rtslib);
+ }
+
+ libmakefile.writeLine("INCS = -I. -I$(strip $(subst ;, -I,$(subst $(space),\\$(space),$(INCDIR)))) -I$("+tooldir+")/include");
+ libmakefile.writeLine("OBJEXT = o"+targetname.suffix);
+ libmakefile.writeLine("AOBJEXT = s"+targetname.suffix);
+ libmakefile.writeLine("CFLAGS_INTERNAL = " +targetname.ccOpts.prefix+" "+targetname.cc.opts);
+ libmakefile.writeLine("ASFLAGS_INTERNAL = " +targetname.asmOpts.prefix+" "+targetname.asm.opts);
+ libmakefile.writeLine("ARFLAGS_INTERNAL = " +targetname.ar.opts);
+ libmakefile.writeLine("LNKFLAGS_INTERNAL = " +targetname.lnk.opts);
+ libmakefile.writeLine("INTERNALDEFS = -MD -MF $@.dep");
+ libmakefile.writeLine("INTERNALLINKDEFS = -o $@ -m $@.map"); /* TBD */
+ libmakefile.writeLine("OBJDIR = $(LIBDIR)/" + device.toString() + "/" + targetDir +"/obj");
+
}
else
{
- print("Error: Non-TI targets are not currently supported ");
- java.lang.System.exit(1);
+
+ if(stringname.match("ti.targets"))
+ {
- }
+ var rtslibtemp = targetname.lnkOpts.suffix.toString().split("/");
+ var rtslib;
+ for(n=0;n<rtslibtemp.length;n++)
+ {
+ if(rtslibtemp[n].match(".lib"))
+ {
+ rtslib=rtslibtemp[n];
+ }
+ }
+
+ libmakefile.writeLine("CC = $("+tooldir+")/bin/"+targetname.cc.cmd);
+ libmakefile.writeLine("AC = $("+tooldir+")/bin/"+targetname.asm.cmd);
+ libmakefile.writeLine("ARIN = $("+tooldir+")/bin/"+targetname.ar.cmd);
+ libmakefile.writeLine("LD = $("+tooldir+")/bin/"+targetname.lnk.cmd);
+ libmakefile.writeLine("RTSLIB = -l $("+tooldir+")/lib/"+rtslib);
+ }
+ else
+ {
+ print("Error: Non-TI targets are not currently supported ");
+ java.lang.System.exit(1);
+ }
libmakefile.writeLine("INCS = -I. -I$(strip $(subst ;, -I,$(subst $(space),\\$(space),$(INCDIR)))) -I$("+tooldir+")/include");
- libmakefile.writeLine("OBJEXT = o"+targetname.suffix);
- libmakefile.writeLine("AOBJEXT = s"+targetname.suffix);
- /* libmakefile.writeLine("INTERNALDEFS = -D"+stringname.replace(/\./g,"_")+" -Dxdc_target_types__=ti/targets/std.h -DMAKEFILE_BUILD -eo.$(OBJEXT) -ea.$(AOBJEXT) -fr=$(@D) -fs=$(@D) -ppa -ppd=$@.dep");*/
- libmakefile.writeLine("INTERNALDEFS = -D"+stringname.replace(/\./g,"_")+" -DMAKEFILE_BUILD -eo.$(OBJEXT) -ea.$(AOBJEXT) -fr=$(@D) -fs=$(@D) -ppa -ppd=$@.dep");
- libmakefile.writeLine("INTERNALLINKDEFS = -o $@ -m $@.map");
- libmakefile.writeLine("OBJDIR = $(LIBDIR)");
+ libmakefile.writeLine("OBJEXT = o"+targetname.suffix);
+ libmakefile.writeLine("AOBJEXT = s"+targetname.suffix);
+ libmakefile.writeLine("CFLAGS_INTERNAL = " +targetname.ccOpts.prefix+" "+targetname.cc.opts);
+ libmakefile.writeLine("ASFLAGS_INTERNAL = " +targetname.asmOpts.prefix+" "+targetname.asm.opts);
+ libmakefile.writeLine("ARFLAGS_INTERNAL = " +targetname.ar.opts);
+ libmakefile.writeLine("LNKFLAGS_INTERNAL = " +targetname.lnk.opts);
+ /* libmakefile.writeLine("INTERNALDEFS = -D"+stringname.replace(/\./g,"_")+" -Dxdc_target_types__=ti/targets/std.h -DMAKEFILE_BUILD -eo.$(OBJEXT) -ea.$(AOBJEXT) -fr=$(@D) -fs=$(@D) -ppa -ppd=$@.dep");*/
+ libmakefile.writeLine("INTERNALDEFS = -D"+stringname.replace(/\./g,"_")+" -DMAKEFILE_BUILD -eo.$(OBJEXT) -ea.$(AOBJEXT) -fr=$(@D) -fs=$(@D) -ppa -ppd=$@.dep");
+ libmakefile.writeLine("INTERNALLINKDEFS = -o $@ -m $@.map");
+ libmakefile.writeLine("OBJDIR = $(LIBDIR)/" + device.toString() + "/" + targetDir +"/obj");
+ }
return libmakefile;
}
-function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, targetName)
+function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, targetName, objDir)
{
var sourcestring = (srcString + fileExt).toString().toUpperCase();
var compileflagstring = sourcestring + "FLAGS";
@@ -390,8 +405,8 @@ function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, target
makefilename.writeLine(compileflagstring+" = "+compileflags +" \n");
makefilename.writeLine("# Make Rule for the "+srcString+" Files");
- makefilename.writeLine(objectliststring +" = $(patsubst %."+fileExt+", $(OBJDIR)/%.$(OBJEXT), $(" + sourcestring + "))");
- makefilename.writeLine("\n$("+objectliststring+"): $(OBJDIR)/%.$(OBJEXT): %."+fileExt);
+ makefilename.writeLine(objectliststring +" = $(patsubst %."+fileExt+", "+objDir+"/%.$(OBJEXT), $(" + sourcestring + "))");
+ makefilename.writeLine("\n$("+objectliststring+"): "+objDir+"/%.$(OBJEXT): %."+fileExt);
if(fileExt == "c")
{
makefilename.writeLine("\t-@echo cl"+targetName.suffix +" $< ...");
@@ -404,21 +419,33 @@ function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, target
if(fileExt == "c")
{
- makefilename.writeLine("\t$(RM) $@.dep");
- makefilename.writeLine("\t$(CC) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) -fc $< ");
- makefilename.writeLine("\t-@$(CP) $@.dep $@.pp; \\");
- makefilename.writeLine(" $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\\\$$//' \\");
- makefilename.writeLine(" -e '/^$$/ d' -e 's/$$/ :/' < $@.pp >> $@.dep; \\");
- makefilename.writeLine(" $(RM) $@.pp ");
+ if ((targetName.name == "A15F") || (targetName.name == "A9F") || (targetName.name == "A8F"))
+ {
+ makefilename.writeLine("\t$(RM) $@.dep");
+ makefilename.writeLine("\t$(CC) $(CFLAGS_INTERNAL) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) $< -o $@");
+ /*
+ TBD
+ */
+ }
+ else
+ {
+ makefilename.writeLine("\t$(RM) $@.dep");
+ makefilename.writeLine("\t$(CC) $(CFLAGS_INTERNAL) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) -fc $< ");
+ makefilename.writeLine("\t-@$(CP) $@.dep $@.pp; \\");
+ makefilename.writeLine(" $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\\\$$//' \\");
+ makefilename.writeLine(" -e '/^$$/ d' -e 's/$$/ :/' < $@.pp >> $@.dep; \\");
+ makefilename.writeLine(" $(RM) $@.pp ");
+ }
}
else if(fileExt == "asm")
{
- makefilename.writeLine("\t$(AC) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) -fa $< ");
+ makefilename.writeLine("\t$(AC) $(ASFLAGS_INTERNAL) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) -fa $< ");
}
else if(fileExt == "sa")
{
- makefilename.writeLine("\t$(AC) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) $< ");
+ makefilename.writeLine("\t$(AC) $(ASFLAGS_INTERNAL) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) $< ");
}
+
makefilename.writeLine("\n#Create Empty rule for dependency");
makefilename.writeLine("$("+objectliststring+"):"+makefilename.$private.fd);
makefilename.writeLine(makefilename.$private.fd+":");
@@ -436,24 +463,60 @@ function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, target
* Utility function which will build a specific library
**************************************************************************/
var makefilelocal;
-function buildLibrary (libOptions, libName, target, libFiles)
+function buildLibrary (socName, isSoc, libOptions, libName, target, libFiles)
{
- var lldFullLibraryPath = "./lib/" + libName;
- var lldFullLibraryPathMake = "$(LIBDIR)/" + libName;
+ var targetDir;
+ var objExtDir;
+
+ if (target.name == "A15F")
+ {
+ targetDir = "armv7";
+ }
+ else if (target.name == "A9F")
+ {
+ targetDir = "armv7";
+ }
+ else if (target.name == "A8F")
+ {
+ targetDir = "armv7";
+ }
+ else if (target.name == "M4")
+ {
+ targetDir = "m4";
+ }
+ else
+ {
+ targetDir = "c66";
+ }
+
+ /* Derive the operating system and soc names */
+ if (isSoc == "true") {
+ var libNameExp = libName+"."+socName;
+ targetDir = socName+"/"+targetDir;
+ objExtDir = "soc";
+ }
+ else {
+ var libNameExp = libName;
+ objExtDir = "all";
+ }
+
+ var lldFullLibraryPath = "./lib/" + targetDir +"/" + libNameExp;
+ var lldFullBuildPath = "./build/" + targetDir +"/" + libNameExp;
+ var lldFullLibraryPathMake = "$(LIBDIR)/" + targetDir +"/" + libNameExp;
/* Create Main make file in the root of package folder */
makefilelocal = createMake(makefilelocal);
/* Write the rule to make library in main makefile */
- lib = lldFullLibraryPath+".a"+target.suffix;
+ lib = lldFullBuildPath+".a"+target.suffix;
libMake = lldFullLibraryPathMake+".a"+target.suffix;
- var objectPath= "./package/lib/"+lldFullLibraryPath;
+ var objectPath= "./package/"+lldFullBuildPath;
makefilelocal.writeLine("\n\n# Make rule to create "+libMake+" library");
makefilelocal.writeLine(".libraries: "+ libMake);
makefilelocal.writeLine(libMake+": FORCE\n\t$(MAKE) -f "+lib+".mk $@");
/* Create Library make file in the lib folder */
- var makefilelib= createLibMake(lib+".mk",target,objectPath);
+ var makefilelib= createLibMake(socName, lib+".mk",target,objectPath);
/* Rule to clean library in main makefile */
makefilelocal.writeLine("# Rule to clean "+libMake+" library");
}
if(cfiles.length > 0)
{
- makeAddObjects("COMMONSRC",makefilelib,cfiles,libOptions,"c",target);
+ makeAddObjects("COMMONSRC",makefilelib,cfiles,libOptions,"c",target, "$(OBJDIR)");
librule += " $(COMMONSRCCOBJS)";
}
if(afiles.length > 0)
{
- makeAddObjects("COMMONSRC",makefilelib,afiles,libOptions,"asm",target);
- librule += " $(COMMONSRCSOBJS)";
+ makeAddObjects("COMMONSRC",makefilelib,afiles,libOptions,"asm",target, "$(OBJDIR)");
+ librule += " $(COMMONSRCASMOBJS)";
}
if(safiles.length > 0)
{
- makeAddObjects("COMMONSRC",makefilelib,safiles,libOptions,"sa",target);
+ makeAddObjects("COMMONSRC",makefilelib,safiles,libOptions,"sa",target, "$(OBJDIR)");
librule += " $(COMMONSRCSAOBJS)";
}
makefilelib.writeLine(librule);
makefilelib.writeLine("\t@echo archiving $? into $@ ...");
- makefilelib.writeLine("\t$(ARIN) $@ $?");
- makefilelib.close();
-
- /* Create the library file and add all the objects to the file. */
- var lib = Pkg.addLibrary(lldFullLibraryPath, target, libOptions);
-
- lib.addObjects (libFiles);
+ makefilelib.writeLine("\tif [ ! -d $(LIBDIR)/"+targetDir+" ]; then $(MKDIR) $(LIBDIR)/"+targetDir+" ; fi;");
+ makefilelib.writeLine("\t$(ARIN) $(ARFLAGS_INTERNAL) $@ $?");
+ makefilelib.close();
/* Create the Epilogue; which executes after all the builds are completed.
* This is used to generate the benchmark information for the built library.
Pkg.makeEpilogue += "\n\t $(TOOLCHAIN_PATH_A15)/bin/$(CROSS_TOOL_PRFX)size " + libFullName + " > " + libFullName + "_size.txt";
}
Pkg.otherFiles[Pkg.otherFiles.length++] = lldFullLibraryPath + ".a" + target.suffix + "_size.txt";
- Pkg.otherFiles[Pkg.otherFiles.length++] = lldFullLibraryPath + ".a" + target.suffix + ".mk";
+ Pkg.otherFiles[Pkg.otherFiles.length++] = lldFullBuildPath + ".a" + target.suffix + ".mk";
+ Pkg.otherFiles[Pkg.otherFiles.length++] = lldFullLibraryPath + ".a" + target.suffix;
/* We need to clean after ourselves; extend the 'clean' target to take care of this. */
- Pkg.makeEpilogue += "clean::\n\t";
- Pkg.makeEpilogue += "$(RM) " + lldFullLibraryPath + ".a" + target.suffix + "_size.txt\n\n";
+ Pkg.makeEpilogue += "\nclean::\n";
+ Pkg.makeEpilogue += "\t$(RM) " + lldFullBuildPath + ".a" + target.suffix + "_size.txt\n";
+ Pkg.makeEpilogue += "\t$(RMDIR) " + "$(LIBDIR)/" + targetDir + "/ \n\n";
return lib;
}