Skip to content

Commit

Permalink
sepl, spec, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zrisher committed May 14, 2017
1 parent ab6ed4d commit a507650
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 212 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ It provides for basic SE mod deployment:
* Runs SE asset building tasks (Mwm Builder)
* Deploys all assets and code distributed through Steam to the SE mods dir

As well as for deploying with [Load-ARMS](https://github.com/Rynchodon/Load-ARMS):
As well as for deploying with [SE Plugin Loader](https://github.com/Rynchodon/SEPL):
* Places git-based revision number in the assembly version
* Stops ARMS-Loader and SE before running ARMS-Loader
* Runs deployment and release tasks via ARMS-Loader
* Restarts SE in development
* Stops SE (and thus SEPL) before running SEPL
* Runs deployment and release tasks via SEPL
* Restarts SE

Once you have installed SE Mod Builder and configured your project,
you will be able to launch it in SE for development or release it to users by
Expand All @@ -18,8 +18,9 @@ simply selecting your configuration in Visual Studio and clicking "Build".

## Requirements
* [Git](https://git-scm.com/downloads) - for releasing and versioning
* [Load-ARMS](https://github.com/Rynchodon/Load-ARMS) - ensure you've installed
and configured it following the readme, including setting the Steam plugin flag
* [SE Plugin Loader](https://github.com/Rynchodon/SEPL) -
ensure you've installed and configured it following the readme,
including setting the Steam plugin flag
and providing a local oAuth token for git.
* [Conda](https://conda.io/docs/) - if you'd like to build SEMB from source

Expand All @@ -34,7 +35,7 @@ Simply download and run the latest installer from [the releases page](https://gi
* Run `conda env create` to create the environment
* Run `conda activate se_mod_builder` to load the environment
* Run `python se_mod_builder.py args` to use it via python
* Run `pyinstaller se_mod_builder.spec -y` to generate the executable
* Run `pyinstaller se_mod_builder.spec` to generate the executable
* Add the executable to your path


Expand Down Expand Up @@ -64,15 +65,15 @@ And the post-build event to:

##### Developing
Simply edit your code and assets, set your configuration to anything besides
`release`, and click "Build" to deploy all changes to the SE mods folder and
ARMS-Loader. SE will start automatically when finished deploying.
`release`, and click "Build" to deploy all changes.
SE will start automatically when finished deploying.

##### Releasing
When your code is ready to release:
* Bump the version in Properties/VersionInfo and commit.
* Push your code to github and ensure it's merged into master.
* Change your build to "release" and click "Build". This will publish your
changes to Load-ARMS.
changes to SEPL.
* If you've changed your steam-shipped code, publish it using SE.


Expand Down
28 changes: 16 additions & 12 deletions build.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
#

# All variables have defaults. If the default isn't correct, provide it below.
# All paths are resolved relative to project root except plugin_build_files,
# which are resolved relative to the build dir.
# All paths are resolved relative to project root.

# project_name: 'project_root_dirname'
# repo_name: 'project_root_dirname'
# repo_owner: 'the author of the first commit to this repo'
# plugin_build_files:
# - ProjectName.dll

#
# Plugin config
#

# build_plugin: True
# plugin_json_path: 'plugin.json'
# plugin_props_dir: 'Scripts/Properties'
# vs_version_filename: 'VersionInfo.cs'
# vs_revision_filename: 'VersionInfo - User.cs'

#
# Steam config
#

# build_steam: True
# steam_audio_dir: 'Audio'
# steam_data_dir: 'Data'
# steam_models_dir: 'Models'
# steam_scripts_dir: 'Scripts/Steam'
# steam_textures_dir: 'Textures'
# vs_version_filename: 'VersionInfo.cs'
# vs_revision_filename: 'VersionInfo - User.cs'




2 changes: 1 addition & 1 deletion config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# If one of these isn't available in a default path, provide it below.

# git_exe_path: 'C:\some\path\to\git.exe'
# load_arms_exe_path: 'C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\LoadARMS.exe'
# mwm_exe_path: 'C:\Program Files (x86)\Steam\SteamApps\common\SpaceEngineers\Tools\MwmBuilder\MwmBuilder.exe'
# se_data_dir: 'C:\Users\UserName\AppData\Roaming\SpaceEngineers'
# se_exe_path: 'C:\Program Files (x86)\Steam\SteamApps\common\SpaceEngineers\Bin\x64\SpaceEngineers.exe'
# se_mods_dir: 'C:\Users\UserName\AppData\Roaming\SpaceEngineers\Mods'
# se_steam_dir: 'C:\Program Files (x86)\Steam\SteamApps\common\SpaceEngineers'
# sepl_exe_path: 'C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\LoadARMS.exe'
18 changes: 10 additions & 8 deletions se_mod_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
Should be run from a build directory.
Builds models.
Distributes steam assets and scripts to mods folder.
Kills SE & Arms Loader processes.
Distributes to arms loader, publishing if env == 'release'.
Kills SE & SEPL processes.
Distributes to SEPL, publishing if env == 'release'.
Starts SE unless env == 'release'.
"""

Expand Down Expand Up @@ -67,23 +67,25 @@ def main():
)

args = parser.parse_args()
publish = args.env == 'release'
restart_se = not publish
task = args.task
print(' ----- SE Mod Builder {} doing {} ----- '.format(__version__, task))

print(' ----- SE Mod Builder {} doing {} ----- '.format(__version__, task))
global_config = load_global_config(INSTALL_DIR, ASSET_DIR)

if task == 'example-config':
tasks.gen_example_project_config(global_config, os.getcwd())
else:
project_config = load_project_config(
os.path.realpath(args.root),
os.path.realpath(args.build_dir),
global_config
os.path.realpath(args.build_dir)
)
if task == 'post-build':
tasks.post_build(global_config, project_config, args.env)
elif task == 'pre-build':
if task == 'pre-build':
tasks.pre_build(global_config, project_config)
if task == 'post-build':
tasks.post_build(global_config, project_config,
publish=publish, restart_se=restart_se)

# return exit code OK
print(' ----- SE Mod Builder finished {} ----- '.format(task))
Expand Down
4 changes: 2 additions & 2 deletions src/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import config
from . import load_arms
from . import mwm
from . import git
from . import mwm
from . import ops
from . import se
from . import sepl
121 changes: 53 additions & 68 deletions src/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def load_global_config(install_dir, asset_dir):
[r'C:\Program Files\Steam\SteamApps\common\SpaceEngineers',
r'C:\Program Files (x86)\Steam\SteamApps\common\SpaceEngineers']
)
load_arms_exe_path = find_path_or_throw(
'load_arms_exe_path', loaded, install_dir,
[se_steam_dir + '\\Bin64\\LoadARMS.exe']
sepl_exe_path = find_path_or_throw(
'sepl_exe_path', loaded, install_dir,
[se_steam_dir + '\\SpaceEngineersPluginLoader\\PluginManager.exe']
)
mwm_exe_path = find_path_or_throw(
'mwm_exe_path', loaded, install_dir,
Expand All @@ -54,17 +54,21 @@ def load_global_config(install_dir, asset_dir):
'asset_dir': asset_dir,
'git_exe_path': git_exe_path,
'install_dir': install_dir,
'load_arms_exe_path': load_arms_exe_path,
'mwm_exe_path': mwm_exe_path,
'se_exe_path': se_exe_path,
'se_mods_dir': se_mods_dir,
'se_steam_dir': se_steam_dir,
'sepl_exe_path': sepl_exe_path,
}


def load_project_config(project_dir, plugin_build_dir, global_config):
print('Using {}: "{}"'.format('project_dir', project_dir))
print('Using {}: "{}"'.format('plugin_build_dir', plugin_build_dir))
def load_project_config(project_dir, plugin_build_dir):
print('Using project_dir: "{}"'.format(project_dir))
print('Using plugin_build_dir: "{}"'.format(plugin_build_dir))
config = {
'plugin_build_dir': plugin_build_dir,
'project_dir': project_dir,
}

# Load config file
file_path = project_dir + r'\build.yml'
Expand All @@ -77,72 +81,54 @@ def load_project_config(project_dir, plugin_build_dir, global_config):
loaded = {}

# Project properties
project_name = get(
config['project_name'] = get(
'project_name', loaded, str(os.path.basename(project_dir))
)
repo_name = get(
'repo_name', loaded, project_name
)
repo_owner = get(
'repo_owner', loaded,
git.first_author(global_config['git_exe_path'], project_dir)
)
vs_version_filename = get(
'vs_version_filename', loaded, 'VersionInfo.cs'
)
vs_revision_filename = get(
'vs_revision_filename', loaded, 'VersionInfo - User.cs'
)

# Steam Assets
steam_audio_dir = find_path_or_throw(
'steam_audio_dir', loaded, project_dir,
[project_dir + "\\Audio"]
)
steam_data_dir = find_path_or_throw(
'steam_data_dir', loaded, project_dir,
[project_dir + "\\Data"]
)
steam_models_dir = find_path_or_throw(
'steam_models_dir', loaded, project_dir,
[project_dir + "\\Models"]
)
steam_scripts_dir = find_path_or_throw(
'steam_scripts_dir', loaded, project_dir,
[project_dir + "\\Scripts\\Steam"]
)
steam_textures_dir = find_path_or_throw(
'steam_textures_dir', loaded, project_dir,
[project_dir + "\\Textures"]
)

# Plugin Assets
plugin_props_dir = find_path_or_throw(
'plugin_props_dir', loaded, project_dir,
[project_dir + "\\Scripts\\Properties"]
)
plugin_build_files = get(
'plugin_build_files', loaded,
[project_name + '.dll']
)
config['build_plugin'] = get('build_plugin', loaded, True)
if config['build_plugin']:
config['plugin_props_dir'] = find_path_or_throw(
'plugin_props_dir', loaded, project_dir,
[project_dir + "\\Scripts\\Properties"]
)
config['plugin_json_path'] = find_path_or_throw(
'plugin_json_path', loaded, project_dir,
[project_dir + "\\plugin.json"]
)
config['vs_version_filename'] = get(
'vs_version_filename', loaded, 'VersionInfo.cs'
)
config['vs_revision_filename'] = get(
'vs_revision_filename', loaded, 'VersionInfo - User.cs'
)

# Steam Assets
config['build_steam'] = get('build_steam', loaded, True)
if config['build_steam']:
config['steam_audio_dir'] = find_path_or_throw(
'steam_audio_dir', loaded, project_dir,
[project_dir + "\\Audio"]
)
config['steam_data_dir'] = find_path_or_throw(
'steam_data_dir', loaded, project_dir,
[project_dir + "\\Data"]
)
config['steam_models_dir'] = find_path_or_throw(
'steam_models_dir', loaded, project_dir,
[project_dir + "\\Models"]
)
config['steam_scripts_dir'] = find_path_or_throw(
'steam_scripts_dir', loaded, project_dir,
[project_dir + "\\Scripts\\Steam"]
)
config['steam_textures_dir'] = find_path_or_throw(
'steam_textures_dir', loaded, project_dir,
[project_dir + "\\Textures"]
)

# Return config dict
return {
'plugin_build_dir': plugin_build_dir,
'plugin_build_files': plugin_build_files,
'plugin_props_dir': plugin_props_dir,
'project_dir': project_dir,
'project_name': project_name,
'repo_name': repo_name,
'repo_owner': repo_owner,
'steam_audio_dir': steam_audio_dir,
'steam_data_dir': steam_data_dir,
'steam_models_dir': steam_models_dir,
'steam_scripts_dir': steam_scripts_dir,
'steam_textures_dir': steam_textures_dir,
'vs_version_filename': vs_version_filename,
'vs_revision_filename': vs_revision_filename
}
return config


def find_path_or_throw(param, loaded_config, root, defaults):
Expand All @@ -154,7 +140,6 @@ def find_path_or_throw(param, loaded_config, root, defaults):
if path and os.path.exists(path):
print('Using {}: "{}"'.format(param, path))
return path

raise ValueError('Unable to find "{}", tried {}'.format(param, paths))


Expand Down
24 changes: 0 additions & 24 deletions src/lib/load_arms.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/se.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


SE_PROCESS_NAMES = [
"SpaceEngineers.exe", "SpaceEngineersDedicated.exe", "LoadARMS.exe"
"SpaceEngineers.exe", "SpaceEngineersDedicated.exe", "PluginManager.exe"
]


Expand Down
18 changes: 18 additions & 0 deletions src/lib/sepl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from subprocess import Popen, PIPE


def run(exe_path, json_config_path, build_dir, version, publish=False):
command_parts = [
exe_path, json_config_path,
# 'version={}'.format(version), # parsing broken, now works from files
'publish={}'.format(publish)
]
print('Running SEPL command:', ' '.join(command_parts))
proc = Popen(command_parts, stdout=PIPE, stderr=PIPE, cwd=build_dir)
(stdout, stderr) = proc.communicate()
if proc.returncode == 0:
print("SEPL succeeded: {}".format(stdout.decode('ascii')))
else:
raise ValueError('SEPL error.\nStdout:\n{}\nStderr:\n{}'
.format(stdout.decode('ascii'),
stderr.decode('ascii')))
10 changes: 10 additions & 0 deletions src/lib/vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ def get_version(version_path):
match = pattern.match(line)
if match:
return match.group(1)


"""
return {
"Build": match.group(1),
"Major": match.group(2),
"Minor": match.group(3),
"Revision": match.group(4)
}
"""
Loading

0 comments on commit a507650

Please sign in to comment.