mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-26 23:24:03 +02:00
Turn to Regex in ModuleReader.java
1st edition of MsaTreeEditor.java Some edit on ia32 x64... in .inf-read and MsaWriter.java git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1278 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
9dc7af1e05
commit
90503bad37
@ -0,0 +1,32 @@
|
|||||||
|
package org.tianocore.migration;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class Common {
|
||||||
|
public static String sourcefiletostring(String filename) throws Exception {
|
||||||
|
BufferedReader rd = new BufferedReader(new FileReader(filename));
|
||||||
|
StringBuffer wholefile = new StringBuffer();
|
||||||
|
String line;
|
||||||
|
while ((line = rd.readLine()) != null) {
|
||||||
|
wholefile.append(line + "\n");
|
||||||
|
}
|
||||||
|
return wholefile.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ensureDir(String objFileWhole) {
|
||||||
|
Pattern ptnseparate = Pattern.compile("(.*)\\\\[^\\\\]*");
|
||||||
|
Matcher mtrseparate;
|
||||||
|
File tempdir;
|
||||||
|
|
||||||
|
mtrseparate = ptnseparate.matcher(objFileWhole);
|
||||||
|
if (mtrseparate.find()) {
|
||||||
|
tempdir = new File(mtrseparate.group(1));
|
||||||
|
if (!tempdir.exists()) tempdir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -25,8 +25,9 @@ public class FirstPanel extends JPanel implements ActionListener, UI {
|
|||||||
private static final long serialVersionUID = 207759413522910399L;
|
private static final long serialVersionUID = 207759413522910399L;
|
||||||
|
|
||||||
private String modulepath;
|
private String modulepath;
|
||||||
|
private ModuleInfo mi;
|
||||||
|
|
||||||
private JButton moduleButton , goButton;
|
private JButton moduleButton, goButton, msaEditorButton;
|
||||||
private JTextField moduletext;
|
private JTextField moduletext;
|
||||||
private JTextArea log;
|
private JTextArea log;
|
||||||
private JFileChooser fc;
|
private JFileChooser fc;
|
||||||
@ -43,6 +44,9 @@ public class FirstPanel extends JPanel implements ActionListener, UI {
|
|||||||
moduleButton = new JButton("Choose ModulePath");
|
moduleButton = new JButton("Choose ModulePath");
|
||||||
moduleButton.addActionListener(this);
|
moduleButton.addActionListener(this);
|
||||||
|
|
||||||
|
msaEditorButton = new JButton("MsaEditor");
|
||||||
|
msaEditorButton.addActionListener(this);
|
||||||
|
|
||||||
moduletext = new JTextField(30);
|
moduletext = new JTextField(30);
|
||||||
|
|
||||||
filebox = new JCheckBox("Output to logfile", true);
|
filebox = new JCheckBox("Output to logfile", true);
|
||||||
@ -54,9 +58,10 @@ public class FirstPanel extends JPanel implements ActionListener, UI {
|
|||||||
modulePanel.add(filebox);
|
modulePanel.add(filebox);
|
||||||
modulePanel.add(screenbox);
|
modulePanel.add(screenbox);
|
||||||
modulePanel.add(goButton);
|
modulePanel.add(goButton);
|
||||||
|
modulePanel.add(msaEditorButton);
|
||||||
add(modulePanel);
|
add(modulePanel);
|
||||||
|
|
||||||
log = new JTextArea(50,25);
|
log = new JTextArea(20,25);
|
||||||
log.setMargin(new Insets(5,5,5,5));
|
log.setMargin(new Insets(5,5,5,5));
|
||||||
log.setEditable(false);
|
log.setEditable(false);
|
||||||
JScrollPane logScrollPane = new JScrollPane(log);
|
JScrollPane logScrollPane = new JScrollPane(log);
|
||||||
@ -100,14 +105,11 @@ public class FirstPanel extends JPanel implements ActionListener, UI {
|
|||||||
return (String)JOptionPane.showInputDialog(this, message,"Choose",JOptionPane.PLAIN_MESSAGE,null,choicelist,choicelist[0]);
|
return (String)JOptionPane.showInputDialog(this, message,"Choose",JOptionPane.PLAIN_MESSAGE,null,choicelist,choicelist[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------//
|
public String getInput(String message) {
|
||||||
|
return (String)JOptionPane.showInputDialog(message);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
//---------------------------------------------------------------------------------------//
|
||||||
public boolean getOption(String item) {
|
|
||||||
if (item.matches("file")) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if ( e.getSource() == moduleButton ) {
|
if ( e.getSource() == moduleButton ) {
|
||||||
@ -123,12 +125,19 @@ public class FirstPanel extends JPanel implements ActionListener, UI {
|
|||||||
logfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "migration.log")));
|
logfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "migration.log")));
|
||||||
println("Project MsaGen");
|
println("Project MsaGen");
|
||||||
println("Copyright (c) 2006, Intel Corporation");
|
println("Copyright (c) 2006, Intel Corporation");
|
||||||
new ModuleInfo(modulepath, this, new Database());
|
mi = new ModuleInfo(modulepath, this, new Database());
|
||||||
logfile.flush();
|
logfile.flush();
|
||||||
} catch (Exception en) {
|
} catch (Exception en) {
|
||||||
println(en.getMessage());
|
println(en.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( e.getSource() == msaEditorButton) {
|
||||||
|
try {
|
||||||
|
MsaTreeEditor.init(mi, this);
|
||||||
|
} catch (Exception en) {
|
||||||
|
println(en.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void itemStateChanged(ItemEvent e) {
|
public void itemStateChanged(ItemEvent e) {
|
||||||
@ -156,7 +165,7 @@ public class FirstPanel extends JPanel implements ActionListener, UI {
|
|||||||
fp.setOpaque(true);
|
fp.setOpaque(true);
|
||||||
frame.setContentPane(fp);
|
frame.setContentPane(fp);
|
||||||
|
|
||||||
frame.setSize(800,600);
|
frame.pack();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -86,7 +86,7 @@ public class ModuleInfo {
|
|||||||
} else {
|
} else {
|
||||||
filename = ui.choose("Found .inf or .msa file in the module\nChoose one Please", msaorinf.toArray());
|
filename = ui.choose("Found .inf or .msa file in the module\nChoose one Please", msaorinf.toArray());
|
||||||
}
|
}
|
||||||
ModuleReader mr = new ModuleReader(modulepath, this, db);
|
ModuleReader mr = new ModuleReader(modulepath, this, db, ui);
|
||||||
if (filename.contains(".inf")) {
|
if (filename.contains(".inf")) {
|
||||||
mr.readInf(filename);
|
mr.readInf(filename);
|
||||||
} else if (filename.contains(".msa")) {
|
} else if (filename.contains(".msa")) {
|
||||||
@ -131,19 +131,6 @@ public class ModuleInfo {
|
|||||||
ui.println(hash);
|
ui.println(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ensureDir(String objFileWhole) {
|
|
||||||
Pattern ptnseparate = Pattern.compile("(.*)\\\\[^\\\\]*");
|
|
||||||
Matcher mtrseparate;
|
|
||||||
File tempdir;
|
|
||||||
|
|
||||||
mtrseparate = ptnseparate.matcher(objFileWhole);
|
|
||||||
if (mtrseparate.find()) {
|
|
||||||
tempdir = new File(mtrseparate.group(1));
|
|
||||||
if (!tempdir.exists()) tempdir.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// add '//' to all non-local include lines
|
// add '//' to all non-local include lines
|
||||||
private void CommentOutNonLocalHFile() throws IOException {
|
private void CommentOutNonLocalHFile() throws IOException {
|
||||||
BufferedReader rd;
|
BufferedReader rd;
|
||||||
@ -158,7 +145,7 @@ public class ModuleInfo {
|
|||||||
while ( ii.hasNext() ) {
|
while ( ii.hasNext() ) {
|
||||||
curFile = ii.next();
|
curFile = ii.next();
|
||||||
rd = new BufferedReader(new FileReader(modulepath + File.separator + curFile));
|
rd = new BufferedReader(new FileReader(modulepath + File.separator + curFile));
|
||||||
ensureDir(modulepath + File.separator + "temp" + File.separator + curFile);
|
Common.ensureDir(modulepath + File.separator + "temp" + File.separator + curFile);
|
||||||
outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "temp" + File.separator + curFile)));
|
outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "temp" + File.separator + curFile)));
|
||||||
while ((line = rd.readLine()) != null) {
|
while ((line = rd.readLine()) != null) {
|
||||||
if (line.contains("#include")) {
|
if (line.contains("#include")) {
|
||||||
|
@ -18,16 +18,20 @@ import java.util.regex.*;
|
|||||||
import org.tianocore.*;
|
import org.tianocore.*;
|
||||||
|
|
||||||
public class ModuleReader {
|
public class ModuleReader {
|
||||||
ModuleReader(String path, ModuleInfo moduleinfo, Database database) {
|
ModuleReader(String path, ModuleInfo moduleinfo, Database database, UI u) {
|
||||||
modulepath = path;
|
modulepath = path;
|
||||||
mi = moduleinfo;
|
mi = moduleinfo;
|
||||||
db = database;
|
db = database;
|
||||||
|
ui = u;
|
||||||
}
|
}
|
||||||
private String modulepath;
|
private String modulepath;
|
||||||
private ModuleInfo mi;
|
private ModuleInfo mi;
|
||||||
private Database db;
|
private Database db;
|
||||||
|
private UI ui;
|
||||||
|
|
||||||
private static Pattern ptninfequation = Pattern.compile("([^ ]*) *= *([^ ]*)");
|
private static Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*=\\s*([^\\s]*)");
|
||||||
|
private static Pattern ptnsection = Pattern.compile("\\[([^\\[\\]]*)\\]([^\\[\\]]*)\\n", Pattern.MULTILINE);
|
||||||
|
private static Pattern ptnfilename = Pattern.compile("[^\\s]+");
|
||||||
|
|
||||||
public void readMsa(String name) throws Exception {
|
public void readMsa(String name) throws Exception {
|
||||||
ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.parse(new File(modulepath + File.separator + name));
|
ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.parse(new File(modulepath + File.separator + name));
|
||||||
@ -53,25 +57,19 @@ public class ModuleReader {
|
|||||||
System.out.println("Parsing INF file: " + name);
|
System.out.println("Parsing INF file: " + name);
|
||||||
BufferedReader rd = new BufferedReader(new FileReader(modulepath + File.separator + name));
|
BufferedReader rd = new BufferedReader(new FileReader(modulepath + File.separator + name));
|
||||||
String line;
|
String line;
|
||||||
|
String wholeline;
|
||||||
String[] linecontext;
|
String[] linecontext;
|
||||||
boolean inSrc = false;
|
boolean inSrc = false;
|
||||||
Matcher mtrinfequation;
|
Matcher mtrinfequation;
|
||||||
|
Matcher mtrsection;
|
||||||
|
Matcher mtrfilename;
|
||||||
|
|
||||||
while ((line = rd.readLine()) != null) {
|
wholeline = Common.sourcefiletostring(modulepath + File.separator + name);
|
||||||
if (line.length() != 0) {
|
mtrsection = ptnsection.matcher(wholeline);
|
||||||
if (inSrc) {
|
while (mtrsection.find()) {
|
||||||
if (line.contains("[")) {
|
if (mtrsection.group(1).matches("defines")) {
|
||||||
inSrc = false;
|
mtrinfequation = ptninfequation.matcher(mtrsection.group(2));
|
||||||
} else {
|
while (mtrinfequation.find()) {
|
||||||
linecontext = line.split(" ");
|
|
||||||
if (linecontext[2].length() != 0) {
|
|
||||||
if (!mi.localmodulesources.contains(linecontext[2])) {
|
|
||||||
System.out.println("Source File Missing! : " + linecontext[2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((mtrinfequation = ptninfequation.matcher(line)).find()) {
|
|
||||||
if (mtrinfequation.group(1).matches("BASE_NAME")) {
|
if (mtrinfequation.group(1).matches("BASE_NAME")) {
|
||||||
mi.modulename = mtrinfequation.group(2);
|
mi.modulename = mtrinfequation.group(2);
|
||||||
}
|
}
|
||||||
@ -81,12 +79,26 @@ public class ModuleReader {
|
|||||||
if (mtrinfequation.group(1).matches("COMPONENT_TYPE")) {
|
if (mtrinfequation.group(1).matches("COMPONENT_TYPE")) {
|
||||||
mi.moduletype = mtrinfequation.group(2);
|
mi.moduletype = mtrinfequation.group(2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mtrsection.group(1).matches("nmake.common")) {
|
||||||
|
mtrinfequation = ptninfequation.matcher(mtrsection.group(2));
|
||||||
|
while (mtrinfequation.find()) {
|
||||||
if (mtrinfequation.group(1).matches("IMAGE_ENTRY_POINT")) {
|
if (mtrinfequation.group(1).matches("IMAGE_ENTRY_POINT")) {
|
||||||
mi.entrypoint = mtrinfequation.group(2);
|
mi.entrypoint = mtrinfequation.group(2);
|
||||||
}
|
}
|
||||||
|
if (mtrinfequation.group(1).matches("DPX_SOURCE")) {
|
||||||
|
if (!mi.localmodulesources.contains(mtrinfequation.group(2))) {
|
||||||
|
ui.println("DPX File Missing! : " + mtrinfequation.group(2));
|
||||||
}
|
}
|
||||||
if (line.contains("sources")) {
|
}
|
||||||
inSrc = true;
|
}
|
||||||
|
}
|
||||||
|
if (mtrsection.group(1).contains("sources.")) {
|
||||||
|
mtrfilename = ptnfilename.matcher(mtrsection.group(2));
|
||||||
|
while (mtrfilename.find()) {
|
||||||
|
if (!mi.localmodulesources.contains(mtrfilename.group())) {
|
||||||
|
ui.println("Source File Missing! : " + mtrfilename.group());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
package org.tianocore.migration;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.tree.*;
|
||||||
|
|
||||||
|
public class MsaTreeEditor extends JPanel {
|
||||||
|
MsaTreeEditor(ModuleInfo m, UI u) {
|
||||||
|
mi = m;
|
||||||
|
ui = u;
|
||||||
|
|
||||||
|
rootNode = new DefaultMutableTreeNode("Root Node");
|
||||||
|
treeModel = new DefaultTreeModel(rootNode);
|
||||||
|
|
||||||
|
tree = new JTree(treeModel);
|
||||||
|
tree.setEditable(true);
|
||||||
|
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
||||||
|
tree.setShowsRootHandles(false);
|
||||||
|
tree.addMouseListener(mouseadapter);
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane(tree);
|
||||||
|
add(scrollPane);
|
||||||
|
|
||||||
|
popupmenu = new JPopupMenu();
|
||||||
|
JMenuItem menuitemadd = new JMenuItem("addNode");
|
||||||
|
JMenuItem menuitemdel = new JMenuItem("deleteNode");
|
||||||
|
popupmenu.add(menuitemadd);
|
||||||
|
popupmenu.add(menuitemdel);
|
||||||
|
menuitemadd.addActionListener(actionListener);
|
||||||
|
menuitemdel.addActionListener(actionListener);
|
||||||
|
|
||||||
|
addNode(rootNode, "1st");
|
||||||
|
addNode(rootNode, "2nd");
|
||||||
|
}
|
||||||
|
|
||||||
|
private ModuleInfo mi;
|
||||||
|
private UI ui;
|
||||||
|
|
||||||
|
private JTree tree;
|
||||||
|
private DefaultMutableTreeNode rootNode;
|
||||||
|
private DefaultTreeModel treeModel;
|
||||||
|
|
||||||
|
private JPopupMenu popupmenu;
|
||||||
|
private MouseAdapter mouseadapter = new MouseAdapter() {
|
||||||
|
public void mouseReleased(MouseEvent me) {
|
||||||
|
if (me.getClickCount() == 1 && SwingUtilities.isRightMouseButton(me)) {
|
||||||
|
tree.setSelectionPath(tree.getPathForLocation(me.getX(), me.getY()));
|
||||||
|
popupmenu.show(tree, me.getX(), me.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private ActionListener actionListener = new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent ae) {
|
||||||
|
addNode();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void addNode() {
|
||||||
|
addNode((DefaultMutableTreeNode)(tree.getSelectionPath().getLastPathComponent()), ui.getInput("Input Node Name"));
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNode(DefaultMutableTreeNode parentNode, Object child) {
|
||||||
|
DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child);
|
||||||
|
treeModel.insertNodeInto(childNode, parentNode, parentNode.getChildCount());
|
||||||
|
tree.scrollPathToVisible(new TreePath(childNode.getPath()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(ModuleInfo mi, UI ui) throws Exception {
|
||||||
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
|
|
||||||
|
JFrame frame = new JFrame("MsaTreeEditor");
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
MsaTreeEditor mte = new MsaTreeEditor(mi, ui);
|
||||||
|
mte.setLayout(new GridBagLayout());
|
||||||
|
mte.setOpaque(true);
|
||||||
|
frame.setContentPane(mte);
|
||||||
|
|
||||||
|
frame.pack();
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
@ -78,7 +78,7 @@ public class MsaWriter {
|
|||||||
msaheader.setCopyright("Copyright (c) 2006, Intel Corporation");
|
msaheader.setCopyright("Copyright (c) 2006, Intel Corporation");
|
||||||
msaheader.setVersion("1.0");
|
msaheader.setVersion("1.0");
|
||||||
msaheader.setAbstract("Component name for module " + mi.modulename);
|
msaheader.setAbstract("Component name for module " + mi.modulename);
|
||||||
msaheader.setDescription("FIX ME!"); //???
|
msaheader.setDescription("FIX ME!");
|
||||||
msaheader.addNewLicense().setStringValue("All rights reserved.\n" +
|
msaheader.addNewLicense().setStringValue("All rights reserved.\n" +
|
||||||
" This software and associated documentation (if any) is furnished\n" +
|
" This software and associated documentation (if any) is furnished\n" +
|
||||||
" under a license and may only be used or copied in accordance\n" +
|
" under a license and may only be used or copied in accordance\n" +
|
||||||
@ -103,9 +103,17 @@ public class MsaWriter {
|
|||||||
externs.addNewSpecification().setStringValue("EDK_RELEASE_VERSION 0x00020000");
|
externs.addNewSpecification().setStringValue("EDK_RELEASE_VERSION 0x00020000");
|
||||||
externs.addNewExtern().setModuleEntryPoint(mi.entrypoint);
|
externs.addNewExtern().setModuleEntryPoint(mi.entrypoint);
|
||||||
|
|
||||||
|
FilenameDocument.Filename filename;
|
||||||
it = mi.localmodulesources.iterator();
|
it = mi.localmodulesources.iterator();
|
||||||
|
//System.out.println(mi.localmodulesources);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
sourcefiles.addNewFilename().setStringValue(it.next());
|
temp = it.next();
|
||||||
|
filename = sourcefiles.addNewFilename();
|
||||||
|
filename.setStringValue(temp);
|
||||||
|
//if (temp.contains("x64" + File.separator)) {
|
||||||
|
//System.out.println("find");
|
||||||
|
//filename.setSupArchList();
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
if (!mi.protocol.isEmpty()) {
|
if (!mi.protocol.isEmpty()) {
|
||||||
protocols = msa.addNewProtocols();
|
protocols = msa.addNewProtocols();
|
||||||
|
@ -85,7 +85,7 @@ public class SourceFileReplacer {
|
|||||||
outname = inname;
|
outname = inname;
|
||||||
}
|
}
|
||||||
ui.println("\nModifying file: " + inname);
|
ui.println("\nModifying file: " + inname);
|
||||||
mi.ensureDir(modulepath + File.separator + "result" + File.separator + outname);
|
Common.ensureDir(modulepath + File.separator + "result" + File.separator + outname);
|
||||||
outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));
|
outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));
|
||||||
outfile.append(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname));
|
outfile.append(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname));
|
||||||
outfile.flush();
|
outfile.flush();
|
||||||
@ -97,9 +97,9 @@ public class SourceFileReplacer {
|
|||||||
outname = inname;
|
outname = inname;
|
||||||
}
|
}
|
||||||
ui.println("\nCopying file: " + inname);
|
ui.println("\nCopying file: " + inname);
|
||||||
mi.ensureDir(modulepath + File.separator + "result" + File.separator + outname);
|
Common.ensureDir(modulepath + File.separator + "result" + File.separator + outname);
|
||||||
outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));
|
outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));
|
||||||
outfile.append(sourcefiletostring(modulepath + File.separator + "temp" + File.separator + inname));
|
outfile.append(Common.sourcefiletostring(modulepath + File.separator + "temp" + File.separator + inname));
|
||||||
outfile.flush();
|
outfile.flush();
|
||||||
outfile.close();
|
outfile.close();
|
||||||
}
|
}
|
||||||
@ -112,8 +112,8 @@ public class SourceFileReplacer {
|
|||||||
|
|
||||||
private void addr8only() throws Exception {
|
private void addr8only() throws Exception {
|
||||||
String paragraph = null;
|
String paragraph = null;
|
||||||
String line = sourcefiletostring(Database.defaultpath + File.separator + "R8Lib.c");
|
String line = Common.sourcefiletostring(Database.defaultpath + File.separator + "R8Lib.c");
|
||||||
mi.ensureDir(modulepath + File.separator + "result" + File.separator + "R8Lib.c");
|
Common.ensureDir(modulepath + File.separator + "result" + File.separator + "R8Lib.c");
|
||||||
PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.c")));
|
PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.c")));
|
||||||
PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.h")));
|
PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.h")));
|
||||||
Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);
|
Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);
|
||||||
@ -142,16 +142,6 @@ public class SourceFileReplacer {
|
|||||||
mi.localmodulesources.add("R8Lib.c");
|
mi.localmodulesources.add("R8Lib.c");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sourcefiletostring(String filename) throws Exception {
|
|
||||||
BufferedReader rd = new BufferedReader(new FileReader(filename));
|
|
||||||
StringBuffer wholefile = new StringBuffer();
|
|
||||||
String line;
|
|
||||||
while ((line = rd.readLine()) != null) {
|
|
||||||
wholefile.append(line + "\n");
|
|
||||||
}
|
|
||||||
return wholefile.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Caution : if there is @ in file , it will be replaced with \n , so is you use Doxygen ... God Bless you!
|
// Caution : if there is @ in file , it will be replaced with \n , so is you use Doxygen ... God Bless you!
|
||||||
private String sourcefilereplace(String filename) throws Exception {
|
private String sourcefilereplace(String filename) throws Exception {
|
||||||
BufferedReader rd = new BufferedReader(new FileReader(filename));
|
BufferedReader rd = new BufferedReader(new FileReader(filename));
|
||||||
|
@ -25,4 +25,6 @@ public interface UI {
|
|||||||
public void println(Set<String> hash);
|
public void println(Set<String> hash);
|
||||||
|
|
||||||
public String choose(String message, Object[] choicelist);
|
public String choose(String message, Object[] choicelist);
|
||||||
|
|
||||||
|
public String getInput(String message);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user