jmpessoa / lazandroidmodulewizard

LAMW: Lazarus Android Module Wizard: Form Designer and Components development model!
240 stars 82 forks source link

[Feature] Add improvents to build.gradle #391

Open bogomolov-a-a opened 3 years ago

bogomolov-a-a commented 3 years ago

Feature request: add improvents for build.gradle

Body: For increase code quality I want add in lintOptions follow code( in AndroidWizard_intf.pas and smartdesigner.pas module):

 strList.Add('    lintOptions {');
              //bad code, unused resources, unwanted classes link in xml files don't go in target apk.
              strList.Add('       abortOnError true');
              strList.Add('       showAll true');
              strList.Add('       checkDependencies true');
              strList.Add('       warningsAsErrors true');
              strList.Add('       ignoreWarnings false');
              strList.Add('       checkTestSources true');
              strList.Add('       checkReleaseBuilds true');
              strList.Add('    }');

For use modern java version(for android build): //use java 8 for compilation

              strList.Add('    compileOptions {');
              strList.Add('       sourceCompatibility 1.8');
              strList.Add('       targetCompatibility 1.8');
              strList.Add('    }'); 

for build with code and resource shrinking:

  strList.Add('    buildTypes {');
              strList.Add('        debug {');
              strList.Add('            debuggable true');
              strList.Add('            jniDebuggable true');
              strList.Add('            shrinkResources false');
              strList.Add('        }');
              strList.Add('        release {');
              strList.Add('            debuggable false');
              strList.Add('            jniDebuggable false');
              strList.Add('            shrinkResources true');// remove unused resources in release build
              strList.Add('            minifyEnabled true');// remove unused code in release build
              strList.Add(
                '            proguardFiles getDefaultProguardFile(''proguard-android-optimize.txt''),''proguard-project.txt''');
//use R8 proguard settings for obfuscate code in release build
              strList.Add('        }');

For add product flavour(may be different resource uses in code):

 strList.Add('    flavorDimensions "version"');
              strList.Add('    productFlavors {');
              strList.Add('             demo {');
              strList.Add('               dimension "version"');
              strList.Add('               versionNameSuffix "-demo"');
              strList.Add('               applicationIdSuffix ".demo"');
              strList.Add('             }');
              strList.Add('             free {');
              strList.Add('               dimension "version"');
              strList.Add('               versionNameSuffix "-free"');
              strList.Add('               applicationIdSuffix ".free"');
              strList.Add('             }');
              strList.Add('             full {');
              strList.Add('               dimension "version"');
              strList.Add('               versionNameSuffix "-full"');
              strList.Add('               applicationIdSuffix ".full"');
              strList.Add('             }');
              strList.Add('      }');
              strList.Add('}');

I want add in gradle properties:

if Pos('AppCompat', FAndroidTheme) > 0 then// for use appcompat dependencies
          begin
            strList.add('android.useAndroidX=true');
            strList.add('android.enableJetifier=true');
          end;
          strList.add('android.enableR8.fullMode=true');// for use code and resource shrinking.

This code added in method 'function TAndroidProjectDescriptor.GetWorkSpaceFromForm(projectType: integer; out outTag: integer): boolean;' in module 'AndroidWizard_intf.pas'

I am java developer and I want help to enhance this project because I compelled my pet project on slow machines (I can't use Intellij idea or Android Studio).

Can I push my changes in separate branch in this repository or I must create fork?

jmpessoa commented 3 years ago

Hello, bogomolov-a-a!

Welcome!!!

1) If these additions don't break previous projects....... 2) and new projects continue to be done transparently from the perspective of other developers....

Then, please, make a ""pull-request" (or send me by e-mail your modified units: jmpessoa@hotmail.com) I will commit your code!!!!

Thank you!!!

PS. happy to know that you are a java developer, we still have a lot to do!

bogomolov-a-a commented 3 years ago

Hello, I think about it. I fork your repository and start to develop.

I want add java comment preprocessor in code, because by default code Controls.java contains a lot of unused methods and lint says about it. Any components( as Vibrator, Telephone... and e.t.c. ) need for them permissions, in androidManifest.xml. I know that Pascal don't include code of methods if it(method) don't really invoked from another code. In java code unused methods in result object file included( may be use jlink, but in android development.

My improvents aim to increase code quality(for example, lint on), and decrease unused method in result java code). I don't change the component code. Only build infrastructure code.

Thank you, for your answer.

bogomolov-a-a commented 3 years ago

@jmpessoa pull request marked as DRAFT, https://github.com/jmpessoa/lazandroidmodulewizard/pull/392, Please revert it. I remove draft, when i finished. I am beginner in github and open source, in my work DRAFT pullrequests don't merged( we use gitlab as scm). I don't knew about it( that pull request be merged at once).

jmpessoa commented 3 years ago

Do we need revert it?

If any part of the code is not good you can make a new one "pull-request" ... or not?

bogomolov-a-a commented 3 years ago

Yes, but I think, 'master' branch used by developers for it projects. But I don't fully tested and... I don't sure that this part dont

If these additions don't break previous projects.......

I was sure that DRAFT pull request don't allow to merge. I start to implement my first post in this issue. If you don't use master as last version for user distributed, then all good, and I add new pull request, when I finished this feature pack.

jmpessoa commented 3 years ago

About " I don't sure that this part dont...... break previous projects......."

I am doing some tests.... soon we will know...

jmpessoa commented 3 years ago

Fatal: FAILURE: Build failed with an exception.

This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.

jmpessoa commented 3 years ago

After editing project "gradle.properties" android.useAndroidX=true

I got:

ERROR: This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 4.1 or newer.

jmpessoa commented 3 years ago

I am testing using demo app "AppCompatBottomNavigationDemo1" ....

jmpessoa commented 3 years ago

And Using LAMW:

Building APK (Gradle)... : FAILURE: Build failed with an exception., Errors: 1

Fatal: FAILURE: Build failed with an exception.

jmpessoa commented 3 years ago

Ok.

My tests: we have many task to make changes compatible with "old" projects !

So, I do a revert "by hand".....

bogomolov-a-a commented 3 years ago

Ok, I say about it.

About permissions: It is excepted behavior, I want add java comment preprocessor for logical exclude unused methods in Controls.java.

bogomolov-a-a commented 3 years ago

I continue develop, code refactoring and testing in my branch migration on new version android gradle plugin with backward compatibility with old projects.

jmpessoa commented 3 years ago

About "I want add java comment preprocessor for logical exclude unused methods in Controls"

Well, what we can see is that the simple use of "AppCompat/Material" framework [androidX] makes a simple "Hello World" application jump from 1.22 MB to 16.67 MB after installed !!!

So, why we need optimize [preprocessor] "Controls.java" ?

I always wanted a clean up in "Controls.java" leaving it just like a simple wrapper to "jForm" class ....

But, Let's go ahead!

Thank you!

bogomolov-a-a commented 3 years ago

R8 must be resolve apk size problem(in release build).

About Controls.java...

It is .... complicated.) If don't refactor this file, need include preprocessor, because in debug build all methods( unused, for example) will be included.

About build process: now in android world is popular gradle wrapper, end user must be download with special java file download his copy of gradle( ant don't actually now). I want add it in wizard.

I have question:

GDX, GUI - does use only these application type android manifest xml file? console, general lib and no gui - what this application type included?

For app build in test env(instead of manually testing): https://github.com/bogomolov-a-a/free-pascal-trunk-docker - may be build application in github action in docker? Result - so lib, and then ./gradlew clean ?

jmpessoa commented 3 years ago

Please, disregard GDX.... that is just "concept proof" .... So, it's still far from being anything useful!

Yes! my favorite solution is refactor "Controls.java"! but before that we still have a lot of "missing" features in LAMW. For example: the "missing" firebase push notification it's too bad in LAMW and the component "jBluetoothLowEnergy", is incomplete....

PS. 1) before I forget: we cannot overshadow/obfuscate java code in LAMW (the JNI requires full access to methods signature)

2)The Lazarus users have few skills with things like "gradle" :)

bogomolov-a-a commented 3 years ago

option -keep JNI methods in java classes save full name class,method and it signature(public api) Pascal developers will be have this wrapper as "black box" in command file gradle-local-build.bat and etc. Command change only for them.

bogomolov-a-a commented 3 years ago

I start refactor many AndroidManifest.txt and buildgradle.txt files, resources, java sources and others.) I build special class for it. And for ant task(deprecated), and gradle(modern) file builder by module type. GDX, GUI, NOGUI,CONSOLE, LIB. Enum for these values. Sorry for my English. I'm from Russia.

jmpessoa commented 3 years ago

Trying to help: I do a clean up in "build.gradle" code construction and update.....

New Project: "GetWorkSpaceFromForm" in "AndroidWizard_intf.pas"

(Re)Open Project: "KeepBuildUpdated" in "SmartDesigner.pas"

English: mine is not good either (Brasil) !!! :) Russia: maybe you can find a great LAMW contributor/author out there in Moscow! :) (see "readme.md")!

bogomolov-a-a commented 3 years ago

I'm from Saint Petersburg. Ok.

New Project: "GetWorkSpaceFromForm" in "AndroidWizard_intf.pas"

(Re)Open Project: "KeepBuildUpdated" in "SmartDesigner.pas"

Yes, I found it, but I didn't understand first, how it works. Many types of projects and longest method code do it complicated for read. Thank you for explanations!

jmpessoa commented 3 years ago

"Many types of projects and longest method code do it complicated for read"

Sorry..... [ little free time and a lot of desire to get results!! ;) ]

Now, I will try refactor "Controls.java" !!!!

Task 1: split out "jForm" in a new file/class "jForm.java"!

Task 2: refactor "jForm.java" (maybe split out somethings like "jSysUtils.pas" ??)

bogomolov-a-a commented 3 years ago

Hi, yes, utils code may be better extracted to jSysUtils.java or AndroidBridgesCommon and write separated module with this native methods.

bogomolov-a-a commented 3 years ago

In Java better one class - one file. In Kotlin that seem to be Pascal( top level function, type aliases and others) can be one more classe in one file, as in Pascal code. Kotlin is popular in android development but... ) We have our Pascal with type aliases and top level functions.

bogomolov-a-a commented 3 years ago

I have an quetion:

if not FileExists(IncludeTrailingPathDelimiter(LazarusIDE.GetPrimaryConfigPath) +
    'LAMW.ini') then
  begin
    if FileExists(IncludeTrailingPathDelimiter(LazarusIDE.GetPrimaryConfigPath) +
      'JNIAndroidProject.ini') then
    begin
      FIniFileName := 'LAMW.ini';
      FIniFileSection := 'NewProject';
      CopyFile(IncludeTrailingPathDelimiter(LazarusIDE.GetPrimaryConfigPath) +
        'JNIAndroidProject.ini',
        IncludeTrailingPathDelimiter(LazarusIDE.GetPrimaryConfigPath) +
        'LAMW.ini');
      //DeleteFile(IncludeTrailingPathDelimiter(LazarusIDE.GetPrimaryConfigPath) + 'JNIAndroidProject.ini');
      FPathToJavaTemplates := DoNewPathToJavaTemplate();
      FPathToSmartDesigner := GetPathToSmartDesigner();
      flag := True;
    end;
  end;

I see one LAMW.ini in lazarus setting directory and don't see in project directory. Why all projects have one setting file?

May be need add setting file into project directory? Separated NDK, separated SDK? One code in java and pascal but conditional for ndk\sdk version?

bogomolov-a-a commented 3 years ago

FBuildSystem - Ant\Gradle, - this is build system(may be replace Ant to Maven, as "modern" then Ant build system? FProjectModel - Ant\Eclipse - may be ide presets? Ant - build system, Eclipse - Java( C++) IDE.

bogomolov-a-a commented 3 years ago

I thnk that ide preset is mindless, because if developer wants add code into project -> notepad ++ or he don't use LAMW and write code on Kotlin instead of.

bogomolov-a-a commented 3 years ago

HI, @jmpessoa. And what does module lamwDesigner.pas? TAndroidWidgetMediator class. Component in pallete register, alright?

jmpessoa commented 3 years ago

Hi!

1) The LAMW.ini store the general config stuff [JDK, SDK,NDK, Gradle, Ant,,,, ] by LAMW form "Paths/Settings" 2) Specifics configs is stored in "*.lpi" file by project.... 3) The "lamwDesigner.pas" unit is the interface to the GUI LAMW form designer.... 4) Today FProjectModel inform only if we are making a new project or replacing a existing [old] project (in the old days: "eclipse" == a project created by eclipse....) 5) about: "I think that ide preset is mindless...." Well, today you can open/change/run/sign LAMW GUI project using Android Studio...

bogomolov-a-a commented 3 years ago

Thank you.

5 I don't work in Android Studio, if I pascal developer.))
4 I.e. this is marker field? 2 AProject.CustomData.Values['LAMW'] := 'GDX'; - for example, alright?

jmpessoa commented 3 years ago

5) Can we edit/change/improve LAMW java code others Editors with some help and facilities? 4) I will update it meaning and remove the word "eclipse"! 6) Yes! and all CustomData values!

jmpessoa commented 3 years ago

reopened!

bogomolov-a-a commented 3 years ago

5 - yes, I create super project with all exists java sources and start refactor it. But very complicated it and I don't process it. When I will know about this code greater then now, and my action doesn't fail all builds, I cleaned up java code, reformat with code style and others. You can use Intellj Idea for this. 6(4) OK 7(2) Thank you!

bogomolov-a-a commented 3 years ago

For eliminate "paths" options i want locate all development kits into user home path.

Work in progress:

project information wiil be saved as text parameter in project descriptor. main project form wiil be redesigned in tabs(specified for project types).

bogomolov-a-a commented 3 years ago
{About semantic versioning at https://semver.org/ }

  { TSemanticVersion }

  TSemanticVersion = class(TPersistent)
  strict private
    FMajor: word;
    FMinor: word;
    FPath: word;
    FRevision: string;
  strict private
  const
    PRINTABLE_FORMAT: string = '%d.%d.%d';
  public
    function ToString: ansistring; override;
  published
    property Major: word read FMajor write FMajor;
    property Minor: word read FMinor write FMinor;
    property Path: word read FPath write FPath;
    property Revision: string read FRevision write FRevision;
  end;

  { Build system plugin maven coordinate}
  TPluginCoordinates = class(TPersistent)
  strict private
    {groupId}
    FGroupId: string;
    {artifactId}
    FArtifactId: string;
  strict private
  const
    PRINTABLE_FORMAT: string = '%s:%s';
  public
    function ToString: ansistring; override;
  published
    property GroupId: string read FGroupId write FGroupId;
    property ArtifactId: string read FArtifactId write FArtifactId;
  end;

  {Full plugin coordinate with version}

  { TPluginInformation }

  TPluginInformation = class(TPersistent)
  strict private
    FCoordinates: TPluginCoordinates;
    FVersion: TSemanticVersion;
  strict private
  const
    PRINTABLE_FORMAT: string = '%s:%s';
  public
    constructor Create;
    destructor Destroy; override;
    function ToString: ansistring; override;
  published
    property Coordinates: TPluginCoordinates read FCoordinates write FCoordinates;
    property Version: TSemanticVersion read FVersion write FVersion;
  end;

  {Build system information using for project}

  { TBuildSystemInformation }

  TBuildSystemInformation = class(TPersistent)
  strict private
    {build system version}
    FVersion: TSemanticVersion;
    {build system type}
    FBSType: TBuildSystemType;
    {If use plugin required, fill this property instead of @link(PathToTool)}
    FPluginInformation: TPluginInformation;
    {Path to build tool (f.e. ant, predefined version of gradle, maven). Don't use it in new projects! @deprecated }
    FPathToTool: string;
    procedure SetPluginInformation(AValue: TPluginInformation);
  public
    constructor Create;
    destructor Destroy; override;
  published
    property Version: TSemanticVersion read FVersion write FVersion;
    property BSType: TBuildSystemType read FBSType write FBSType;
    property PluginInformation: TPluginInformation
      read FPluginInformation write SetPluginInformation;
    property PathToTool: string read FPathToTool write FPathToTool;
  end;

  {Android manifest API version information}
  TApiInformation = class(TPersistent)
  strict private
    FMinApiVersion: word;
    FTargetApiVersion: word;
    FCompileApiVersion: word;
  published
    property MinApiVersion: word read FMinApiVersion write FMinApiVersion;
    property TargetApiVersion: word read FTargetApiVersion write FTargetApiVersion;
    property CompileApiVersion: word read FCompileApiVersion write FCompileApiVersion;
  end;

  {Information about main package,basic theme}

  { TGeneratedSourceInformation }

  TGeneratedSourceInformation = class(TPersistent)
  strict private
    {Main package name, with app class,used as applicationId in build files }
    FPackageName: string;
    {Main app theme, f.e. NoActionBar}
    FThemeName: string;
    {If ThemeName contains 'AppCompat'}
    FIsAppCompat: boolean;
    function GetIsAppCompat: boolean;
  published
    property PackageName: string read FPackageName write FPackageName;
    property ThemeName: string read FThemeName write FThemeName;
    property IsAppCompat: boolean read GetIsAppCompat write FIsAppCompat;
  end;

  {Architecture cross-compiler, for example arm, instruction set optional}
  TCompilerArchitecture = class(TPersistent)
  strict private
    {by default 'ArmV6'}FInstructionSet: string;
    {by default 'Soft'}FFPUSet: string;
  published
    property InstructionSet: string read FInstructionSet write FInstructionSet;
    property FPUSet: string read FFPUSet write FFPUSet;
  end;

  TDevelepmentKitInformation = class(TPersistent)
  strict private
    {path on user device with development kit}
    FPathToDevelopmentKit: string;
    {download url for specified version from internet}
    FDownloadUrl: string;
  published
    property PathToPathToDevelopmentKit: string
      read FPathToDevelopmentKit write FPathToDevelopmentKit;
    property DownloadLink: string read FDownloadUrl write FDownloadUrl;
  end;

  {Using NDK for JNI project build}

  { TNdkInformation }

  TNdkInformation = class(TDevelepmentKitInformation)
  strict private
    {version, for example 11+}
    FVersion: TSemanticVersion;
    {version name, for example r10e}
    FNdkVersionName: string;
  public
    constructor Create;
    destructor Destroy; override;
  published
    property Version: TSemanticVersion read FVersion write FVersion;
    property NdkVersionName: string read FNdkVersionName write FNdkVersionName;

  end;

  {Used Android SDK project information}
  TSdkInformation = class(TDevelepmentKitInformation)
  strict private
    {Number of platform version of Android SDK, for example '29'}
    FBuildToolsVersionPlatform: word;
    {Full version of Android SDK, for example '29.0.3'}
    FBuildToolsVersionName: string;
    {path on user device with sdk}
  published
    property BuildToolsVersionPlatform: word
      read FBuildToolsVersionPlatform write FBuildToolsVersionPlatform;
    property BuildToolsVersionName: string read FBuildToolsVersionName
      write FBuildToolsVersionName;
  end;

  {Information about used JDK}

  { TJdkInformation }

  TJdkInformation = class(TPersistent)
  strict private
    {jdk version for source and target compatibility}
    FVersion: TSemanticVersion;
  public
    constructor Create;
    destructor Destroy; override;
  published
    property Version: TSemanticVersion read FVersion write FVersion;
  end;

  {Dimension application.
  You can use it for separate application code by device architecture, screen resolution,
  free and payed version and others...}
  TDimension = class(TPersistent)
  strict private
    {dimension name, f.e. 'version' for demo,free,payed version}
    FName: string;
  published
    property Name: string read FName write FName;
  end;

  TDimensionList = specialize TList<TDimension>;
  {Product flavor can used for separate application code by device architecture, screen resolution,
  free and payed version and others. For each flavor must be specified his dimension.}
  TProductFlavor = class(TPersistent)
  strict private
    {Flavor name}
    FName: string;
    {Relative dimension name}
    FDimensionName: string;
    {applicationId suffix}
    FApplicationIdSuffix: string;
    {version name suffix}
    FVersionNameSuffix: string;
  published
    property Name: string read FName write FName;
    property DimensionName: string read FDimensionName write FDimensionName;
    property ApplicationIdSuffix: string read FApplicationIdSuffix
      write FApplicationIdSuffix;
    property VersionNameSuffix: string read FVersionNameSuffix write FVersionNameSuffix;
  end;

  TProductFlavorList = specialize TList<TProductFlavor>;
  {Application build type (f.e. debug,release... )}
  TBuildType = class(TPersistent)
  strict private
    FName: string;
  published
    property Name: string read FName write FName;
  end;

  TBuildTypeList = specialize TList<TBuildType>;

  TBuildMode = class(TPersistent)
  strict private
    FProductFlavorName: string;
    FBuildTypeName: string;
  published
    property ProductFlavorName: string read FProductFlavorName write FProductFlavorName;
    property BuildTypeName: string read FBuildTypeName write FBuildTypeName;
  end;

  TBuildModeList = specialize TList<TBuildMode>;
  { TProjectInformation }

  TProjectInformation = class(TPersistent)
  strict private
    // project info

    FName: string;
    FProjectPath: string;
    FVersion: TSemanticVersion;
    FVersionName: string;
    FSyntaxMode: TSyntaxMode;
    FModuleType: TModuleType;

    //compiler info

    FCompilerArchitecture: TCompilerArchitecture;

    //build system info

    FBuildSystemInformation: TBuildSystemInformation;

    //java code information
    FGeneratedSourceInformation: TGeneratedSourceInformation;
    // api versions
    FApiInformation: TApiInformation;

    // build types and flavors
    FProductFlavors: TProductFlavorList;
    FBuildTypes: TBuildTypeList;
    FBuildModes: TBuildModeList;

    // development kit informations
    FJdkInformation: TJdkInformation;
    FNdkInformation: TNdkInformation;
    FSdkInformation: TSdkInformation;
  public
    constructor Create;
    destructor Destroy; override;
    function ToJsonString(): string;
    class function FromJsonString(Data: string): TProjectInformation;
  published
    property Name: string read FName write FName;
    property ProjectPath: string read FProjectPath write FProjectPath;
    property Version: TSemanticVersion read FVersion write FVersion;
    property VersionName: string read FVersionName write FVersionName;
    property SyntaxMode: TSyntaxMode read FSyntaxMode write FSyntaxMode;
    property ModuleType: TModuleType read FModuleType write FModuleType;

    //compiler info

    property CompilerArchitecture: TCompilerArchitecture
      read FCompilerArchitecture write FCompilerArchitecture;

    //build system info

    property BuildSystemInformation: TBuildSystemInformation
      read FBuildSystemInformation write FBuildSystemInformation;

    //java code information
    property GeneratedSourceInformation: TGeneratedSourceInformation
      read FGeneratedSourceInformation write FGeneratedSourceInformation;
    // api versions
    property ApiInformation: TApiInformation read FApiInformation write FApiInformation;

    // build types and flavors
    property ProductFlavors: TProductFlavorList read FProductFlavors;
    property BuildTypes: TBuildTypeList read FBuildTypes;
    property BuildModes: TBuildModeList read FBuildModes;

    // development kit informations
    property JdkInformation: TJdkInformation read FJdkInformation write FJdkInformation;
    property NdkInformation: TNdkInformation read FNdkInformation write FNdkInformation;
    property SdkInformation: TSdkInformation read FSdkInformation write FSdkInformation;
  end;      
bogomolov-a-a commented 3 years ago

BuildMode - this is lazarus build mode, for gradle clean build, with resources, and code for specified mode. Can I add Paths to lpi for specified build mode code? Or must be use condition compiler better?

 {$ifdef buildMode='payed'}
procedure payedProcedure();
{$endif}

and in java code will be added specified source set.

jmpessoa commented 3 years ago

1) Great work!

2) About "BuildMode"

You are talking about Project folder ".....\jni\build-modes" config files??

If yes, we need to keep them "up to date" ... ----> UpdateBuildModes() in "SmartDesigner.pas"

So, user can select others builds (chipset, gradle/ant) ::: menu "Project" --> "Projec Options" --> "[LAMW] ...." ---> "Build"

bogomolov-a-a commented 3 years ago
  1. Yes, I want add custom build modes in project (for jni project) and condtional compiler directives in pascal code for demo,free,payed and other product flavor code and resources. F.e. I want add feature for my super application after google pay transaction done. This feature don't include in "free" version, but include "super-payed" version. F.e. any form(view).
jmpessoa commented 3 years ago

About " I want add custom build modes in project (for jni project)"

Where? In "*.lpi" ?

[ we need to keep them "up to date" ... according to the user's system configuration .....]

bogomolov-a-a commented 3 years ago

Yes, in 'lpi', or in project configuration image They stored in 'lpi'?

bogomolov-a-a commented 3 years ago

Or in lps? How to create them automatically?

jmpessoa commented 3 years ago

".lps" is very "dirty/messy"... in general it should be deleted when we send a project to another user..... [maybe can "clean up" it ..... before send a project to another user..... ]

Today the build-modes are created in "DoInitDescriptor" for each project type .... in "AndroidWizard_intf.pas" and uptaded in UpdateBuildModes() in "SmartDesigner.pas" when the project is re-opened ....

Maybe you can re-use "........\jni\build-modes\" files and handle gradle config separately in another place.....

bogomolov-a-a commented 3 years ago

Thank you!

bogomolov-a-a commented 3 years ago
   <BuildModes Count="3">
      <Item1 Name="Default" Default="True"/>
      <Item2 Name="Debug">
        <CompilerOptions>
          <Version Value="11"/>
          <PathDelim Value="\"/>
          <Target>
            <Filename Value="..\libs\armeabi-v7a\libcontrols"/>
          </Target>
          <SearchPaths>
            <IncludeFiles Value="$(ProjOutDir)"/>
            <Libraries Value="C:\Users\artem.bogomolov.a\develop\instruments\AndroidSDK\ndk\android-ndk-r21e\platforms\android-22\arch-arm\usr\lib\;C:\Users\artem.bogomolov.a\develop\instruments\AndroidSDK\ndk\android-ndk-r21e\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.9\"/>
            <UnitOutputDirectory Value="..\obj\controls"/>
          </SearchPaths>
          <Parsing>
            <SyntaxOptions>
              <SyntaxMode Value="Delphi"/>
              <IncludeAssertionCode Value="True"/>
              <CStyleMacros Value="True"/>
            </SyntaxOptions>
          </Parsing>
          <CodeGeneration>
            <Checks>
              <IOChecks Value="True"/>
              <RangeChecks Value="True"/>
              <OverflowChecks Value="True"/>
              <StackChecks Value="True"/>
            </Checks>
            <VerifyObjMethodCallValidity Value="True"/>
            <TargetCPU Value="arm"/>
            <TargetOS Value="android"/>
            <SmallerCode Value="True"/>
          </CodeGeneration>
          <Linking>
            <Debugging>
              <DebugInfoType Value="dsDwarf3"/>
              <UseHeaptrc Value="True"/>
              <TrashVariables Value="True"/>
              <StripSymbols Value="True"/>
              <UseExternalDbgSyms Value="True"/>
            </Debugging>
            <Options>
              <ExecutableType Value="Library"/>
            </Options>
          </Linking>
          <Other>
            <CustomOptions Value="-Xd -CfSoft -CpARMV7A -XParm-linux-androideabi- -FDC:\Users\artem.bogomolov.a\develop\instruments\AndroidSDK\ndk\android-ndk-r21e\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin"/>
          </Other>
        </CompilerOptions>
      </Item2>
      <Item3 Name="Release">
        <CompilerOptions>
          <Version Value="11"/>
          <PathDelim Value="\"/>
          <Target>
            <Filename Value="..\libs\armeabi-v7a\libcontrols"/>
          </Target>
          <SearchPaths>
            <IncludeFiles Value="$(ProjOutDir)"/>
            <Libraries Value="C:\Users\artem.bogomolov.a\develop\instruments\AndroidSDK\ndk\android-ndk-r21e\platforms\android-22\arch-arm\usr\lib\;C:\Users\artem.bogomolov.a\develop\instruments\AndroidSDK\ndk\android-ndk-r21e\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\lib\gcc\arm-linux-androideabi\4.9\"/>
            <UnitOutputDirectory Value="..\obj\controls"/>
          </SearchPaths>
          <Parsing>
            <SyntaxOptions>
              <SyntaxMode Value="Delphi"/>
              <CStyleMacros Value="True"/>
            </SyntaxOptions>
          </Parsing>
          <CodeGeneration>
            <SmartLinkUnit Value="True"/>
            <TargetCPU Value="arm"/>
            <TargetOS Value="android"/>
            <Optimizations>
              <OptimizationLevel Value="3"/>
            </Optimizations>
            <SmallerCode Value="True"/>
          </CodeGeneration>
          <Linking>
            <Debugging>
              <GenerateDebugInfo Value="False"/>
              <StripSymbols Value="True"/>
            </Debugging>
            <LinkSmart Value="True"/>
            <Options>
              <ExecutableType Value="Library"/>
            </Options>
          </Linking>
          <Other>
            <CustomOptions Value="-Xd -CfSoft -CpARMV7A -XParm-linux-androideabi- -FDC:\Users\artem.bogomolov.a\develop\instruments\AndroidSDK\ndk\android-ndk-r21e\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin"/>
          </Other>
        </CompilerOptions>
      </Item3>
    </BuildModes>

I about it.

bogomolov-a-a commented 3 years ago

They stored in 'lpi' file, and can be migrate from user to user. Directories set from my device.

jmpessoa commented 3 years ago

Yes, the default "buid-mode" is stored in ".lpi" and the optional are stored in ".....\jni\buide-modes" folder

User can select others builds (chipset, gradle/ant)
by Lazarus menu "Project" --> "Projec Options" --> "[LAMW] ...." ---> "Build"