I'm trying to compile my Java code with this Makefile. How ever when I run make, it compiles the code more than once.
Makefile:
.PHONY: all clean run
SOURCES = \
Models/CustomException \
Models/Forest \
Models/ForestContainer \
Models/Owner \
Models/OwnerContainer \
Models/Tree
SRC = $(addprefix src/, $(addsuffix .java, $(SOURCES)))
BIN = $(addprefix bin/, $(addsuffix .class, $(SOURCES)))
all: ${BIN}
clean:
-rm -f ${BIN};
${BIN}: ${SRC}
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin ${SRC};
run: all
java -cp bin Program;
Output:
┌─( klim ) - ( ~/workspace/Forest-mvc )
└─> make
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
As you can see it runs the commands more than once, actually 6 times. The number of times it run the commands increase/decrease as number of SOURCES are added/removed
How can this be?
just add the main classes after javac.
${BIN}: ${SRC}
javac -d bin -cp . Models/Tree.java
All the classes and the folders (packages) that depend of the main classes will be automatically compiled. Your make is compiling again and again some classes that have already been compiled.
The first target in your Makefile, all, depends on 6 different sub-targets. Presumably, at the beginning of the run, none of these exists, so make thinks it needs to build each of those 6 sub-targets. However, building any one of those sub-targets actually builds all 6 of them the way you have this defined - but make doesn't know that.
The bottom line is, it's doing what you told it to. The fact that what you told it to do is redundant doesn't matter to make.
For each target int ${BIN} make will invoke the ${BIN}: ${SRC} rule but you give it all the sources on the command line for javac. You probably want to replace the ${SRC} with $< on the javac line.
Related
i want to run a java project in jenkins in mac.i have the following .sh file and its code is given below:
#!/bin/bash
echo $#
${jvmargs[#]}
DIR=$(dirname $0)
args=( "$#" )
javaProps=( )
server_jvmargs=( -Djava.awt.headless=true -Xms1024m -Xmx1024m"${jvmargs[#]}" )
XX_HOME="$DIR"
client_classpath="$XX_HOME/lib/others/*:$XX_HOME/lib/http/*:$XX_HOME/lib/selenium-java-2.37.0/*:$XX_HOME/lib/selenium-java-2.37.0/libs/*:$XX_HOME/lib/TestNG/*:$XX_HOME/lib/mailactivation/*:$XX_HOME/bin"
BIN_PATH="$XX_HOME/bin"
SRC_PATH="$XX_HOME/src"
rm -rfv "$BIN_PATH"
chmod 777 "$BIN_PATH"
mkdir -p "$BIN_PATH"
cd $DIR
javac \
-cp "$client_classpath" \
-d "$BIN_PATH" \
-sourcepath $SRC_PATH src/com/*.java
java \
"${server_jvmargs[#]}" \
"${javaProps[#]}" \
-Dxx.home="$XX_HOME" \
-Duser.dir="$XX_HOME" \
-cp "$client_classpath" \
org.testng.TestNG temp-testng-customsuite.xml
i set the custom workspace and use this run.sh file in build setup(Execute Shell). But it shows the following error:
Started by user Ali Azam JenkinTest
Building in workspace /Users/aliazam/Desktop/App/eclipse/workspace/Training
java.io.IOException: Failed to mkdirs: /Users/aliazam/Desktop/App/eclipse/workspace/Training
at hudson.FilePath.mkdirs(FilePath.java:1164)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1268)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild. java:610)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:532)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Finished: FAILURE
can anyone please help me to solve this problem????
When I run eclim -? commands, I get the following output.
Available Commands:
archive_read -f file
history_add -p project -f file
history_clear -p project -f file
history_list -p project -f file
history_revision -p project -f file -r revision
jobs [-f family]
locate_file -p pattern -s scope [-n project] [-f file]
[-i]
ping
problems -p project [-e]
project_build -p project
project_by_resource -f file
project_close -p project
project_create -f folder [-p name] -n natures [-d depends]
[-a args]
project_delete -p project
project_import -f folder
project_info -p project
project_link_resource -f file
project_list [-n nature]
project_move -p project -d dir
project_nature_add -p project -n nature [-a args]
project_nature_aliases [-m]
project_nature_remove -p project -n nature
project_natures [-p project]
project_open -p project
project_refresh -p project
project_refresh_file -p project -f file
project_rename -p project -n name
project_run [-p project] [-v vim_instance_name] [-x vim_executable] [-l]
[-d] [-c] [-n name]
project_run_terminate [-l launchid]
project_setting -p project -s setting [-v value]
project_settings [-p project]
project_update -p project [-b buildfile] [-s settings]
projects
refactor_redo [-p]
refactor_undo [-p]
reload
setting -s setting
settings
settings_update [-s settings]
shutdown
workspace_dir
xml_format -f file -w linewidth -i indent -m fileformat
xml_validate -p project -f file [-s]
I do not see Java commands such as java_search or java_element_doc. How can I access them?
I have installed eclim version 2.5, and selected "Java Development" in the installation menu.
We have our own build system for android for a multitude of reason. We currently build the apk with aapt. Problem is now there is a dependency to a jar file that contains custom resources. For example the jar file looks like this:
/META-INF
/foo.properties
/my_custom_dir/
/i_hate_my_life/
using the following command :
aapt p --auto-add-overlay -f \
-M src/main/AndroidManifest.xml \
-I $(ANDROID_HOME)/platforms/android-19/android.jar \
-S src/main/res/ \
-S $(ANDROID_HOME)/extras/android/support/v7/appcompat/res/ \
-S $(ANDROID_HOME)/extras/google/google_play_services/libproject/google-play-services_lib/res/ \
-F bin/SampleApp.unaligned 1>/dev/null
totally ignores those extra directories and my app crashes well because that jar needs those little buggers.
I've tried the -j switch and that only includes the classes. Anyone have a clue other than to write a custom script or unzip the third party jar and use appt add (barf)?
Before you say use ant or gradle...it's not an option!
UPDATE:
For now I have this nastyness in my Makefile and it's working...
#mkdir -p bin/tmp/
#for i in $(JARS_MIN); do\
cp $$i bin/tmp/; \
done;
#cd bin/tmp/; \
for i in `ls`; do\
unzip -o $$i; \
rm $$i; \
rm -rf META-INF/; \
rm -rf com/; \
rm -rf org/; \
rm -rf android/; \
rm -rf edu/; \
rm -rf javax/; \
rm -rf net/; \
done;
cd bin/tmp/; zip -g -r ../SampleApp.unaligned *
I am trying to access functions from a c++ .so file in java(JNA). I am able to call simple "Hello" type function from this .so file. But when I am trying to access other functions which internally calls functions from other files (.so file which is written in C), I am getting exception like:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/stpl/workspace/TestJNA/bin/libhello.so: undefined symbol: PInit
I am stuck in this. Any help will be appreciated.
Now my problem is solved.
In case anyone have the same problem, the problem was in .so file.
Below is the script for .mk file to create .so file.
CC=g++
CFLAG= -g -O0
PRNINC= -I ./Include -I ./PRT.IF -I./app
PRNLIBS= -lHWIGotPrinter -lcommon -lpthread -ldl
ASTYLE=astyle
ASTYLEFLAGS= --style=ansi -t -p -b -S -K
compiledate=$(shell date '+%F %T')
DEFS=-D DEFINE_MKDATE="\"$(compiledate)\""
INC_PUB= -I./Include -I./PRT.IF -I./SCANNER.IF -I ./Include
INCLUDE=$(INC_PUB)
%.o: %.cpp
$(CC) $(CFLAG) $(DEFS) -fPIC $(INCLUDE) -c $< -shared -o $#
%.o: %.c
$(CC) $(CFLAG) $(DEFS) -fPIC $(INCLUDE) -c $< -shared -o $#
.PHONY:all
all: PRN
HSCAN CDU UPS
PRNAPPS= bin/libprntest.so
PRN: $(PRNAPPS)
bin/libprntest.so: app/prn_proc.cpp app/prntest.cpp app/myCpp.cpp
$(CC) $(CFLAG) $(DEFS) $(PRNINC) $(PRNLIBS) $^ -shared -o $#
dist: all
mkdir -p insttest
rm -rf insttest/*
cp -a bin insttest/
cp -f Makefile inst/
tar -czf inst-$(MAJOR).$(MINOR).tgz insttest/
rm -rf insttest
install:
install -m 755 $(PRNAPPS) /usr/bin
cleanbak:
find . -name *.o |xargs rm -f
find . -name *~ |xargs rm -f
find . -name *.bak |xargs rm -f
find . -name *.orig |xargs rm -f
find . -name *.cpp |xargs chmod 644
find . -name .h |xargs chmod 644
chmod 644 ./etc-lib/gotlib.
clean:
find . -name *.o |xargs rm -f
find . -name *~ |xargs rm -f
find . -name *.bak |xargs rm -f
find . -name *.orig |xargs rm -f
find . -name *.cpp |xargs chmod 644
find . -name *.h |xargs chmod 644
rm -f $(PRNAPPS) $(SCANAPPS) $(HSCANAPPS) $(UPSAPPS) $(CDUAPPS) $(HARDWAREAPPS) $(CMOSAPPS) $(TOOLSAPPS)
help:
echo "make style "
echo "make cleanbak"
echo "make clean"
echo "make"
echo "make dist"
echo "make install"
I am new to Haxe. Today I install it by reading the instructions in the http://www.haxenme.org;
and download the "Acurate Example".
I run the example with FalshDevelop, when I build it to flash(nme test "Acurate Example.nmml" flash), it goes well!
But when I use nme test "Acurate Example.nmml" android, it crashes!!
I have setting the android variables ok.
Please help me, thanks in advance!
PS: Errors here:
C:\Documents and Settings\Neusoft\桌面\11yue\HaXe\Demos\Actuate_Example>nme test
"Actuate Example.nmml" android
haxelib run hxcpp Build.xml haxe -Dactuate -Dandroid -Dcpp -Dhaxe_208 -Dmobile -
Dnme -Dnme_install_tool -Dtrue
mkdir obj/android
mkdir obj/android/src
mkdir obj/android/src/nme
mkdir obj/android/src/nme/display
mkdir obj/android/src/nme/events
mkdir obj/android/src/nme/geom
mkdir obj/android/src/nme/text
mkdir obj/android/src/nme/errors
mkdir obj/android/src/nme/utils
mkdir obj/android/src/com
mkdir obj/android/src/com/eclecticdesignstudio
mkdir obj/android/src/com/eclecticdesignstudio/motion
mkdir obj/android/src/com/eclecticdesignstudio/motion/actuators
mkdir obj/android/src/haxe
mkdir obj/android/src/haxe/io
mkdir obj/android/src/nme/media
mkdir obj/android/src/cpp
mkdir obj/android/src/com/eclecticdesignstudio/motion/easing
mkdir obj/android/src/cpp/zip
mkdir obj/android/src/nme/filters
mkdir obj/android/src/cpp/rtti
mkdir obj/android/src/nme/net
mkdir obj/android/src/nme/installer
mkdir obj/android/src/cpp/io
mkdir obj/android/src/com/eclecticdesignstudio/motion/_Actuate
mkdir obj/android/src/cpp/io/_Process
mkdir obj/android/__pch
mkdir obj/android/__pch/haxe
Creating obj/android/__pch/haxe/hxcpp.h.gch...
arm-linux-androideabi-g++ -Iinclude --sysroot=D:/AndroidDev/android-ndk-r5/platf
orms/android-5/arch-arm -ID:/AndroidDev/android-ndk-r5/sources/cxx-stl/gnu-libst
dc++/4.4.3/include -ID:/AndroidDev/android-ndk-r5/sources/cxx-stl/gnu-libstdc++/
4.4.3/libs/armeabi/include -ID:\HaXe_ProgramFiles\Motion-Twin\haxe\lib\hxcpp\2,0
8,1//include -Iinclude -fpic -fvisibility=hidden -ffunction-sections -funwind-ta
bles -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__A
RM_ARCH_5E__ -D__ARM_ARCH_5TE__ -D_LINUX_STDDEF_H -Wno-psabi -march=armv5te -mt
une=xscale -msoft-float -fomit-frame-pointer -fexceptions -fno-strict-aliasing -
finline-limit=10000 -DANDROID -Wa,--noexecstack -O2 -DNDEBUG -c -frtti -o obj/an
droid/__pch/haxe/hxcpp.h.gch D:\HaXe_ProgramFiles\Motion-Twin\haxe\lib\hxcpp\2,0
8,1//include/hxcpp.h
Called from ? line 1
Called from BuildTool.hx line 1342
Called from BuildTool.hx line 591
Called from BuildTool.hx line 626
Called from BuildTool.hx line 760
Called from BuildTool.hx line 791
Called from BuildTool.hx line 174
Uncaught exception - Error creating pch: 1 - build cancelled
Error : Build failed
And It popup a Error dialog with message:
cc1plus.exe-error;Application cannot normally initiate(0xc0000005).
Could you try testing the Pirate Pig sample, to see if that compiles alright?