Also replace so name for proj.android when new project

This commit is contained in:
halx99 2020-10-20 16:26:53 +08:00
parent ee3bd4cfd9
commit 546ebfc4d4
9 changed files with 51 additions and 6 deletions

View File

@ -71,8 +71,7 @@ list(APPEND GAME_HEADER
)
if(ANDROID)
# change APP_NAME to the share library name for Android, it's value depend on AndroidManifest.xml
set(APP_NAME MyGame)
# the APP_NAME should match on AndroidManifest.xml
list(APPEND GAME_SOURCE
proj.android/app/jni/hellocpp/main.cpp
)

View File

@ -24,6 +24,12 @@
"proj.android/app/AndroidManifest.xml"
]
},
"project_replace_so_name": {
"src_so_name": "HelloCpp",
"files": [
"proj.android/app/AndroidManifest.xml"
]
},
"project_replace_mac_bundleid": {
"src_bundle_id": "org.cocos2dx.hellocpp",
"files": [

View File

@ -14,7 +14,7 @@
<!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="MyGame" />
android:value="HelloCpp" />
<activity
android:name="org.cocos2dx.cpp.AppActivity"

View File

@ -68,8 +68,7 @@ set(GAME_SOURCE ${RUNTIME_SRC_ROOT}/Classes/AppDelegate.cpp)
# sources need to compile info, include dirs and source files
if(ANDROID)
# change APP_NAME to the share library name for Android, it's value depend on AndroidManifest.xml
set(APP_NAME cocos2dlua)
# the APP_NAME should match on AndroidManifest.xml
list(APPEND GAME_SOURCE ${RUNTIME_SRC_ROOT}/proj.android/app/jni/hellolua/main.cpp)
elseif(LINUX)
list(APPEND GAME_SOURCE ${RUNTIME_SRC_ROOT}/proj.linux/main.cpp)

View File

@ -115,6 +115,12 @@
"frameworks/runtime-src/proj.android/app/build.gradle",
"frameworks/runtime-src/proj.android/app/AndroidManifest.xml" ]
},
"project_replace_so_name": {
"src_so_name": "HelloLua",
"files": [
"frameworks/runtime-src/proj.android/app/AndroidManifest.xml"
]
},
"project_replace_mac_bundleid": {
"src_bundle_id": "org.cocos2dx.hellolua",
"files": [

View File

@ -12,7 +12,7 @@
<!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="cocos2dlua" />
android:value="HelloLua" />
<activity
android:name="org.cocos2dx.lua.AppActivity"

View File

@ -47,6 +47,12 @@
"proj.android/AndroidManifest.xml"
]
},
"project_replace_so_name": {
"src_so_name": "HelloCpp",
"files": [
"proj.android/app/AndroidManifest.xml"
]
},
"project_replace_mac_bundleid": {
"src_bundle_id": "org.cocos2dx.hellocpp",
"files": [

View File

@ -80,6 +80,12 @@
"frameworks/runtime-src/proj.android/AndroidManifest.xml"
]
},
"project_replace_so_name": {
"src_so_name": "HelloLua",
"files": [
"frameworks/runtime-src/proj.android/app/AndroidManifest.xml"
]
},
"project_replace_mac_bundleid": {
"src_bundle_id": "org.cocos2dx.hellolua",
"files": [

View File

@ -643,6 +643,29 @@ class TPCreator(object):
cocos.Logging.warning(MultiLanguage.get_string('NEW_WARNING_FILE_NOT_FOUND_FMT',
os.path.join(dst_project_dir, dst)))
def project_replace_so_name(self, v):
""" will modify the content of the file
"""
src_so_name = v['src_so_name']
dst_so_name = self.project_name
if src_so_name == dst_so_name:
return
cocos.Logging.info(MultiLanguage.get_string('NEW_INFO_STEP_REPLACE_SO_FMT',
(src_so_name, dst_so_name)))
files = v['files']
if not dst_so_name:
raise cocos.CCPluginError(MultiLanguage.get_string('NEW_ERROR_PKG_NAME_NOT_SPECIFIED'),
cocos.CCPluginError.ERROR_WRONG_ARGS)
for f in files:
dst = f.replace("PROJECT_NAME", self.project_name)
dstpath = os.path.join(self.project_dir, dst)
if os.path.exists(dstpath):
replace_string(dstpath, src_so_name, dst_so_name)
else:
cocos.Logging.warning(MultiLanguage.get_string('NEW_WARNING_FILE_NOT_FOUND_FMT',
dstpath))
def project_replace_mac_bundleid(self, v):
""" will modify the content of the file
"""