Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBR-4578 Add Java ATK Wrapper #475

Open
wants to merge 38 commits into
base: jbr21
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3fc3625
JBR-4578 Add Java ATK Wrapper
tanya011 Nov 6, 2024
98bf033
Add libatk-bridge2.0-dev
tanya011 Jan 16, 2025
039a17c
Add logic for missing dependencies
tanya011 Jan 16, 2025
e529045
PKG_CHECK_MODULES
tanya011 Jan 16, 2025
58d9f0d
Append all _CFLAGS and _LIBS to one variable
tanya011 Jan 16, 2025
b0f19d9
at-spi version
tanya011 Jan 16, 2025
19e5fb3
merge lib-glib.m4 and lib-glibconfig.m4
tanya011 Jan 16, 2025
f0a4bb6
disable atk-wrapper by default
tanya011 Jan 16, 2025
0b79fe5
README.md
tanya011 Jan 16, 2025
6ae0668
Reformat .c and .h files
tanya011 Feb 3, 2025
0abe88b
Reformat .java files
tanya011 Feb 3, 2025
632683a
remove `exports org.GNOME.Accessibility;`
tanya011 Feb 3, 2025
04b8638
logging via `sun.util.logging.PlatformLogger`
tanya011 Feb 3, 2025
9616ac9
Don't perform redundant objects allocation and don't perform characte…
tanya011 Feb 3, 2025
810a8d5
Change access levels to private where it is possible
tanya011 Feb 3, 2025
9d5d6be
Enhanced instanceof wherever it improves the code
tanya011 Feb 3, 2025
065a6c9
signal_emit_handler Sig_Text_Property_Changed handles `text_changed::…
tanya011 Feb 3, 2025
cb6a99e
Changes in loadAtkBridge and initNativeLibrary
tanya011 Feb 3, 2025
d15082a
return ATK_ROLE_UNKNOWN if jniEnv == NULL
tanya011 Feb 3, 2025
e4a767f
unreachable expression
tanya011 Feb 3, 2025
22f2e76
better describing name for the thread
tanya011 Feb 4, 2025
a1d0601
key_dispatch
tanya011 Feb 4, 2025
f97c33d
`GTYPE_TO_POINTER` redefines macros from glib
tanya011 Feb 4, 2025
47171c4
pkg-config to "$PKG_CONFIG"
tanya011 Feb 4, 2025
3a9756d
add libatk-bridge2.0-dev
tanya011 Feb 4, 2025
607f976
Do not append all _CFLAGS and _LIBS to one variable
tanya011 Feb 4, 2025
0f15aca
gc
tanya011 Feb 4, 2025
0cd4556
system property `linux.jdk.accessibility.atkwrapper.block`
tanya011 Feb 5, 2025
5ff70a6
loadAtkBridge():
tanya011 Feb 5, 2025
55629ed
Get rid of `META-INF/services/javax.accessibility.AccessibilityProvider`
tanya011 Feb 6, 2025
7942a7e
processing AccessibleContext.ACCESSIBLE_TEXT_PROPERTY
tanya011 Feb 6, 2025
7626019
key_dispatch_handler synchronization
tanya011 Feb 6, 2025
3febf16
Don't terminate the application
tanya011 Feb 6, 2025
6829fe8
release objects using disposer
tanya011 Feb 6, 2025
f83061c
Remove JAW from `Ubuntu Linux` part in README.md
tanya011 Feb 7, 2025
744be62
Dispatching only certain key events
tanya011 Feb 7, 2025
91c9880
Release global_key_event
tanya011 Feb 9, 2025
0fd66b9
Dispatch all key events
tanya011 Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-cross-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
g++-${{ inputs.gcc-major-version }} \
gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} \
g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} \
libxrandr-dev libxtst-dev libcups2-dev libasound2-dev
libxrandr-dev libxtst-dev libcups2-dev libasound2-dev libatspi2.0-dev libatk1.0-dev libglib2.0-dev libatk-bridge2.0-dev
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }}

- name: 'Check cache for sysroot'
Expand All @@ -133,7 +133,7 @@ jobs:
sudo debootstrap
--arch=${{ matrix.debian-arch }}
--verbose
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype-dev,libpng-dev
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype-dev,libpng-dev,libatspi2.0-dev,libatk1.0-dev,libglib2.0-dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype-dev,libpng-dev,libatspi2.0-dev,libatk1.0-dev,libglib2.0-dev
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype-dev,libpng-dev,libatspi2.0-dev,libatk1.0-dev,libglib2.0-dev,libatk-bridge2.0-dev

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done at 3a9756d

--resolve-deps
--variant=minbase
${{ matrix.debian-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
fi
sudo apt-get update
sudo apt-get install --only-upgrade apt
sudo apt-get install gcc-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} g++-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }}
sudo apt-get install gcc-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} g++-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} libatspi2.0-dev${{ steps.arch.outputs.suffix }} libatk1.0-dev${{ steps.arch.outputs.suffix }} libglib2.0-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }}

- name: 'Configure'
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ $ docker run -v `pwd`../../../../:/JetBrainsRuntime -it 942ea9900054
# make images CONF=linux-x86_64-normal-server-release
```

#### Java Atk Wrapper

To enable [Java Atk Wrapper](https://wiki.gnome.org/Accessibility/JavaAtkWrapper):
1. Go to [Debian Package Search](https://www.debian.org/distrib/packages), search for the following packages for your target system, and download them:
- `atk`
- `at-spi2`
- `glib2`
2. Run configure using `--enable-java-atk-wrapper`

### Ubuntu Linux
Install the necessary tools, libraries, and headers with:
```
Expand All @@ -141,6 +150,15 @@ $ make images
```
This will build the release configuration under `./build/linux-x86_64-server-release/`.

#### Java-Atk-Wrapper

To enable [Java Atk Wrapper](https://wiki.gnome.org/Accessibility/JavaAtkWrapper):
1. Install the necessary libraries and headers with:
```
$ sudo apt-get install libatspi2.0-dev libatk1.0-dev libglib2.0-dev libatk-bridge2.0-dev
```
2. Run configure using `--enable-java-atk-wrapper`

### Windows
<a name="build-windows"></a>
Install the following:
Expand Down
2 changes: 2 additions & 0 deletions make/autoconf/help.m4
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ apt_help() {
PKGHANDLER_COMMAND="sudo apt-get install systemtap-sdt-dev" ;;
capstone)
PKGHANDLER_COMMAND="sudo apt-get install libcapstone-dev" ;;
atk)
PKGHANDLER_COMMAND="sudo apt-get install libatspi2.0-dev libatk1.0-dev libglib2.0-dev" ;;
esac
}

Expand Down
22 changes: 22 additions & 0 deletions make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,28 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
A11Y_JAWS_ANNOUNCING_ENABLED=false
fi
AC_SUBST(A11Y_JAWS_ANNOUNCING_ENABLED)

# Should we build support for Java ATK Wrapper?
if test "x$OPENJDK_TARGET_OS" = xlinux; then
AC_MSG_CHECKING([if Java ATK Wrapper support is enabled])

A11Y_JAVA_ATK_WRAPPER_ENABLED=false
AC_ARG_ENABLE(
[java-atk-wrapper],
[AS_HELP_STRING([--enable-java-atk-wrapper], [Set to enable the Java ATK Wrapper])],
[
if test "x$ENABLE_HEADLESS_ONLY" = xtrue; then
AC_MSG_WARN([--[enable|disable]-java-atk-wrapper[=*] flags are ignored for headless builds])
elif test "x$enableval" == xyes; then
A11Y_JAVA_ATK_WRAPPER_ENABLED=true
fi
]
)
AC_MSG_RESULT([$A11Y_JAVA_ATK_WRAPPER_ENABLED])
else
A11Y_JAVA_ATK_WRAPPER_ENABLED=false
fi
AC_SUBST(A11Y_JAVA_ATK_WRAPPER_ENABLED)
])

###############################################################################
Expand Down
70 changes: 70 additions & 0 deletions make/autoconf/lib-at-spi2-atk.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
################################################################################
# Setup at-spi2-atk
################################################################################
AC_DEFUN_ONCE([LIB_SETUP_AT_SPI2_ATK],
[
AC_ARG_WITH(at-spi2-atk, [AS_HELP_STRING([--with-at-spi2-atk],
[specify prefix directory for the at-spi2-atk package
(expecting the headers under PATH/include); required for atk-wrapper to work])])
AC_ARG_WITH(at-spi2-atk-include, [AS_HELP_STRING([--with-at-spi2-atk-include],
[specify directory for the at-spi2-atk include files])])
AC_ARG_WITH(at-spi2-atk-version, [AS_HELP_STRING([--with-at-spi2-atk-version],
[specify version for the at-spi2-atk package])])

if test "x$NEEDS_LIB_AT_SPI2_ATK" = xfalse || test "x${with_at_spi2_atk}" = xno || \
test "x${with_at_spi2_atk_include}" = xno; then
if (test "x${with_at_spi2_atk}" != x && test "x${with_at_spi2_atk}" != xno) || \
(test "x${with_at_spi2_atk_include}" != x && test "x${with_at_spi2_atk_include}" != xno); then
AC_MSG_WARN([[at-spi2-atk not used, so --with-at-spi2-atk[-*] is ignored]])
fi
else
AT_SPI2_ATK_FOUND=no
if test "x${with_at_spi2_atk}" != x && test "x${with_at_spi2_atk}" != xyes; then
AC_MSG_CHECKING([for at-spi2-atk header and library])
if test "x${with_at_spi2_atk_version}" != x && "x${with_at_spi2_atk_version}" != xyes; then
AT_SPI2_ATK_VERSION="${with_at_spi2_atk_version}"
else
AC_MSG_ERROR([Define at-spi2-atk package version using --with-at-spi2-atk-version if you use --with-at-spi2-atk option.])
fi
if test -s "${with_at_spi2_atk}/include/at-spi2-atk/2.0/atk-bridge.h"; then
AT_SPI2_ATK_CFLAGS="-I${with_at_spi2_atk}/include/at-spi2-atk/2.0"
AT_SPI2_ATK_LIBS="-L${with_at_spi2_atk}/lib -latk-bridge-2.0"
AT_SPI2_ATK_FOUND=yes
AC_MSG_RESULT([$AT_SPI2_ATK_FOUND])
else
AC_MSG_ERROR([Can't find '/include/at-spi2-atk/2.0/atk-bridge.h' under ${with_at_spi2_atk} given with the --with-at-spi2-atk option.])
fi
fi
if test "x${with_at_spi2_atk_include}" != x; then
AC_MSG_CHECKING([for at-spi2-atk headers])
if test "x${with_at_spi2_atk_version}" != x && "x${with_at_spi2_atk_version}" != xyes; then
AT_SPI2_ATK_VERSION="${with_at_spi2_atk_version}"
else
AC_MSG_ERROR([Define at-spi2-atk package version using --with-at-spi2-atk-version if you use --with-at-spi2-atk-include option.])
fi
if test -s "${with_at_spi2_atk_include}/at-spi2-atk/2.0/atk-bridge.h"; then
AT_SPI2_ATK_CFLAGS="-I${with_at_spi2_atk_include}/at-spi2-atk/2.0"
AT_SPI2_ATK_FOUND=yes
AC_MSG_RESULT([$AT_SPI2_ATK_FOUND])
else
AC_MSG_ERROR([Can't find 'include/at-spi2-atk-2.0/atk-bridge.h' under ${with_at_spi2_atk_include} given with the --with-at-spi2-atk-include option.])
fi
fi
if test "x$AT_SPI2_ATK_FOUND" = xno; then
# Are the at-spi2-atk headers installed in the default /usr/include location?
PKG_CHECK_MODULES([AT_SPI2_ATK], [atk-bridge-2.0],
[AT_SPI2_ATK_FOUND=yes; AT_SPI2_ATK_VERSION=$(pkg-config --modversion atk-bridge-2.0)],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[AT_SPI2_ATK_FOUND=yes; AT_SPI2_ATK_VERSION=$(pkg-config --modversion atk-bridge-2.0)],
[AT_SPI2_ATK_FOUND=yes; AT_SPI2_ATK_VERSION=$("$PKG_CONFIG" --modversion atk-bridge-2.0)],

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done at 47171c4

[AT_SPI2_ATK_FOUND=no; break]
)
fi
if test "x$AT_SPI2_ATK_FOUND" = xno; then
HELP_MSG_MISSING_DEPENDENCY([at-spi2-atk])
AC_MSG_ERROR([Could not find at-spi2-atk! $HELP_MSG ])
else
ATK_WRAPPER_CFLAGS="$ATK_WRAPPER_CFLAGS $AT_SPI2_ATK_CFLAGS -DATSPI_MAJOR_VERSION=$(echo $AT_SPI2_ATK_VERSION | cut -d. -f1) -DATSPI_MINOR_VERSION=$(echo $AT_SPI2_ATK_VERSION | cut -d. -f2) -DATSPI_MICRO_VERSION=$(echo $AT_SPI2_ATK_VERSION | cut -d. -f3)"
ATK_WRAPPER_LIBS="$ATK_WRAPPER_LIBS $AT_SPI2_ATK_LIBS"
AC_SUBST(ATK_WRAPPER_CFLAGS)
AC_SUBST(ATK_WRAPPER_LIBS)
fi
fi
])
54 changes: 54 additions & 0 deletions make/autoconf/lib-atk.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
################################################################################
# Setup atk
################################################################################
AC_DEFUN_ONCE([LIB_SETUP_ATK],
[
AC_ARG_WITH(atk, [AS_HELP_STRING([--with-atk],
[specify prefix directory for the atk package
(expecting the headers under PATH/include); required for atk-wrapper to work])])
AC_ARG_WITH(atk-include, [AS_HELP_STRING([--with-atk-include],
[specify directory for the atk include files])])
if test "x$NEEDS_LIB_ATK" = xfalse || test "x${with_atk}" = xno || \
test "x${with_atk_include}" = xno; then
if (test "x${with_atk}" != x && test "x${with_atk}" != xno) || \
(test "x${with_atk_include}" != x && test "x${with_atk_include}" != xno); then
AC_MSG_WARN([[atk not used, so --with-atk[-*] is ignored]])
fi
else
ATK_FOUND=no
if test "x${with_atk}" != x && test "x${with_atk}" != xyes; then
AC_MSG_CHECKING([for atk header and library])
if test -s "${with_atk}/include/atk-1.0/atk/atk.h"; then
ATK_CFLAGS="-I${with_atk}/include/atk-1.0"
ATK_LIBS="-L${with_atk}/lib -latk-1.0"
ATK_FOUND=yes
AC_MSG_RESULT([$ATK_FOUND])
else
AC_MSG_ERROR([Can't find '/include/atk-1.0/atk/atk.h' under ${with_atk} given with the --with-atk option.])
fi
fi
if test "x${with_atk_include}" != x; then
AC_MSG_CHECKING([for atk headers])
if test -s "${with_atk_include}/atk-1.0/atk/atk.h"; then
ATK_CFLAGS="-I${with_atk_include}/atk-1.0"
ATK_FOUND=yes
AC_MSG_RESULT([$ATK_FOUND])
else
AC_MSG_ERROR([Can't find 'include/atk-1.0/atk/atk.h' under ${with_atk_include} given with the --with-atk-include option.])
fi
fi
if test "x$ATK_FOUND" = xno; then
# Are the atk headers installed in the default /usr/include location?
PKG_CHECK_MODULES([ATK], [atk], [ATK_FOUND=yes;], [ATK_FOUND=no; break])
fi
if test "x$ATK_FOUND" = xno; then
HELP_MSG_MISSING_DEPENDENCY([atk])
AC_MSG_ERROR([Could not find atk! $HELP_MSG ])
else
ATK_WRAPPER_CFLAGS="$ATK_WRAPPER_CFLAGS $ATK_CFLAGS"
ATK_WRAPPER_LIBS="$ATK_WRAPPER_LIBS $ATK_LIBS"
AC_SUBST(ATK_WRAPPER_CFLAGS)
AC_SUBST(ATK_WRAPPER_LIBS)
fi
fi
])
86 changes: 86 additions & 0 deletions make/autoconf/lib-glib.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
################################################################################
# Setup glib
################################################################################
AC_DEFUN_ONCE([LIB_SETUP_GLIB],
[
AC_ARG_WITH(glib, [AS_HELP_STRING([--with-glib],
[specify prefix directory for the glib package
(expecting the headers under PATH/include); required for atk-wrapper to work])])
AC_ARG_WITH(glib-include, [AS_HELP_STRING([--with-glib-include],
[specify directory for the glib include files])])
AC_ARG_WITH(glibconfig, [AS_HELP_STRING([--with-glibconfig],
[specify prefix directory for the glibconfig package
(expecting the headers under PATH/include); required for atk-wrapper to work])])
AC_ARG_WITH(glibconfig-include, [AS_HELP_STRING([--with-glibconfig-include],
[specify directory for the glibconfig include files])])

if test "x$NEEDS_LIB_GLIB" = xfalse || test "x${with_glib}" = xno || \
test "x${with_glib_include}" = xno || \
test "x${with_glibconfig}" = xno || test "x${with_glibconfig_include}" = xno; then
if (test "x${with_glib}" != x && test "x${with_glib}" != xno) || \
(test "x${with_glib_include}" != x && test "x${with_glib_include}" != xno) || \
(test "x${with_glibconfig}" != x && test "x${with_glibconfig}" != xno) || \
(test "x${with_glibconfig_include}" != x && test "x${with_glibconfig_include}" != xno); then
AC_MSG_WARN([[glib not used, so --with-glib[-*] and --with-glibconfig[-*] are ignored]])
fi
else
GLIB_FOUND=no
GLIBCONFIG_FOUND=no
GLIBCONFIG_CFLAGS=
if test "x${with_glib}" != x && test "x${with_glib}" != xyes; then
AC_MSG_CHECKING([for glib header and library])
if test -s "${with_glib}/include/glib-2.0/glib.h"; then
GLIB_CFLAGS="-I${with_glib}/include/glib-2.0"
GLIB_LIBS="-L${with_glib}/lib -lglib-2.0"
GLIB_FOUND=yes
AC_MSG_RESULT([$GLIB_FOUND])
else
AC_MSG_ERROR([Can't find '/include/glib-2.0/glib.h' under ${with_glib} given with the --with-glib option.])
fi
fi
if test "x${with_glib_include}" != x; then
AC_MSG_CHECKING([for glib headers])
if test -s "${with_glib_include}/glib-2.0/glib.h"; then
GLIB_CFLAGS="-I${with_glib_include}"
GLIB_FOUND=yes
AC_MSG_RESULT([$GLIB_FOUND])
else
AC_MSG_ERROR([Can't find '/include/glib-2.0/glib.h' under ${with_glib_include} given with the --with-glib-include option.])
fi
fi
if test "x${with_glibconfig}" != x && test "x${with_glibconfig}" != xyes; then
AC_MSG_CHECKING([for glibconfig header])
if test -s "${with_glibconfig}/include/glibconfig.h"; then
GLIBCONFIG_CFLAGS="-I${with_glibconfig}/include"
GLIBCONFIG_FOUND=yes
AC_MSG_RESULT([$GLIBCONFIG_FOUND])
else
AC_MSG_ERROR([Can't find '/include/glibconfig.h' under ${with_glibconfig} given with the --with-glibconfig option.])
fi
fi
if test "x${with_glibconfig_include}" != x; then
AC_MSG_CHECKING([for glibconfig headers])
if test -s "${with_glibconfig_include}/glibconfig.h"; then
GLIBCONFIG_CFLAGS="-I${with_glibconfig_include}"
GLIBCONFIG_FOUND=yes
AC_MSG_RESULT([$GLIBCONFIG_FOUND])
else
AC_MSG_ERROR([Can't find '/include/glibconfig.h' under ${with_glibconfig_include} given with the --with-glibconfig-include option.])
fi
fi
if test "x$GLIB_FOUND" = xno || test "x$GLIBCONFIG_FOUND" = xno; then
# Are the glib headers installed in the default /usr/include location?
PKG_CHECK_MODULES([GLIB], [glib-2.0], [GLIB_FOUND=yes; GLIBCONFIG_FOUND=yes], [GLIB_FOUND=no; GLIBCONFIG_FOUND=no; break])
fi
# AC_MSG_ERROR([$GLIB_CFLAGS $GLIB_LIBS])
if test "x$GLIB_FOUND" = xno || test "x$GLIBCONFIG_FOUND" = xno; then
HELP_MSG_MISSING_DEPENDENCY([glib])
AC_MSG_ERROR([Could not find glib! $HELP_MSG])
else
ATK_WRAPPER_CFLAGS="$ATK_WRAPPER_CFLAGS $GLIB_CFLAGS $GLIBCONFIG_CFLAGS"
ATK_WRAPPER_LIBS="$ATK_WRAPPER_LIBS $GLIB_LIBS"
AC_SUBST(ATK_WRAPPER_CFLAGS)
AC_SUBST(ATK_WRAPPER_LIBS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO the proper responsibility area of each lib-...m4 is (or should be) to only provide all the required information for the buildsystem about the corresponding library. The advantages of this approach are especially clearly visible in case of GLib since it's a general purpose library. Let's imagine JBR will want to build another component (e.g. a library) using it. In that case the developer won't be able to reuse this file because it provides flags for building the atk wrapper and not flags for using GLib itself.

From this point of view, your initial approach, where you combined all the flags together in Libs.gmk, was great.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I returned it back. But what did you mean in this comment? #475 (comment)

When the custom paths flags (e.g. --with-atk-include) are used, the corresponding _CFLAGS and _LIBS flags should propagate the same dependency flags as PKG_CHECK_MODULES does for consistency. In this particular case we can just append $GLIB_CFLAGS to ATK_CFLAGS (and $GLIB_LIBS to ATK_LIBS if PKG_CHECK_MODULES does it, I haven't checked). Before doing so we may also check if GLIB_FOUND is true.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done at 607f976

fi
fi
])
59 changes: 59 additions & 0 deletions make/autoconf/lib-gobject.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
################################################################################
# Setup gobject
################################################################################
AC_DEFUN_ONCE([LIB_SETUP_GOBJECT],
[
AC_ARG_WITH(gobject, [AS_HELP_STRING([--with-gobject],
[specify prefix directory for the gobject package
(expecting the headers under PATH/include); required for atk-wrapper to work])])
AC_ARG_WITH(gobject-include, [AS_HELP_STRING([--with-gobject-include],
[specify directory for the gobject include files])])

if test "x$NEEDS_LIB_GOBJECT" = xfalse || test "x${with_gobject}" = xno || \
test "x${with_gobject_include}" = xno; then
if (test "x${with_gobject}" != x && test "x${with_gobject}" != xno) || \
(test "x${with_gobject_include}" != x && test "x${with_gobject_include}" != xno); then
AC_MSG_WARN([[gobject not used, so --with-gobject[-*] is ignored]])
fi
else
GOBJECT_FOUND=no

if test "x${with_gobject}" != x && test "x${with_gobject}" != xyes; then
AC_MSG_CHECKING([for gobject header and library])
if test -s "${with_gobject}/include/glib-2.0/gobject/gobject.h"; then
GOBJECT_CFLAGS="-I${with_gobject}/include/glib-2.0/gobject"
GOBJECT_LIBS="-L${with_gobject}/lib -lgobject-2.0"
GOBJECT_FOUND=yes
AC_MSG_RESULT([$GOBJECT_FOUND])
else
AC_MSG_ERROR([Can't find '/include/glib-2.0/gobject/gobject.h' under ${with_gobject} given with the --with-gobject option.])
fi
fi
if test "x${with_gobject_include}" != x; then
AC_MSG_CHECKING([for gobject headers])
if test -s "${with_gobject_include}/glib-2.0/gobject/gobject.h"; then
GOBJECT_CFLAGS="-I${with_gobject_include}/glib-2.0/gobject"
GOBJECT_FOUND=yes
AC_MSG_RESULT([$GOBJECT_FOUND])
else
AC_MSG_ERROR([Can't find '/include/glib-2.0/gobject/gobject.h' under ${with_gobject_include} given with the --with-gobject-include option.])
fi
fi
if test "x$GOBJECT_FOUND" = xno; then
# Are the gobject headers installed in the default /usr/include location?
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0],
[ GOBJECT_FOUND=yes;],
[ GOBJECT_FOUND=no; break ]
)
fi
if test "x$GOBJECT_FOUND" = xno; then
HELP_MSG_MISSING_DEPENDENCY([gobject])
AC_MSG_ERROR([Could not find gobject! $HELP_MSG ])
else
ATK_WRAPPER_CFLAGS="$ATK_WRAPPER_CFLAGS $GOBJECT_CFLAGS"
ATK_WRAPPER_LIBS="$ATK_WRAPPER_LIBS $GOBJECT_LIBS"
AC_SUBST(ATK_WRAPPER_CFLAGS)
AC_SUBST(ATK_WRAPPER_LIBS)
fi
fi
])
Loading