Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mplab2makefile
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Franco (nextime) Lanza
mplab2makefile
Commits
97152deb
Commit
97152deb
authored
May 01, 2015
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first commit
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
0 deletions
+105
-0
mplab2makefile.py
mplab2makefile.py
+105
-0
No files found.
mplab2makefile.py
0 → 100755
View file @
97152deb
#!/usr/bin/env python
from
ConfigParser
import
SafeConfigParser
as
cp
import
sys
import
os
def
main
(
mcp
):
c
=
cp
()
try
:
c
.
read
(
mcp
)
pname
=
mcp
[:
-
4
]
f
=
open
(
"Makefile"
,
"w"
)
f
.
write
(
"# Makefile generated by mplab2makefile
\n\n
"
)
f
.
write
(
"CC=mcc18
\n
"
)
f
.
write
(
"LD=mplink
\n
"
)
f
.
write
(
"AS=MPASMWIN
\n
"
)
f
.
write
(
"AR=mplib
\n
"
)
f
.
write
(
"RM=rm
\n\n
"
)
outdirs
=
c
.
get
(
"PATH_INFO"
,
"dir_bin"
)
objdirs
=
c
.
get
(
"PATH_INFO"
,
"dir_tmp"
)
incdirs
=
c
.
get
(
"PATH_INFO"
,
"dir_inc"
)
lkrdirs
=
c
.
get
(
"PATH_INFO"
,
"dir_lkr"
)
libdirs
=
c
.
get
(
"PATH_INFO"
,
"dir_lib"
)
mcu
=
c
.
get
(
"HEADER"
,
"device"
)
.
replace
(
"PIC"
,
""
)
f
.
write
(
"MCU="
+
mcu
+
"
\n
"
)
if
outdirs
==
""
:
outdirs
=
"."
else
:
outdirs
=
outdirs
.
replace
(
"
\\
"
,
"/"
)
if
objdirs
==
""
:
objdirs
=
"."
else
:
objdirs
=
objdirs
.
replace
(
"
\\
"
,
"/"
)
f
.
write
(
"BINDIR_="
+
outdirs
+
"/
\n
"
)
f
.
write
(
"NAME="
+
pname
+
"
\n
"
)
f
.
write
(
"#VERSION=0.1
\n
"
)
f
.
write
(
"#DATE=$(shell date -I)
\n
"
)
f
.
write
(
"#TARGETBASE=${NAME}-v${VERSION}_build-${DATE}
\n\n
"
)
f
.
write
(
"TARGETBASE=${NAME}
\n\n
"
)
includes
=
""
for
inc
in
incdirs
.
split
(
";"
):
if
len
(
includes
)
==
0
:
includes
+=
"
\"
"
+
inc
.
replace
(
"
\\
"
,
"/"
)
+
"
\"
"
else
:
includes
+=
" -I
\"
"
+
inc
.
replace
(
"
\\
"
,
"/"
)
+
"
\"
"
f
.
write
(
"INCLUDES="
+
includes
+
"
\n
"
)
f
.
write
(
"CFLAGS= -k -sco -mL
\n\n
"
)
clist
=
[]
hlist
=
[]
llist
=
[]
lkr
=
False
for
idx
,
cf
in
c
.
items
(
"FILE_INFO"
):
cf
=
cf
.
replace
(
"
\\
"
,
"/"
)
.
replace
(
" "
,
"
\\
"
)
if
cf
[
-
1
:]
==
'c'
:
clist
.
append
(
cf
)
elif
cf
[
-
1
:]
==
'h'
:
hlist
.
append
(
cf
)
elif
cf
[
-
3
:]
==
'lib'
:
llist
.
append
(
cf
)
elif
cf
[
-
3
:]
==
'lkr'
:
lkr
=
cf
f
.
write
(
"build:
\n
"
)
for
cfile
in
clist
:
f
.
write
(
"
\t
$(CC) -p=${MCU} /i${INCLUDES}
\"
"
+
cfile
+
"
\"
-fo=
\"
"
+
objdirs
+
"/"
+
os
.
path
.
basename
(
cfile
)[:
-
1
]
+
"o
\"
${CFLAGS}
\n
"
)
f
.
write
(
"
\n
"
)
f
.
write
(
"
\t
${LD} /p${MCU} /l
\"
"
+
libdirs
.
replace
(
"
\\
"
,
"/"
)
+
"
\"
"
)
if
lkr
:
f
.
write
(
"
\"
"
+
lkr
+
"
\"
"
)
f
.
write
(
"
\\\n
"
)
for
cfile
in
clist
:
f
.
write
(
"
\t\t\"
"
+
objdirs
+
"/"
+
os
.
path
.
basename
(
cfile
)[:
-
1
]
+
"o
\"
\\\n
"
)
for
lfile
in
llist
:
f
.
write
(
"
\t\t\"
"
+
lfile
+
"
\"
\\\n
"
)
f
.
write
(
"
\t\t
/u_CRUNTIME /z__MPLAB_BUILD=1 /m
\"
${BINDIR_}/${TARGETBASE}.map
\"
/w /o
\"
${BINDIR_}/${TARGETBASE}.cof
\"
/i"
)
f
.
write
(
"
\n\n
"
)
f
.
write
(
"clean:
\n
"
)
f
.
write
(
"
\t
${RM} "
+
objdirs
+
"/*.o
\n
"
)
f
.
write
(
"
\t
${RM} ${BINDIR_}/*.cof ${BINDIR_}/*.lst ${BINDIR_}/*.map ${BINDIR_}/*.hex
\n
"
)
except
:
print
'this isn
\'
t a valid MPLAB Project file!'
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
>
1
:
mcp
=
sys
.
argv
[
1
]
if
os
.
path
.
isfile
(
mcp
):
main
(
mcp
)
else
:
print
mcp
+
" Is not a file!"
else
:
print
"please tell me where is the file to open!"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment