Coder Social home page Coder Social logo

j4make's Introduction

j4make

java Makefile Graph parser

Build Status

Compilation

make

an executable jar is created in dist/j4make.jar

Usage

 -f,--format <FORMAT>   output format one of [XML, DOT, GEXF, RDF]
 -h,--help              Print Help and exit
 -v,--version           Print version and exit

Example

Dot output

$ make -ndBr | java -jar dist/j4make.jar 2> /dev/null 
digraph G {
n3[label="all"];
n8[label="lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar"];
n6[label="lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar"];
n2[label="Makefile"];
n4[label="j4make"];
n1[label="<ROOT>"];
n7[label="lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar"];
n5[label="/home/lindenb/src/j4make/src/main/java/com/github/lindenb/j4make/J4Make.java"];
n4 -> n3;
n5 -> n4;
n6 -> n4;
n7 -> n4;
n8 -> n4;
n2 -> n1;
n3 -> n1;
}

XML output

$ make -ndBr | java -jar dist/j4make.jar --format XML 2> /dev/null   | xmllint --format -
<?xml version="1.0" encoding="UTF-8"?>
<make>
  <target name="all">
    <prerequisites>
      <prerequisite ref="j4make"/>
    </prerequisites>
    <shell/>
  </target>
  <target name="lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar">
    <prerequisites/>
    <shell>
      <p>mkdir -p lib/org/slf4j/slf4j-api/1.7.13/ &amp;&amp; wget -O "lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar" "http://central.maven.org/maven2/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar"</p>
    </shell>
  </target>
  <target name="lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar">
    <prerequisites/>
    <shell>
      <p>mkdir -p lib/commons-codec/commons-codec/1.10/ &amp;&amp; wget -O "lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar" "http://central.maven.org/maven2/commons-codec/commons-codec/1.10/commons-codec-1.10.jar"</p>
    </shell>
  </target>
  <target name="Makefile">
    <prerequisites/>
    <shell/>
  </target>
  <target name="j4make">
    <prerequisites>
      <prerequisite ref="/home/lindenb/src/j4make/src/main/java/com/github/lindenb/j4make/J4Make.java"/>
      <prerequisite ref="lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar"/>
      <prerequisite ref="lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar"/>
      <prerequisite ref="lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar"/>
    </prerequisites>
    <shell>
      <p>mkdir -p /home/lindenb/src/j4make/_tmp/META-INF /home/lindenb/src/j4make/src/main/generated-sources/java/com/github/lindenb/j4make/ /home/lindenb/src/j4make/dist</p>
      <p>#compile</p>
      <p>javac -d /home/lindenb/src/j4make/_tmp -g -classpath "lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar:lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar" -sourcepath /home/lindenb/src/j4make/src/main/java:/home/lindenb/src/j4make/src/main/generated-sources/java /home/lindenb/src/j4make/src/main/java/com/github/lindenb/j4make/J4Make.java</p>
      <p>#create META-INF/MANIFEST.MF</p>
      <p>echo "Manifest-Version: 1.0" &gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF</p>
      <p>echo "Main-Class: com.github.lindenb.j4make.J4Make" &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF</p>
      <p>echo "Class-Path: /home/lindenb/src/j4make/lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar /home/lindenb/src/j4make/lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar /home/lindenb/src/j4make/lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar /home/lindenb/src/j4make/dist/j4make.jar" | fold -w 71 | awk '{printf("%s%s\n",(NR==1?"": " "),$0);}' &gt;&gt;  /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF</p>
      <p>echo -n "Git-Hash: " &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF</p>
      <p>cat /home/lindenb/src/j4make/.git/refs/heads/master  &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF </p>
      <p>echo -n "Compile-Date: " &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF</p>
      <p>date +%Y-%m-%d:%H-%m-%S &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF</p>
      <p>#create jar</p>
      <p>jar cfm /home/lindenb/src/j4make/dist/j4make.jar /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF  -C /home/lindenb/src/j4make/_tmp .</p>
      <p>#create bash executable</p>
      <p>echo '#!/bin/bash' &gt; /home/lindenb/src/j4make/dist/j4make</p>
      <p>echo 'java -Dfile.encoding=UTF8 -Xmx500m    -cp "/home/lindenb/src/j4make/lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/home/lindenb/src/j4make/lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar:/home/lindenb/src/j4make/lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar:/home/lindenb/src/j4make/dist/j4make.jar" com.github.lindenb.j4make.J4Make $*' &gt;&gt; /home/lindenb/src/j4make/dist/j4make</p>
      <p>chmod  ugo+rx /home/lindenb/src/j4make/dist/j4make</p>
      <p>#cleanup</p>
      <p>rm -rf /home/lindenb/src/j4make/_tmp</p>
    </shell>
  </target>
  <target name="&lt;ROOT&gt;">
    <prerequisites>
      <prerequisite ref="Makefile"/>
      <prerequisite ref="all"/>
    </prerequisites>
    <shell/>
  </target>
  <target name="lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar">
    <prerequisites/>
    <shell>
      <p>mkdir -p lib/commons-cli/commons-cli/1.3.1/ &amp;&amp; wget -O "lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar" "http://central.maven.org/maven2/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar"</p>
    </shell>
  </target>
  <target name="/home/lindenb/src/j4make/src/main/java/com/github/lindenb/j4make/J4Make.java">
    <prerequisites/>
    <shell/>
  </target>
</make>

Gexf output

$ make -ndBr | java -jar dist/j4make.jar --format gexf 2> /dev/null   | xmllint --format -
<?xml version="1.0" encoding="UTF-8"?>
<gexf xmlns="http://www.gexf.net/1.2draft" version="1.2">
  <meta>
    <creator>Pierre Lindenbaum</creator>
    <description>Made with j4make https://github.com/lindenb/j4make</description>
  </meta>
  <graph mode="static" defaultedgetype="directed">
    <attributes class="node" mode="static"/>
    <nodes>
      <node id="3" label="all"/>
      <node id="8" label="lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar"/>
      <node id="6" label="lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar"/>
      <node id="2" label="Makefile"/>
      <node id="4" label="j4make"/>
      <node id="1" label="&lt;ROOT&gt;"/>
      <node id="7" label="lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar"/>
      <node id="5" label="/home/lindenb/src/j4make/src/main/java/com/github/lindenb/j4make/J4Make.java"/>
    </nodes>
    <edges>
      <edge id="E1" type="directed" source="4" target="3"/>
      <edge id="E2" type="directed" source="5" target="4"/>
      <edge id="E3" type="directed" source="6" target="4"/>
      <edge id="E4" type="directed" source="7" target="4"/>
      <edge id="E5" type="directed" source="8" target="4"/>
      <edge id="E6" type="directed" source="2" target="1"/>
      <edge id="E7" type="directed" source="3" target="1"/>
    </edges>
  </graph>
</gexf>

RDF output

<?xml version="1.0" encoding="UTF-8"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:m="https://github.com/lindenb/j4make#"><m:Target rdf:about="file:/home/lindenb/src/j4make/all"><m:hasPrerequisite rdf:resource="file:/home/lindenb/src/j4make/j4make"/><m:shell></m:shell></m:Target><m:Target rdf:about="file:/home/lindenb/src/j4make/lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar"><m:length rdf:datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">33088</m:length><m:lastModified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2015-11-10T21:14:11+0100</m:lastModified><m:shell>mkdir -p lib/org/slf4j/slf4j-api/1.7.13/ &amp;&amp; wget -O "lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar" "http://central.maven.org/maven2/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar"
</m:shell></m:Target><m:Target rdf:about="file:/home/lindenb/src/j4make/lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar"><m:length rdf:datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">284184</m:length><m:lastModified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2014-11-06T15:15:33+0100</m:lastModified><m:shell>mkdir -p lib/commons-codec/commons-codec/1.10/ &amp;&amp; wget -O "lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar" "http://central.maven.org/maven2/commons-codec/commons-codec/1.10/commons-codec-1.10.jar"
</m:shell></m:Target><m:Target rdf:about="file:/home/lindenb/src/j4make/Makefile"><m:length rdf:datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">2454</m:length><m:lastModified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2015-11-12T16:41:57+0100</m:lastModified><m:shell></m:shell></m:Target><m:Target rdf:about="file:/home/lindenb/src/j4make/j4make"><m:hasPrerequisite rdf:resource="file:/home/lindenb/src/j4make/src/main/java/com/github/lindenb/j4make/J4Make.java"/><m:hasPrerequisite rdf:resource="file:/home/lindenb/src/j4make/lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar"/><m:hasPrerequisite rdf:resource="file:/home/lindenb/src/j4make/lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar"/><m:hasPrerequisite rdf:resource="file:/home/lindenb/src/j4make/lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar"/><m:shell>mkdir -p /home/lindenb/src/j4make/_tmp/META-INF /home/lindenb/src/j4make/src/main/generated-sources/java/com/github/lindenb/j4make/ /home/lindenb/src/j4make/dist
#compile
javac -d /home/lindenb/src/j4make/_tmp -g -classpath "lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar:lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar" -sourcepath /home/lindenb/src/j4make/src/main/java:/home/lindenb/src/j4make/src/main/generated-sources/java /home/lindenb/src/j4make/src/main/java/com/github/lindenb/j4make/J4Make.java
#create META-INF/MANIFEST.MF
echo "Manifest-Version: 1.0" &gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF
echo "Main-Class: com.github.lindenb.j4make.J4Make" &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF
echo "Class-Path: /home/lindenb/src/j4make/lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar /home/lindenb/src/j4make/lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar /home/lindenb/src/j4make/lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar /home/lindenb/src/j4make/dist/j4make.jar" | fold -w 71 | awk '{printf("%s%s\n",(NR==1?"": " "),$0);}' &gt;&gt;  /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF
echo -n "Git-Hash: " &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF
cat /home/lindenb/src/j4make/.git/refs/heads/master  &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF 
echo -n "Compile-Date: " &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF
date +%Y-%m-%d:%H-%m-%S &gt;&gt; /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF
#create jar
jar cfm /home/lindenb/src/j4make/dist/j4make.jar /home/lindenb/src/j4make/_tmp/META-INF/MANIFEST.MF  -C /home/lindenb/src/j4make/_tmp .
#create bash executable
echo '#!/bin/bash' &gt; /home/lindenb/src/j4make/dist/j4make
echo 'java -Dfile.encoding=UTF8 -Xmx500m    -cp "/home/lindenb/src/j4make/lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/home/lindenb/src/j4make/lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar:/home/lindenb/src/j4make/lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar:/home/lindenb/src/j4make/dist/j4make.jar" com.github.lindenb.j4make.J4Make $*' &gt;&gt; /home/lindenb/src/j4make/dist/j4make
chmod  ugo+rx /home/lindenb/src/j4make/dist/j4make
#cleanup
rm -rf /home/lindenb/src/j4make/_tmp
</m:shell></m:Target><m:Target rdf:about="file:/home/lindenb/src/j4make/%3CROOT%3E"><m:hasPrerequisite rdf:resource="file:/home/lindenb/src/j4make/Makefile"/><m:hasPrerequisite rdf:resource="file:/home/lindenb/src/j4make/all"/><m:shell></m:shell></m:Target><m:Target rdf:about="file:/home/lindenb/src/j4make/lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar"><m:length rdf:datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">52988</m:length><m:lastModified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2015-06-14T12:06:20+0200</m:lastModified><m:shell>mkdir -p lib/commons-cli/commons-cli/1.3.1/ &amp;&amp; wget -O "lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar" "http://central.maven.org/maven2/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar"
</m:shell></m:Target><m:Target rdf:about="file:/home/lindenb/src/j4make/src/main/java/com/github/lindenb/j4make/J4Make.java"><m:length rdf:datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">9875</m:length><m:lastModified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2015-11-12T20:13:52+0100</m:lastModified><m:shell></m:shell></m:Target></rdf:RDF>

Author

  • Pierre Lindenbaum PhD

License

MIT License

See also

j4make's People

Contributors

fredcooke avatar lindenb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

j4make's Issues

compiling j4make

Hello,

Problem in compiling j4make. Don't know java at all. Here is the output:

javac -d /home/toto/makefile_to_dot/j4make/_tmp -g -classpath "lib/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:lib/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar:lib/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.jar" -sourcepath /home/toto/makefile_to_dot/j4make/src/main/java:     /home/toto/makefile_to_dot/j4make/src/main/generated-sources/java /home/toto/makefile_to_dot/j4make/src/main/java/com/github/lindenb/j4make/J4Make.java /home/toto/makefile_to_dot/j4make/src/main/java/com/github/lindenb/j4make/Target.java:51: illegal start of type
    protected List<String> shellLines = new ArrayList<>();
                                                      ^
/home/toto/makefile_to_dot/j4make/src/main/java/com/github/lindenb/j4make/Target.java:55: illegal start of type
    protected Set<Target> _prerequisites= new LinkedHashSet<>();
                                                            ^
2 errors

Thank by advance,

does this can scan file like this?

edit : main.o kbd.o command.o display.o insert.osearch.o files.o utils.o \ cc -o edit main.o kbd.o command.o display.o insert.o search.o files.outils.o main.o : main.c defs.h cc -c main.c kbd.o : kbd.c defs.hcommand.h cc -c kbd.c command.o : command.cdefs.h command.h cc -c command.c display.o : display.cdefs.h buffer.h cc -c display.c insert.o : insert.cdefs.h buffer.h cc -c insert.c search.o : search.cdefs.h buffer.h cc -c search.c files.o : files.c defs.hbuffer.h command.h cc -c files.c utils.o : utils.c defs.h cc -c utils.c clean : rm edit main.o kbd.o command.o display.o insert.o search.o files.o utils.o

output of test in readme different from the one in readme

After installing java8, I ran the test in the readme:

make -ndBr | java -jar dist/j4make.jar 2> /dev/null

and got (only)

digraph G {
n1[label="<ROOT>"];
}

Is it what I should get, because it is different from what it is in the readme?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.