%%{ /* * Copyright (c) 2013, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ %%} %%{ var File = xdc.module("xdc.services.io.File"); var Build = xdc.module("ti.sdo.utils.Build"); var TARGET = $args[0]; var XDCROOT = String(environment['xdc.rootDir'] + '/packages/').replace(/\\/g, "/"); var BIOS = xdc.module("ti.sysbios.BIOS"); var CGEN = TARGET.rootDir.replace(/\\/g, "/"); function baseName(path) { return path.substr(path.lastIndexOf('/') + 1).replace(/\.[^\.]+$/, ""); } function packageName(path) { var dirpath = path.substring(0, path.lastIndexOf('/')); return dirpath.substr(dirpath.lastIndexOf('/') + 1); } var OBJS = []; %%} vpath % `File.getDOSPath(this.$package.packageRepository) + "ti/sdo/"` vpath %.c `XDCROOT` XOPTS = `'-I"' + XDCROOT + '"' + " -Dxdc_target_types__=" + File.getDOSPath(TARGET.$package.packageRepository) + TARGET.stdInclude + " -Dxdc_target_name__=" + TARGET.name` CCOPTS ?= `BIOS.getCCOpts(TARGET.$name)` XDC_ROOT = `XDCROOT` IPC_ROOT = `File.getDOSPath(this.$package.packageRepository) + "ti/sdo/"` BUILD_DEFS = `Build.getDefs()` BIOS_INC = -I"`xdc.getPackageRepository("ti.bios")`" SYSBIOS_INC = -I"`xdc.getPackageRepository("ti.sysbios")`" IPC_INC = -I"`xdc.getPackageRepository("ti.sdo.ipc")`" UTILS_INC = -I"`xdc.getPackageRepository("ti.sdo.utils")`" CC = `CGEN`/bin/`TARGET.cc.cmd` $(CCOPTS) -I `CGEN`/include ASM = `CGEN`/bin/`TARGET.asm.cmd` $(CCOPTS) -I `CGEN`/include AR = `CGEN`/bin/`TARGET.ar.cmd` `TARGET.ar.opts` %if (environment["os.name"].match(/Windows.*/i)) { %if (BIOS.buildingAppLib == false) { % Build.$private.libDir = Build.$private.libDir.replace(/\//g,'\\'); %} DEL = cmd.exe /q /c del /f CP = cmd.exe /q /c copy /Y %} %else { DEL = rm -f CP = cp -f %} define RM $(if $(wildcard $1),$(DEL) $1,:) endef define ASSEMBLE @echo asm`TARGET.suffix` $< ... @$(ASM) $(BUILD_DEFS) $(XOPTS) $(UTILS_INC) $< endef %var LIB = "utils.a" + TARGET.suffix; %if (BIOS.buildingAppLib == false) { all: `Build.$private.libDir``LIB` %} %else { all: `LIB` %} %var sources = Build.getAsmFiles(TARGET.$name); %for each (var s in sources) { % var obj = packageName(s) + "_" + baseName(s) + ".obj"; % OBJS.push(obj) `obj`: `s` makefile @-$(call RM, $@) $(ASSEMBLE) --output_file=`obj` %} UTILS.obj: `Build.getCFiles(TARGET.$name)` makefile @-$(call RM, $@) @echo cl`TARGET.suffix` $< ... @$(CC) $(BUILD_DEFS) $(XOPTS) $(SYSBIOS_INC) $(BIOS_INC) \ $(IPC_INC) $(UTILS_INC) \ %var sources = Build.getCFiles(TARGET.$name).split(' '); %for each (var s in sources) { % if (s.substring(0,4) == "xdc/") { $(XDC_ROOT)`s` \ % } else { $(IPC_ROOT)`s` \ % } %} `LIB`: UTILS.obj `OBJS.join(" ")` @echo ar`TARGET.suffix` $^ ... @-$(call RM, $@) @$(AR) $@ $^ %if (BIOS.buildingAppLib == false) { `Build.$private.libDir``LIB`: `LIB` @echo cp `LIB` @-$(call RM, "`Build.$private.libDir``LIB`") @$(CP) `LIB` "`Build.$private.libDir``LIB`" %} clean: @-$(call RM, `LIB`) %if (BIOS.buildingAppLib == false) { @-$(call RM, "`Build.$private.libDir``LIB`") %} @-$(call RM, UTILS.obj) %for (var i = 0; i < OBJS.length; i++) { @-$(call RM, `OBJS[i]`) %}