%%{ /* * Copyright (c) 2013-2014 Texas Instruments Incorporated - http://www.ti.com * 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 BIOS = xdc.module("ti.sysbios.BIOS"); var Build = xdc.module("ti.sdo.ipc.Build"); var TARGET = $args[0]; var XDCROOT = String(environment['xdc.rootDir'] + '/packages/').replace(/\\/g, "/"); 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 = []; var CFILES = Build.getCFiles(TARGET.$name); %%} 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 = `Build.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.sysbios")`" TARGET_INC = -I"`xdc.getPackageRepository("ti.targets")`" IPC_INC = -I"`xdc.getPackageRepository("ti.sdo.ipc")`" UTILS_INC = -I"`xdc.getPackageRepository("ti.sdo.utils")`" INCS = $(BIOS_INC) $(TARGET_INC) $(IPC_INC) $(UTILS_INC) %if (TARGET.$name.match(/gnu/)) { CC = `CGEN`/`TARGET.ccBin.cmd` $(CCOPTS) -I `CGEN`/arm-none-eabi/include ASM = `CGEN`/`TARGET.asmBin.cmd` $(CCOPTS) -I `CGEN`/arm-none-eabi/include AR = `CGEN`/`TARGET.arBin.cmd` `TARGET.ar.opts` %} %else { CC = `CGEN`/bin/`TARGET.cc.cmd` $(CCOPTS) --output_file=$@ -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 MKDIR = mkdir %} %else { DEL = rm -f CP = cp -f MKDIR = mkdir -p %} define RM $(if $(wildcard $1),$(DEL) $1,:) endef define ASSEMBLE @echo asm`TARGET.suffix` $< ... @$(ASM) $(BUILD_DEFS) $(XOPTS) $(INCS) $< endef %var LIB = "ipc.a" + TARGET.suffix; %if (BIOS.buildingAppLib == false) { all: `Build.$private.libDir``LIB` %} %else { all: `LIB` %} %var sources = Build.getAsmFiles(TARGET.$name); %for (var i = 0; i < sources.length; i++) { % var s = sources[i]; %if (TARGET.$name.match(/gnu/)) { % var obj = packageName(s) + "_" + baseName(s) + ".o"; %} %else { % var obj = packageName(s) + "_" + baseName(s) + ".obj"; %} % OBJS.push(obj) `obj`: `s` makefile @-$(call RM, $@) %if (TARGET.$name.match(/gnu/)) { $(ASSEMBLE) -o `obj` %} %else { $(ASSEMBLE) --output_file=`obj` %} %} %if (TARGET.$name.match(/gnu/)) { Ipc.o: `CFILES` makefile @-$(call RM, Ipc.o) @-$(call RM, Ipc.o.dep) %} %else { Ipc.obj: `CFILES` makefile @-$(call RM, $@) %} @echo cl`TARGET.suffix` $< ... @$(CC) $(BUILD_DEFS) $(XOPTS) $(INCS) \ %var sources = CFILES.split(' '); %for (var i = 0; i < sources.length; i++) { % var s = sources[i] + (i == (sources.length - 1) ? "" : " \\"); % if (s.substring(0,4) == "xdc/") { $(XDC_ROOT)`s` % } else if (s.substring(0,2) == "./") { `s` % } else { $(IPC_ROOT)`s` % } %} %if (TARGET.$name.match(/gnu/)) { `LIB`: Ipc.o `OBJS.join(" ")` %} %else { `LIB`: Ipc.obj `OBJS.join(" ")` %} @-$(call RM, $@) @echo ar`TARGET.suffix` $^ ... @$(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`") %} %if (TARGET.$name.match(/gnu/)) { @-$(call RM, Ipc.o) %} %else { @-$(call RM, Ipc.obj) %} %for (var i = 0; i < OBJS.length; i++) { @-$(call RM, `OBJS[i]`) %} %if (Build.$private.libDir != null) { # create output directories ifneq ($(MAKECMDGOALS),clean) ifeq ($(wildcard `Build.$private.libDir`),) $(shell $(MKDIR) `Build.$private.libDir`) endif endif %}