Added python script to edit uproject file.
This commit is contained in:
parent
c0c24f6756
commit
bffd921958
|
@ -12,6 +12,7 @@ Plugins/Carla/Debug
|
||||||
Plugins/Carla/DerivedDataCache
|
Plugins/Carla/DerivedDataCache
|
||||||
Plugins/Carla/Intermediate
|
Plugins/Carla/Intermediate
|
||||||
Plugins/Carla/Saved
|
Plugins/Carla/Saved
|
||||||
|
CarlaUE4.uproject
|
||||||
|
|
||||||
/Content
|
/Content
|
||||||
Config/CarlaSettings.ini
|
Config/CarlaSettings.ini
|
||||||
|
|
|
@ -106,8 +106,10 @@ if %BUILD_UE4_EDITOR% == true (
|
||||||
echo %FILE_N% Building Unreal Editor...
|
echo %FILE_N% Building Unreal Editor...
|
||||||
|
|
||||||
if %USE_CARSIM% == true (
|
if %USE_CARSIM% == true (
|
||||||
|
py -3 %ROOT_PATH%../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject" -e
|
||||||
echo CarSim ON > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
|
echo CarSim ON > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
|
||||||
) else (
|
) else (
|
||||||
|
py -3 %ROOT_PATH%../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject"
|
||||||
echo CarSim OFF > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
|
echo CarSim OFF > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -117,14 +117,16 @@ fi
|
||||||
|
|
||||||
if ${BUILD_CARLAUE4} ; then
|
if ${BUILD_CARLAUE4} ; then
|
||||||
|
|
||||||
if [ ! -f Makefile ]; then
|
|
||||||
|
|
||||||
if ${USE_CARSIM} ; then
|
if ${USE_CARSIM} ; then
|
||||||
|
python ${PWD}/../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject" -e
|
||||||
echo "CarSim ON" > ${PWD}/Config/CarSimConfig.ini
|
echo "CarSim ON" > ${PWD}/Config/CarSimConfig.ini
|
||||||
else
|
else
|
||||||
|
python ${PWD}/../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject"
|
||||||
echo "CarSim OFF" > ${PWD}/Config/CarSimConfig.ini
|
echo "CarSim OFF" > ${PWD}/Config/CarSimConfig.ini
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -f Makefile ]; then
|
||||||
|
|
||||||
# This command fails sometimes but normally we can continue anyway.
|
# This command fails sometimes but normally we can continue anyway.
|
||||||
set +e
|
set +e
|
||||||
log "Generate Unreal project files."
|
log "Generate Unreal project files."
|
||||||
|
|
|
@ -100,8 +100,10 @@ rem ============================================================================
|
||||||
if %DO_PACKAGE%==true (
|
if %DO_PACKAGE%==true (
|
||||||
|
|
||||||
if %USE_CARSIM% == true (
|
if %USE_CARSIM% == true (
|
||||||
|
py -3 %ROOT_PATH%../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject" -e
|
||||||
echo CarSim ON > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
|
echo CarSim ON > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
|
||||||
) else (
|
) else (
|
||||||
|
py -3 %ROOT_PATH%../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject"
|
||||||
echo CarSim OFF > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
|
echo CarSim OFF > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -91,9 +91,11 @@ if ${DO_CARLA_RELEASE} ; then
|
||||||
|
|
||||||
pushd "${CARLAUE4_ROOT_FOLDER}" >/dev/null
|
pushd "${CARLAUE4_ROOT_FOLDER}" >/dev/null
|
||||||
|
|
||||||
if [ ${USE_CARSIM} ]; then
|
if ${USE_CARSIM} ; then
|
||||||
|
python ${PWD}/../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject" -e
|
||||||
echo "CarSim ON" > ${PWD}/Config/CarSimConfig.ini
|
echo "CarSim ON" > ${PWD}/Config/CarSimConfig.ini
|
||||||
else
|
else
|
||||||
|
python ${PWD}/../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject"
|
||||||
echo "CarSim OFF" > ${PWD}/Config/CarSimConfig.ini
|
echo "CarSim OFF" > ${PWD}/Config/CarSimConfig.ini
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma de
|
||||||
|
# Barcelona (UAB).
|
||||||
|
#
|
||||||
|
# This work is licensed under the terms of the MIT license.
|
||||||
|
# For a copy, see <https://opensource.org/licenses/MIT>.
|
||||||
|
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Edits the uproject file to enable and disable the CarSim plugin
|
||||||
|
"""
|
||||||
|
argparser = argparse.ArgumentParser()
|
||||||
|
argparser.add_argument(
|
||||||
|
'-f', '--file',
|
||||||
|
metavar='F',
|
||||||
|
default="",
|
||||||
|
type=str,
|
||||||
|
help='Path to the uproject file')
|
||||||
|
argparser.add_argument(
|
||||||
|
'-e', '--enable',
|
||||||
|
action='store_true',
|
||||||
|
help='enable carsim')
|
||||||
|
args = argparser.parse_args()
|
||||||
|
|
||||||
|
# Read uproject (json) file
|
||||||
|
uproject_file = open(args.file, 'r')
|
||||||
|
uproject_json = json.load(uproject_file)
|
||||||
|
uproject_file.close()
|
||||||
|
|
||||||
|
# Get the plugin list
|
||||||
|
plugin_list = uproject_json["Plugins"]
|
||||||
|
|
||||||
|
# Edit plugin
|
||||||
|
should_do_changes = False
|
||||||
|
carsim_found = False
|
||||||
|
for plugin in plugin_list:
|
||||||
|
if plugin['Name'] == 'CarSim':
|
||||||
|
if args.enable:
|
||||||
|
if not plugin['Enabled']:
|
||||||
|
should_do_changes = True
|
||||||
|
plugin['Enabled'] = True
|
||||||
|
else:
|
||||||
|
if plugin['Enabled']:
|
||||||
|
should_do_changes = True
|
||||||
|
plugin['Enabled'] = False
|
||||||
|
carsim_found = True
|
||||||
|
if not carsim_found and args.enable:
|
||||||
|
should_do_changes = True
|
||||||
|
plugin_list.append({'Name':'CarSim', 'MarketplaceURL': 'com.epicgames.launcher://ue/marketplace/content/2d712649ca864c80812da7b5252f5608', "Enabled": True})
|
||||||
|
|
||||||
|
# Save file if there are changes to do
|
||||||
|
if should_do_changes:
|
||||||
|
uproject_file = open(args.file, 'w')
|
||||||
|
uproject_file.write(json.dumps(uproject_json, indent = 4, sort_keys=True))
|
||||||
|
uproject_file.close()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue