Skip to content

Commit

Permalink
Merge pull request #4 from cxw42/marshal
Browse files Browse the repository at this point in the history
Marshal data between Wren and Vala
  • Loading branch information
cxw42 committed Apr 25, 2021
2 parents fef588f + 454b323 commit 665267d
Show file tree
Hide file tree
Showing 32 changed files with 1,341 additions and 1,551 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Generated by configure
Makefile
libwren*.pc
/src/basics.vapi
/src/marshal.vala
/src/trampoline.vala
/src/vm.vala
/src/wrennull.c
/t/common.sh

# Prerequisites
Expand Down
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "wren-pkg/wren"]
branch = wren-vala-2
path = wren-pkg/wren
url = https://github.com/wren-lang/wren.git
url = https://github.com/cxw42/wren.git
13 changes: 7 additions & 6 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ distcheck-hook:
phony += prettyprint
prettyprint:
-$(AM_V_GEN)uncrustify -l VALA -c $(top_srcdir)/.uncrustifyrc --replace \
src/basics.vapi.in \
src/marshal.vala.in \
src/trampoline.vala.in \
src/vm.vala.in \
src/wrennull.c.in \
$(vala_all_sources) \
t/000-sanity-t.vala \
t/090-util-t.vala \
t/105-tramp-t.vala \
t/100-vmv-t.vala \
t/110-hello-world-s.vala \
Expand All @@ -43,11 +40,15 @@ prettyprint:
t/140-roundtrip-data-t.vala \
t/150-marshal-t.vala \
t/200-expose-class-t.vala \
t/210-marshal-class-t.vala \
$(EOL)
-$(AM_V_GEN)uncrustify -c $(top_srcdir)/.uncrustifyrc --replace \
$(c_all_sources) \
$(EOL)

phony += p
p: prettyprint
-ctags -R
-ctags -R --exclude='doc/*' --exclude='wren-vala-coverage/*'

phony += cleanwren
cleanwren:
Expand Down
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,21 @@ After cloning:

After doing one of the above "From" subsections:

If you do not already have Wren installed, run
`./configure --enable-wren-install && make -j && sudo make -j install`
```
./configure && make -j && sudo make -j install
```

After that, or if you do have Wren installed, run
`./configure && make -j && sudo make -j install`.
Wren is statically linked into wren-vala.

Note that `make` will only build EITHER Wren OR `wren-vala`. The default
is `wren-vala`. To build Wren itself, pass `--enable-wren-install` to
`./configure`. Yes, this is a bit odd, but it's the best I can think of
at the moment! :)

## After building from a Git repo

The `wren-pkg/wren` submodule may be dirty. To restore it to its clean state,
run `make cleanwren`. This will **remove** any files in `wren-pkg/wren` that
are not checked in, so use this command carefully!
Note: the version number of wren-vala matches the version of Wren in
the first three digits.

# Repo contents

- `src/`: source code for the Vala bindings
- `t/`: tests for the Vala bindings
- `doc/`: documentation for the Vala bindings
- `wren-pkg/`: Code to install wren to the system. Only tested on Linux,
as of present.
- `wren-pkg/`: Version of Wren that is statically linked into wren-vala
- `wren-pkg/wren/`: [wren-lang/wren](https://github.com/wren-lang/wren),
as a git submodule

Expand All @@ -58,6 +49,8 @@ are not checked in, so use this command carefully!
- Code coverage of the test suite: run `./coverage.sh`, then open
`wren-vala-coverage/index.html` in a Web browser. Requires gcov(1) and
lcov(1).
- Note: You can't run `make distcheck` if you're configured for
coverage. Just re-run `./configure` to go back to non-coverage mode.
- Documentation: run `make html`, then open `doc/valadoc/index.html` in a
Web browser.

Expand Down
6 changes: 3 additions & 3 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* config.h.in. Generated from configure.ac by autoheader. */

/* Wren API version */
#undef APIVER

/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H

Expand Down Expand Up @@ -30,9 +33,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

/* Define to 1 if you have the <wren.h> header file. */
#undef HAVE_WREN_H

/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR

Expand Down
74 changes: 6 additions & 68 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -53,67 +53,19 @@ AC_MSG_NOTICE([Wren version $WREN_VERSION])

PKG_INSTALLDIR
AC_SUBST([APIVER], [$WREN_VERSION]) dnl Just to reduce typing :)
AC_DEFINE_UNQUOTED([APIVER],["$WREN_VERSION"], [Wren API version])
AC_SUBST([APIVERSH], [AS_TR_SH([$WREN_VERSION])])

dnl === Installing Wren from wren-pkg/ ====================================
dnl === Wren ==============================================================

AC_ARG_ENABLE([wren-install],
AS_HELP_STRING([--enable-wren-install],
[Build and install Wren itself INSTEAD OF wren-vala. You will need to re-run
configure without this option to install wren-vala.])
)
AM_CONDITIONAL([WREN_INSTALL], [test "x$enable_wren_install" '=' 'xyes'])
AC_CHECK_FILE([$srcdir/wren-pkg/wren/README.md], [],
[AC_MSG_ERROR([You asked me to install Wren but the source tree does not appear to be full. Try 'git submodule update --init --recursive" if you have not yet done so.])])

dnl Set up for the Wren compilation
whichtarget='wren-vala'
AM_COND_IF([WREN_INSTALL],
[
dnl Sanity check
AC_CHECK_FILE([wren-pkg/wren/README.md], [],
[AC_MSG_ERROR([You asked me to install Wren but the source tree does not appear to be full. Try 'git submodule update --init --recursive" if you have not yet done so.])])
whichtarget='Wren itself (after installing, re-run ./configure to build wren-vala)'
]
)

dnl === Check for Wren ====================================================
dnl Don't use pkg-config since Wren itself does not provide a .pc file.
dnl However, we could be using a hand-installed Wren or a Wren we installed
dnl using versioned names.

wren_exists='yes'
AC_SUBST([WREN_HEADER])
AC_CHECK_HEADERS([wren.h "wren-$APIVER.h"],
[
WREN_HEADER="$ac_header"
break
],
)
AS_IF([test "x$WREN_HEADER" '=' 'x'],
[
dnl No wren.h found
AC_MSG_WARN([Could not find wren.h])
wren_exists=''
]
)
AC_SUBST([MERGED_HEADER], [wren-vala-$APIVER.h])

AC_SEARCH_LIBS([log2], [m],
[], [
AC_MSG_WARN([Could not find -lm])
]
)

AC_SEARCH_LIBS([wrenNewVM], [wren "wren-$APIVER"],
[], [
AC_MSG_WARN([Could not find -lwren])
wren_exists=''
],
[-lm]
)

AS_IF([ test "x$wren_exists" '!=' 'xyes' && test "x$enable_wren_install" '!=' 'xyes' ],
[
AC_MSG_ERROR([I could not find Wren on your system. Try "$0 --enable-wren-install" to build and install a Wren package.])
AC_MSG_WARN([Could not find -lm, which Wren requires])
]
)

Expand Down Expand Up @@ -195,22 +147,8 @@ AC_CONFIG_FILES([
wren-pkg/Makefile
])

dnl Source files: make them RO
AC_CONFIG_FILES([src/basics.vapi], [chmod a-w src/basics.vapi])
AC_CONFIG_FILES([src/marshal.vala], [chmod a-w src/marshal.vala])
AC_CONFIG_FILES([src/trampoline.vala], [chmod a-w src/trampoline.vala])
AC_CONFIG_FILES([src/vm.vala], [chmod a-w src/vm.vala])
AC_CONFIG_FILES([src/wrennull.c], [chmod a-w src/wrennull.c])

dnl pkg-config files: name them after the Wren version
AC_CONFIG_FILES([wren-pkg/libwren-"${APIVER}".pc:wren-pkg/libwren.pc.in], [], [APIVER=$APIVER])
AC_CONFIG_FILES([src/libwren-vala-"${APIVER}".pc:src/libwren-vala.pc.in], [], [APIVER=$APIVER])

dnl Tell the user what is going to happen
AC_CONFIG_COMMANDS([notify],
[echo "*** Ready to build $whichtarget ***"],
[whichtarget="$whichtarget"]
)

AM_SILENT_RULES([yes])
AC_OUTPUT
5 changes: 1 addition & 4 deletions doc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ valadoc:
$(AM_V_GEN)valadoc -o valadoc -b $(top_srcdir)/src --verbose --force \
--package-name='@PACKAGE_TARNAME@' \
--package-version='@PACKAGE_VERSION@' \
$(top_srcdir)/src/basics.vapi \
$(top_srcdir)/src/marshal.vala \
$(top_srcdir)/src/trampoline.vala \
$(top_srcdir)/src/vm.vala \
$(vala_all_sources) \
--doclet=html \
$(MY_VALA_PKGS) \
$(EOL)
Expand Down
20 changes: 19 additions & 1 deletion rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ vapidir = $(datadir)/vala/vapi

# === Variables =========================================================

vala_all_sources = \
$(top_srcdir)/src/basics.vapi \
$(top_srcdir)/src/marshal.vala \
$(top_srcdir)/src/trampoline.vala \
$(top_srcdir)/src/util.vala \
$(top_srcdir)/src/vm.vala \
$(EOL)

c_all_sources = \
$(top_srcdir)/src/myconfig.c \
$(top_srcdir)/src/shim.c \
$(EOL)

# Vala settings.
# - LOCAL_VALA_FLAGS is filled in by each Makefile.am with any other valac
# options that Makefile.am needs.
Expand All @@ -35,7 +48,12 @@ MY_VALA_PKGS = \

# C settings, which are the same throughout. LOCAL_CFLAGS is filled in
# by each Makefile.am.
AM_CFLAGS = $(LOCAL_CFLAGS) $(BASE_CFLAGS) $(CODE_COVERAGE_CFLAGS)
AM_CFLAGS = \
-I$(top_srcdir)/wren-pkg -I$(top_builddir)/wren-pkg \
$(LOCAL_CFLAGS) $(BASE_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
$(EOL)

AM_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)

# Libs. $(LOCAL_LIBS) is added to $(LIBS) in configure.ac.
Expand Down
3 changes: 3 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*.c
*.h
lib*.vapi

# Hand-made files
!wren-vala-merged.h
Loading

0 comments on commit 665267d

Please sign in to comment.