#!/usr/bin/env omake #---------------------------------------------------------------------------- # Project: Horizon # File: commondefs.gl.om # # Copyright 2007-2009 Nintendo. All rights reserved. # # These coded instructions, statements, and computer programs contain # proprietary information of Nintendo of America Inc. and/or Nintendo # Company Ltd., and are protected by Federal copyright law. They may # not be disclosed to third parties or copied or duplicated in any form, # in whole or in part, without the prior written consent of Nintendo. # # $Date:: 2011-01-28#$ # $Rev: 33889 $ # $Author: hatamoto_minoru $ #---------------------------------------------------------------------------- # Assembler/linker definitions public.VSASM = $(ROOT_COMMANDS)$(DIRSEP)ctr_VertexShaderAssembler32.exe public.VSLD = $(ROOT_COMMANDS)$(DIRSEP)ctr_VertexShaderLinker32.exe # Directory where a built shader is stored public.SHADER_PREBUILT_ROOT = $(ROOT_RESOURCES)$(DIRSEP)shaders # Include directory passed with -I to the assembler/linker public.SHADER_INCLUDES = $(SHADER_PREBUILT_ROOT) # Generate command line to specify the include directory (delay evaluation) public.PREFIXED_SHADER_INCLUDES = $`(addprefix -I, $(set $(absname $(SHADER_INCLUDES)))) # Extension definitions EXT_VSASM = .vsh EXT_VSOBJ = .obj EXT_VSBIN = .shbin # While continuing to return the storage destination for .obj/.shbin, define generation rules for the parent directory getShaderObjectDirectory() = return $(makeDirectory $(getObjectBaseDirectory)$(DIRSEP)CTR.Shader) # Generate .obj files # sourcefiles - .vsh file (multiple OK) VertexShaderObjects(sourcefiles) = # Get the directory where .obj is stored obj_dir_parent = $(getShaderObjectDirectory) OFILES = export OFILES # Define rules for each .vsh file foreach(sourcefile, $(sourcefiles)) # Get the full path of the file name to output OFILE = $(file $(obj_dir_parent)/$(basename $(removesuffix $(sourcefile)))$(EXT_VSOBJ)) # Add to return values OFILES += $(OFILE) # Define the assembler rules (when there are no warning or errors, cut output with grep) # Make directory dependent as well and generate automatically $(OFILE): $(sourcefile) $(obj_dir_parent) $(VSASM) $(VSASM) $< $(PREFIXED_SHADER_INCLUDES) -O$@ | grep -v '^.*finished - 0 error, 0 warning' # Define the clean rules clean: rm -rf $(obj_dir_parent) return $(OFILES) # Generate .shbin files # name - .shbin name (no extension) # sourcefiles - .obj file generated with OMakefile # sourcefiles_pre - built .obj file under resources VertexShaderBinary(name, sourcefiles, sourcefiles_pre) = # Find the directory where .obj is stored obj_dir_parent = $(getShaderObjectDirectory) # Convert sourcefiles_pre to full path in order to correctly obtain the dependency relationship. # (When relying on -I, no rebuild occurs when a built .obj is updated.) sourcefiles_pre = $(addprefix $(SHADER_PREBUILT_ROOT)$(DIRSEP), $(sourcefiles_pre)) # Get the full path of the file name to output OFILE = $(file $(obj_dir_parent)/$(basename $(name))$(EXT_VSBIN)) # Define the link rules (when there are no warning or errors, cut output with grep) $(OFILE): $(sourcefiles) $(sourcefiles_pre) $(obj_dir_parent) $(VSLD) $(VSLD) $(sourcefiles) $(sourcefiles_pre) $(PREFIXED_SHADER_INCLUDES) -M -nodebug -O$@ | grep -v '^.*finished - 0 error, 0 warning' if $(not $(defined SHBIN_INSTALL_ROOT)) if $(defined ROMFS_ROOT) SHBIN_INSTALL_ROOT = $(ROMFS_ROOT) export export # When SHBIN_INSTALL_ROOT is defined, copy binary under SHBIN_INSTALL_ROOT if $(and $(defined SHBIN_INSTALL_ROOT), $(not $(equal $(SHBIN_INSTALL_ROOT),$(EMPTY)))) # Find file name of the installation destination OFILE_INSTALL = $(SHBIN_INSTALL_ROOT)$(DIRSEP)$(basename $(OFILE)) # Save to the installation destination $(OFILE_INSTALL): $(OFILE) $(SHBIN_INSTALL_ROOT) ln-or-cp $< $@ # Create directory in the installation destination $(SHBIN_INSTALL_ROOT): mkdir -p $@ #Define the clean rules clean: rm -f $(OFILE_INSTALL) # Must prepare the file in ROMFS before MAKEROM build-romfs: $(OFILE_INSTALL) # Define the clean rules clean: rm -rf $(obj_dir_parent) # Always return the binary generated in objects return $(OFILE)