Use targets in hak environment for cross-compiling

This arranges the hak environment target info around target IDs that come from
the builder, which simplifies cross-compiling. The `target.js` module is a
generated copy of the builder's `target.ts`.
This commit is contained in:
J. Ryan Stinnett
2021-06-18 17:38:22 +01:00
parent a171fa417b
commit 997f2c21bf
3 changed files with 53 additions and 29 deletions

View File

@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ENABLED_TARGETS = exports.TARGETS = void 0;
exports.isHost = exports.isHostId = exports.getHost = exports.ENABLED_TARGETS = exports.TARGETS = void 0;
const aarch64AppleDarwin = {
id: 'aarch64-apple-darwin',
platform: 'darwin',
@@ -58,3 +58,16 @@ exports.ENABLED_TARGETS = [
exports.TARGETS['x86_64-unknown-linux-gnu'],
exports.TARGETS['i686-pc-windows-msvc'],
];
function getHost() {
return Object.values(exports.TARGETS).find(target => (target.platform === process.platform &&
target.arch === process.arch));
}
exports.getHost = getHost;
function isHostId(id) {
return getHost()?.id === id;
}
exports.isHostId = isHostId;
function isHost(target) {
return getHost()?.id === target.id;
}
exports.isHost = isHost;