Skip to content

Commit c8b388f

Browse files
committed
better vscode build experience
1 parent 6def554 commit c8b388f

File tree

9 files changed

+241
-113
lines changed

9 files changed

+241
-113
lines changed

.vscode/tasks.json

Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "[Android] Build Android Demo",
7+
"label": "[Debug] Build Android Demo",
88
"type": "shell",
99
"command": "bash",
1010
"args": [
1111
"vscode_tasks.sh",
12+
"--debug",
1213
"--build"
1314
],
1415
"options": {
@@ -18,11 +19,12 @@
1819
"problemMatcher": "$gcc"
1920
},
2021
{
21-
"label": "[Android] Run Android Demo",
22+
"label": "[Debug] Run Android Demo",
2223
"type": "shell",
2324
"command": "bash",
2425
"args": [
2526
"vscode_tasks.sh",
27+
"--debug",
2628
"--run"
2729
],
2830
"options": {
@@ -32,11 +34,12 @@
3234
"problemMatcher": "$gcc"
3335
},
3436
{
35-
"label": "[Android] Build And Run Android Demo",
37+
"label": "[Debug] Build And Run Android Demo",
3638
"type": "shell",
3739
"command": "bash",
3840
"args": [
3941
"vscode_tasks.sh",
42+
"--debug",
4043
"--build",
4144
"--run"
4245
],
@@ -47,7 +50,53 @@
4750
"problemMatcher": "$gcc"
4851
},
4952
{
50-
"label": "[Android] Build Native Library",
53+
"label": "[Release] Build Android Demo",
54+
"type": "shell",
55+
"command": "bash",
56+
"args": [
57+
"vscode_tasks.sh",
58+
"--release",
59+
"--build"
60+
],
61+
"options": {
62+
"cwd": "${workspaceFolder}"
63+
},
64+
"group": "build",
65+
"problemMatcher": "$gcc"
66+
},
67+
{
68+
"label": "[Release] Run Android Demo",
69+
"type": "shell",
70+
"command": "bash",
71+
"args": [
72+
"vscode_tasks.sh",
73+
"--release",
74+
"--run"
75+
],
76+
"options": {
77+
"cwd": "${workspaceFolder}"
78+
},
79+
"group": "build",
80+
"problemMatcher": "$gcc"
81+
},
82+
{
83+
"label": "[Release] Build And Run Android Demo",
84+
"type": "shell",
85+
"command": "bash",
86+
"args": [
87+
"vscode_tasks.sh",
88+
"--release",
89+
"--build",
90+
"--run"
91+
],
92+
"options": {
93+
"cwd": "${workspaceFolder}"
94+
},
95+
"group": "build",
96+
"problemMatcher": "$gcc"
97+
},
98+
{
99+
"label": "[Release] Build Native Library With NDK Build",
51100
"type": "shell",
52101
"command": "bash",
53102
"args": [
@@ -58,6 +107,52 @@
58107
},
59108
"group": "build",
60109
"problemMatcher": "$gcc"
110+
},
111+
{
112+
"label": "Enable Gradle CMake Build",
113+
"type": "shell",
114+
"command": "bash",
115+
"args": [
116+
"vscode_tasks.sh",
117+
"--enable-cmake"
118+
],
119+
"options": {
120+
"cwd": "${workspaceFolder}"
121+
},
122+
"group": "build",
123+
"problemMatcher": "$gcc"
124+
},
125+
{
126+
"label": "[Debug] Enable CMake And Build Project With CMake",
127+
"type": "shell",
128+
"command": "bash",
129+
"args": [
130+
"vscode_tasks.sh",
131+
"--debug",
132+
"--enable-cmake",
133+
"--build"
134+
],
135+
"options": {
136+
"cwd": "${workspaceFolder}"
137+
},
138+
"group": "build",
139+
"problemMatcher": "$gcc"
140+
},
141+
{
142+
"label": "[Release] Enable CMake And Build Project With CMake",
143+
"type": "shell",
144+
"command": "bash",
145+
"args": [
146+
"vscode_tasks.sh",
147+
"--release",
148+
"--enable-cmake",
149+
"--build"
150+
],
151+
"options": {
152+
"cwd": "${workspaceFolder}"
153+
},
154+
"group": "build",
155+
"problemMatcher": "$gcc"
61156
}
62157
]
63158
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.2.2'
9+
classpath 'com.android.tools.build:gradle:7.3.1'
1010

1111
// NOTE: Do not place your application dependencies here; they belong
1212
// in the individual module build.gradle files

cgeDemo/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ android {
3131
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3232
}
3333
}
34+
namespace 'org.wysaid.cgeDemo'
3435

3536
}
3637

cgeDemo/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="org.wysaid.cgeDemo">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43
<!-- <uses-sdk android:minSdkVersion="14" -->
54
<!-- android:targetSdkVersion="22" -->
65
<!-- /> -->

library/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ android {
2121
defaultConfig {
2222
minSdkVersion rootProject.ext.android.minSdkVersion
2323
targetSdkVersion rootProject.ext.android.targetSdkVersion
24-
versionCode rootProject.ext.android.versionCode
25-
versionName rootProject.ext.android.versionName
2624

2725
if (usingCMakeCompile()) {
2826
externalNativeBuild {
@@ -90,6 +88,7 @@ android {
9088
sourceCompatibility JavaVersion.VERSION_1_8
9189
targetCompatibility JavaVersion.VERSION_1_8
9290
}
91+
namespace 'org.wysaid.library'
9392
}
9493

9594
dependencies {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.wysaid.library">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
22
</manifest>

library/src/main/jni/CMakeLists.txt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ if (NOT DEFINED ANDROID_ABI)
4242
add_definitions(-DANDROID_ABI=arm64-v8a)
4343
else ()
4444
add_definitions(-DANDROID_ABI=${ANDROID_ABI})
45-
set(JNI_LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI})
45+
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../libs/${ANDROID_ABI}")
4646
endif ()
4747

4848
execute_process(COMMAND find ${CMAKE_CURRENT_SOURCE_DIR}/cge -maxdepth 3 -type d OUTPUT_VARIABLE CGE_CORE_HEADER_DIR)
49-
execute_process(COMMAND bash -c "find \"${CMAKE_CURRENT_SOURCE_DIR}/cge\" -type f -iname '*.cpp'" OUTPUT_VARIABLE CGE_CORE_SRC)
49+
execute_process(COMMAND bash -c "find \"${CMAKE_CURRENT_SOURCE_DIR}/cge\" -type f -iname '*.cpp' -o -iname '*.c'" OUTPUT_VARIABLE CGE_CORE_SRC)
5050

5151
string(REGEX REPLACE "\n" ";" CGE_CORE_HEADER_DIR ${CGE_CORE_HEADER_DIR})
5252
string(REGEX REPLACE "\n" ";" CGE_CORE_SRC ${CGE_CORE_SRC})
@@ -73,10 +73,14 @@ if (CGE_USE_VIDEO_MODULE)
7373
${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg/${ANDROID_ABI}/libffmpeg.so)
7474

7575
set(CGE_VIDEO_MODULE "ffmpeg")
76-
# if (DEFINED ANDROID_ABI)
77-
# set_target_properties(ffmpeg PROPERTIES
78-
# LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libs/${ANDROID_ABI})
79-
# endif ()
76+
if (DEFINED ANDROID_ABI)
77+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg/${ANDROID_ABI}/libffmpeg.so
78+
${CMAKE_CURRENT_SOURCE_DIR}/../libs/${ANDROID_ABI}/libffmpeg.so COPYONLY)
79+
# set_target_properties(ffmpeg PROPERTIES
80+
# LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libs/${ANDROID_ABI})
81+
# set_target_properties(ffmpeg PROPERTIES
82+
# ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libs/${ANDROID_ABI})
83+
endif ()
8084
endif ()
8185

8286
if (NOT DEFINED ANDROID_GRADLE OR NOT ANDROID_GRADLE)
@@ -94,12 +98,12 @@ file(GLOB_RECURSE CGE_EXT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/custom/*.cpp")
9498

9599
add_library(CGEExt SHARED ${CGE_EXT_SRC})
96100

97-
# if (DEFINED ANDROID_ABI)
98-
# set_target_properties(CGE PROPERTIES
99-
# LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libs/${ANDROID_ABI})
100-
# set_target_properties(CGEExt PROPERTIES
101-
# LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libs/${ANDROID_ABI})
102-
# endif ()
101+
if (DEFINED ANDROID_ABI)
102+
set_target_properties(CGE PROPERTIES
103+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libs/${ANDROID_ABI})
104+
set_target_properties(CGEExt PROPERTIES
105+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libs/${ANDROID_ABI})
106+
endif ()
103107

104108
target_link_libraries(CGE
105109
${CGE_VIDEO_MODULE}

run_android_app.sh

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)