Skip to content

Commit eb00dfc

Browse files
committed
Build libyamlstar with gloat.mk
1 parent c8cf3a9 commit eb00dfc

2 files changed

Lines changed: 24 additions & 56 deletions

File tree

Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ M := .cache/makes
22
$(shell [ -d $M ] || git clone -q https://github.com/makeplus/makes $M)
33
include $M/init.mk
44
include $M/gh.mk
5-
include $M/graalvm.mk
6-
include $M/lein.mk
5+
include $M/gloat.mk
76
include $M/yamlscript.mk
87
include $M/clean.mk
98
include $M/shell.mk
@@ -54,10 +53,8 @@ ALL-TESTS := \
5453
$(BINDING-TESTS)
5554

5655

57-
build jar install::
58-
$(MAKE) -C core $@ v=$v
59-
$(MAKE) -C cli $@ v=$v
60-
$(MAKE) -C libyamlstar $@ v=$v
56+
build install::
57+
$(MAKE) -C libyamlstar $@
6158

6259
test:: test-core
6360

libyamlstar/Makefile

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,43 @@
11
include ../common/init.mk
2-
include $M/graalvm.mk
3-
include $M/lein.mk
2+
include $M/gloat.mk
43
include ../common/common.mk
5-
include ../common/native.mk
64

75
MAKES-CLEAN := \
8-
target \
9-
.lein-* \
10-
src/libyamlstar/*.class \
11-
12-
MAKES-REALCLEAN := \
136
lib \
147

158
# Library paths and names
16-
API-VERSION := 0
17-
18-
# JAR files still use -SNAPSHOT (from project.clj)
19-
# but .so files use clean version
209
LIB-DIR := lib
2110
LIB-NAME := $(LIB-DIR)/libyamlstar
2211
LIB-SO := $(LIB-NAME).$(SO)
23-
LIB-SO-VERSIONED := $(LIB-NAME).$(SO).$(LIBYAMLSTAR-VERSION)
24-
LIB-JAR := target/libyamlstar-$(LIBYAMLSTAR-VERSION)-SNAPSHOT-standalone.jar
12+
LIB-HEADER := $(LIB-NAME).h
2513

26-
# Core dependency jar in local maven repository
27-
CORE-JAR := $(MAVEN-REPOSITORY)/yamlstar/core/$(LIBYAMLSTAR-VERSION)-SNAPSHOT/core-$(LIBYAMLSTAR-VERSION)-SNAPSHOT.jar
14+
CORE-YAMLSTAR := ../core/src/yamlstar
2815

29-
# Header files generated by native-image --shared
30-
LIB-HEADERS := \
31-
$(LIB-DIR)/graal_isolate.h \
32-
$(LIB-NAME).h \
16+
# Clojure source files compiled by gloat (order matters for namespaces)
17+
GLOAT-SRCS := \
18+
$(CORE-YAMLSTAR)/parser/prelude.clj \
19+
$(CORE-YAMLSTAR)/parser/parser.clj \
20+
$(CORE-YAMLSTAR)/parser/receiver.clj \
21+
$(CORE-YAMLSTAR)/parser/grammar.clj \
22+
$(CORE-YAMLSTAR)/parser.clj \
23+
$(CORE-YAMLSTAR)/composer.clj \
24+
$(CORE-YAMLSTAR)/resolver.clj \
25+
$(CORE-YAMLSTAR)/constructor.clj \
26+
$(CORE-YAMLSTAR)/core.clj \
27+
src/libyamlstar.clj \
3328

3429

3530
build: $(LIB-SO)
3631

3732
test:
3833

39-
jar: $(LIB-JAR)
40-
4134
install: $(LIB-SO)
42-
mkdir -p $(PREFIX)/include/
43-
install -m 644 $(LIB-HEADERS) $(PREFIX)/include/
4435
mkdir -p $(PREFIX)/lib/
45-
install -m 644 $(LIB-SO-VERSIONED) $(PREFIX)/lib/
46-
ln -sf $(notdir $(LIB-SO-VERSIONED)) $(PREFIX)/lib/$(notdir $(LIB-SO))
47-
ln -sf $(notdir $(LIB-SO-VERSIONED)) $(PREFIX)/lib/$(notdir $(LIB-SO)).$(API-VERSION)
36+
install -m 644 $(LIB-SO) $(PREFIX)/lib/
37+
install -m 644 $(LIB-HEADER) $(PREFIX)/include/ 2>/dev/null || true
4838

49-
$(CORE-JAR):
50-
$(MAKE) -C ../core install
51-
52-
$(LIB-JAR): $(CORE-JAR) $(LEIN)
53-
lein uberjar
54-
55-
$(LIB-SO): $(LIB-JAR) $(REFLECTION-JSON) $(GRAALVM)
56-
@echo "Building shared library..."
39+
$(LIB-SO): $(GLOAT-SRCS) | $(GLOAT-DIR)
40+
@echo "Building shared library with gloat..."
5741
mkdir -p $(LIB-DIR)
58-
$(GRAALVM) \
59-
$(NATIVE-OPTS) \
60-
--shared \
61-
-jar $< \
62-
-o $(LIB-NAME)
63-
mv $(LIB-SO) $(LIB-SO-VERSIONED)
64-
ln -sf $(notdir $(LIB-SO-VERSIONED)) $(LIB-SO)
65-
ln -sf $(notdir $(LIB-SO-VERSIONED)) $(LIB-SO).$(API-VERSION)
66-
@echo "Shared library created at: $(LIB-SO)"
67-
@echo "Headers: $(LIB-HEADERS)"
68-
69-
# Declare that these files are created as side effects of building $(LIB-SO)
70-
$(LIB-SO-VERSIONED): $(LIB-SO)
71-
$(LIB-NAME).h: $(LIB-SO)
72-
$(LIB-DIR)/graal_isolate.h: $(LIB-SO)
42+
env -u GOROOT $(GLOAT-BIN)/gloat $(GLOAT-SRCS) -o $@
43+
@echo "Shared library created at: $@"

0 commit comments

Comments
 (0)