Skip to content

Commit

Permalink
Fix build scripts (#1048)
Browse files Browse the repository at this point in the history
Adding the ability to specify a build target
Fix warning
  • Loading branch information
AtomXY authored Feb 22, 2024
1 parent d38b13d commit b1a003b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
49 changes: 44 additions & 5 deletions ton_client/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,47 @@ const {
devMode,
} = require('./build-lib');
const platform = os.platform();
const arch = os.arch();
const cArch = os.arch();
const getArch = () => {
for (let i = 1; i < process.argv.length - 1; i++) {
if(process.argv[i] === '--target') {
return process.argv[i + 1];
}
}
return cArch;
}
const getRustTarget = () => {
if(cArch === arch) {
return '';

}
const platformTargets = {
linux: {
arm: 'armv7-unknown-linux-gnueabihf',
arm64: 'aarch64-unknown-linux-gnu',
x64: 'x86_64-unknown-linux-gnu'
},
win32: {
x64: 'x86_64-pc-windows-msvc'
},
darwin: {
x64: 'x86_64-apple-darwin',
arm64: 'aarch64-apple-darwin'
}
};
return platformTargets[platform]?.[arch] ?? '';
}
const arch = getArch();
const rustTarget = getRustTarget();

main(async () => {
await spawnProcess('cargo', ['build', '--release']);
if(rustTarget) {
await spawnProcess('rustup', ['target', 'add', rustTarget]);
}
console.log('Executing: cargo',
['build', '--release'].concat(rustTarget ? ['--target', rustTarget] : []).join(' ')
);
await spawnProcess('cargo', ['build', '--release'].concat(rustTarget ? ['--target', rustTarget] : []));
deleteFolderRecursive(root_path('bin'));
fs.mkdirSync(root_path('bin'), { recursive: true });
const platformNames = {
Expand All @@ -30,10 +67,12 @@ main(async () => {
},
};
for (const [src, dstSuffix] of platformNames[platform][arch] || []) {
const target = ['..', 'target', 'release', src.replace('{}', 'ton_client')];
const target = ['..', 'target', rustTarget, 'release', src.replace('{}', 'ton_client')];
await postBuild(target, platform);
await gz(
target,
`tonclient_${version}_${platform}${dstSuffix || ''}`, [__dirname, 'build']);
target,
`tonclient_${version}_${platform}${cArch==arch ? '' : `_${arch}`}${dstSuffix || ''}`,
[__dirname, 'build']
);
}
});
2 changes: 1 addition & 1 deletion ton_client/src/processing/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Error {
"message_id": message_id,
});
if let Some(shard_block_id) = shard_block_id {
data["shard_block_id"] = shard_block_id.clone().into();
data["shard_block_id"] = shard_block_id.into();
}
error_with_data(code, message, data)
}
Expand Down

0 comments on commit b1a003b

Please sign in to comment.