我知道make的静音标志(-s)会隐藏食谱完全回显,但是这很难看到进展。
例如,目前我有数百行,例如(我打破了这条线以适应SO):
g++ -I. -std=c++11 -Wall -Wno-unused-local-typedefs -Wno-literal-suffix
-Wno-unused-but-set-variable `wx-config --cxxflags --unicode=no`
-MT dialog_export.o -MD -MP -MF .deps/dialog_export.Tpo
-c -o dialog_export.o dialog_export.cpp
如果可以打印部分线条,比如说没有标记,就会很好:
g++ dialog_export.o dialog_export.cpp
或者只是某种看待进展的方式,但没有用一大堆信息向控制台发送垃圾邮件。
答案 0 :(得分:0)
从autotools到内核构建系统到CMake等的许多构建系统都是这样做的。
诀窍是动态控制配方行上是否存在静默@
,以及是否用一些更友好的消息的手动回声替换它。
要获得您想要的消息,您可以使用以下内容:
E_g++ := @echo 'g++ $(filter %.o,$^) $@'
%.o: %.cpp
$(E_g++)g++ ... -o $@ $^
在不使用autotools或类似我编写的Silent Make Rules之类的项目中,让自己更容易做到这一点。
您可以这样使用:
include silent_rules.mk
$(eval $(call vrule,G++,g++ $$(filter %.o,$$^) $$@))
%.o: %.cpp:
$(SR_V_G++)g++ ... -o $@ $^
这也(如autotools和内核make版本)允许您在make命令行上指定V=1
以返回正常的make输出并使用V=-1
完全静音输出。
答案 1 :(得分:0)
我喜欢这样的规则:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;
public class GUIroughdraft implements Runnable, ActionListener
{
private JFrame frame;
private JMenuBar menuBar;
private JMenu FileMenu;
private JMenu ActionMenu;
private JMenu HelpMenu;
private JMenuItem SaveMenuItem;
private JMenuItem LoadMenuItem;
private JMenuItem ExitMenuItem;
private JMenuItem BuyMenuItem;
private JMenuItem SellMenuItem;
private JMenuItem AboutMenuItem;
private JMenuItem UserManualMenuItem;
public static void main(String[] args)
{
// needed on mac os x
System.setProperty("apple.laf.useScreenMenuBar", "true");
// the proper way to show a jframe (invokeLater)
SwingUtilities.invokeLater(new GUIroughdraft());
}
private JFrame frmBgszStockSimulator;
/**
* @wbp.nonvisual location=53,14
*/
//private final JLabel lblBgszStockSimulator = DefaultComponentFactory.getInstance().createTitle("BGSZ Stock Simulator");
private JTextField searchBar;
private JTable table;
/**
* Launch the application. Testing Comment
*/
/*
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
GUIroughdraft window = new GUIroughdraft();
window.frmBgszStockSimulator.setVisible(true);
} catch (Exception e)
{
e.printStackTrace();
}
}
});
}
*/
/**
* Create the application.
*/
/*
public GUIroughdraft()
{
run();
}
*/
/**
* Initialize the contents of the frame.
*/
public void run()
{
frmBgszStockSimulator = new JFrame("BGSZ Stock Simulator");
frmBgszStockSimulator.getContentPane().setBackground(Color.GRAY);
frmBgszStockSimulator.setTitle("BGSZ Stock Simulator");
frmBgszStockSimulator.setBounds(100, 100, 775, 510);
frmBgszStockSimulator.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmBgszStockSimulator.setVisible(true);
//Builds menu bar
menuBar = new JMenuBar();
//Builds the File menu
FileMenu = new JMenu("File");
SaveMenuItem = new JMenuItem("Save");
LoadMenuItem = new JMenuItem("Load");
ExitMenuItem = new JMenuItem("Exit");
SaveMenuItem.addActionListener(this);
LoadMenuItem.addActionListener(this);
ExitMenuItem.addActionListener(this);
FileMenu.add(SaveMenuItem);
FileMenu.add(LoadMenuItem);
FileMenu.add(ExitMenuItem);
//Builds the Actions menu
ActionMenu = new JMenu("Actions");
BuyMenuItem = new JMenuItem("Buy");
SellMenuItem = new JMenuItem("Sell");
ActionMenu.add(BuyMenuItem);
ActionMenu.add(SellMenuItem);
//Builds the Help menu
HelpMenu = new JMenu("Help");
AboutMenuItem = new JMenuItem("About");
UserManualMenuItem = new JMenuItem("User Manual");
HelpMenu.add(AboutMenuItem);
HelpMenu.add(UserManualMenuItem);
menuBar.add(FileMenu);
menuBar.add(ActionMenu);
menuBar.add(HelpMenu);
frmBgszStockSimulator.setJMenuBar(menuBar);
JScrollBar scrollBar = new JScrollBar();
scrollBar.setBackground(Color.LIGHT_GRAY);
scrollBar.setBounds(323, 47, 21, 317);
frmBgszStockSimulator.getContentPane().add(scrollBar);
JTextArea displayBox = new JTextArea();
displayBox.setEditable(false);
displayBox.setLineWrap(true);
displayBox.setWrapStyleWord(true);
displayBox.setText("This will be a text field that displays all your actions and information about stocks, purchases, sales, errors, etc.");
//when the user clicks the search button that is not there anymore
//create a new instance of the getStockData class
//get the data from the input line something like String userInput = searchBar.getText()
//pass that to the getData(userInput);
//set the displayBox.setText(the return from getData());
displayBox.setBounds(12, 47, 312, 317);
frmBgszStockSimulator.getContentPane().add(displayBox);
searchBar = new JTextField();
searchBar.setText("Enter your text here");
searchBar.setBounds(12, 377, 733, 22);
frmBgszStockSimulator.getContentPane().add(searchBar);
searchBar.setColumns(10);
JProgressBar progressBar = new JProgressBar();
progressBar.setStringPainted(true);
progressBar.setValue(75);
progressBar.setBounds(78, 412, 586, 14);
frmBgszStockSimulator.getContentPane().add(progressBar);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
{"Stock Name", "Stock Value", "Amount Owned", "Total Value"},
{" BAC", "$13.48", "4", "$53.92"},
{" RIG", "$8.89", "0", "$0.00"},
{" SUNE", "$0.59", "12", "$7.08"},
{" FCX", "$10.29", "2", "$20.58"},
{" PBR", "$5.86", "0", "$0.00"},
{" GE", "$31.83", "0", "$0.00"},
{" VALE", "$4.24", "24", "$101.76"},
{" VRX", "$27.07", "0", "$0.00"},
{" PFE", "$30.07", "0", "$0.00"},
{" CRC", "$1.05", "8", "$8.40"},
{" GGB", "$1.82", "0", "$0.00"},
{" CHK", "$4.01", "6", "$24.06"},
{" T", "$39.37", "0", "$0.00"},
{" F", "$13.35", "5", "$66.75"},
{" WLL", "$7.66", "0", "$0.00"},
},
new String[] {
"New column", "New column", "New column", "New column"
}
));
table.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
table.setBounds(350, 51, 395, 313);
frmBgszStockSimulator.getContentPane().add(table);
JTextArea txtrValue = new JTextArea();
txtrValue.setText("Displays Cash Value");
txtrValue.setLineWrap(true);
txtrValue.setEditable(false);
txtrValue.setBounds(99, 12, 172, 22);
frmBgszStockSimulator.getContentPane().add(txtrValue);
JTextArea txtrCurrentPortfolioValue = new JTextArea();
txtrCurrentPortfolioValue.setText("Display Portfolio Value");
txtrCurrentPortfolioValue.setLineWrap(true);
txtrCurrentPortfolioValue.setEditable(false);
txtrCurrentPortfolioValue.setBounds(376, 12, 206, 22);
frmBgszStockSimulator.getContentPane().add(txtrCurrentPortfolioValue);
JLabel lblCashValue = new JLabel("Cash Value:");
lblCashValue.setBounds(24, 15, 111, 16);
frmBgszStockSimulator.getContentPane().add(lblCashValue);
JLabel lblPortfolioValue = new JLabel("Portfolio Value:");
lblPortfolioValue.setBounds(283, 15, 123, 16);
frmBgszStockSimulator.getContentPane().add(lblPortfolioValue);
}
public void actionPerformed(ActionEvent ev)
{
SaveDialog dialog = new SaveDialog();
dialog.setModal(true);
dialog.setVisible(true);
}
private class SaveDialog extends JDialog implements ActionListener
{
private JButton okButton = new JButton("Your File has been saved!");
private SaveDialog()
{
super(frame, "Save", true);
JPanel panel = new JPanel(new FlowLayout());
panel.add(okButton);
getContentPane().add(panel);
okButton.addActionListener(this);
setPreferredSize(new Dimension(250, 75));
pack();
setLocationRelativeTo(frame);
}
public void actionPerformed(ActionEvent ev)
{
setVisible(false);
}
}
public void actionPerformed2(ActionEvent ev)
{
LoadDialog dialog = new LoadDialog();
dialog.setModal(true);
dialog.setVisible(true);
}
private class LoadDialog extends JDialog implements ActionListener
{
private JButton LoadButton = new JButton("Your File has successfully loaded!");
private LoadDialog()
{
super(frame, "Load", true);
JPanel panel = new JPanel(new FlowLayout());
panel.add(LoadButton);
getContentPane().add(panel);
LoadButton.addActionListener(this);
setPreferredSize(new Dimension(250, 75));
pack();
setLocationRelativeTo(frame);
}
public void actionPerformed(ActionEvent ev)
{
setVisible(false);
}
}
}
领先' @'符号抑制命令回显,第一个命令回显目标的名称:
dialog_export.o: dialog_export.cpp
@echo $@...
@g++ -I. -std=c++11 -Wall -Wno-unused-local-typedefs -Wno-literal-suffix -Wno-unused-but-set-variable `wx-config --cxxflags --unicode=no` -MT dialog_export.o -MD -MP -MF .deps/dialog_export.Tpo -c -o $@ $<
如果你有一个包含数百个规则的makefile,你可以使用一个好的编辑器在几分钟内将它们全部转换为该表单。如果你是粗体,或者使用宏或sed更快。
(如果你有这样的数百行,那么你的makefile可能会被简化很多,但那是另一天。)
答案 2 :(得分:0)
我总是使用$(Q)
:
ifeq ("$(V)","1")
Q :=
vecho = @echo
else
Q := @
vecho = @true
endif
somerule:
$(vecho) building $@ verbosely
$(Q)do command
然后,您可以修改模式规则,仅输出您关注的文本。如果您需要更详细,那么您只需使用make V=1
构建。我不认为这样做的任何捷径都可以自动保存输出sed
(我不推荐)。