Skip to content

Commit 5d2b26a

Browse files
authored
Merge pull request #1 from tigercosmos/console-stdout
Console stdout
2 parents e40e0d9 + 3c02148 commit 5d2b26a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+940
-376
lines changed

.github/workflows/devbuild.yml

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818

1919
env:
20-
JOB_MAKE_ARGS: VERBOSE=1 BUILD_QT=ON USE_CLANG_TIDY=OFF
2120
QT_DEBUG_PLUGINS: 1
2221
QT_QPA_PLATFORM: offscreen
2322

@@ -80,33 +79,48 @@ jobs:
8079
echo "flake8 path: $(which flake8)"
8180
echo "flake8 version: $(flake8 --version)"
8281
83-
- name: make buildext
82+
- name: make buildext BUILD_QT=OFF
8483
run: |
85-
make buildext \
86-
${JOB_MAKE_ARGS} \
84+
rm -f build/*/Makefile
85+
make cmake \
86+
VERBOSE=1 USE_CLANG_TIDY=OFF \
87+
BUILD_QT=OFF \
8788
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
8889
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
90+
make buildext VERBOSE=1
8991
90-
- name: make pytest
92+
- name: make pytest BUILD_QT=OFF
9193
run: |
92-
make pytest \
93-
${JOB_MAKE_ARGS} \
94+
python3 -c "import modmesh; assert modmesh.HAS_VIEW == False"
95+
make pytest VERBOSE=1
96+
97+
- name: make buildext BUILD_QT=ON
98+
run: |
99+
rm -f build/*/Makefile
100+
make cmake \
101+
VERBOSE=1 USE_CLANG_TIDY=OFF \
102+
BUILD_QT=ON \
94103
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
95104
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
105+
make buildext VERBOSE=1
106+
107+
- name: make pytest BUILD_QT=ON
108+
run: |
109+
python3 -c "import modmesh; assert modmesh.HAS_VIEW == True"
110+
make pytest VERBOSE=1
96111
97112
- name: make viewer
98113
run: |
114+
rm -f build/*/Makefile
99115
make viewer \
100-
${JOB_MAKE_ARGS} \
116+
VERBOSE=1 USE_CLANG_TIDY=OFF \
117+
BUILD_QT=ON \
101118
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
102119
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
103120
104121
- name: make run_viewer_pytest
105122
run: |
106-
make run_viewer_pytest \
107-
${JOB_MAKE_ARGS} \
108-
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
109-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
123+
make run_viewer_pytest VERBOSE=1
110124
111125
build_macos:
112126

@@ -117,7 +131,6 @@ jobs:
117131
runs-on: ${{ matrix.os }}
118132

119133
env:
120-
JOB_MAKE_ARGS: VERBOSE=1 BUILD_QT=ON USE_CLANG_TIDY=OFF
121134
QT_DEBUG_PLUGINS: 1
122135

123136
strategy:
@@ -180,36 +193,54 @@ jobs:
180193
echo "flake8 path: $(which flake8)"
181194
echo "flake8 version: $(flake8 --version)"
182195
183-
- name: make buildext
196+
- name: make buildext BUILD_QT=OFF
184197
run: |
185-
make buildext \
186-
${JOB_MAKE_ARGS} \
198+
rm -f build/*/Makefile
199+
make cmake \
200+
VERBOSE=1 USE_CLANG_TIDY=OFF \
201+
BUILD_QT=OFF \
187202
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
188203
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
204+
make buildext VERBOSE=1
189205
190-
- name: make pytest
206+
- name: make pytest BUILD_QT=OFF
191207
run: |
208+
JOB_MAKE_ARGS="VERBOSE=1"
192209
if [ "${{ matrix.os }}" == "macos-12" ] ; then \
193210
JOB_MAKE_ARGS="${JOB_MAKE_ARGS} BUILD_METAL=ON" ; \
194211
fi
195-
make pytest \
196-
${JOB_MAKE_ARGS} \
212+
make pytest ${JOB_MAKE_ARGS}
213+
214+
- name: make buildext BUILD_QT=ON
215+
run: |
216+
rm -f build/*/Makefile
217+
make cmake \
218+
VERBOSE=1 USE_CLANG_TIDY=OFF \
219+
BUILD_QT=ON \
197220
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
198221
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
222+
make buildext VERBOSE=1
223+
224+
- name: make pytest BUILD_QT=ON
225+
run: |
226+
JOB_MAKE_ARGS="VERBOSE=1"
227+
if [ "${{ matrix.os }}" == "macos-12" ] ; then \
228+
JOB_MAKE_ARGS="${JOB_MAKE_ARGS} BUILD_METAL=ON" ; \
229+
fi
230+
make pytest ${JOB_MAKE_ARGS}
199231
200232
- name: make viewer
201233
run: |
234+
rm -f build/*/Makefile
202235
make viewer \
203-
${JOB_MAKE_ARGS} \
236+
VERBOSE=1 USE_CLANG_TIDY=OFF \
237+
BUILD_QT=ON \
204238
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
205239
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
206240
207241
- name: make run_viewer_pytest
208242
run: |
209-
make run_viewer_pytest \
210-
${JOB_MAKE_ARGS} \
211-
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
212-
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
243+
make run_viewer_pytest VERBOSE=1
213244
214245
build_windows:
215246

.github/workflows/nouse_install.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ jobs:
8181
cp -a tests tmp/
8282
cd tmp/
8383
python3 -c 'import os; print(os.getcwd())'
84-
python3 -c "import modmesh; print(modmesh._modmesh.__file__)"
84+
python3 -c "import modmesh; print(modmesh.__file__)"
85+
python3 -c "import _modmesh; print(_modmesh.__file__)"
8586
pytest --rootdir=/tmp -v
8687
cd ..
8788
@@ -163,6 +164,7 @@ jobs:
163164
cp -a tests tmp/
164165
cd tmp/
165166
python3 -c 'import os; print(os.getcwd())'
166-
python3 -c "import modmesh; print(modmesh._modmesh.__file__)"
167+
python3 -c "import modmesh; print(modmesh.__file__)"
168+
python3 -c "import _modmesh; print(_modmesh.__file__)"
167169
pytest --rootdir=/tmp -v
168170
cd ..

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ include(Flake8)
4747
set(CMAKE_CXX_STANDARD 17)
4848
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4949
set(CMAKE_CXX_EXTENSIONS OFF)
50+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
5051
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Export compile commands")
5152

5253
option(HIDE_SYMBOL "hide the symbols of python wrapper" OFF)

cpp/binary/pymod_modmesh/CMakeLists.txt

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,39 @@ project(modmesh_pymod)
77
pybind11_add_module(
88
_modmesh
99
module.cpp
10-
${MODMESH_PYMOD_MODMESH_HEADERS}
11-
${MODMESH_PYMOD_MODMESH_SOURCES}
12-
${MODMESH_PYMOD_ONEDIM_HEADERS}
13-
${MODMESH_PYMOD_ONEDIM_SOURCES}
14-
${MODMESH_PYMOD_SPACETIME_HEADERS}
15-
${MODMESH_PYMOD_SPACETIME_SOURCES}
16-
${MODMESH_HEADERS}
17-
${MODMESH_SOURCES}
18-
${MODMESH_ONEDIM_HEADERS}
19-
${MODMESH_ONEDIM_SOURCES}
20-
${MODMESH_SPACETIME_HEADERS}
21-
${MODMESH_SPACETIME_SOURCES}
22-
${MODMESH_PYTHON_HEADERS}
23-
${MODMESH_PYTHON_SOURCES}
2410
)
2511

26-
if(APPLE)
27-
find_library(APPLE_FWK_FOUNDATION Foundation REQUIRED)
28-
find_library(APPLE_FWK_QUARTZ_CORE QuartzCore REQUIRED)
29-
find_library(APPLE_FWK_METAL Metal REQUIRED)
30-
31-
target_link_libraries(
32-
_modmesh PUBLIC
33-
${APPLE_FWK_FOUNDATION}
34-
${APPLE_FWK_QUARTZ_CORE}
35-
${APPLE_FWK_METAL}
36-
)
37-
endif()
12+
target_link_libraries(
13+
_modmesh PUBLIC
14+
pybind11::module
15+
modmesh_primary
16+
)
3817

39-
if(HIDE_SYMBOL)
18+
if (HIDE_SYMBOL)
4019
set_target_properties(_modmesh PROPERTIES CXX_VISIBILITY_PRESET "hidden")
41-
else()
20+
else () # HIDE_SYMBOL
4221
set_target_properties(_modmesh PROPERTIES CXX_VISIBILITY_PRESET "default")
43-
endif()
22+
endif () # HIDE_SYMBOL
4423

45-
if(MSVC)
46-
target_compile_options(
47-
_modmesh PRIVATE
48-
${COMMON_COMPILER_OPTIONS}
49-
)
50-
else()
51-
target_compile_options(
52-
_modmesh PRIVATE
53-
${COMMON_COMPILER_OPTIONS}
54-
-Wno-unused-value # for PYBIND11_EXPAND_SIDE_EFFECTS in pybind11.h
55-
-Wno-noexcept-type # GCC
56-
)
57-
endif()
24+
target_compile_options(
25+
_modmesh PRIVATE
26+
${COMMON_COMPILER_OPTIONS}
27+
)
5828

59-
if(CLANG_TIDY_EXE AND USE_CLANG_TIDY)
29+
if (CLANG_TIDY_EXE AND USE_CLANG_TIDY)
6030
set_target_properties(
6131
_modmesh PROPERTIES
6232
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
6333
)
64-
endif()
34+
endif ()
6535

6636
execute_process(
6737
COMMAND python3-config --extension-suffix
68-
OUTPUT_VARIABLE PYEXTSUFFIX)
38+
OUTPUT_VARIABLE PYEXTSUFFIX
39+
)
6940

7041
add_custom_target(_modmesh_py
71-
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:_modmesh> ${MODMESH_PY_DIR}/_modmesh${PYEXTSUFFIX}
42+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:_modmesh> ${MODMESH_PY_DIR}/../_modmesh${PYEXTSUFFIX}
7243
DEPENDS _modmesh)
7344

7445
message(STATUS "CMAKE_INSTALL_INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR}")

cpp/binary/pymod_modmesh/module.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,11 @@
2020
*/
2121

2222
#include <modmesh/python/python.hpp> // Must be the first include.
23-
#include <modmesh/python/wrapper/modmesh/modmesh.hpp>
24-
#include <modmesh/python/wrapper/onedim/onedim.hpp>
25-
#include <modmesh/python/wrapper/spacetime/spacetime.hpp>
23+
#include <modmesh/python/module.hpp>
2624

2725
PYBIND11_MODULE(_modmesh, mod) // NOLINT
2826
{
29-
modmesh::python::initialize_modmesh(mod);
30-
pybind11::module_ spacetime_mod = mod.def_submodule("spacetime", "spacetime");
31-
modmesh::python::initialize_spacetime(spacetime_mod);
32-
pybind11::module_ onedim_mod = mod.def_submodule("onedim", "onedim");
33-
modmesh::python::initialize_onedim(onedim_mod);
27+
modmesh::python::initialize(mod);
3428
}
3529

3630
// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4 sts=4:

cpp/binary/viewer/CMakeLists.txt

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ project(viewer LANGUAGES CXX)
66

77
set(CMAKE_INCLUDE_CURRENT_DIR ON)
88

9-
set(CMAKE_AUTOMOC ON)
10-
set(CMAKE_AUTORCC ON)
11-
set(CMAKE_AUTOUIC ON)
12-
139
# get the root of the modmdesh project
1410
set(PROJECT_ROOT_DIR ${PROJECT_SOURCE_DIR}/../../../)
1511

1612
if(NOT DEFINED INSTALL_VIEWERDIR)
1713
set(INSTALL_VIEWERDIR "viewer")
1814
endif()
1915

16+
set(CMAKE_AUTOMOC ON)
17+
set(CMAKE_AUTORCC ON)
18+
set(CMAKE_AUTOUIC ON)
19+
2020
find_package(Qt6 COMPONENTS Core)
2121
find_package(Qt6 COMPONENTS Widgets)
2222
find_package(Qt6 COMPONENTS Gui)
@@ -28,25 +28,20 @@ find_package(Qt6 COMPONENTS 3DExtras)
2828
qt_add_executable(
2929
viewer
3030
viewer.cpp
31-
${MODMESH_HEADERS}
32-
${MODMESH_SOURCES}
33-
${MODMESH_VIEW_HEADERS}
34-
${MODMESH_VIEW_SOURCES}
35-
${MODMESH_ONEDIM_HEADERS}
36-
${MODMESH_ONEDIM_SOURCES}
37-
${MODMESH_SPACETIME_HEADERS}
38-
${MODMESH_SPACETIME_SOURCES}
39-
${MODMESH_PYTHON_HEADERS}
40-
${MODMESH_PYTHON_SOURCES}
41-
${MODMESH_PYMOD_MODMESH_HEADERS}
42-
${MODMESH_PYMOD_MODMESH_SOURCES}
43-
${MODMESH_PYMOD_ONEDIM_HEADERS}
44-
${MODMESH_PYMOD_ONEDIM_SOURCES}
45-
${MODMESH_PYMOD_SPACETIME_HEADERS}
46-
${MODMESH_PYMOD_SPACETIME_SOURCES}
4731
)
4832

49-
add_custom_target(run_viewer_pytest $<TARGET_FILE:viewer> --mode=pytest)
33+
target_link_libraries(
34+
viewer PUBLIC
35+
pybind11::embed
36+
modmesh_primary
37+
)
38+
if(WIN32)
39+
set_target_properties(
40+
viewer
41+
PROPERTIES
42+
LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE" # open the console for debug mode
43+
)
44+
endif(WIN32)
5045

5146
qt_add_resources(
5247
viewer "app_icon"
@@ -56,19 +51,6 @@ qt_add_resources(
5651
${PROJECT_ROOT_DIR}/resources/viewer/icon.ico
5752
)
5853

59-
if(APPLE)
60-
find_library(APPLE_FWK_FOUNDATION Foundation REQUIRED)
61-
find_library(APPLE_FWK_QUARTZ_CORE QuartzCore REQUIRED)
62-
find_library(APPLE_FWK_METAL Metal REQUIRED)
63-
64-
target_link_libraries(
65-
viewer PUBLIC
66-
${APPLE_FWK_FOUNDATION}
67-
${APPLE_FWK_QUARTZ_CORE}
68-
${APPLE_FWK_METAL}
69-
)
70-
endif()
71-
7254
if(HIDE_SYMBOL)
7355
set_target_properties(viewer PROPERTIES CXX_VISIBILITY_PRESET "hidden")
7456
else()
@@ -100,17 +82,20 @@ set_target_properties(
10082
MACOSX_BUNDLE TRUE
10183
)
10284

103-
target_link_libraries(
104-
viewer PUBLIC
105-
pybind11::embed
106-
Qt::Widgets
107-
Qt::3DCore
108-
Qt::3DExtras
109-
Qt::3DInput
110-
Qt::3DRender
111-
Qt::Core
112-
Qt::Gui
113-
)
85+
if(APPLE)
86+
find_library(APPLE_FWK_FOUNDATION Foundation REQUIRED)
87+
find_library(APPLE_FWK_QUARTZ_CORE QuartzCore REQUIRED)
88+
find_library(APPLE_FWK_METAL Metal REQUIRED)
89+
90+
target_link_libraries(
91+
viewer PUBLIC
92+
${APPLE_FWK_FOUNDATION}
93+
${APPLE_FWK_QUARTZ_CORE}
94+
${APPLE_FWK_METAL}
95+
)
96+
endif()
97+
98+
add_custom_target(run_viewer_pytest $<TARGET_FILE:viewer> --mode=pytest)
11499

115100
install(TARGETS viewer
116101
RUNTIME DESTINATION "${INSTALL_VIEWERDIR}"

0 commit comments

Comments
 (0)