在特定于目标的变量中使用目标名称

时间:2015-09-24 13:53:48

标签: makefile

我可以在特定目标变量中使用目标名称吗?

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using No_IdeaV2.API_Key_Window;
using System.IO;

namespace No_IdeaV2.API_Key_Window
{
public partial class UCAPIn : Form
{        
    public UCAPIn()
    {
        InitializeComponent();
    }

    private void label1_Click(object sender, EventArgs e)
    {
    }

    private void menuStrip1_ItemClicked(object sender,  ToolStripItemClickedEventArgs e)
    {

    }

    private void whatAmIDoingToolStripMenuItem_Click(object sender, EventArgs e)
    {

    }

    private void textBox1_TextChanged(object sender, EventArgs e)
    {

    }

    public List<Serialization> list = null;
    private void UCAPIn_Load(object sender, EventArgs e)
    {
        list = new List<Serialization>();
        var doc = XDocument.Load("data.XML");

        foreach (XElement element in doc.Descendants("Serialization"))
        {
            list.Add(new Serialization()
            { ID = element.Element("ID").Value, APIKEY = element.Element("APIKEY").Value, VCODE = element.Element("VCODE").Value });
        }
    }

    public void button1_Click(object sender, EventArgs e)
    {
        {
            try
            {
                Serialization info = new Serialization();
                info.APIKEY = txtAPI.Text;
                info.VCODE = txtVerC.Text;
                info.ID = Guid.NewGuid().ToString();
                list.Add(info);
                Serialization.SaveData(list, "data.XML");

            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }

    private void button2_Click(object sender, EventArgs e)
    {
        this.Close();
    }

    private void whatIsThisToolStripMenuItem_Click(object sender, EventArgs e)
    {

    }





        public class Serialization
    {
        private string id;
        private string APIkey;
        private string VCode;

        public string ID
        {
            get { return id; }
            set { id = value; }
        }

        public string APIKEY
        {
            get { return APIkey; }
            set { APIkey = value; }
        }

        public string VCODE
        {
            get { return VCode; }
            set { VCode = value; }

        }

        public static void SaveData(List<Serialization> list, string      Filename)
        {
            XmlSerializer sr = new XmlSerializer(list.GetType());
            TextWriter writer = new StreamWriter(Filename, true);
            sr.Serialize(writer, list);
            writer.Close();
        }
    }

}

因此,在执行“make program_xyz”时,CFILE将为“path / program_xyz / do_it.c”。

1 个答案:

答案 0 :(得分:1)

这取决于您要使用的内容CFILE。既然你没有给我们任何细节,我只会回答你的确切问题:当然,你可以这样做:

program_% : CFILE = path/program_$*/do_it.c

program_% : ; @echo $(CFILE)

$ make program_foo
path/program_foo/do_it.c

但是,我怀疑你想在CFILE中做更多事情,只需在这个食谱中使用它。如果是这样,上面的解决方案我不适合你真正想做的事情......