Skip to content

Various improvements in build script #5778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 25, 2017
Merged
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
6 changes: 2 additions & 4 deletions arduino-core/src/cc/arduino/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,8 @@ private void callArduinoBuilder(TargetBoard board, TargetPlatform platform, Targ
addPathFlagIfPathExists(cmd, "-tools", Paths.get(BaseNoGui.getHardwarePath(), "tools", "avr").toFile());
addPathFlagIfPathExists(cmd, "-tools", installedPackagesFolder);

cmd.add("-built-in-libraries");
cmd.add(BaseNoGui.getContentFile("libraries").getAbsolutePath());
cmd.add("-libraries");
cmd.add(BaseNoGui.getSketchbookLibrariesFolder().getAbsolutePath());
addPathFlagIfPathExists(cmd, "-built-in-libraries", BaseNoGui.getContentFile("libraries"));
addPathFlagIfPathExists(cmd, "-libraries", BaseNoGui.getSketchbookLibrariesFolder());

String fqbn = Stream.of(aPackage.getId(), platform.getId(), board.getId(), boardOptions(board)).filter(s -> !s.isEmpty()).collect(Collectors.joining(":"));
cmd.add("-fqbn=" + fqbn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,22 @@ public class ContributionsIndexer {
private final File builtInHardwareFolder;
private final Platform platform;
private final SignatureVerifier signatureVerifier;
private ContributionsIndex index;
private final ContributionsIndex index;

public ContributionsIndexer(File preferencesFolder, File builtInHardwareFolder, Platform platform, SignatureVerifier signatureVerifier) {
this.preferencesFolder = preferencesFolder;
this.builtInHardwareFolder = builtInHardwareFolder;
this.platform = platform;
this.signatureVerifier = signatureVerifier;
index = new EmptyContributionIndex();
packagesFolder = new File(preferencesFolder, "packages");
stagingFolder = new File(preferencesFolder, "staging" + File.separator + "packages");
}

public void parseIndex() throws Exception {
// Read bundled index...
File bundledIndexFile = new File(builtInHardwareFolder, Constants.BUNDLED_INDEX_FILE_NAME);
index = parseIndex(bundledIndexFile);
mergeContributions(bundledIndexFile);

// ...and overlay the default index if present
File defaultIndexFile = getIndexFile(Constants.DEFAULT_INDEX_FILE_NAME);
Expand All @@ -93,7 +94,7 @@ public void parseIndex() throws Exception {
throw new SignatureVerificationFailedException(Constants.DEFAULT_INDEX_FILE_NAME);
}

mergeContributions(parseIndex(defaultIndexFile), defaultIndexFile);
mergeContributions(defaultIndexFile);
}

// Set main and bundled indexes as trusted
Expand All @@ -104,8 +105,7 @@ public void parseIndex() throws Exception {

for (File indexFile : indexFiles) {
try {
ContributionsIndex contributionsIndex = parseIndex(indexFile);
mergeContributions(contributionsIndex, indexFile);
mergeContributions(indexFile);
} catch (JsonProcessingException e) {
System.err.println(I18n.format(tr("Skipping contributed index file {0}, parsing error occured:"), indexFile));
System.err.println(e);
Expand Down Expand Up @@ -136,7 +136,11 @@ public void parseIndex() throws Exception {
index.fillCategories();
}

private void mergeContributions(ContributionsIndex contributionsIndex, File indexFile) {
private void mergeContributions(File indexFile) throws IOException {
if (!indexFile.exists())
return;

ContributionsIndex contributionsIndex = parseIndex(indexFile);
boolean signed = signatureVerifier.isSigned(indexFile);
boolean trustall = PreferencesData.getBoolean(Constants.PREF_CONTRIBUTIONS_TRUST_ALL);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This file is part of Arduino.
*
* Copyright 2014 Arduino LLC (http://www.arduino.cc/)
*
* Arduino is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As a special exception, you may use this file as part of a free software
* library without restriction. Specifically, if other files instantiate
* templates or use macros or inline functions from this file, or you compile
* this file and link it with other files to produce an executable, this
* file does not by itself cause the resulting executable to be covered by
* the GNU General Public License. This exception does not however
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/

package cc.arduino.contributions.packages;

import java.util.ArrayList;
import java.util.List;

class EmptyContributionIndex extends ContributionsIndex {
List<ContributedPackage> packs = new ArrayList<>();

@Override
public List<ContributedPackage> getPackages() {
return packs;
}
}
82 changes: 22 additions & 60 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -472,21 +472,7 @@
<copy file="macosx/liblistSerials-${LIBLISTSERIAL-VERSION}/osx/liblistSerialsj.dylib" todir="macosx/work/${staging_hardware_folder}/../lib/" />
<chmod perm="755" file="macosx/work/${staging_hardware_folder}/../lib/liblistSerialsj.dylib" />

<delete dir="${staging_folder}/arduino-builder-macosx" includeemptydirs="true"/>
<mkdir dir="${staging_folder}/arduino-builder-macosx"/>
<antcall target="untar">
<param name="archive_file" value="./arduino-builder-macosx-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="archive_url" value="https://downloads.arduino.cc/tools/arduino-builder-macosx-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="final_folder" value="${staging_folder}/arduino-builder-macosx/arduino-builder" />
<param name="dest_folder" value="${staging_folder}/arduino-builder-macosx" />
</antcall>
<copy file="${staging_folder}/arduino-builder-macosx/arduino-builder" tofile="macosx/work/${staging_hardware_folder}/../arduino-builder" />
<chmod perm="755" file="macosx/work/${staging_hardware_folder}/../arduino-builder" />
<move file="${staging_folder}/arduino-builder-macosx/tools" tofile="macosx/work/${staging_hardware_folder}/../tools-builder"/>
<copy todir="macosx/work/${staging_hardware_folder}" overwrite="true">
<fileset dir="${staging_folder}/arduino-builder-macosx/hardware" includes="*.txt"/>
</copy>
<delete dir="${staging_folder}/arduino-builder-macosx" includeemptydirs="true"/>
<antcall target="build-arduino-builder" />

<antcall target="portable-${portable}">
<param name="parentdir" value="macosx/work/${staging_hardware_folder}/.." />
Expand Down Expand Up @@ -706,21 +692,7 @@
<param name="JVM" value="${LINUXARM_BUNDLED_JVM}"/>
</antcall>

<delete dir="${staging_folder}/arduino-builder-arm" includeemptydirs="true"/>
<mkdir dir="${staging_folder}/arduino-builder-arm"/>
<antcall target="untar">
<param name="archive_file" value="./arduino-builder-arm-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="archive_url" value="https://downloads.arduino.cc/tools/arduino-builder-arm-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="final_folder" value="${staging_folder}/arduino-builder-arm/arduino-builder" />
<param name="dest_folder" value="${staging_folder}/arduino-builder-arm" />
</antcall>
<copy file="${staging_folder}/arduino-builder-arm/arduino-builder" tofile="linux/work/arduino-builder" />
<chmod perm="755" file="linux/work/arduino-builder" />
<move file="${staging_folder}/arduino-builder-arm/tools" tofile="linux/work/tools-builder"/>
<copy todir="linux/work/hardware" overwrite="true">
<fileset dir="${staging_folder}/arduino-builder-arm/hardware" includes="*.txt"/>
</copy>
<delete dir="${staging_folder}/arduino-builder-arm" includeemptydirs="true"/>
<antcall target="build-arduino-builder" />

<antcall target="avr-toolchain-bundle">
<param name="unpack_target" value="untar"/>
Expand All @@ -738,21 +710,7 @@
<param name="JVM" value="${LINUX32_BUNDLED_JVM}"/>
</antcall>

<delete dir="${staging_folder}/arduino-builder-linux32" includeemptydirs="true"/>
<mkdir dir="${staging_folder}/arduino-builder-linux32"/>
<antcall target="untar">
<param name="archive_file" value="./arduino-builder-linux32-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="archive_url" value="https://downloads.arduino.cc/tools/arduino-builder-linux32-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="final_folder" value="${staging_folder}/arduino-builder-linux32/arduino-builder" />
<param name="dest_folder" value="${staging_folder}/arduino-builder-linux32" />
</antcall>
<copy file="${staging_folder}/arduino-builder-linux32/arduino-builder" tofile="linux/work/arduino-builder" />
<chmod perm="755" file="linux/work/arduino-builder" />
<move file="${staging_folder}/arduino-builder-linux32/tools" tofile="linux/work/tools-builder"/>
<copy todir="linux/work/hardware" overwrite="true">
<fileset dir="${staging_folder}/arduino-builder-linux32/hardware" includes="*.txt"/>
</copy>
<delete dir="${staging_folder}/arduino-builder-linux32" includeemptydirs="true"/>
<antcall target="build-arduino-builder" />

<antcall target="avr-toolchain-bundle">
<param name="unpack_target" value="untar"/>
Expand All @@ -770,21 +728,7 @@
<param name="JVM" value="${LINUX64_BUNDLED_JVM}"/>
</antcall>

<delete dir="${staging_folder}/arduino-builder-linux64" includeemptydirs="true"/>
<mkdir dir="${staging_folder}/arduino-builder-linux64"/>
<antcall target="untar">
<param name="archive_file" value="./arduino-builder-linux64-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="archive_url" value="https://downloads.arduino.cc/tools/arduino-builder-linux64-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="final_folder" value="${staging_folder}/arduino-builder-linux64/arduino-builder" />
<param name="dest_folder" value="${staging_folder}/arduino-builder-linux64" />
</antcall>
<copy file="${staging_folder}/arduino-builder-linux64/arduino-builder" tofile="linux/work/arduino-builder" />
<chmod perm="755" file="linux/work/arduino-builder" />
<move file="${staging_folder}/arduino-builder-linux64/tools" tofile="linux/work/tools-builder"/>
<copy todir="linux/work/hardware" overwrite="true">
<fileset dir="${staging_folder}/arduino-builder-linux64/hardware" includes="*.txt"/>
</copy>
<delete dir="${staging_folder}/arduino-builder-linux64" includeemptydirs="true"/>
<antcall target="build-arduino-builder" />

<antcall target="avr-toolchain-bundle">
<param name="unpack_target" value="untar"/>
Expand Down Expand Up @@ -827,6 +771,24 @@
<exec executable="./linux/work/arduino" spawn="false" failonerror="true"/>
</target>

<target name="build-arduino-builder" unless="no_arduino_builder">
<delete dir="${staging_folder}/arduino-builder-${platform}" includeemptydirs="true"/>
<mkdir dir="${staging_folder}/arduino-builder-${platform}"/>
<antcall target="untar">
<param name="archive_file" value="./arduino-builder-${platform}-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="archive_url" value="https://downloads.arduino.cc/tools/arduino-builder-${platform}-${ARDUINO-BUILDER-VERSION}.tar.bz2" />
<param name="final_folder" value="${staging_folder}/arduino-builder-${platform}/arduino-builder" />
<param name="dest_folder" value="${staging_folder}/arduino-builder-${platform}" />
</antcall>
<copy file="${staging_folder}/arduino-builder-${platform}/arduino-builder" tofile="${staging_folder}/work/${staging_hardware_folder}/../arduino-builder" />
<chmod perm="755" file="${staging_folder}/work/${staging_hardware_folder}/../arduino-builder" />
<move file="${staging_folder}/arduino-builder-${platform}/tools" tofile="${staging_folder}/work/${staging_hardware_folder}/../tools-builder"/>
<copy todir="${staging_folder}/work/${staging_hardware_folder}" overwrite="true">
<fileset dir="${staging_folder}/arduino-builder-${platform}/hardware" includes="*.txt"/>
</copy>
<delete dir="${staging_folder}/arduino-builder-${platform}" includeemptydirs="true"/>
</target>

<!-- Set '${dist_file}_available' property if toolchain dist_file is downloaded -->
<!-- Set '${dist_file}_installed' property if toolchain is installed in working directory -->
<!-- hardware/tools/${dist_check_file} is checked for existence -->
Expand Down