Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use offline Cargo builds for Rust #561

Merged
merged 2 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .docker.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dmoj.citest import ci_test
from dmoj.executors import get_available

ALLOW_FAIL = {'GASARM', 'JAVA9', 'JAVA10', 'OBJC', 'RUST'}
ALLOW_FAIL = {'GASARM', 'JAVA9', 'JAVA10', 'OBJC'}
OVERRIDES = {}


Expand Down
6 changes: 5 additions & 1 deletion dmoj/executors/RUST.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from dmoj.executors.compiled_executor import CompiledExecutor
from dmoj.utils.os_ext import bool_env

CARGO_TOML = b'''\
[package]
Expand Down Expand Up @@ -88,7 +89,10 @@ def get_versionable_commands(cls):
return [('rustc', os.path.join(os.path.dirname(cls.get_command()), 'rustc'))]

def get_compile_args(self):
return [self.get_command(), 'build', '--release']
args = [self.get_command(), 'build', '--release']
if bool_env('DMOJ_CARGO_OFFLINE'):
args += ['--offline']
return args

def get_compiled_file(self):
return self._file('target', 'release', 'user_submission')
5 changes: 5 additions & 0 deletions dmoj/utils/os_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ def file_arch(path):


INTERPRETER_ARCH = file_arch(sys.executable)


def bool_env(name):
value = os.environ.get(name, '')
return value.lower() in ('true', 'yes', '1', 'y', 't')