Skip to content

Commit

Permalink
Added selection for newlib-nano independently of optimization setting
Browse files Browse the repository at this point in the history
  • Loading branch information
luni64 committed Oct 17, 2021
1 parent d69f18c commit f526337
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 10 deletions.
4 changes: 2 additions & 2 deletions VisualTeensy/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.3")]
[assembly: AssemblyFileVersion("1.3.3")]
[assembly: AssemblyVersion("1.4.0")]
[assembly: AssemblyFileVersion("1.4.0")]
[assembly: NeutralResourcesLanguage("en")]

17 changes: 16 additions & 1 deletion VisualTeensy/ViewModel/ProjectTab/ProjectTabVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,22 @@ public LibStrategy coreStragegy
}
}
}


public StdLibType stdLib
{
get => project.selectedConfiguration.stdLib;
set
{
if (value != project.selectedConfiguration.stdLib)
{
project.selectedConfiguration.stdLib = value;
updateFiles();
OnPropertyChanged("");
}
}
}


public string makefileExtension
{
get => project.selectedConfiguration.makefileExtension;
Expand Down
11 changes: 10 additions & 1 deletion VisualTeensy/Views/ProjectTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ d:DesignHeight="800" d:DesignWidth="1000">

<!--Expert Setup ____________________________________-->
<StackPanel Grid.Row="4" Grid.ColumnSpan="2" Width="auto" Margin="0,1,0,0" Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=radioButton1}" x:Name="Expert_Settings">
<!--<StackPanel Grid.Row="4" Grid.ColumnSpan="2" Width="auto" Margin="0,1,0,0" Visibility="Visible" x:Name="Expert_Settings">-->
<!--<Label Content="boards.txt " FontSize="12" FontWeight="SemiBold" Padding="0" />
<local:PSelector SelectedPath="{Binding boardTxtPath, ValidatesOnDataErrors=True}" Style="{DynamicResource ValidatingControl}" />
<CheckBox Content="Copy to project folder (recommended)" FontSize="10" IsChecked="{Binding copyBoardTxt}"/>-->

<Label Content="Compiler (gcc-arm-none-eabi):" FontWeight="SemiBold" FontSize="12" Foreground="{DynamicResource PrimaryHueDarkBrush}" Padding="0" Margin="0,25,0,0" />
<Label Content="Compiler (gcc-arm-none-eabi):" FontWeight="SemiBold" FontSize="12" Foreground="{DynamicResource PrimaryHueDarkBrush}" Padding="0" Margin="0,20,0,0" />
<local:PSelector SelectedPath="{Binding compilerPath, ValidatesOnDataErrors=True}" Style="{DynamicResource ValidatingControl}" isFolderDialog="True" />

<Label Content="Teensyduino core" FontSize="12" FontWeight="SemiBold" Foreground="{DynamicResource PrimaryHueDarkBrush}" Padding="0" Margin="0,20,0,5" />
Expand All @@ -132,6 +133,14 @@ d:DesignHeight="800" d:DesignWidth="1000">
GroupName="core"
Margin="10,5,0.4,0"
IsChecked="{Binding coreStragegy, ConverterParameter={x:Static if:LibStrategy.clone}, Converter={StaticResource EnumBooleanConverter}}"/>

<Label Content="Override standard libraries (libc and libc++)" FontWeight="SemiBold" FontSize="12" Foreground="{DynamicResource PrimaryHueDarkBrush}" Padding="0" Margin="0,15,0,0" />
<RadioButton
Content="Use newlib (standard setting)" Margin="10,5,0,0"
IsChecked="{Binding stdLib, ConverterParameter={x:Static if:StdLibType.newlib}, Converter={StaticResource EnumBooleanConverter}}"/>
<RadioButton
Content="Use newlib-nano (smaller code)" Margin="10,5,0,0"
IsChecked="{Binding stdLib, ConverterParameter={x:Static if:StdLibType.nanolib}, Converter={StaticResource EnumBooleanConverter}}"/>

<Label Content="Additional entries to makefile:" FontWeight="SemiBold" FontSize="12" Foreground="{DynamicResource PrimaryHueDarkBrush}" Padding="0" Margin="0,25,0,0" />
</StackPanel>
Expand Down
6 changes: 5 additions & 1 deletion vtCore/Implementation/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public string core
}
}


// newlib nano
public StdLibType stdLib { get; set; }

// makefile ------------------------
public string makefile { get; set; }
Expand Down Expand Up @@ -117,6 +118,7 @@ public static IConfiguration getDefault(SetupData setupData)
{
setup = setupData,
setupType = SetupTypes.quick,
//setupType = SetupTypes.expert,
name = "default",
};

Expand All @@ -125,6 +127,8 @@ public static IConfiguration getDefault(SetupData setupData)
pd.compilerBase.path = setupData.arduinoCompiler;
pd.parseBoardsTxt(/*setupData.arduinoBoardsTxt*/null);
pd.logProject();
pd.coreStrategy = LibStrategy.copy;
pd.stdLib = StdLibType.newlib;

return pd;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,16 @@ static public string generate(IProject project, LibManager libManager, SetupData

mf.Append("\n");
mf.Append(makeEntry("FLAGS_CPU := ", "build.flags.cpu", options) + "\n");
mf.Append(makeEntry("FLAGS_OPT := ", "build.flags.optimize", options) + "\n");


string opt = makeEntry("FLAGS_OPT := ", "build.flags.optimize", options);
if (cfg.setupType == SetupTypes.expert && cfg.stdLib == StdLibType.nanolib && !opt.Contains("nano.specs"))
{
opt += " --specs=nano.specs";
}
mf.Append( opt + "\n");


mf.Append(makeEntry("FLAGS_COM := ", "build.flags.common", options) + makeEntry(" ", "build.flags.dep", options) + "\n");
mf.Append(makeEntry("FLAGS_LSP := ", "build.flags.ldspecs", options) + "\n");

Expand Down Expand Up @@ -428,7 +437,9 @@ static public string generate(IProject project, LibManager libManager, SetupData

private static string makeEntry(String txt, String key, Dictionary<String, String> options)
{
return options.ContainsKey(key) ? $"{txt}{options[key]}" : "";
// return options.ContainsKey(key) ? $"{txt}{options[key]}" : "";
string s = options.ContainsKey(key) ? $"{txt}{options[key]}" : "";
return s;
}

private static string colEsc(Color c)
Expand Down
1 change: 1 addition & 0 deletions vtCore/Implementation/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private void openExistingFolder(string vsTeensyJsonPath)
configuration.coreStrategy = configuration.copyCore ? LibStrategy.copy : LibStrategy.link;
}

configuration.stdLib = cfg.stdLib;

// add shared libraries ---------------------
if (cfg.sharedLibraries != null)
Expand Down
9 changes: 7 additions & 2 deletions vtCore/Implementation/vtTransferData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,16 @@ public class vtConfiguration
public LibStrategy coreStrategy { get; set; }

[JsonProperty(Order = 11)]
public IEnumerable<string> sharedLibraries { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public StdLibType stdLib { get; set; }

[JsonProperty(Order = 12)]
public IEnumerable<string> projectLibraries { get; set; }
public IEnumerable<string> sharedLibraries { get; set; }

[JsonProperty(Order = 13)]
public IEnumerable<string> projectLibraries { get; set; }

[JsonProperty(Order = 14)]
public vtBoard board { get; set; }

public vtConfiguration(IConfiguration configuration)
Expand All @@ -106,6 +110,7 @@ public vtConfiguration(IConfiguration configuration)
coreBase = configuration.coreBase.path;
//copyCore = configuration.copyCore;
coreStrategy = configuration.coreStrategy;
stdLib = configuration.stdLib;

// boardTxtPath = configuration.boardTxtPath;
// copyBoardTxt = configuration.copyBoardTxt;
Expand Down
2 changes: 1 addition & 1 deletion vtCore/Interfaces/IConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public interface IConfiguration

CheckedPath coreBase { get; }
LibStrategy coreStrategy { get; set; }

string core { get; }

StdLibType stdLib { get; set; }

string compiler { get; }
CheckedPath compilerBase { get; }
Expand Down
6 changes: 6 additions & 0 deletions vtCore/Interfaces/IProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public enum LibStrategy
copy, link, clone
}

public enum StdLibType
{
newlib,
nanolib
};

public enum GitError
{
OK,
Expand Down

0 comments on commit f526337

Please sign in to comment.