Skip to content

Commit

Permalink
second public release
Browse files Browse the repository at this point in the history
  • Loading branch information
norswap committed Aug 22, 2015
1 parent 9839142 commit da4730e
Show file tree
Hide file tree
Showing 139 changed files with 11,234 additions and 4,188 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ java.hprof.txt
*.log

# Dependencies
/deps/
/deps/
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Copyright (c) 2015, Nicolas LAURENT
All rights reserved.

(BSD 3-Clause License)

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
127 changes: 127 additions & 0 deletions library.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
o?=dev
LIBS?=
OUTDIR?=out/$o
MVN_OUTPUT?=deps/fetched

ifeq ($(OS),Windows_NT)
SEP=;
else
SEP=:
endif

ifeq ($o,debug)
DEBUG=-g
else ifeq ($o,opti)
DEBUG=-g:none
endif

define MANUAL_TEXT
build

Compiles all java files in 'src', as well as all java files in the
directories listed in the LIBS variable.

The generated class files are put in the output directory. This
directory can be set via the OUTDIR variable and default to 'out/$o'.

'o' is the build type variable. Setting this to 'debug' will cause local
variables to be included in the class files debug information. Using
'opti' will disable *all* debugging information. Defaults to 'dev'.

clean

Deletes OUTDIR. Recall OUTDIR default to 'out/$o', and 'o' is the build
type variable.

run

Runs the class indicate in variable 't' (e.g. 'my.pkg.Main'), passing
the variable 'a' as argument (optional).

trace

Same as 'run', but uses hprof to benchmark the CPU use of the program.
The results are stored in the file 'java.hprof.txt'.

For more info:
https://docs.oracle.com/javase/8/docs/technotes/guides/
troubleshoot/tooldescr008.html

fetch

Fetches the maven artifact (e.g. jar file) specified in the 'a' variable, in
Gradle format. It does not fetch the dependencies of the artifact
transitively.

The downloaded files are put in the directory indicated by the
MVN_OUTPUT variable, defaulting to 'deps/fetched'.

fetchpom

Fetches all the jar dependencies listed in 'deps.xml' and fetches their
dependencies transitively.

The downloaded files are put in '$MVN_OUTPUT/jar', where MVN_OUTPUT is a
variable defaulting to 'deps/fetched'.

fetchdev

Fetches the sources and javadoc artifacts corresponding to the jars
listed in 'deps.xml' and their transitive dependencies.

The downloaded files are put in '$MVN_OUTPUT/src' and '$MVN_OUTPUT/jdoc',
where MVN_OUTPUT is a variable defaulting to 'deps/fetched'.

endef

# NOTE(norswap): no idea why this voodoo dance works, but naive attempts were
# unsuccessful. Kudos http://stackoverflow.com/questions/7281395

export MANUAL=$(MANUAL_TEXT)

help:
@echo "$$MANUAL"

# NOTE(norswap): The quotes around "deps/*" are necessary to avoid shell
# wildcard expansion. The wildcard must be processed by javac.

build:
mkdir -p $(OUTDIR)
cp -R resources/* $(OUTDIR)
javac -Xlint:unchecked $(DEBUG) -d $(OUTDIR) -cp "deps/*" `find src $(LIBS) -name *.java`

clean:
rm -rf $(OUTDIR)

run:
java -cp "$(OUTDIR)$(SEP)deps/*$(SEP)$(OUTDIR)/resources" $t $a

trace:
java -cp "$(OUTDIR)$(SEP)deps/*$(SEP)$(OUTDIR)/resources" -agentlib:hprof=cpu=samples $t $a

fetch:
mkdir -p $(MVN_OUTPUT)
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \
-DrepoUrl=http://repo1.maven.org/maven2/ \
-Ddest=$(MVN_OUTPUT)
-Dartifact=$a

fetchpom:
mvn dependency:copy-dependencies -f deps.xml \
-DoutputDirectory=$(MVN_OUTPUT)/jar

fetchdev:
mvn dependency:copy-dependencies -f deps.xml \
-DoutputDirectory=$(MVN_OUTPUT)/jdoc -Dclassifier=sources
mvn dependency:copy-dependencies -f deps.xml \
-DoutputDirectory=$(MVN_OUTPUT)/src -Dclassifier=javadoc

.PHONY: \
help \
build \
clean \
run \
trace \
fetch \
fetchpom \
fetchdev
14 changes: 14 additions & 0 deletions libs/java_utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# IntelliJ IDEA
/.idea/
*.iml

# Mac
.DS_Store

# Output
/out
java.hprof.txt
*.log

# Dependencies
/deps/
127 changes: 127 additions & 0 deletions libs/java_utils/library.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
o?=dev
LIBS?=
OUTDIR?=out/$o
MVN_OUTPUT?=deps/fetched

ifeq ($(OS),Windows_NT)
SEP=;
else
SEP=:
endif

ifeq ($o,debug)
DEBUG=-g
else ifeq ($o,opti)
DEBUG=-g:none
endif

define MANUAL_TEXT
build

Compiles all java files in 'src', as well as all java files in the
directories listed in the LIBS variable.

The generated class files are put in the output directory. This
directory can be set via the OUTDIR variable and default to 'out/$o'.

'o' is the build type variable. Setting this to 'debug' will cause local
variables to be included in the class files debug information. Using
'opti' will disable *all* debugging information. Defaults to 'dev'.

clean

Deletes OUTDIR. Recall OUTDIR default to 'out/$o', and 'o' is the build
type variable.

run

Runs the class indicate in variable 't' (e.g. 'my.pkg.Main'), passing
the variable 'a' as argument (optional).

trace

Same as 'run', but uses hprof to benchmark the CPU use of the program.
The results are stored in the file 'java.hprof.txt'.

For more info:
https://docs.oracle.com/javase/8/docs/technotes/guides/
troubleshoot/tooldescr008.html

fetch

Fetches the maven artifact (e.g. jar file) specified in the 'a' variable, in
Gradle format. It does not fetch the dependencies of the artifact
transitively.

The downloaded files are put in the directory indicated by the
MVN_OUTPUT variable, defaulting to 'deps/fetched'.

fetchpom

Fetches all the jar dependencies listed in 'deps.xml' and fetches their
dependencies transitively.

The downloaded files are put in '$MVN_OUTPUT/jar', where MVN_OUTPUT is a
variable defaulting to 'deps/fetched'.

fetchdev

Fetches the sources and javadoc artifacts corresponding to the jars
listed in 'deps.xml' and their transitive dependencies.

The downloaded files are put in '$MVN_OUTPUT/src' and '$MVN_OUTPUT/jdoc',
where MVN_OUTPUT is a variable defaulting to 'deps/fetched'.

endef

# NOTE(norswap): no idea why this voodoo dance works, but naive attempts were
# unsuccessful. Kudos http://stackoverflow.com/questions/7281395

export MANUAL=$(MANUAL_TEXT)

help:
@echo "$$MANUAL"

# NOTE(norswap): The quotes around "deps/*" are necessary to avoid shell
# wildcard expansion. The wildcard must be processed by javac.

build:
mkdir -p $(OUTDIR)
cp -R resources/* $(OUTDIR)
javac -Xlint:unchecked $(DEBUG) -d $(OUTDIR) -cp "deps/*" `find src $(LIBS) -name *.java`

clean:
rm -rf $(OUTDIR)

run:
java -cp "$(OUTDIR)$(SEP)deps/*$(SEP)$(OUTDIR)/resources" $t $a

trace:
java -cp "$(OUTDIR)$(SEP)deps/*$(SEP)$(OUTDIR)/resources" -agentlib:hprof=cpu=samples $t $a

fetch:
mkdir -p $(MVN_OUTPUT)
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \
-DrepoUrl=http://repo1.maven.org/maven2/ \
-Ddest=$(MVN_OUTPUT)
-Dartifact=$a

fetchpom:
mvn dependency:copy-dependencies -f deps.xml \
-DoutputDirectory=$(MVN_OUTPUT)/jar

fetchdev:
mvn dependency:copy-dependencies -f deps.xml \
-DoutputDirectory=$(MVN_OUTPUT)/jdoc -Dclassifier=sources
mvn dependency:copy-dependencies -f deps.xml \
-DoutputDirectory=$(MVN_OUTPUT)/src -Dclassifier=javadoc

.PHONY: \
help \
build \
clean \
run \
trace \
fetch \
fetchpom \
fetchdev
1 change: 1 addition & 0 deletions libs/java_utils/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include library.mk
Loading

0 comments on commit da4730e

Please sign in to comment.