Replace javah by javac -h, only write new constant files if something changes.
The const_generator changes help to ensure that e.g. Java rebuilds don't keep rebuilding everything.
This commit is contained in:
@@ -159,8 +159,9 @@ def gen(lang):
|
|||||||
templ = template[lang]
|
templ = template[lang]
|
||||||
for target in include:
|
for target in include:
|
||||||
prefix = templ[target]
|
prefix = templ[target]
|
||||||
outfile = open(templ['out_file'] %(prefix), 'wb') # open as binary prevents windows newlines
|
outfn = templ['out_file'] % prefix
|
||||||
outfile.write((templ['header'] % (prefix)).encode("utf-8"))
|
outfile = open(outfn + ".tmp", 'wb') # open as binary prevents windows newlines
|
||||||
|
outfile.write((templ['header'] % prefix).encode("utf-8"))
|
||||||
if target == 'unicorn.h':
|
if target == 'unicorn.h':
|
||||||
prefix = ''
|
prefix = ''
|
||||||
with open(os.path.join(INCL_DIR, target)) as f:
|
with open(os.path.join(INCL_DIR, target)) as f:
|
||||||
@@ -278,6 +279,19 @@ def gen(lang):
|
|||||||
outfile.write((templ['footer']).encode("utf-8"))
|
outfile.write((templ['footer']).encode("utf-8"))
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
|
||||||
|
if os.path.isfile(outfn):
|
||||||
|
with open(outfn, "rb") as infile:
|
||||||
|
cur_data = infile.read()
|
||||||
|
with open(outfn + ".tmp", "rb") as infile:
|
||||||
|
new_data = infile.read()
|
||||||
|
if cur_data == new_data:
|
||||||
|
os.unlink(outfn + ".tmp")
|
||||||
|
else:
|
||||||
|
os.unlink(outfn)
|
||||||
|
os.rename(outfn + ".tmp", outfn)
|
||||||
|
else:
|
||||||
|
os.rename(outfn + ".tmp", outfn)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
lang = sys.argv[1]
|
lang = sys.argv[1]
|
||||||
if lang == "all":
|
if lang == "all":
|
||||||
|
|||||||
1
bindings/java/.gitignore
vendored
1
bindings/java/.gitignore
vendored
@@ -1,2 +1 @@
|
|||||||
target/
|
target/
|
||||||
unicorn_Unicorn.h
|
|
||||||
|
|||||||
@@ -26,14 +26,11 @@ CFLAGS=-fPIC
|
|||||||
LDFLAGS=-shared -fPIC
|
LDFLAGS=-shared -fPIC
|
||||||
# May also use -lunicorn to dynamically link against the installed unicorn
|
# May also use -lunicorn to dynamically link against the installed unicorn
|
||||||
LIBS=../../build/libunicorn.a
|
LIBS=../../build/libunicorn.a
|
||||||
INCS=-I$(JAVA_INC) -I$(JAVA_PLATFORM_INC) -I$(UNICORN_INC)
|
INCS=-I target/headers -I$(JAVA_INC) -I$(JAVA_PLATFORM_INC) -I$(UNICORN_INC)
|
||||||
|
|
||||||
OBJS=unicorn_Unicorn.o
|
OBJS=unicorn_Unicorn.o
|
||||||
|
|
||||||
unicorn_Unicorn.h: src/main/java/unicorn/Unicorn.java
|
unicorn_Unicorn.o: unicorn_Unicorn.c target/headers/unicorn_Unicorn.h
|
||||||
javah -cp src/main/java -o $@ unicorn.Unicorn
|
|
||||||
|
|
||||||
unicorn_Unicorn.o: unicorn_Unicorn.c unicorn_Unicorn.h
|
|
||||||
$(CC) -O2 -Wall -Wextra -Wno-unused-parameter -c $(CFLAGS) $(INCS) $< -o $@
|
$(CC) -O2 -Wall -Wextra -Wno-unused-parameter -c $(CFLAGS) $(INCS) $< -o $@
|
||||||
|
|
||||||
libunicorn_java$(LIB_EXT): $(OBJS)
|
libunicorn_java$(LIB_EXT): $(OBJS)
|
||||||
@@ -41,7 +38,6 @@ libunicorn_java$(LIB_EXT): $(OBJS)
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f libunicorn_java$(LIB_EXT)
|
rm -f libunicorn_java$(LIB_EXT)
|
||||||
rm -f unicorn_Unicorn.h
|
|
||||||
rm -f $(OBJS)
|
rm -f $(OBJS)
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|||||||
@@ -33,6 +33,12 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.11.0</version>
|
<version>3.11.0</version>
|
||||||
|
<configuration>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-h</arg>
|
||||||
|
<arg>target/headers</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
|||||||
Reference in New Issue
Block a user