-
Notifications
You must be signed in to change notification settings - Fork 0
/
bxbuild
executable file
·54 lines (44 loc) · 1.94 KB
/
bxbuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
import argparse
import os
import shutil
import sys
from bxdev import compiler
from bxdev import util
def main():
"""Main function that does everything"""
parser = argparse.ArgumentParser(description="Compile projects for the BasicX programming language and microcontroller (see www.basicx.com)")
parser.add_argument("project", metavar="PROJECT", type=str, help="The full name and path of the BasicX project file (.bxp)")
parser.add_argument("-d", "--download", dest="download", action='store_true', help="Attempt to download project to the microcontroller after building.")
parser.add_argument("-t", "--target", dest="target", help="The build target for the project, valid targets are BX01, BX24, and BX25.", default="BX24")
args = parser.parse_args()
#Get the build target
target = util.getBuildTarget(args.target)
#Check to see if we are going to download the code
download = False
if args.download is True:
download = True
#Get the name and directory of the project
if not os.path.isfile(args.project):
print "Error: Specified project file (" + args.project + ") does not exist"
return
project, filename, directory = compiler.getProjectData(args.project)
#Set wine project dir if we're on *nix
wineDirectory = directory
if not sys.platform == "win32" and not sys.platform == "cygwin":
wineDirectory = compiler.pathToWine(directory)
#Access the registry (...should be platform independent, but I BET IT ISN'T) to get and set data
key = util.openBasicXKey()
success = compiler.setRegistryData(key, wineDirectory, target)
if not success:
print "Exiting..."
return
bxPath = compiler.getBasicXPath(key)
if bxPath is None:
print "Error: Unable to find an installation of the BasicX environment"
return
#Build the command to run, run it, and retrieve output
command = compiler.getCompilerCommand(bxPath, project, download)
compiler.runCompilerCommand(command, directory)
if __name__ == '__main__':
main()