forked from algorithm-archivists/algorithm-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using SCons tools (algorithm-archivists#977)
Changing the SCons architecture to clean up SConstruct and isolating languages more
- Loading branch information
Showing
7 changed files
with
209 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from SCons.Builder import Builder | ||
from SCons.Script import Move | ||
import SCons.Util | ||
|
||
class ToolCargoWarning(SCons.Warnings.SConsWarning): | ||
pass | ||
|
||
class CargoNotFound(ToolCargoWarning): | ||
pass | ||
|
||
SCons.Warnings.enableWarningClass(ToolCargoWarning) | ||
|
||
def _detect(env): | ||
try: | ||
return env['cargo'] | ||
except KeyError: | ||
pass | ||
|
||
cargo = env.WhereIs('cargo') | ||
if cargo: | ||
return cargo | ||
|
||
SCons.Warnings.warn(CargoNotFound, 'Could not detect cargo') | ||
|
||
def exists(env): | ||
return env.Detect('cargo') | ||
|
||
|
||
def generate(env): | ||
env['CARGO'] = _detect(env) | ||
env['CARGOFLAGS'] = [] | ||
env['MANIFEST'] = [] | ||
|
||
rust_cargo_builder = Builder( | ||
action=['"$CARGO" build $CARGOFLAGS --bins --manifest-path $MANIFEST', | ||
Move('$TARGET$PROGSUFFIX', | ||
'$SOURCE_DIR/target/debug/main$PROGSUFFIX') | ||
], | ||
suffix='$PROGSUFFIX', | ||
) | ||
env.Append(BUILDERS={'cargo': rust_cargo_builder}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from SCons.Builder import Builder | ||
import SCons.Util | ||
|
||
class ToolCocoWarning(SCons.Warnings.SConsWarning): | ||
pass | ||
|
||
class CoconutNotFound(ToolCocoWarning): | ||
pass | ||
|
||
SCons.Warnings.enableWarningClass(ToolCocoWarning) | ||
|
||
def _detect(env): | ||
try: | ||
return env['coconut'] | ||
except KeyError: | ||
pass | ||
|
||
coconut = env.WhereIs('coconut') | ||
if coconut: | ||
return coconut | ||
|
||
SCons.Warnings.warn(CoconutNotFound, 'Could not find Coconut executable') | ||
|
||
|
||
def generate(env): | ||
env['COCONUT'] = _detect(env) | ||
env['COCONUTFLAGS'] = [] | ||
|
||
coconut_compiler = Builder( | ||
action='"$COCONUT" $COCONUTFLAGS $SOURCE $TARGET', | ||
src_suffix='.coco', | ||
suffix='.py', | ||
) | ||
|
||
env.Append(BUILDERS={'Coconut': coconut_compiler}) | ||
|
||
def exists(env): | ||
return env.Detect('coconut') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from SCons.Builder import Builder | ||
import SCons.Util | ||
|
||
class ToolGoWarning(SCons.Warnings.SConsWarning): | ||
pass | ||
|
||
class GoNotFound(ToolGoWarning): | ||
pass | ||
|
||
SCons.Warnings.enableWarningClass(ToolGoWarning) | ||
|
||
def _detect(env): | ||
try: | ||
return env['go'] | ||
except KeyError: | ||
pass | ||
|
||
go = env.WhereIs('go') | ||
if go: | ||
return go | ||
|
||
SCons.Warnings.warn(GoNotFound, 'Could not find go executable') | ||
|
||
def exists(env): | ||
env.Detect('go') | ||
|
||
def generate(env): | ||
env['GO'] = _detect(env) | ||
env['GOFLAGS'] = [] | ||
|
||
go_builder = Builder( | ||
action='"$GO" build -o $TARGET $GOFLAGS $SOURCE', | ||
src_suffix='.go', | ||
suffix='$PROGSUFFIX', | ||
) | ||
|
||
env.Append(BUILDERS={'Go': go_builder}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from SCons.Builder import Builder | ||
import SCons.Util | ||
|
||
class ToolRustcWarning(SCons.Warnings.SConsWarning): | ||
pass | ||
|
||
class RustcNotFound(ToolRustcWarning): | ||
pass | ||
|
||
SCons.Warnings.enableWarningClass(ToolRustcWarning) | ||
|
||
def _detect(env): | ||
try: | ||
return env['rustc'] | ||
except KeyError: | ||
pass | ||
|
||
cargo = env.WhereIs('rustc') | ||
if cargo: | ||
return cargo | ||
|
||
SCons.Warnings.warn(RustcNotFound, 'Could not detect rustc') | ||
|
||
|
||
def exists(env): | ||
return env.Detect('rustc') | ||
|
||
def rustc_emitter(target, source, env): | ||
src_name = str(source[0]) | ||
pdb_name = src_name.replace(source[0].suffix, '.pdb') | ||
env.SideEffect(pdb_name, target) | ||
env.Clean(target, pdb_name) | ||
return (target, source) | ||
|
||
def generate(env): | ||
env['RUSTC'] = _detect(env) | ||
env['RUSTCFLAGS'] = [] | ||
|
||
rust_cargo_builder = Builder( | ||
action='"$RUSTC" $RUSTCFLAGS -o $TARGET $SOURCE', | ||
suffix='$PROGSUFFIX', | ||
src_suffix='.rs', | ||
emitter=rustc_emitter, | ||
) | ||
env.Append(BUILDERS={'rustc': rust_cargo_builder}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters