#---------------------------------------------------------------------------- # Project: Horizon # File: CTR.commondefs.gl.om # # Copyright (C)2009-2011 Nintendo Co., Ltd. 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. # # $Rev: 44723 $ #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # Constant definitions #---------------------------------------------------------------------------- # Assembler/linker definitions global.VSASM = $(ROOT_COMMANDS)$(DIRSEP)ctr_VertexShaderAssembler32.exe global.VSLD = $(ROOT_COMMANDS)$(DIRSEP)ctr_VertexShaderLinker32.exe # Extension definitions global.EXT_VSASM = .vsh global.EXT_VSOBJ = .obj global.EXT_VSBIN = .shbin # Directory where a built shader is stored private.SHADER_PREBUILT_ROOT = $(ROOT_RESOURCES)$(DIRSEP)shaders # Include directory passed with -I to the assembler/linker global.SHADER_INCLUDES = $(SHADER_PREBUILT_ROOT) # Generate command line to specify the include directory (delay evaluation) private.PREFIXED_SHADER_INCLUDES = $`(addprefix -I, $(set $(absname $(SHADER_INCLUDES)))) # Option specified in the assembler global.SHADER_ASFLAGS = # Option specified in the linker global.SHADER_LDFLAGS = -M #---------------------------------------------------------------------------- # Function definitions #---------------------------------------------------------------------------- #------------------------------------------------------- # getShaderObjectDirectory # # Overview # While continuing to return the storage destination for .obj/.shbin, define generation rules for the parent directory # # Referenced global variables # None. #------------------------------------------------------- getShaderObjectDirectory() = return $(makeDirectory $(getObjectBaseDirectory)$(DIRSEP)CTR.Shader) #------------------------------------------------------- # VertexShaderObjects # # Overview # Generate .obj files # sourcefiles - .vsh file (multiple OK) # options - option to specify in the shader assembler # # Referenced global variables # PREFIXED_SHADER_INCLUDES #------------------------------------------------------- VertexShaderObjects(sourcefiles, options) = # Get the directory where .obj is stored private.obj_dir_parent = $(getShaderObjectDirectory) # Define rules for each .vsh file private.ofiles = foreach(sourcefile, $(sourcefiles)) # Get the full path of the filename to output private.ofile = $(file $(obj_dir_parent)/$(basename $(removesuffix $(sourcefile)))$(EXT_VSOBJ)) # 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$@ $(options) | grep -v '^.*finished - 0 error, 0 warning' value $(ofile) # Define the clean rules clean: rm -rf $(obj_dir_parent) return $(ofiles) #------------------------------------------------------- # VertexShaderBinary # # Overview # Generate .shbin files # name - .shbin name (no extension) # sourcefiles - .obj file generated with OMakefile # sourcefiles_pre - built .obj file under resources # options - option to specify in the shader linker # # Referenced global variables # PREFIXED_SHADER_INCLUDES, SHBIN_INSTALL_ROOT #------------------------------------------------------- VertexShaderBinary(name, sourcefiles, sourcefiles_pre, options) = # Get the directory where .obj is stored private.obj_dir_parent = $(getShaderObjectDirectory) # Convert sourcefiles_pre to full path to correctly obtain the dependency relationship. # (When relying on -I, no rebuild occurs when a built .obj is updated.) private.sourcefiles_pre = $(addprefix $(SHADER_PREBUILT_ROOT)$(DIRSEP), $(sourcefiles_pre)) # Get the full path of the filename to output private.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) $(options) -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 filename of the installation destination private.ofile_install = $(SHBIN_INSTALL_ROOT)$(DIRSEP)$(basename $(ofile)) # Save to the installation destination $(ofile_install): $(ofile) $(SHBIN_INSTALL_ROOT) 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)