Skip to content

Commit

Permalink
mcbundle: Windows version (from Andy)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Soquet committed Aug 4, 2021
1 parent 715475b commit 66c468f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 25 deletions.
5 changes: 5 additions & 0 deletions build/makefiles/win/tools.mak
Expand Up @@ -117,6 +117,7 @@ MODULES = \
$(MOD_DIR)\colorcellencode.xsb \
$(MOD_DIR)\compressbmf.xsb \
$(MOD_DIR)\image2cs.xsb \
$(MOD_DIR)\mcbundle.xsb \
$(MOD_DIR)\mcconfig.xsb \
$(MOD_DIR)\mclocal.xsb \
$(MOD_DIR)\mcmanifest.xsb \
Expand Down Expand Up @@ -184,6 +185,7 @@ COMMANDS = \
$(BIN_DIR)\colorcellencode.bat \
$(BIN_DIR)\compressbmf.bat \
$(BIN_DIR)\image2cs.bat \
$(BIN_DIR)\mcbundle.bat \
$(BIN_DIR)\mcconfig.bat \
$(BIN_DIR)\mclocal.bat \
$(BIN_DIR)\mcrez.bat \
Expand Down Expand Up @@ -358,6 +360,9 @@ $(BIN_DIR)\compressbmf.bat :
$(BIN_DIR)\image2cs.bat :
@echo # image2cs.bat
echo @$(BIN_DIR)\tools image2cs %%* 1> $(BIN_DIR)\image2cs.bat
$(BIN_DIR)\mcbundle.bat :
@echo # mcbundle.bat
echo @$(BIN_DIR)\tools mcbundle %%* 1> $(BIN_DIR)\mcbundle.bat
$(BIN_DIR)\mcconfig.bat :
@echo # mcconfig.bat
echo @$(BIN_DIR)\tools mcconfig %%* 1> $(BIN_DIR)\mcconfig.bat
Expand Down
80 changes: 55 additions & 25 deletions tools/mcbundle.js
Expand Up @@ -243,34 +243,64 @@ export default class extends TOOL {
const build = this.debug ? "debug" : "release";
const name = this.environment.NAME;
const option = this.debug ? "-d" : "";
const filePath = `${outputPath}/${id}.sh`;
const filePath = (this.windows) ? `${outputPath}\\${id}.bat` : `${outputPath}/${id}.sh`;
const file = new ShellFile(filePath)
file.line("#!/bin/bash");
file.line(`OUTPUT=${outputPath}/${id}`);
file.line(`rm -R $OUTPUT`);
file.line(`mkdir $OUTPUT`);
if (sourceESP32)
file.line(`source $IDF_PATH/export.sh`);
if (sourceWASM)
file.line(`source $EMSDK/emsdk_env.sh`);
for (let result of results) {
file.line(`echo "# ${result.id}"`);
file.line(`mcconfig ${option} -m -p ${result.platform} -s ${signature} -t build`);
file.line(`mkdir $OUTPUT/${result.id}`);
for (let target of result.targets) {
file.line(`cp $MODDABLE/build/bin/${result.platform}/${build}/${name}/${target} $OUTPUT/${result.id}/${target}`);
if (!this.windows) {
file.line("#!/bin/bash");
file.line(`OUTPUT=${outputPath}/${id}`);
file.line(`rm -R $OUTPUT`);
file.line(`mkdir $OUTPUT`);
if (sourceESP32)
file.line(`source $IDF_PATH/export.sh`);
if (sourceWASM)
file.line(`source $EMSDK/emsdk_env.sh`);
for (let result of results) {
file.line(`echo "# ${result.id}"`);
file.line(`mcconfig ${option} -m -p ${result.platform} -s ${signature} -t build`);
file.line(`mkdir $OUTPUT/${result.id}`);
for (let target of result.targets) {
file.line(`cp $MODDABLE/build/bin/${result.platform}/${build}/${name}/${target} $OUTPUT/${result.id}/${target}`);
}
}
if (iconPath)
file.line(`cp ${iconPath} $OUTPUT/icon.png`);
if (customPath) {
file.line(`cp -R ${customPath} $OUTPUT`);
}
file.line(`rm -f $OUTPUT.zip`);
file.line(`cd ${outputPath}`);
file.line(`zip -r ${id}.zip ${id}`);
file.close();
if (this.make)
this.then("bash", filePath);
}
if (iconPath)
file.line(`cp ${iconPath} $OUTPUT/icon.png`);
if (customPath) {
file.line(`cp -R ${customPath} $OUTPUT`);
else {
file.line(`set OUTPUT=${outputPath}\\${id}`);
file.line(`rmdir /s /q %OUTPUT%`);
file.line(`mkdir %OUTPUT%`);
if (sourceESP32)
file.line(`call %IDF_PATH%\\export.bat`);
if (sourceWASM)
throw new Error("WASM mcbundle not yet supported on Windows");
for (let result of results) {
file.line(`echo "# ${result.id}"`);
file.line(`call mcconfig ${option} -m -p ${result.platform} -s ${signature} -t build`);
file.line(`mkdir %OUTPUT%\\${result.id}`);
for (let target of result.targets) {
file.line(`copy %MODDABLE%\\build\\bin\\${this.resolveSlash(result.platform)}\\${build}\\${name}\\${target} %OUTPUT%\\${result.id}\\${target}`);
}
}
if (iconPath)
file.line(`copy ${iconPath} %OUTPUT%\\icon.png`);
if (customPath)
file.line(`xcopy ${customPath} %OUTPUT%\\custom /E/H/I`);

file.line(`del /f/q %OUTPUT%.zip`);
file.line(`cd ${outputPath}`);
file.line(`tar.exe -a -c -f ${id}.zip ${id}`);
file.close();
if (this.make)
this.then(filePath);
}
file.line(`rm -f $OUTPUT.zip`);
file.line(`cd ${outputPath}`);
file.line(`zip -r ${id}.zip ${id}`);
file.close();
if (this.make)
this.then("bash", filePath);
}
}

0 comments on commit 66c468f

Please sign in to comment.