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:
parent
763d04127c
commit
f55e7834ba
|
@ -159,8 +159,9 @@ def gen(lang):
|
|||
templ = template[lang]
|
||||
for target in include:
|
||||
prefix = templ[target]
|
||||
outfile = open(templ['out_file'] %(prefix), 'wb') # open as binary prevents windows newlines
|
||||
outfile.write((templ['header'] % (prefix)).encode("utf-8"))
|
||||
outfn = templ['out_file'] % prefix
|
||||
outfile = open(outfn + ".tmp", 'wb') # open as binary prevents windows newlines
|
||||
outfile.write((templ['header'] % prefix).encode("utf-8"))
|
||||
if target == 'unicorn.h':
|
||||
prefix = ''
|
||||
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.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():
|
||||
lang = sys.argv[1]
|
||||
if lang == "all":
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
target/
|
||||
unicorn_Unicorn.h
|
||||
|
|
|
@ -26,14 +26,11 @@ CFLAGS=-fPIC
|
|||
LDFLAGS=-shared -fPIC
|
||||
# May also use -lunicorn to dynamically link against the installed unicorn
|
||||
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
|
||||
|
||||
unicorn_Unicorn.h: src/main/java/unicorn/Unicorn.java
|
||||
javah -cp src/main/java -o $@ unicorn.Unicorn
|
||||
|
||||
unicorn_Unicorn.o: unicorn_Unicorn.c unicorn_Unicorn.h
|
||||
unicorn_Unicorn.o: unicorn_Unicorn.c target/headers/unicorn_Unicorn.h
|
||||
$(CC) -O2 -Wall -Wextra -Wno-unused-parameter -c $(CFLAGS) $(INCS) $< -o $@
|
||||
|
||||
libunicorn_java$(LIB_EXT): $(OBJS)
|
||||
|
@ -41,7 +38,6 @@ libunicorn_java$(LIB_EXT): $(OBJS)
|
|||
|
||||
clean:
|
||||
rm -f libunicorn_java$(LIB_EXT)
|
||||
rm -f unicorn_Unicorn.h
|
||||
rm -f $(OBJS)
|
||||
|
||||
.PHONY: all clean
|
||||
|
|
|
@ -33,6 +33,12 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<compilerArgs>
|
||||
<arg>-h</arg>
|
||||
<arg>target/headers</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
|
Loading…
Reference in New Issue