Skip to content

Commit

Permalink
Use the offline to install offline compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
delasy committed Feb 1, 2025
1 parent 57c7ed3 commit 27cd01b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 379 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- run: npm run all
- uses: ./
- run: the -v
- run: the run test/example --compiler=compiler
- run: the run test/example
test-version:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
186 changes: 5 additions & 181 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,123 +1,6 @@
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({

/***/ 3499:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.cmake = exports.CMake = void 0;
const exec_1 = __nccwpck_require__(5236);
// https://cmake.org/cmake/help/latest/manual/cmake.1.html
class CMake {
generate(sourcePath, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const args = [sourcePath];
if (options.buildPath !== undefined) {
args.push('-B', options.buildPath);
}
if (options.generator !== undefined) {
args.push('-G', options.generator);
}
if (options.variables !== undefined) {
args.push(...this.variables(options.variables));
}
yield (0, exec_1.exec)('cmake', args);
});
}
build(dir, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const args = ['--build', dir];
if (options.config !== undefined) {
args.push('--config', options.config);
}
if (options.preset !== undefined) {
args.push('--preset', options.preset);
}
if (options.target !== undefined) {
args.push('--target', options.target);
}
yield (0, exec_1.exec)('cmake', args);
});
}
install(dir, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const args = ['--install', dir];
if (options.config !== undefined) {
args.push('--config', options.config);
}
if (options.prefix !== undefined) {
args.push('--prefix', options.prefix);
}
yield (0, exec_1.exec)('cmake', args);
});
}
variables(variables) {
return variables.map((variable) => {
if (variable.type !== undefined) {
return ['-D', `${variable.name}:${variable.type}=${variable.value}`];
}
return ['-D', `${variable.name}=${variable.value}`];
}).flat();
}
}
exports.CMake = CMake;
exports.cmake = new CMake();


/***/ }),

/***/ 9412:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

"use strict";

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.git = exports.Git = void 0;
const exec_1 = __nccwpck_require__(5236);
class Git {
clone(repository, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const args = ['clone'];
if (options.depth !== undefined) {
args.push('--depth', options.depth.toString());
}
if (options.singleBranch !== undefined) {
args.push('--single-branch');
}
args.push(repository);
if (options.directory !== undefined) {
args.push(options.directory);
}
yield (0, exec_1.exec)('git', args);
});
}
}
exports.Git = Git;
exports.git = new Git();


/***/ }),

/***/ 5915:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

Expand Down Expand Up @@ -157,55 +40,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(7484));
const exec_1 = __nccwpck_require__(5236);
const fs = __importStar(__nccwpck_require__(1943));
const io = __importStar(__nccwpck_require__(4994));
const path = __importStar(__nccwpck_require__(6928));
const tc = __importStar(__nccwpck_require__(3472));
const cmake_1 = __nccwpck_require__(3499);
const git_1 = __nccwpck_require__(9412);
const utils = __importStar(__nccwpck_require__(9277));
function installCompiler(version) {
return __awaiter(this, void 0, void 0, function* () {
core.debug('Installing The compiler dependencies ...');
const tempDirectory = utils.tempDirectory();
const installationDirectory = path.join(tempDirectory, `the-${version}-deps`);
const dependenciesTarballPath = yield tc.downloadTool('https://cdn.thelang.io/deps.tar.gz');
const dependenciesPath = yield tc.extractTar(dependenciesTarballPath, path.join(installationDirectory, 'deps'));
core.exportVariable('THE_DEPS_DIR', path.join(dependenciesPath, utils.dependenciesPath()));
core.debug('Installing The compiler ...');
const compilerDirectory = path.join(installationDirectory, 'the');
const compilerBuildDirectory = path.join(compilerDirectory, 'build');
const compilerReleaseDirectory = utils.isWin
? path.join(compilerBuildDirectory, 'Release')
: compilerBuildDirectory;
const compilerTargetDirectory = path.join(utils.homeDirectory(), (utils.isWin ? 'The' : '.the'), 'bin');
const compilerTargetLocation = path.join(compilerTargetDirectory, `compiler${utils.binaryExtension()}`);
yield git_1.git.clone('https://github.com/thelang-io/the.git', {
depth: 1,
directory: compilerDirectory,
singleBranch: true
});
yield cmake_1.cmake.generate(compilerDirectory, {
buildPath: compilerBuildDirectory,
variables: [
{ name: 'CMAKE_BUILD_TYPE', value: 'Release' }
]
});
yield cmake_1.cmake.build(compilerBuildDirectory, {
config: 'Release',
target: 'the'
});
yield io.mkdirP(compilerTargetDirectory);
yield io.cp(path.join(compilerReleaseDirectory, `the${utils.binaryExtension()}`), compilerTargetLocation);
core.addPath(compilerTargetDirectory);
});
}
function download(version) {
return __awaiter(this, void 0, void 0, function* () {
core.debug(`Couldn't find The programming language ${version} in cache, downloading it ...`);
const tempDirectory = utils.tempDirectory();
const installationDirectory = path.join(tempDirectory, `the-${version}`);
const installationPath = yield tc.downloadTool(utils.cliUrl(version), path.join(installationDirectory, `the${utils.binaryExtension()}`));
const installationPath = yield tc.downloadTool(utils.cliUrl(version), path.join(installationDirectory, `the${utils.binaryExtension}`));
if (!utils.isWin) {
yield fs.chmod(installationPath, 0o755);
}
Expand All @@ -220,7 +65,7 @@ function run() {
let cachedPath = tc.find('the', version);
if (cachedPath.length === 0) {
cachedPath = yield download(version);
yield installCompiler(version);
yield (0, exec_1.exec)('the offline');
}
core.addPath(cachedPath);
core.setOutput('the-version', utils.installedVersion());
Expand Down Expand Up @@ -276,14 +121,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.tempDirectory = exports.platformName = exports.platformArch = exports.installedVersion = exports.homeDirectory = exports.dependenciesPath = exports.cliUrl = exports.binaryExtension = exports.isWin = void 0;
exports.tempDirectory = exports.platformName = exports.platformArch = exports.installedVersion = exports.cliUrl = exports.binaryExtension = exports.isWin = void 0;
const exec_1 = __nccwpck_require__(5236);
const path = __importStar(__nccwpck_require__(6928));
exports.isWin = process.platform === 'win32';
function binaryExtension() {
return exports.isWin ? '.exe' : '';
}
exports.binaryExtension = binaryExtension;
exports.binaryExtension = exports.isWin ? '.exe' : '';
function cliUrl(version) {
const platform = platformName();
const arch = platformArch();
Expand All @@ -297,24 +139,6 @@ function cliUrl(version) {
}
}
exports.cliUrl = cliUrl;
function dependenciesPath() {
const platform = platformName();
const arch = platformArch();
if (platform === 'macos') {
return path.join('native', platform, arch);
}
return path.join('native', platform);
}
exports.dependenciesPath = dependenciesPath;
function homeDirectory() {
var _a, _b;
const result = (_b = (_a = process.env.HOME) !== null && _a !== void 0 ? _a : process.env.USERPROFILE) !== null && _b !== void 0 ? _b : '';
if (result === '') {
throw new Error('HOME environment variable is not set');
}
return result;
}
exports.homeDirectory = homeDirectory;
function installedVersion() {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.2"
},
"devDependencies": {
Expand Down
89 changes: 0 additions & 89 deletions src/cmake.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/git.ts

This file was deleted.

Loading

0 comments on commit 27cd01b

Please sign in to comment.