classdef (Abstract) MccDependencyWriter < compiler.internal.mcc.MccWriter
	% MCCWRITER Abstract class that provides utilities for generating
    % mcc commands for targets that use dependency analysis (all targets
    % except for MPS Excel)

%   Copyright 2021-2022 The MathWorks, Inc.

    methods
        function obj = MccDependencyWriter(options)
             obj = obj@compiler.internal.mcc.MccWriter(options);
        end
    end
    
    % define abstract
    methods(Access=protected)
        function writeDependencyAnalysisOptions(obj)
            
            % -X
            obj.writeCommandForDataFiles
            
            % -a
            obj.writeCommandForAdditionalFiles
            
            % -Z
            obj.writeCommandForSupportPackages

            %-s -j
            obj.writeCommandForObfuscateArchive
        end
    end
    
    methods(Access = protected)
        function writeCommandForDataFiles(obj)
            if(~obj.Options.AutoDetectDataFiles)
                obj.addCommand("-X");
            end
        end

        function writeCommandForObfuscateArchive(obj)
            if(obj.Options.ObfuscateArchive)
                obj.addCommand("-s");
                obj.addCommand("-j");
            end
        end
        
        
        function writeCommandForAdditionalFiles(obj)
            resources = obj.Options.AdditionalFiles;
            for n = 1:numel(resources)
                obj.addCommand("-a")
                obj.addCommand(string(resources{n}))
            end
        end
        
        function writeCommandForSupportPackages(obj)
            spkgs = obj.Options.SupportPackages;
            for n = 1:numel(spkgs)
                obj.addCommand("-Z")
                obj.addCommand(string(spkgs{n}))
            end
        end
    end

end