From e9183b88775e8f0e8d5163d89388fb8047b2540a Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Tue, 12 Jun 2018 23:27:01 -0400 Subject: [PATCH] Add a plugin to provide cc65 assembly syntax highlighting. Fix the C file template so the guards work. Supporting adding extra directories to look for source files to build. --- Makefile | 10 +- make/head.mk | 3 +- make/tail.mk | 7 +- .../cc65.ideplugin/Contents/Info.plist | 36 ++ .../Contents/Resources/cc65.xcplugindata | 83 +++++ pkg/Specifications/ca65.xclangspec | 334 ++++++++++++++++++ .../Apple II Asm Project.xctemplate/main.s | 5 +- .../TemplateInfo.plist | 8 +- .../___FILEBASENAME___.s | 2 +- .../Default/___FILEBASENAME___.c | 2 +- .../WithHeader/___FILEBASENAME___.c | 2 +- .../WithHeader/___FILEBASENAME___.h | 8 +- pkg/createPackage | 15 +- pkg/scripts/postinstall | 3 + 14 files changed, 489 insertions(+), 29 deletions(-) create mode 100755 pkg/Plug-ins/cc65.ideplugin/Contents/Info.plist create mode 100755 pkg/Plug-ins/cc65.ideplugin/Contents/Resources/cc65.xcplugindata create mode 100644 pkg/Specifications/ca65.xclangspec create mode 100755 pkg/scripts/postinstall diff --git a/Makefile b/Makefile index 197fffd..4727205 100644 --- a/Makefile +++ b/Makefile @@ -48,13 +48,9 @@ PGM=___PACKAGENAME___ # Note: You can assemble for 65816 in 16-bit mode but the C compiler # will only produce 8-bit code. -# Any *.c files in your main project directory will automatically be -# built. But, if you have subdirectories with C files in them, you -# should add them to the list of C_SRCS to build. Do that by -# uncommenting the following line and changing "someSubDir" to match -# the subdirectory you have created. Add multiple lines like this -# for each subdirectory: -# C_SRCS += $(wildcard someSubDir/*.c) +# Add any other directories where you are putting C or assembly source +# files to this list: +SRCDIRS+= # Any *.s files in your main project directory will automatically be # built. But, if you have subdirectories with assembly files in them, diff --git a/make/head.mk b/make/head.mk index 0710ce8..410608f 100644 --- a/make/head.mk +++ b/make/head.mk @@ -20,8 +20,7 @@ CC65=$(CC65_BIN)/cc65 AC=make/AppleCommander.jar -C_SRCS=$(wildcard *.c) -ASM_SRCS=$(wildcard *.s) +SRCDIRS=. MACHINE=apple2 CPU=6502 diff --git a/make/tail.mk b/make/tail.mk index 4bca120..29d6f5d 100644 --- a/make/tail.mk +++ b/make/tail.mk @@ -14,10 +14,14 @@ export PATH := $(PATH):$(CC65_BIN) CWD=$(shell pwd) +C_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.c, $(SRCDIRS)))) C_OBJS=$(C_SRCS:.c=.o) C_DEPS=$(C_SRCS:.c=.u) + +ASM_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.s, $(SRCDIRS)))) ASM_OBJS=$(ASM_SRCS:.s=.o) ASM_LSTS=$(ASM_SRCS:.s=.lst) + OBJS=$(C_OBJS) $(ASM_OBJS) MAPFILE=$(PGM).map @@ -79,9 +83,6 @@ clean: rm -f $(ASM_LSTS) rm -f "$(DISKIMAGE)" -createPackage: - pkg/createPackage - cleanMacCruft: rm -rf pkg diff --git a/pkg/Plug-ins/cc65.ideplugin/Contents/Info.plist b/pkg/Plug-ins/cc65.ideplugin/Contents/Info.plist new file mode 100755 index 0000000..7623c1a --- /dev/null +++ b/pkg/Plug-ins/cc65.ideplugin/Contents/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleIdentifier + com.rand-family.xcode.cc65 + CFBundleName + cc65 Xcode Plug-in + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + CFBundlePackageType + BNDL + CFBundleSignature + ???? + CFBundleDevelopmentRegion + English + CFBundleSupportedPlatforms + + MacOSX + + DVTPlugInCompatibilityUUIDs + + DF11C142-1584-4A99-87AC-1925D5F5652A + 8A66E736-A720-4B3C-92F1-33D9962C69DF + 65C57D32-1E9B-44B8-8C04-A27BA7AAE2C4 + DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 + E0A62D1F-3C18-4D74-BFE5-A4167D643966 + DFFB3951-EB0A-4C09-9DAC-5F2D28CC839C + CA351AD8-3176-41CB-875C-42A05C7CDEC7 + + + diff --git a/pkg/Plug-ins/cc65.ideplugin/Contents/Resources/cc65.xcplugindata b/pkg/Plug-ins/cc65.ideplugin/Contents/Resources/cc65.xcplugindata new file mode 100755 index 0000000..b1d74b7 --- /dev/null +++ b/pkg/Plug-ins/cc65.ideplugin/Contents/Resources/cc65.xcplugindata @@ -0,0 +1,83 @@ + + + + + plug-in + + extensions + + Xcode.FileDataType.ca65.Assembly + + id + Xcode.FileDataType.ca65.Assembly + localizedDescription + ca65 Assembly Source + name + File type for ca65 assembly + point + Xcode.FileDataType + typeConformedTo + + + typeIdentifier + public.assembly-source + + + typeIdentifier + com.rand-family.xcode.ca65 + version + 1.0 + + Xcode.FileDataTypeDetector.ca65.Assembly + + detectedTypeIdentifier + com.rand-family.xcode.ca65 + id + Xcode.FileDataTypeDetector.ca65.Assembly + matchesExtension + s + point + Xcode.FileDataTypeDetector + + Xcode.SourceCodeLanguage.ca65-Assembly + + commentSyntax + + + prefix + ; + + + conformsTo + + + identifier + Xcode.SourceCodeLanguage.Generic + + + fileDataType + + + identifier + com.rand-family.xcode.ca65 + + + id + Xcode.SourceCodeLanguage.ca65-Assembly + languageName + ca65 Assembly + languageSpecification + xcode.lang.asm.ca65 + name + ca65 Assembly + point + Xcode.SourceCodeLanguage + supportsIndentation + true + version + 1.0 + + + + + diff --git a/pkg/Specifications/ca65.xclangspec b/pkg/Specifications/ca65.xclangspec new file mode 100644 index 0000000..3c0b796 --- /dev/null +++ b/pkg/Specifications/ca65.xclangspec @@ -0,0 +1,334 @@ +// ca65 Assembler language specs +( + +/****************************************************************************/ +// MARK: Keywords +/****************************************************************************/ + + { + Identifier = "xcode.lang.asm.ca65.identifier"; + Syntax = { + CaseSensitive = NO; + StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@"; + Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + Type = "xcode.syntax.identifier"; + }; + }, + + { + Identifier = "xcode.lang.asm.ca65.keyword"; + Syntax = { + CaseSensitive = NO; + StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_~"; + Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~"; + Words = ( + "adc", + "and", + "asl", + "bcc", + "bcs", + "beq", + "bge", + "bit", + "blt", + "bmi", + "bne", + "bpl", + "bra", + "brk", + "brl", + "bvc", + "bvs", + "clc", + "cld", + "cli", + "clv", + "cmp", + "cop", + "cpa", + "cpx", + "cpy", + "dec", + "dex", + "dey", + "eor", + "inc", + "inx", + "iny", + "jmp", + "jsl", + "jsr", + "lda", + "ldx", + "ldy", + "lsr", + "mvn", + "mvp", + "nop", + "ora", + "pea", + "pei", + "per", + "pha", + "phb", + "phd", + "phk", + "php", + "phx", + "phy", + "pla", + "plb", + "pld", + "plp", + "plx", + "ply", + "rep", + "rol", + "ror", + "rti", + "rtl", + "rts", + "sbc", + "sec", + "sed", + "sei", + "sep", + "sta", + "stp", + "stx", + "sty", + "stz", + "tax", + "tay", + "tcd", + "tcs", + "tdc", + "trb", + "tsb", + "tsc", + "tsx", + "txa", + "txs", + "txy", + "tya", + "tyx", + "wai", + "wdm", + "xba", + "xce", + + ".asize", + ".cpu", + ".isize", + ".paramcount", + ".time", + ".version", + + ".addrsize", + ".bank", + ".bankbyte", + ".blank", + ".concat", + ".const", + ".hibyte", + ".hiword", + ".ident", + ".left", + ".lobyte", + ".loword", + ".match", + ".max", + ".mid", + ".min", + ".ref", + ".referenced", + ".right", + ".sizeof", + ".strat", + ".sprintf", + ".string", + ".strlen", + ".tcount", + ".xmatch", + + ".a16", + ".a8", + ".addr", + ".align", + ".asciiz", + ".assert", + ".autoimport", + ".bankbytes", + ".bss", + ".byt", + ".byte", + ".case", + ".charmap", + ".code", + ".condes", + ".constructor", + ".data", + ".dbyt", + ".debuginfo", + ".define", + ".delmac", + ".delmacro", + ".def", + ".defined", + ".definemacro", + ".destructor", + ".dword", + ".else", + ".elseif", + ".end", + ".endenum", + ".endif", + ".endmac", + ".endmacro", + ".endproc", + ".endrep", + ".endrepeat", + ".endscope", + ".endstruct", + ".endunion", + ".enum", + ".error", + ".exitmac", + ".exitmacro", + ".export", + ".exportzp", + ".faraddr", + ".fatal", + ".feature", + ".fileopt", + ".fopt", + ".forceimport", + ".global", + ".globalzp", + ".hibytes", + ".i16", + ".i8", + ".if", + ".ifblank", + ".ifconst", + ".ifdef", + ".ifnblank", + ".ifndef", + ".ifnref", + ".ifp02", + ".ifp4510", + ".ifp816", + ".ifpc02", + ".ifpsc02", + ".ifref", + ".import", + ".importzp", + ".incbin", + ".include", + ".interruptor", + ".ismnem", + ".ismnemonic", + ".linecont", + ".list", + ".listbytes", + ".lobytes", + ".local", + ".localchar", + ".macpack", + ".mac", + ".macro", + ".org", + ".out", + ".p02", + ".p4510", + ".p816", + ".pagelen", + ".pagelength", + ".pc02", + ".popcpu", + ".popseg", + ".proc", + ".psc02", + ".pushcpu", + ".pushseg", + ".reloc", + ".repeat", + ".res", + ".rodata", + ".scope", + ".segment", + ".set", + ".setcpu", + ".smart", + ".struct", + ".tag", + ".undef", + ".undefine", + ".union", + ".warning", + ".word", + ".zeropage" + ); + Type = "xcode.syntax.keyword"; + AltType = "xcode.syntax.identifier"; + }; + }, + +/****************************************************************************/ +// MARK: Simple Syntax Coloring +/****************************************************************************/ + + { + Identifier = "xcode.lang.asm.ca65"; + Description = "ca65 Assembler Coloring"; + BasedOn = "xcode.lang.simpleColoring"; + IncludeInMenu = YES; + Name = "Assembly (ca65)"; + Syntax = { + Tokenizer = "xcode.lang.asm.ca65.lexer"; + IncludeRules = ( + "xcode.lang.asm.ca65.codeblock", + ); + Type = "xcode.syntax.plain"; + }; + }, + { + Identifier = "xcode.lang.asm.ca65.lexer"; + Syntax = { + IncludeRules = ( + "xcode.lang.asm.ca65.comment.semi", + "xcode.lang.string", + "xcode.lang.character", + "xcode.lang.number", + "xcode.lang.asm.ca65.keyword", + "xcode.lang.asm.ca65.identifier", + ); + }; + }, + + { + Identifier = "xcode.lang.asm.ca65.comment.semi"; + Syntax = { + StartAtBOL = YES; + StartAtColumnZero = YES; + Start = ";"; + End = "\n"; + IncludeRules = ( "xcode.lang.url", "xcode.lang.url.mail", "xcode.lang.comment.mark" ); + Type = "xcode.syntax.comment"; + }; + }, + + { + Identifier = "xcode.lang.asm.ca65.codeblock"; + Syntax = { + Tokenizer = "xcode.lang.asm.ca65.lexer"; + Start = ".proc"; + End = ".endproc"; + Recursive = NO; + Foldable = YES; + Type = "xcode.syntax.definition.function"; + IncludeRules = ( + ); + }; + }, +) diff --git a/pkg/Templates/Apple II/Apple II Asm Project.xctemplate/main.s b/pkg/Templates/Apple II/Apple II Asm Project.xctemplate/main.s index ac4ec38..96ac6fe 100644 --- a/pkg/Templates/Apple II/Apple II Asm Project.xctemplate/main.s +++ b/pkg/Templates/Apple II/Apple II Asm Project.xctemplate/main.s @@ -3,7 +3,7 @@ ; ___PROJECTNAME___ ; ; Created by ___FULLUSERNAME___ on ___DATE___. -;___COPYRIGHT___ +; ___COPYRIGHT___ ; @@ -11,7 +11,7 @@ COUT = $fded KEYBOARD = $c000 STROBE = $c010 -main: +.proc main ldx #$00 loop: lda msg, X @@ -26,5 +26,6 @@ wait: bpl wait lda STROBE rts +.endproc msg: .asciiz "HELLO, WORLD" diff --git a/pkg/Templates/File Templates/Apple II/Assembly File.xctemplate/TemplateInfo.plist b/pkg/Templates/File Templates/Apple II/Assembly File.xctemplate/TemplateInfo.plist index ea02c9e..b607635 100644 --- a/pkg/Templates/File Templates/Apple II/Assembly File.xctemplate/TemplateInfo.plist +++ b/pkg/Templates/File Templates/Apple II/Assembly File.xctemplate/TemplateInfo.plist @@ -1,7 +1,11 @@ - + + AllowedTypes + + com.rand-family.xcode.ca65 + DefaultCompletionName File Description @@ -12,5 +16,5 @@ ___FILEBASENAME___.s Summary An assembly source file - + diff --git a/pkg/Templates/File Templates/Apple II/Assembly File.xctemplate/___FILEBASENAME___.s b/pkg/Templates/File Templates/Apple II/Assembly File.xctemplate/___FILEBASENAME___.s index b03c9e2..156c233 100755 --- a/pkg/Templates/File Templates/Apple II/Assembly File.xctemplate/___FILEBASENAME___.s +++ b/pkg/Templates/File Templates/Apple II/Assembly File.xctemplate/___FILEBASENAME___.s @@ -3,5 +3,5 @@ ; ___PROJECTNAME___ ; ; Created by ___FULLUSERNAME___ on ___DATE___. -;___COPYRIGHT___ +; ___COPYRIGHT___ ; diff --git a/pkg/Templates/File Templates/Apple II/C File.xctemplate/Default/___FILEBASENAME___.c b/pkg/Templates/File Templates/Apple II/C File.xctemplate/Default/___FILEBASENAME___.c index 8743098..352f773 100644 --- a/pkg/Templates/File Templates/Apple II/C File.xctemplate/Default/___FILEBASENAME___.c +++ b/pkg/Templates/File Templates/Apple II/C File.xctemplate/Default/___FILEBASENAME___.c @@ -3,7 +3,7 @@ // ___PROJECTNAME___ // // Created by ___FULLUSERNAME___ on ___DATE___. -//___COPYRIGHT___ +// ___COPYRIGHT___ // #include diff --git a/pkg/Templates/File Templates/Apple II/C File.xctemplate/WithHeader/___FILEBASENAME___.c b/pkg/Templates/File Templates/Apple II/C File.xctemplate/WithHeader/___FILEBASENAME___.c index 8922fef..045751f 100644 --- a/pkg/Templates/File Templates/Apple II/C File.xctemplate/WithHeader/___FILEBASENAME___.c +++ b/pkg/Templates/File Templates/Apple II/C File.xctemplate/WithHeader/___FILEBASENAME___.c @@ -3,7 +3,7 @@ // ___PROJECTNAME___ // // Created by ___FULLUSERNAME___ on ___DATE___. -//___COPYRIGHT___ +// ___COPYRIGHT___ // #include "___FILEBASENAME___.h" diff --git a/pkg/Templates/File Templates/Apple II/C File.xctemplate/WithHeader/___FILEBASENAME___.h b/pkg/Templates/File Templates/Apple II/C File.xctemplate/WithHeader/___FILEBASENAME___.h index a5112a0..ee8f92e 100644 --- a/pkg/Templates/File Templates/Apple II/C File.xctemplate/WithHeader/___FILEBASENAME___.h +++ b/pkg/Templates/File Templates/Apple II/C File.xctemplate/WithHeader/___FILEBASENAME___.h @@ -3,12 +3,12 @@ // ___PROJECTNAME___ // // Created by ___FULLUSERNAME___ on ___DATE___. -//___COPYRIGHT___ +// ___COPYRIGHT___ // -#ifndef _____PROJECTNAMEASIDENTIFIER________FILEBASENAMEASIDENTIFIER_____ -#define _____PROJECTNAMEASIDENTIFIER________FILEBASENAMEASIDENTIFIER_____ +#ifndef _GUARD_PROJECT___PROJECTNAMEASIDENTIFIER____FILE___FILEBASENAMEASIDENTIFIER____ +#define _GUARD_PROJECT___PROJECTNAMEASIDENTIFIER____FILE___FILEBASENAMEASIDENTIFIER____ -#endif /* defined(_____PROJECTNAMEASIDENTIFIER________FILEBASENAMEASIDENTIFIER_____) */ +#endif /* define _GUARD_PROJECT___PROJECTNAMEASIDENTIFIER____FILE___FILEBASENAMEASIDENTIFIER____ */ diff --git a/pkg/createPackage b/pkg/createPackage index a46dbf5..53977c2 100755 --- a/pkg/createPackage +++ b/pkg/createPackage @@ -2,16 +2,19 @@ TMPDIR=/tmp/pkg.$$ +mkdir $TMPDIR cp -R pkg/Templates $TMPDIR +cp -R pkg/Specifications $TMPDIR +cp -R pkg/Plug-ins $TMPDIR -cp -R make $TMPDIR/'Apple II/Apple II C Project.xctemplate/' -cp Makefile $TMPDIR/'Apple II/Apple II C Project.xctemplate/' -cp main.c $TMPDIR/'Apple II/Apple II C Project.xctemplate/' +cp -R make $TMPDIR/Templates/'Apple II/Apple II C Project.xctemplate/' +cp Makefile $TMPDIR/Templates/'Apple II/Apple II C Project.xctemplate/' +cp main.c $TMPDIR/Templates/'Apple II/Apple II C Project.xctemplate/' -cp -R make $TMPDIR/'Apple II/Apple II Asm Project.xctemplate/' -cp Makefile $TMPDIR/'Apple II/Apple II Asm Project.xctemplate/' +cp -R make $TMPDIR/Templates/'Apple II/Apple II Asm Project.xctemplate/' +cp Makefile $TMPDIR/Templates/'Apple II/Apple II Asm Project.xctemplate/' -pkgbuild --root $TMPDIR --version 1.4 --identifier com.halcyontouch.Apple2Template.pkg --install-location /Library/Developer/Xcode/Templates/ --scripts pkg/scripts/ AppleXcodeTemplate.pkg +pkgbuild --root $TMPDIR --version 2.0 --identifier com.halcyontouch.Apple2Template.pkg --install-location /Library/Developer/Xcode/ --scripts pkg/scripts/ AppleXcodeTemplate.pkg productbuild --distribution pkg/Distribution.xml --resource ./pkg temp.pkg rm AppleXcodeTemplate.pkg productsign --sign "Developer ID Installer" temp.pkg AppleXcodeTemplate.pkg diff --git a/pkg/scripts/postinstall b/pkg/scripts/postinstall new file mode 100755 index 0000000..67e9beb --- /dev/null +++ b/pkg/scripts/postinstall @@ -0,0 +1,3 @@ +#!/bin/bash + +defaults write ~/Library/Developer/Xcode/Plug-ins/cc65.ideplugin/Contents/Info.plist DVTPlugInCompatibilityUUIDs -array $(defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID)