Skip to content
Open
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
37 changes: 37 additions & 0 deletions Logos-Xcode/src/AdditionalLanguages.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Xcode.SourceCodeLanguage.Logos</key>
<dict>
<key>languageSpecification</key>
<string>xcode.lang.logos</string>
<key>fileDataType</key>
<array>
<dict>
<key>identifier</key>
<string>com.apple.xcode.logos-source</string>
</dict>
</array>
<key>id</key>
<string>Xcode.SourceCodeLanguage.Logos</string>
<key>point</key>
<string>Xcode.SourceCodeLanguage</string>
<key>languageName</key>
<string>Logos</string>
<key>version</key>
<string>1.0</string>
<key>documentationAbbreviation</key>
<string>logos</string>
<key>conformsTo</key>
<array>
<dict>
<key>identifier</key>
<string>Xcode.SourceCodeLanguage.Generic</string>
</dict>
</array>
<key>name</key>
<string>Logos Language</string>
</dict>
</dict>
</plist>
Empty file added Logos-Xcode/src/Logos.xc
Empty file.
15 changes: 15 additions & 0 deletions Logos-Xcode/src/Logos.xcspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Logos.xcspec: Xcode file type for Logos
*
**/

(
{
Type = FileType;
Identifier = sourcecode.logos;
BasedOn = sourcecode;
Name = "Logos file";
Extensions = ( xm );
Language = "xcode.lang.logos";
}
)
74 changes: 74 additions & 0 deletions Logos-Xcode/src/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

#
# pr0crustes version.
# Edited version of the work of Tiago Bastos and Alex Karahalios.
# Last edited 15/9/2018
#

set -e

# Path were this script is located
Script_Path="/opt/MonkeyDev/Logos-Xcode/src"
# "$(dirname "$(realpath "$0")")"

# Checks if has enought permission
echo "Checking Permissions..."
if [ $EUID -ne 0 ]; then
echo "$0 needs to be run as root."
echo " Check README for info."
echo " Aborting..."
exit 2
fi

# Assumes Xcode 4+.
echo "Checking Xcode..."
XCODE_MAJOR_VERSION=`xcodebuild -version | awk 'NR == 1 {print int($2)}'`
if [ "$XCODE_MAJOR_VERSION" -lt "4" ]; then
echo "Xcode 4+ not found."
exit 1
fi

# Check if Logos.xclangspec is present in the same folder
echo "Finding Logos.xclangspec..."
if [ ! -f $Script_Path/Logos.xclangspec ]; then
echo "Logos.xclangspec was not found."
echo "You probably forgot to run 'python(3) xclangspec_generator.py'"
exit 1
fi


echo "It's highly recommended that, if you are installing for the first time, you make a backup of the folder /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources"
while true; do
read -p "Do you wish to continue? (Y)es, (N)o " yn
case $yn in
[Yy]*)
# This framework is found withing the Xcode.app package and is used when Xcode is a monolithic install (all contained in Xcode.app)
DVTFountain_Path="/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/"

# Backup
cp "$DVTFountain_Path/DVTFoundation.xcplugindata" "$DVTFountain_Path/DVTFoundation.xcplugindata.bak"

# Now merge in the additonal languages to DVTFoundation.xcplugindata
echo "Merging..."
/usr/libexec/PlistBuddy "$DVTFountain_Path/DVTFoundation.xcplugindata" -c "Merge $Script_Path/AdditionalLanguages.plist plug-in:extensions"

# Copy in the xclangspecs for the languages (assumes in same directory as this shell script)
cp "$Script_Path/Logos.xclangspec" "$DVTFountain_Path"

# Remove any cached Xcode plugins
rm -rf /private/var/folders/*/*/*/com.apple.DeveloperTools/*/Xcode/PlugInCache.xcplugincache

# Final message
echo "Sucessfully Installed."
echo "Syntax coloring must be manually selected from the Editor - Syntax Coloring menu in Xcode."
exit 0
;;
[Nn]*)
echo "Exiting..."
exit 1
;;
*)
;;
esac
done
91 changes: 91 additions & 0 deletions Logos-Xcode/src/xclangspec_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
'''
#
# Run with python3
# Script that generates the Logos xclangspec
#
# xclangspec_generator is a script created by pr0crustes (https://github.com/pr0crustes)
# that is provided as it is, without any warranty.
# pr0crustes @ 2018 - all rights reserved.
#
'''
import os

global_new_keywords = [
"// Start Logos Keywords",
"%group",
"%hook",
"%new",
"%subclass",
"%property",
"%end",
"%config",
"%hookf",
"%ctor",
"%dtor",
"%init",
"%class",
"%c",
"%orig",
"%log",
"// End Logos Keywords",
"// Start Other Keywords",
"NSLog",
"NSString",
"NSInteger",
"NSObject",
"// End Other Keywords"
]


global_ident1 = "Words = ("
global_ident2 = "Chars = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_\";"
global_ident3 = "StartChars = \"@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\";"


class XClangGenerator(object):

def __init__(self):
self.objc_spec_file = "/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/ObjectiveC.xclangspec"
self.objc_spec_content = []
self.new_lines = []

def __get_loaded_file(self):
print("Reading File...")
for line in open(self.objc_spec_file, 'r'):
if line.strip() and not line.strip().startswith("/"):
self.objc_spec_content.append(line)

def __get_parsed_file(self):
print("Parsing File...")
for i in range(len(self.objc_spec_content)):
line = self.objc_spec_content[i].replace("objc", "logos")
self.new_lines.append(line)
if global_ident1 in line and i > 3 and global_ident2 in self.objc_spec_content[i-1] and global_ident3 in self.objc_spec_content[i-2]:
print("Inserting Logos Keywords Into New File...")
for new_word in global_new_keywords:
if new_word.strip().startswith("//"):
self.new_lines.append("\t\t\t\t" + new_word + "\n")
else:
self.new_lines.append("\t\t\t\t\"" + new_word + "\",\n")

def __save_file(self):
print("Saving New File...")
with open("Logos.xclangspec", "w") as file:
file.write("// Logos xclangspec was generated by spec_gen\n")
file.write("// Script made by pr0crustes\n")
for line in self.new_lines:
file.write(line)

def execute(self):
self.__get_loaded_file()
self.__get_parsed_file()
self.__save_file()
print("XClangSpec Generator was successfully runned.")


if __name__ == '__main__':

os.rename("/opt/MonkeyDev/Logos-Xcode/src/Logos.xc", "/opt/MonkeyDev/Logos-Xcode/src/Logos.xclangspec")
gen = XClangGenerator()
gen.execute()

14 changes: 14 additions & 0 deletions bin/md-install
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,18 @@ function writeDictToSpecification(){ #args: filePath, content
/usr/libexec/PlistBuddy -x -c "merge $tempfile 0" "$filePath" > /dev/null
}

# 安裝Logos語法高亮
function installXcode10LogosSupports(){

echo "install Xcode10 Logos Supports..."
chmod +x $MonkeyDevPath/Logos-Xcode/src/xclangspec_generator.py
python $MonkeyDevPath/Logos-Xcode/src/xclangspec_generator.py
chmod +x $MonkeyDevPath/Logos-Xcode/src/install.sh
sudo sh -x $MonkeyDevPath/Logos-Xcode/src/install.sh

}


# start it
# 创建/opt/MonkeyDev
mkdir -p "$MonkeyDevPath" || \
Expand Down Expand Up @@ -374,4 +386,6 @@ if [[ $hasProductTypeForCommandLineTool != "true" ]]; then
writeDictToSpecification "$specificationFile" "$toolDict"
fi

installXcode10LogosSupports

exit 0