Skip to content

Commit 3182bcd

Browse files
committed
Meson build for MMCoreJ
1 parent f7e5df5 commit 3182bcd

File tree

5 files changed

+203
-0
lines changed

5 files changed

+203
-0
lines changed

MMCoreJ_wrap/meson.build

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# This Meson script is experimental and potentially incomplete. It is not part
2+
# of the supported build system for Micro-Manager or mmCoreAndDevices.
3+
4+
# IMPORTANT: This build script uses mmcore and mmdevice from the mirror
5+
# repositories, not the MMCore/ and MMDevice/ in mmCoreAndDevices. This is
6+
# because this build script is expected to be put in use when MMCoreJ is moved
7+
# out of mmCoreAndDevices.
8+
# The versions used are defined in mmdevice.wrap and mmcore.wrap.
9+
10+
project(
11+
'mmcorej',
12+
'cpp', 'java',
13+
# TODO version (set here and generate pom.xml)
14+
meson_version: '>=1.3.0',
15+
default_options: [
16+
'cpp_std=c++14',
17+
'warning_level=3',
18+
],
19+
)
20+
21+
cxx = meson.get_compiler('cpp')
22+
23+
if cxx.get_id() in ['gcc', 'clang']
24+
# SWIG Java typemaps call for -fno-strict-aliasing when compiling the
25+
# SWIG-generated code (see SWIG docs).
26+
add_project_arguments('-fno-strict-aliasing', language: 'cpp')
27+
endif
28+
29+
if cxx.get_id() in ['msvc', 'clang-cl']
30+
add_project_arguments('-DNOMINMAX', language: 'cpp')
31+
endif
32+
33+
fs = import('fs')
34+
35+
swig = find_program('swig', native: true)
36+
37+
mmcore_proj = subproject(
38+
'mmcore',
39+
default_options: {
40+
'default_library': 'static',
41+
'tests': 'disabled',
42+
},
43+
)
44+
mmcore_dep = mmcore_proj.get_variable('mmcore')
45+
46+
jni_dep = dependency('jni', version: '>= 1.8.0')
47+
48+
threads_dep = dependency('threads')
49+
50+
swig_include_dirs = mmcore_proj.get_variable('swig_include_dirs')
51+
swig_incdir_args = []
52+
foreach abspath : swig_include_dirs
53+
swig_incdir_args += '-I' + fs.relative_to(
54+
abspath,
55+
meson.project_build_root(),
56+
)
57+
endforeach
58+
59+
subdir('src/main/java') # Get java_sources
60+
61+
# TODO Add check to ensure we don't miss any
62+
swig_gen_java_source_names = [
63+
'ActionType.java',
64+
'BooleanVector.java',
65+
'CharVector.java',
66+
'CMMCore.java',
67+
'Configuration.java',
68+
'DeviceDetectionStatus.java',
69+
'DeviceInitializationState.java',
70+
'DeviceNotification.java',
71+
'DeviceType.java',
72+
'DoubleVector.java',
73+
'FocusDirection.java',
74+
'LongVector.java',
75+
'Metadata.java',
76+
'MetadataArrayTag.java',
77+
'MetadataError.java',
78+
'MetadataSingleTag.java',
79+
'MetadataTag.java',
80+
'MMCoreJ.java',
81+
'MMCoreJConstants.java',
82+
'MMCoreJJNI.java',
83+
'MMEventCallback.java',
84+
'pair_ss.java',
85+
'PortType.java',
86+
'PropertySetting.java',
87+
'PropertyType.java',
88+
'StrMap.java',
89+
'StrVector.java',
90+
'SWIGTYPE_p_std__istringstream.java',
91+
'UnsignedVector.java',
92+
]
93+
94+
swig_gen = custom_target(
95+
'swig-mmcorej',
96+
input: 'MMCoreJ.i',
97+
output: [
98+
'MMCoreJ_swig_wrap.cpp', # @OUTPUT0@, swig_gen[0]
99+
'MMCoreJ_swig_wrap.h', # @OUTPUT1@, swig_gen[1]
100+
swig_gen_java_source_names,
101+
],
102+
depfile: 'MMCoreJ_swig_wrap.d',
103+
command: [
104+
swig,
105+
'-c++',
106+
'-java',
107+
'-package', 'mmcorej',
108+
'-module', 'MMCoreJ',
109+
swig_incdir_args,
110+
'-MD', '-MF', '@DEPFILE@',
111+
'-o', '@OUTPUT0@',
112+
'-oh', '@OUTPUT1@',
113+
'-outdir', '@OUTDIR@',
114+
'@INPUT@',
115+
],
116+
)
117+
118+
swig_gen_cpp_sources = [swig_gen[0], swig_gen[1]]
119+
120+
swig_gen_java_sources = []
121+
foreach src : swig_gen.to_list()
122+
if src.full_path().endswith('.h') or src.full_path().endswith('.cpp')
123+
continue
124+
endif
125+
swig_gen_java_sources += src
126+
endforeach
127+
128+
# Note that JNI libraries are supposed to be dylibs, not Mach-O bundles, on
129+
# macOS, even though they are loaded by dlopen() (other platforms don't have
130+
# this distinction). So we use shared_library(), not shared_module().
131+
shared_library(
132+
'MMCoreJ_wrap',
133+
swig_gen_cpp_sources,
134+
dependencies: [
135+
jni_dep,
136+
mmcore_dep,
137+
threads_dep,
138+
],
139+
gnu_symbol_visibility: 'hidden',
140+
install: true,
141+
)
142+
143+
jar(
144+
'MMCoreJ',
145+
java_sources,
146+
swig_gen_java_sources,
147+
java_resources: structured_sources([
148+
# TODO pom.xml
149+
]),
150+
override_options: [
151+
'warning_level=1', # Disable -Xdoclint:all, keep -Xlint:all
152+
],
153+
install: true,
154+
)
155+
156+
# TODO Javadoc jar (needs parsing of Doxygen XML; see old generator)
157+
# TODO Source jar (create externally from source dist?)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
java_sources = files(
2+
'mmcorej/org/json/CDL.java',
3+
'mmcorej/org/json/Cookie.java',
4+
'mmcorej/org/json/CookieList.java',
5+
'mmcorej/org/json/HTTP.java',
6+
'mmcorej/org/json/HTTPTokener.java',
7+
'mmcorej/org/json/JSONArray.java',
8+
'mmcorej/org/json/JSONException.java',
9+
'mmcorej/org/json/JSONObject.java',
10+
'mmcorej/org/json/JSONStringer.java',
11+
'mmcorej/org/json/JSONTokener.java',
12+
'mmcorej/org/json/JSONWriter.java',
13+
'mmcorej/org/json/Test.java',
14+
'mmcorej/org/json/XML.java',
15+
'mmcorej/org/json/XMLTokener.java',
16+
17+
'mmcorej/TaggedImage.java',
18+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/packagecache/
2+
3+
/mmcore/
4+
/mmdevice/
5+
6+
# Subprojects installed by meson wrap
7+
/*-*/
8+
9+
# Ignore *.wrap by default (may be auto-installed transitive dependencies)
10+
/*.wrap
11+
12+
# Do not ignore wraps we provide
13+
!/mmcore.wrap
14+
!/mmdevice.wrap
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[wrap-git]
2+
url = https://github.com/micro-manager/mmcore.git
3+
revision = 187adc00dac41b5257dc34068cc42042152dcd93
4+
depth = 1
5+
6+
[provide]
7+
dependency_names = mmcore
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[wrap-git]
2+
url = https://github.com/micro-manager/mmdevice.git
3+
revision = 19efe5076245d19ccb486ee337f2330f172ce180
4+
depth = 1
5+
6+
[provide]
7+
dependency_names = mmdevice

0 commit comments

Comments
 (0)