Skip to content

Commit ab619bb

Browse files
committed
adjust cli project
更新CMakelist编译结束后自动复制编译结果到assets目录,更新stb库,更新gradle版本和配置,消除一些编译warning
1 parent 4205709 commit ab619bb

File tree

32 files changed

+2376
-1355
lines changed

32 files changed

+2376
-1355
lines changed

3rdparty/copy_cli_build_result.bat

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,10 @@ setlocal
33

44
set "target_dir=..\RealSR-NCNN-Android-GUI\app\src\main\assets\realsr"
55

6-
xcopy "ncnn-android-vulkan-shared\arm64-v8a\lib\libncnn.so" "%target_dir%" /Y
7-
8-
:: old project path
9-
:: for /d %%D in (..\*) do (
10-
:: if exist "%%D\app\build\intermediates\cmake\debug\obj\arm64-v8a\*-ncnn" (
11-
:: rem echo Copying files from "%%D\app\build\intermediates\cmake\debug\obj\arm64-v8a"
12-
:: xcopy "%%D\app\build\intermediates\cmake\debug\obj\arm64-v8a\*-ncnn" "%target_dir%" /Y
13-
:: )
14-
::
15-
:: if exist "%%D\app\build\intermediates\cmake\release\obj\arm64-v8a\*-ncnn" (
16-
:: rem echo Copying files from "%%D\app\build\intermediates\cmake\release\obj\arm64-v8a"
17-
:: xcopy "%%D\app\build\intermediates\cmake\release\obj\arm64-v8a\*-ncnn" "%target_dir%" /Y
18-
:: )
19-
:: )
6+
xcopy "..\RealSR-NCNN-Android-CLI\Anime4k\build\intermediates\merged_native_libs\release\mergeReleaseNativeLibs\out\lib\arm64-v8a\*" "%target_dir%" /Y
207

21-
:: new project path
22-
for /d %%D in (..\RealSR-NCNN-Android-CLI\*) do (
23-
if exist "%%D\build\intermediates\cmake\debug\obj\arm64-v8a\*-ncnn" (
24-
rem echo Copying files from "%%D\app\build\intermediates\cmake\debug\obj\arm64-v8a"
25-
xcopy "%%D\build\intermediates\cmake\debug\obj\arm64-v8a\*-ncnn" "%target_dir%" /Y
26-
)
27-
28-
if exist "%%D\build\intermediates\cmake\release\obj\arm64-v8a\*-ncnn" (
29-
rem echo Copying files from "%%D\app\build\intermediates\cmake\release\obj\arm64-v8a"
30-
xcopy "%%D\build\intermediates\cmake\release\obj\arm64-v8a\*-ncnn" "%target_dir%" /Y
31-
)
32-
)
8+
xcopy "ncnn-android-vulkan-shared\arm64-v8a\lib\libncnn.so" "%target_dir%" /Y
339

34-
if exist "..\RealSR-NCNN-Android-CLI\Anime4k\build\intermediates\cmake\debug\obj\arm64-v8a\Anime4k" (
35-
xcopy "..\RealSR-NCNN-Android-CLI\Anime4k\build\intermediates\cmake\debug\obj\arm64-v8a\*" "%target_dir%" /Y
36-
)
3710

38-
if exist "..\RealSR-NCNN-Android-CLI\Anime4k\build\intermediates\cmake\release\obj\arm64-v8a\Anime4k" (
39-
xcopy "..\RealSR-NCNN-Android-CLI\Anime4k\build\intermediates\cmake\release\obj\arm64-v8a\*" "%target_dir%" /Y
40-
)
41-
4211
echo Done.
4312
pause

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ download ncnn-yyyymmdd-android-vulkan-shared.zip.
8787
https://github.com/webmproject/libwebp
8888
download the source of libwebp.
8989
https://opencv.org/releases/
90-
download opencv-android-sdk. (for anime4k)
90+
download opencv-android-sdk.
9191

9292
### step2
9393
extract `ncnn-yyyymmdd-android-vulkan-shared.zip` into `../3rdparty/ncnn-android-vulkan-shared`

README_CHS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ https://github.com/Tencent/ncnn/releases
100100
https://github.com/webmproject/libwebp
101101
下载libwebp的源码
102102
https://opencv.org/releases/
103-
下载opencv-android-sdk(供Anime4k使用)
103+
下载opencv-android-sdk
104104

105105
### step2
106106
解压 `ncnn-yyyymmdd-android-vulkan-shared.zip``../3rdparty/ncnn-android-vulkan-shared`
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 24
4+
compileSdk 34
55

66
defaultConfig {
7+
minSdk 24
8+
targetSdk 34
9+
versionCode 40
710
applicationId "com.tumuyan.ncnn.realsr"
811
archivesBaseName = "$applicationId"
912

1013
ndk {
1114
moduleName "ncnn"
15+
//noinspection ChromeOsAbiSupport
1216
abiFilters "arm64-v8a" //, "armeabi-v7a", "x86"
1317
}
14-
minSdkVersion 24
1518
}
1619

1720
externalNativeBuild {
@@ -21,4 +24,5 @@ android {
2124
}
2225
}
2326
ndkVersion '25.2.9519653'
27+
namespace 'com.tumuyan.ncnn.realsr'
2428
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.tumuyan.ncnn.realsr">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43
</manifest>

RealSR-NCNN-Android-CLI/Anime4k/src/main/jni/CLI/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,18 @@ if(Build_CLI)
3939
RUNTIME DESTINATION bin
4040
)
4141

42+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
43+
COMMAND ${CMAKE_COMMAND} -E copy_directory
44+
$<TARGET_FILE_DIR:${PROJECT_NAME}>
45+
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../RealSR-NCNN-Android-GUI/app/src/main/assets/realsr
46+
)
47+
48+
# add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
49+
# COMMAND ${CMAKE_COMMAND} -E copy_directory
50+
# ${CMAKE_CURRENT_SOURCE_DIR}/../../../../build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/arm64-v8a
51+
# ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../RealSR-NCNN-Android-GUI/app/src/main/assets/realsr
52+
# COMMENT "Copying libncnn.so libomp.so to assets directory"
53+
# )
54+
55+
4256
endif()
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 28
4+
compileSdk 34
55

66
defaultConfig {
7+
minSdk 24
8+
targetSdk 34
9+
versionCode 40
710
applicationId "com.tumuyan.ncnn.realsr"
811
archivesBaseName = "$applicationId"
912

1013
ndk {
1114
moduleName "ncnn"
1215
abiFilters "arm64-v8a" //, "armeabi-v7a", "x86"
1316
}
14-
minSdkVersion 24
1517
}
1618

1719
externalNativeBuild {
@@ -21,4 +23,5 @@ android {
2123
}
2224
}
2325
ndkVersion '25.2.9519653'
26+
namespace 'com.tumuyan.ncnn.realsr'
2427
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.tumuyan.ncnn.realsr">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43
</manifest>

RealSR-NCNN-Android-CLI/RealCUGAN/src/main/jni/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ if(NOT USE_SYSTEM_WEBP)
4545
include_directories(${CMAKE_BINARY_DIR}/libwebp/src)
4646
endif()
4747

48-
add_executable(realcugan-ncnn main.cpp realcugan.cpp)
48+
add_executable(${PROJECT_NAME} main.cpp realcugan.cpp)
4949

50-
target_link_libraries(realcugan-ncnn webp ncnn ${OpenCV_LIBS})
50+
target_link_libraries(${PROJECT_NAME} webp ncnn ${OpenCV_LIBS})
51+
52+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
53+
COMMAND ${CMAKE_COMMAND} -E copy_directory
54+
$<TARGET_FILE_DIR:${PROJECT_NAME}>
55+
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../RealSR-NCNN-Android-GUI/app/src/main/assets/realsr
56+
)

RealSR-NCNN-Android-CLI/RealCUGAN/src/main/jni/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ void* save(void* args)
439439
if (success)
440440
{
441441
float end = clock();
442-
fprintf(stderr, "save result use time: %.3f\n", (end - begin) / CLOCKS_PER_SEC);
442+
fprintf(stderr, "save result use time: %.3lf\n", (end - begin) / CLOCKS_PER_SEC);
443443

444444
if (verbose)
445445
{

0 commit comments

Comments
 (0)