Skip to content

Commit

Permalink
Merge pull request fuse-open#436 from mortend/net6-restore
Browse files Browse the repository at this point in the history
update pack/restore for net6.0 (beta-3.0)
  • Loading branch information
mortend authored Jan 7, 2023
2 parents abbefd9 + 529e00d commit ee0c88c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions scripts/pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ function rm-identical {
h1 "Optimizing package"

# OpenTK and Xamarin.Mac will be added back by restore.js
rm-identical bin node_modules/@fuse-open/xamarin-mac *.dll *.dylib
rm-identical bin/mac node_modules/@fuse-open/xamarin-mac *.dll *.dylib
rm-identical bin/win node_modules/@fuse-open/opentk *.dll
rm-identical bin/net6.0 node_modules/@fuse-open/xamarin-mac *.dll *.dylib
rm-identical bin/mac/net6.0 node_modules/@fuse-open/xamarin-mac *.dll *.dylib
rm-identical bin/win/net6.0-windows node_modules/@fuse-open/opentk *.dll

# Drop superfluous build artifacts
rm-all bin *.config *.mdb *.pdb *.xml
rm-all bin *.config *.pdb *.xml
44 changes: 22 additions & 22 deletions scripts/restore.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
const fs = require("fs");
const path = require("path");
const fs = require("fs")
const path = require("path")

function findup(suffix) {
for (let dir = __dirname, parent = undefined;;
dir = path.dirname(dir)) {

if (dir == parent)
throw Error(`${suffix} was not found`);
throw Error(`${suffix} was not found`)

parent = dir;
const file = path.join(dir, suffix);
parent = dir
const file = path.join(dir, suffix)

if (fs.existsSync(file))
return file;
return file
}
}

function findNodeModule(name) {
const package = findup(`node_modules/${name}/package.json`);
return path.dirname(package);
const package = findup(`node_modules/${name}/package.json`)
return path.dirname(package)
}

function restoreFiles(src, dst) {
if (!fs.existsSync(dst))
return;
return

for (file of fs.readdirSync(src)) {
const srcf = path.join(src, file);
const dstf = path.join(dst, file);
const placeholder = dstf + ".restore";
const srcf = path.join(src, file)
const dstf = path.join(dst, file)
const placeholder = dstf + ".restore"

if (!fs.existsSync(placeholder))
continue;
continue

const relative = path.relative(process.cwd(), dstf);
console.log(`restoring ${relative}`);
fs.copyFileSync(srcf, dstf);
fs.unlinkSync(placeholder);
const relative = path.relative(process.cwd(), dstf)
console.log(`restoring ${relative}`)
fs.copyFileSync(srcf, dstf)
fs.unlinkSync(placeholder)
}
}

// Restore Xamarin.Mac binaries.
const xamarin = findNodeModule("@fuse-open/xamarin-mac");
restoreFiles(xamarin, path.join(__dirname, "..", "bin"));
restoreFiles(xamarin, path.join(__dirname, "..", "bin", "mac"));
const xamarin = findNodeModule("@fuse-open/xamarin-mac")
restoreFiles(xamarin, path.join(__dirname, "..", "bin", "net6.0"))
restoreFiles(xamarin, path.join(__dirname, "..", "bin", "mac", "net6.0"))

// Restore OpenTK and ANGLE (Windows only).
const opentk = findNodeModule("@fuse-open/opentk");
restoreFiles(opentk, path.join(__dirname, "..", "bin", "win"));
const opentk = findNodeModule("@fuse-open/opentk")
restoreFiles(opentk, path.join(__dirname, "..", "bin", "win", "net6.0-windows"))

0 comments on commit ee0c88c

Please sign in to comment.